Transformed glfwEnable/Disable/SetCursorMode into glfwGetInputMode/SetInputMode.

This commit is contained in:
Camilla Berglund
2012-02-04 00:51:35 +01:00
parent 011ef7463a
commit ce288a8939
19 changed files with 219 additions and 279 deletions
+2 -8
View File
@@ -298,10 +298,7 @@ static void key_callback(GLFWwindow window, int key, int action)
case GLFW_KEY_R:
{
keyrepeat = !keyrepeat;
if (keyrepeat)
glfwEnable(window, GLFW_KEY_REPEAT);
else
glfwDisable(window, GLFW_KEY_REPEAT);
glfwSetInputMode(window, GLFW_KEY_REPEAT, keyrepeat);
printf("(( key repeat %s ))\n", keyrepeat ? "enabled" : "disabled");
break;
@@ -310,10 +307,7 @@ static void key_callback(GLFWwindow window, int key, int action)
case GLFW_KEY_S:
{
systemkeys = !systemkeys;
if (systemkeys)
glfwEnable(window, GLFW_SYSTEM_KEYS);
else
glfwDisable(window, GLFW_SYSTEM_KEYS);
glfwSetInputMode(window, GLFW_SYSTEM_KEYS, systemkeys);
printf("(( system keys %s ))\n", systemkeys ? "enabled" : "disabled");
break;
+1 -1
View File
@@ -91,7 +91,7 @@ int main(void)
}
glfwSwapInterval(1);
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
glfwSetWindowFocusCallback(window_focus_callback);
glfwSetKeyCallback(window_key_callback);
+3 -6
View File
@@ -35,7 +35,6 @@
#include <stdio.h>
#include <stdlib.h>
static GLboolean cursor_captured = GL_FALSE;
static GLFWwindow window_handle = NULL;
static int cursor_x;
static int cursor_y;
@@ -44,18 +43,16 @@ static GLboolean open_window(void);
static void toggle_mouse_cursor(GLFWwindow window)
{
if (cursor_captured)
if (glfwGetInputMode(window, GLFW_CURSOR_MODE) == GLFW_CURSOR_CAPTURED)
{
printf("Released cursor\n");
glfwSetCursorMode(window, GLFW_CURSOR_NORMAL);
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_NORMAL);
}
else
{
printf("Captured cursor\n");
glfwSetCursorMode(window, GLFW_CURSOR_CAPTURED);
glfwSetInputMode(window, GLFW_CURSOR_MODE, GLFW_CURSOR_CAPTURED);
}
cursor_captured = !cursor_captured;
}
static void mouse_position_callback(GLFWwindow window, int x, int y)