Made more consistent use of key code conversion.

This commit is contained in:
Camilla Berglund 2012-03-07 15:10:53 +01:00
parent 8155f90bf3
commit 89eec8af09

View File

@ -392,11 +392,11 @@ static int convertMacKeyCode(unsigned int macKeyCode)
{ {
NSUInteger i, length; NSUInteger i, length;
NSString* characters; NSString* characters;
int code = convertMacKeyCode([event keyCode]); int key = convertMacKeyCode([event keyCode]);
if (code != -1) if (key != -1)
{ {
_glfwInputKey(window, code, GLFW_PRESS); _glfwInputKey(window, key, GLFW_PRESS);
if ([event modifierFlags] & NSCommandKeyMask) if ([event modifierFlags] & NSCommandKeyMask)
{ {
@ -416,7 +416,7 @@ static int convertMacKeyCode(unsigned int macKeyCode)
- (void)flagsChanged:(NSEvent *)event - (void)flagsChanged:(NSEvent *)event
{ {
int mode; int mode, key;
unsigned int newModifierFlags = unsigned int newModifierFlags =
[event modifierFlags] | NSDeviceIndependentModifierFlagsMask; [event modifierFlags] | NSDeviceIndependentModifierFlagsMask;
@ -426,14 +426,17 @@ static int convertMacKeyCode(unsigned int macKeyCode)
mode = GLFW_RELEASE; mode = GLFW_RELEASE;
window->NS.modifierFlags = newModifierFlags; window->NS.modifierFlags = newModifierFlags;
_glfwInputKey(window, MAC_TO_GLFW_KEYCODE_MAPPING[[event keyCode]], mode);
key = convertMacKeyCode([event keyCode]);
if (key != -1)
_glfwInputKey(window, key, mode);
} }
- (void)keyUp:(NSEvent *)event - (void)keyUp:(NSEvent *)event
{ {
int code = convertMacKeyCode([event keyCode]); int key = convertMacKeyCode([event keyCode]);
if (code != -1) if (key != -1)
_glfwInputKey(window, code, GLFW_RELEASE); _glfwInputKey(window, key, GLFW_RELEASE);
} }
- (void)scrollWheel:(NSEvent *)event - (void)scrollWheel:(NSEvent *)event