mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 00:30:57 +00:00
Added GLFW_REPEAT.
This commit is contained in:
+12
-15
@@ -438,24 +438,21 @@ static int convertMacKeyCode(unsigned int macKeyCode)
|
||||
{
|
||||
NSUInteger i, length;
|
||||
NSString* characters;
|
||||
int key = convertMacKeyCode([event keyCode]);
|
||||
const int key = convertMacKeyCode([event keyCode]);
|
||||
if (key == -1)
|
||||
return;
|
||||
|
||||
if (key != -1)
|
||||
_glfwInputKey(window, key, GLFW_PRESS);
|
||||
|
||||
if ([event modifierFlags] & NSCommandKeyMask)
|
||||
[super keyDown:event];
|
||||
else
|
||||
{
|
||||
_glfwInputKey(window, key, GLFW_PRESS);
|
||||
characters = [event characters];
|
||||
length = [characters length];
|
||||
|
||||
if ([event modifierFlags] & NSCommandKeyMask)
|
||||
{
|
||||
[super keyDown:event];
|
||||
}
|
||||
else
|
||||
{
|
||||
characters = [event characters];
|
||||
length = [characters length];
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
_glfwInputChar(window, [characters characterAtIndex:i]);
|
||||
}
|
||||
for (i = 0; i < length; i++)
|
||||
_glfwInputChar(window, [characters characterAtIndex:i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-11
@@ -120,23 +120,18 @@ void _glfwInputKey(_GLFWwindow* window, int key, int action)
|
||||
if (key < 0 || key > GLFW_KEY_LAST)
|
||||
return;
|
||||
|
||||
// Are we trying to release an already released key?
|
||||
if (action == GLFW_RELEASE && window->key[key] != GLFW_PRESS)
|
||||
return;
|
||||
if (action == GLFW_PRESS && window->key[key] == GLFW_PRESS)
|
||||
repeated = GL_TRUE;
|
||||
|
||||
// Register key action
|
||||
if (action == GLFW_RELEASE && window->stickyKeys)
|
||||
window->key[key] = _GLFW_STICK;
|
||||
else
|
||||
{
|
||||
if (action == GLFW_PRESS && window->key[key] == GLFW_PRESS)
|
||||
repeated = GL_TRUE;
|
||||
|
||||
window->key[key] = (char) action;
|
||||
}
|
||||
|
||||
// Call user callback function
|
||||
if (window->callbacks.key && !repeated)
|
||||
if (repeated)
|
||||
action = GLFW_REPEAT;
|
||||
|
||||
if (window->callbacks.key)
|
||||
window->callbacks.key((GLFWwindow*) window, key, action);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ typedef struct _GLFWmonitor _GLFWmonitor;
|
||||
//========================================================================
|
||||
|
||||
// Internal key state used for sticky keys
|
||||
#define _GLFW_STICK 2
|
||||
#define _GLFW_STICK 3
|
||||
|
||||
|
||||
//========================================================================
|
||||
|
||||
+8
-2
@@ -488,11 +488,17 @@ static GLboolean initDisplay(void)
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported);
|
||||
if (!XkbSetDetectableAutoRepeat(_glfw.x11.display, True, &supported))
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"X11: Failed to set detectable key repeat");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (!supported)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
"X11: Detectable key repeat is not available");
|
||||
"X11: Detectable key repeat is not supported");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user