Use glfwSetInputMode to change raw input mode

This commit is contained in:
Nathan Poirier 2018-12-14 17:50:13 +01:00
parent 86544e7c3a
commit 02c2a77362
No known key found for this signature in database
GPG Key ID: 94C1CE923BD6A70C
4 changed files with 8 additions and 30 deletions

View File

@ -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
*/

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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;