diff --git a/include/GL/glfw3.h b/include/GL/glfw3.h index 6bf5f548..75f82e1d 100644 --- a/include/GL/glfw3.h +++ b/include/GL/glfw3.h @@ -564,12 +564,12 @@ GLFWAPI void glfwPollEvents(void); GLFWAPI void glfwWaitEvents(void); /* Input handling */ +GLFWAPI int glfwGetInputMode(GLFWwindow window, int mode); +GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value); GLFWAPI int glfwGetKey(GLFWwindow window, int key); GLFWAPI int glfwGetMouseButton(GLFWwindow window, int button); GLFWAPI void glfwGetMousePos(GLFWwindow window, int* xpos, int* ypos); GLFWAPI void glfwSetMousePos(GLFWwindow window, int xpos, int ypos); -GLFWAPI int glfwGetInputMode(GLFWwindow window, int mode); -GLFWAPI void glfwSetInputMode(GLFWwindow window, int mode, int value); GLFWAPI void glfwGetScrollOffset(GLFWwindow window, int* xoffset, int* yoffset); GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun); GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun); diff --git a/src/input.c b/src/input.c index 5b11d8e9..0ad3c1b8 100644 --- a/src/input.c +++ b/src/input.c @@ -266,6 +266,77 @@ void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y) ////// GLFW public API ////// ////////////////////////////////////////////////////////////////////////// +//======================================================================== +// Returns the specified input mode of the specified window +//======================================================================== + +GLFWAPI int glfwGetInputMode(GLFWwindow handle, int mode) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + + if (!_glfwInitialized) + { + _glfwSetError(GLFW_NOT_INITIALIZED, NULL); + return 0; + } + + switch (mode) + { + case GLFW_CURSOR_MODE: + return window->cursorMode; + case GLFW_STICKY_KEYS: + return window->stickyKeys; + case GLFW_STICKY_MOUSE_BUTTONS: + return window->stickyMouseButtons; + case GLFW_SYSTEM_KEYS: + return window->systemKeys; + case GLFW_KEY_REPEAT: + return window->keyRepeat; + default: + _glfwSetError(GLFW_INVALID_ENUM, NULL); + return 0; + } +} + + +//======================================================================== +// Sets the specified input mode of the specified window +//======================================================================== + +GLFWAPI void glfwSetInputMode(GLFWwindow handle, int mode, int value) +{ + _GLFWwindow* window = (_GLFWwindow*) handle; + + if (!_glfwInitialized) + { + _glfwSetError(GLFW_NOT_INITIALIZED, NULL); + return; + } + + switch (mode) + { + case GLFW_CURSOR_MODE: + setCursorMode(window, value); + break; + case GLFW_STICKY_KEYS: + setStickyKeys(window, value ? GL_TRUE : GL_FALSE); + break; + case GLFW_STICKY_MOUSE_BUTTONS: + setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE); + break; + case GLFW_SYSTEM_KEYS: + setSystemKeys(window, value ? GL_TRUE : GL_FALSE); + break; + case GLFW_KEY_REPEAT: + setKeyRepeat(window, value ? GL_TRUE : GL_FALSE); + break; + default: + _glfwSetError(GLFW_INVALID_ENUM, NULL); + break; + } +} + + //======================================================================== // Returns the state of the specified key for the specified window //======================================================================== @@ -394,77 +465,6 @@ GLFWAPI void glfwSetMousePos(GLFWwindow handle, int xpos, int ypos) } -//======================================================================== -// Returns the specified input mode of the specified window -//======================================================================== - -GLFWAPI int glfwGetInputMode(GLFWwindow handle, int mode) -{ - _GLFWwindow* window = (_GLFWwindow*) handle; - - if (!_glfwInitialized) - { - _glfwSetError(GLFW_NOT_INITIALIZED, NULL); - return 0; - } - - switch (mode) - { - case GLFW_CURSOR_MODE: - return window->cursorMode; - case GLFW_STICKY_KEYS: - return window->stickyKeys; - case GLFW_STICKY_MOUSE_BUTTONS: - return window->stickyMouseButtons; - case GLFW_SYSTEM_KEYS: - return window->systemKeys; - case GLFW_KEY_REPEAT: - return window->keyRepeat; - default: - _glfwSetError(GLFW_INVALID_ENUM, NULL); - return 0; - } -} - - -//======================================================================== -// Sets the specified input mode of the specified window -//======================================================================== - -GLFWAPI void glfwSetInputMode(GLFWwindow handle, int mode, int value) -{ - _GLFWwindow* window = (_GLFWwindow*) handle; - - if (!_glfwInitialized) - { - _glfwSetError(GLFW_NOT_INITIALIZED, NULL); - return; - } - - switch (mode) - { - case GLFW_CURSOR_MODE: - setCursorMode(window, value); - break; - case GLFW_STICKY_KEYS: - setStickyKeys(window, value ? GL_TRUE : GL_FALSE); - break; - case GLFW_STICKY_MOUSE_BUTTONS: - setStickyMouseButtons(window, value ? GL_TRUE : GL_FALSE); - break; - case GLFW_SYSTEM_KEYS: - setSystemKeys(window, value ? GL_TRUE : GL_FALSE); - break; - case GLFW_KEY_REPEAT: - setKeyRepeat(window, value ? GL_TRUE : GL_FALSE); - break; - default: - _glfwSetError(GLFW_INVALID_ENUM, NULL); - break; - } -} - - //======================================================================== // Returns the scroll offset for the specified window //========================================================================