Cleaned up shared key repeat detection.
This commit is contained in:
parent
d95b1b33e5
commit
22e1b525a5
15
src/input.c
15
src/input.c
@ -130,24 +130,19 @@ static void setStickyMouseButtons(_GLFWwindow* window, int enabled)
|
|||||||
|
|
||||||
void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
|
void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||||
{
|
{
|
||||||
GLboolean repeated = GL_FALSE;
|
|
||||||
|
|
||||||
if (action == GLFW_RELEASE && window->key[key] == GLFW_RELEASE)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (key >= 0 && key <= GLFW_KEY_LAST)
|
if (key >= 0 && key <= GLFW_KEY_LAST)
|
||||||
{
|
{
|
||||||
if (action == GLFW_PRESS && window->key[key] == GLFW_PRESS)
|
if (action == GLFW_RELEASE && window->key[key] == GLFW_RELEASE)
|
||||||
repeated = GL_TRUE;
|
return;
|
||||||
|
|
||||||
if (action == GLFW_RELEASE && window->stickyKeys)
|
if (action == GLFW_RELEASE && window->stickyKeys)
|
||||||
window->key[key] = _GLFW_STICK;
|
window->key[key] = _GLFW_STICK;
|
||||||
else
|
else
|
||||||
window->key[key] = (char) action;
|
window->key[key] = (char) action;
|
||||||
}
|
|
||||||
|
|
||||||
if (repeated)
|
if (action == GLFW_PRESS && window->key[key] == GLFW_PRESS)
|
||||||
action = GLFW_REPEAT;
|
action = GLFW_REPEAT;
|
||||||
|
}
|
||||||
|
|
||||||
if (window->callbacks.key)
|
if (window->callbacks.key)
|
||||||
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
window->callbacks.key((GLFWwindow*) window, key, scancode, action, mods);
|
||||||
|
Loading…
Reference in New Issue
Block a user