From 02c2a77362f0aa1c7630dd8418c930c9f3f46c2e Mon Sep 17 00:00:00 2001 From: Nathan Poirier Date: Fri, 14 Dec 2018 17:50:13 +0100 Subject: [PATCH] Use glfwSetInputMode to change raw input mode --- include/GLFW/glfw3.h | 11 +---------- src/input.c | 4 ++++ src/window.c | 17 ----------------- tests/cursor.c | 6 +++--- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/include/GLFW/glfw3.h b/include/GLFW/glfw3.h index f90e4d40b..04d753a04 100644 --- a/include/GLFW/glfw3.h +++ b/include/GLFW/glfw3.h @@ -1002,6 +1002,7 @@ extern "C" { #define GLFW_STICKY_KEYS 0x00033002 #define GLFW_STICKY_MOUSE_BUTTONS 0x00033003 #define GLFW_LOCK_KEY_MODS 0x00033004 +#define GLFW_RAW_INPUT 0x00033005 #define GLFW_CURSOR_NORMAL 0x00034001 #define GLFW_CURSOR_HIDDEN 0x00034002 @@ -3415,16 +3416,6 @@ GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* window, void* pointer); */ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* window); -/*! - * TODO - */ -GLFWAPI int glfwGetWindowUseRawInput(GLFWwindow* handle); - -/*! - * TODO - */ -GLFWAPI void glfwSetWindowUseRawInput(GLFWwindow* handle, int value); - /*! * TODO */ diff --git a/src/input.c b/src/input.c index 2186fdd71..f3dbeec0c 100644 --- a/src/input.c +++ b/src/input.c @@ -475,6 +475,8 @@ GLFWAPI int glfwGetInputMode(GLFWwindow* handle, int mode) return window->stickyMouseButtons; case GLFW_LOCK_KEY_MODS: return window->lockKeyMods; + case GLFW_RAW_INPUT: + return window->useRawInput; } _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); @@ -552,6 +554,8 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value) } else if (mode == GLFW_LOCK_KEY_MODS) window->lockKeyMods = value ? GLFW_TRUE : GLFW_FALSE; + else if (mode == GLFW_RAW_INPUT) + _glfwPlatformSetWindowUseRawInput(window, value ? GLFW_TRUE : GLFW_FALSE); else _glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode 0x%08X", mode); } diff --git a/src/window.c b/src/window.c index ecd9d7117..40991ba3f 100644 --- a/src/window.c +++ b/src/window.c @@ -971,23 +971,6 @@ GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle) return window->userPointer; } -GLFWAPI int glfwGetWindowUseRawInput(GLFWwindow* handle) -{ - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - - return window->useRawInput; -} - -GLFWAPI void glfwSetWindowUseRawInput(GLFWwindow* handle, - int value) -{ - _GLFWwindow* window = (_GLFWwindow*) handle; - assert(window != NULL); - - _glfwPlatformSetWindowUseRawInput(window, value ? GLFW_TRUE : GLFW_FALSE); -} - GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle, GLFWwindowposfun cbfun) { diff --git a/tests/cursor.c b/tests/cursor.c index 6d88c23cf..a64c0bf80 100644 --- a/tests/cursor.c +++ b/tests/cursor.c @@ -164,14 +164,14 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action, break; case GLFW_KEY_R: - if (glfwGetWindowUseRawInput(window)) + if (glfwGetInputMode(window, GLFW_RAW_INPUT)) { - glfwSetWindowUseRawInput(window, GLFW_FALSE); + glfwSetInputMode(window, GLFW_RAW_INPUT, GLFW_FALSE); printf("(( raw input is disabled ))\n"); } else { - glfwSetWindowUseRawInput(window, GLFW_TRUE); + glfwSetInputMode(window, GLFW_RAW_INPUT, GLFW_TRUE); printf("(( raw input is enabled ))\n"); } break;