1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

Made key code translation table private to function.

This commit is contained in:
Camilla Berglund 2012-03-07 15:13:41 +01:00
parent 89eec8af09
commit 339fb7d246

View File

@ -135,157 +135,153 @@
@end @end
//========================================================================
// Keyboard symbol translation table
//========================================================================
// TODO: Need to find mappings for F13-F15, volume down/up/mute, and eject.
static const unsigned int MAC_TO_GLFW_KEYCODE_MAPPING[128] =
{
/* 00 */ GLFW_KEY_A,
/* 01 */ GLFW_KEY_S,
/* 02 */ GLFW_KEY_D,
/* 03 */ GLFW_KEY_F,
/* 04 */ GLFW_KEY_H,
/* 05 */ GLFW_KEY_G,
/* 06 */ GLFW_KEY_Z,
/* 07 */ GLFW_KEY_X,
/* 08 */ GLFW_KEY_C,
/* 09 */ GLFW_KEY_V,
/* 0a */ GLFW_KEY_GRAVE_ACCENT,
/* 0b */ GLFW_KEY_B,
/* 0c */ GLFW_KEY_Q,
/* 0d */ GLFW_KEY_W,
/* 0e */ GLFW_KEY_E,
/* 0f */ GLFW_KEY_R,
/* 10 */ GLFW_KEY_Y,
/* 11 */ GLFW_KEY_T,
/* 12 */ GLFW_KEY_1,
/* 13 */ GLFW_KEY_2,
/* 14 */ GLFW_KEY_3,
/* 15 */ GLFW_KEY_4,
/* 16 */ GLFW_KEY_6,
/* 17 */ GLFW_KEY_5,
/* 18 */ GLFW_KEY_EQUAL,
/* 19 */ GLFW_KEY_9,
/* 1a */ GLFW_KEY_7,
/* 1b */ GLFW_KEY_MINUS,
/* 1c */ GLFW_KEY_8,
/* 1d */ GLFW_KEY_0,
/* 1e */ GLFW_KEY_RIGHT_BRACKET,
/* 1f */ GLFW_KEY_O,
/* 20 */ GLFW_KEY_U,
/* 21 */ GLFW_KEY_LEFT_BRACKET,
/* 22 */ GLFW_KEY_I,
/* 23 */ GLFW_KEY_P,
/* 24 */ GLFW_KEY_ENTER,
/* 25 */ GLFW_KEY_L,
/* 26 */ GLFW_KEY_J,
/* 27 */ GLFW_KEY_APOSTROPHE,
/* 28 */ GLFW_KEY_K,
/* 29 */ GLFW_KEY_SEMICOLON,
/* 2a */ GLFW_KEY_BACKSLASH,
/* 2b */ GLFW_KEY_COMMA,
/* 2c */ GLFW_KEY_SLASH,
/* 2d */ GLFW_KEY_N,
/* 2e */ GLFW_KEY_M,
/* 2f */ GLFW_KEY_PERIOD,
/* 30 */ GLFW_KEY_TAB,
/* 31 */ GLFW_KEY_SPACE,
/* 32 */ GLFW_KEY_WORLD_1,
/* 33 */ GLFW_KEY_BACKSPACE,
/* 34 */ -1,
/* 35 */ GLFW_KEY_ESCAPE,
/* 36 */ GLFW_KEY_RIGHT_SUPER,
/* 37 */ GLFW_KEY_LEFT_SUPER,
/* 38 */ GLFW_KEY_LEFT_SHIFT,
/* 39 */ GLFW_KEY_CAPS_LOCK,
/* 3a */ GLFW_KEY_LEFT_ALT,
/* 3b */ GLFW_KEY_LEFT_CONTROL,
/* 3c */ GLFW_KEY_RIGHT_SHIFT,
/* 3d */ GLFW_KEY_RIGHT_ALT,
/* 3e */ GLFW_KEY_RIGHT_CONTROL,
/* 3f */ -1, /* Function */
/* 40 */ GLFW_KEY_F17,
/* 41 */ GLFW_KEY_KP_DECIMAL,
/* 42 */ -1,
/* 43 */ GLFW_KEY_KP_MULTIPLY,
/* 44 */ -1,
/* 45 */ GLFW_KEY_KP_ADD,
/* 46 */ -1,
/* 47 */ GLFW_KEY_NUM_LOCK, /* Really KeypadClear... */
/* 48 */ -1, /* VolumeUp */
/* 49 */ -1, /* VolumeDown */
/* 4a */ -1, /* Mute */
/* 4b */ GLFW_KEY_KP_DIVIDE,
/* 4c */ GLFW_KEY_KP_ENTER,
/* 4d */ -1,
/* 4e */ GLFW_KEY_KP_SUBTRACT,
/* 4f */ GLFW_KEY_F18,
/* 50 */ GLFW_KEY_F19,
/* 51 */ GLFW_KEY_KP_EQUAL,
/* 52 */ GLFW_KEY_KP_0,
/* 53 */ GLFW_KEY_KP_1,
/* 54 */ GLFW_KEY_KP_2,
/* 55 */ GLFW_KEY_KP_3,
/* 56 */ GLFW_KEY_KP_4,
/* 57 */ GLFW_KEY_KP_5,
/* 58 */ GLFW_KEY_KP_6,
/* 59 */ GLFW_KEY_KP_7,
/* 5a */ GLFW_KEY_F20,
/* 5b */ GLFW_KEY_KP_8,
/* 5c */ GLFW_KEY_KP_9,
/* 5d */ -1,
/* 5e */ -1,
/* 5f */ -1,
/* 60 */ GLFW_KEY_F5,
/* 61 */ GLFW_KEY_F6,
/* 62 */ GLFW_KEY_F7,
/* 63 */ GLFW_KEY_F3,
/* 64 */ GLFW_KEY_F8,
/* 65 */ GLFW_KEY_F9,
/* 66 */ -1,
/* 67 */ GLFW_KEY_F11,
/* 68 */ -1,
/* 69 */ GLFW_KEY_F13,
/* 6a */ GLFW_KEY_F16,
/* 6b */ GLFW_KEY_F14,
/* 6c */ -1,
/* 6d */ GLFW_KEY_F10,
/* 6e */ -1,
/* 6f */ GLFW_KEY_F12,
/* 70 */ -1,
/* 71 */ GLFW_KEY_F15,
/* 72 */ GLFW_KEY_INSERT, /* Really Help... */
/* 73 */ GLFW_KEY_HOME,
/* 74 */ GLFW_KEY_PAGE_UP,
/* 75 */ GLFW_KEY_DELETE,
/* 76 */ GLFW_KEY_F4,
/* 77 */ GLFW_KEY_END,
/* 78 */ GLFW_KEY_F2,
/* 79 */ GLFW_KEY_PAGE_DOWN,
/* 7a */ GLFW_KEY_F1,
/* 7b */ GLFW_KEY_LEFT,
/* 7c */ GLFW_KEY_RIGHT,
/* 7d */ GLFW_KEY_DOWN,
/* 7e */ GLFW_KEY_UP,
/* 7f */ -1,
};
//======================================================================== //========================================================================
// Converts a Mac OS X keycode to a GLFW keycode // Converts a Mac OS X keycode to a GLFW keycode
//======================================================================== //========================================================================
static int convertMacKeyCode(unsigned int macKeyCode) static int convertMacKeyCode(unsigned int macKeyCode)
{ {
// Keyboard symbol translation table
// TODO: Need to find mappings for F13-F15, volume down/up/mute, and eject.
static const unsigned int table[128] =
{
/* 00 */ GLFW_KEY_A,
/* 01 */ GLFW_KEY_S,
/* 02 */ GLFW_KEY_D,
/* 03 */ GLFW_KEY_F,
/* 04 */ GLFW_KEY_H,
/* 05 */ GLFW_KEY_G,
/* 06 */ GLFW_KEY_Z,
/* 07 */ GLFW_KEY_X,
/* 08 */ GLFW_KEY_C,
/* 09 */ GLFW_KEY_V,
/* 0a */ GLFW_KEY_GRAVE_ACCENT,
/* 0b */ GLFW_KEY_B,
/* 0c */ GLFW_KEY_Q,
/* 0d */ GLFW_KEY_W,
/* 0e */ GLFW_KEY_E,
/* 0f */ GLFW_KEY_R,
/* 10 */ GLFW_KEY_Y,
/* 11 */ GLFW_KEY_T,
/* 12 */ GLFW_KEY_1,
/* 13 */ GLFW_KEY_2,
/* 14 */ GLFW_KEY_3,
/* 15 */ GLFW_KEY_4,
/* 16 */ GLFW_KEY_6,
/* 17 */ GLFW_KEY_5,
/* 18 */ GLFW_KEY_EQUAL,
/* 19 */ GLFW_KEY_9,
/* 1a */ GLFW_KEY_7,
/* 1b */ GLFW_KEY_MINUS,
/* 1c */ GLFW_KEY_8,
/* 1d */ GLFW_KEY_0,
/* 1e */ GLFW_KEY_RIGHT_BRACKET,
/* 1f */ GLFW_KEY_O,
/* 20 */ GLFW_KEY_U,
/* 21 */ GLFW_KEY_LEFT_BRACKET,
/* 22 */ GLFW_KEY_I,
/* 23 */ GLFW_KEY_P,
/* 24 */ GLFW_KEY_ENTER,
/* 25 */ GLFW_KEY_L,
/* 26 */ GLFW_KEY_J,
/* 27 */ GLFW_KEY_APOSTROPHE,
/* 28 */ GLFW_KEY_K,
/* 29 */ GLFW_KEY_SEMICOLON,
/* 2a */ GLFW_KEY_BACKSLASH,
/* 2b */ GLFW_KEY_COMMA,
/* 2c */ GLFW_KEY_SLASH,
/* 2d */ GLFW_KEY_N,
/* 2e */ GLFW_KEY_M,
/* 2f */ GLFW_KEY_PERIOD,
/* 30 */ GLFW_KEY_TAB,
/* 31 */ GLFW_KEY_SPACE,
/* 32 */ GLFW_KEY_WORLD_1,
/* 33 */ GLFW_KEY_BACKSPACE,
/* 34 */ -1,
/* 35 */ GLFW_KEY_ESCAPE,
/* 36 */ GLFW_KEY_RIGHT_SUPER,
/* 37 */ GLFW_KEY_LEFT_SUPER,
/* 38 */ GLFW_KEY_LEFT_SHIFT,
/* 39 */ GLFW_KEY_CAPS_LOCK,
/* 3a */ GLFW_KEY_LEFT_ALT,
/* 3b */ GLFW_KEY_LEFT_CONTROL,
/* 3c */ GLFW_KEY_RIGHT_SHIFT,
/* 3d */ GLFW_KEY_RIGHT_ALT,
/* 3e */ GLFW_KEY_RIGHT_CONTROL,
/* 3f */ -1, /* Function */
/* 40 */ GLFW_KEY_F17,
/* 41 */ GLFW_KEY_KP_DECIMAL,
/* 42 */ -1,
/* 43 */ GLFW_KEY_KP_MULTIPLY,
/* 44 */ -1,
/* 45 */ GLFW_KEY_KP_ADD,
/* 46 */ -1,
/* 47 */ GLFW_KEY_NUM_LOCK, /* Really KeypadClear... */
/* 48 */ -1, /* VolumeUp */
/* 49 */ -1, /* VolumeDown */
/* 4a */ -1, /* Mute */
/* 4b */ GLFW_KEY_KP_DIVIDE,
/* 4c */ GLFW_KEY_KP_ENTER,
/* 4d */ -1,
/* 4e */ GLFW_KEY_KP_SUBTRACT,
/* 4f */ GLFW_KEY_F18,
/* 50 */ GLFW_KEY_F19,
/* 51 */ GLFW_KEY_KP_EQUAL,
/* 52 */ GLFW_KEY_KP_0,
/* 53 */ GLFW_KEY_KP_1,
/* 54 */ GLFW_KEY_KP_2,
/* 55 */ GLFW_KEY_KP_3,
/* 56 */ GLFW_KEY_KP_4,
/* 57 */ GLFW_KEY_KP_5,
/* 58 */ GLFW_KEY_KP_6,
/* 59 */ GLFW_KEY_KP_7,
/* 5a */ GLFW_KEY_F20,
/* 5b */ GLFW_KEY_KP_8,
/* 5c */ GLFW_KEY_KP_9,
/* 5d */ -1,
/* 5e */ -1,
/* 5f */ -1,
/* 60 */ GLFW_KEY_F5,
/* 61 */ GLFW_KEY_F6,
/* 62 */ GLFW_KEY_F7,
/* 63 */ GLFW_KEY_F3,
/* 64 */ GLFW_KEY_F8,
/* 65 */ GLFW_KEY_F9,
/* 66 */ -1,
/* 67 */ GLFW_KEY_F11,
/* 68 */ -1,
/* 69 */ GLFW_KEY_F13,
/* 6a */ GLFW_KEY_F16,
/* 6b */ GLFW_KEY_F14,
/* 6c */ -1,
/* 6d */ GLFW_KEY_F10,
/* 6e */ -1,
/* 6f */ GLFW_KEY_F12,
/* 70 */ -1,
/* 71 */ GLFW_KEY_F15,
/* 72 */ GLFW_KEY_INSERT, /* Really Help... */
/* 73 */ GLFW_KEY_HOME,
/* 74 */ GLFW_KEY_PAGE_UP,
/* 75 */ GLFW_KEY_DELETE,
/* 76 */ GLFW_KEY_F4,
/* 77 */ GLFW_KEY_END,
/* 78 */ GLFW_KEY_F2,
/* 79 */ GLFW_KEY_PAGE_DOWN,
/* 7a */ GLFW_KEY_F1,
/* 7b */ GLFW_KEY_LEFT,
/* 7c */ GLFW_KEY_RIGHT,
/* 7d */ GLFW_KEY_DOWN,
/* 7e */ GLFW_KEY_UP,
/* 7f */ -1,
};
if (macKeyCode >= 128) if (macKeyCode >= 128)
return -1; return -1;
// This treats keycodes as *positional*; that is, we'll return 'a' // This treats keycodes as *positional*; that is, we'll return 'a'
// for the key left of 's', even on an AZERTY keyboard. The charInput // for the key left of 's', even on an AZERTY keyboard. The charInput
// function should still get 'q' though. // function should still get 'q' though.
return MAC_TO_GLFW_KEYCODE_MAPPING[macKeyCode]; return table[macKeyCode];
} }