mirror of
https://github.com/glfw/glfw.git
synced 2024-11-29 07:34:35 +00:00
Moved input mode functions to top.
This commit is contained in:
parent
5a05da441d
commit
609c008a19
@ -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);
|
||||
|
142
src/input.c
142
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
|
||||
//========================================================================
|
||||
|
Loading…
Reference in New Issue
Block a user