Browse Source

Tweak indentation

pull/156/head
Patrick Desaulniers 6 years ago
parent
commit
86c40bc529
4 changed files with 164 additions and 164 deletions
  1. +128
    -128
      dgl/src/pugl/pugl.h
  2. +10
    -10
      dgl/src/pugl/pugl_osx.m
  3. +11
    -11
      dgl/src/pugl/pugl_win.cpp
  4. +15
    -15
      dgl/src/pugl/pugl_x11.c

+ 128
- 128
dgl/src/pugl/pugl.h View File

@@ -124,136 +124,136 @@ typedef enum {

/**
Layout-independent keycodes.
These keycodes are relative to an US QWERTY keyboard.
These keycodes are relative to an US QWERTY keyboard.
Therefore, the keycode for the letter 'A' on an AZERTY keyboard will be equal to PUGL_KC_Q.
*/
*/
typedef enum {
/* Zero, does not correspond to any key. */
PUGL_KC_None = 0,
PUGL_KC_A = 4,
PUGL_KC_B = 5,
PUGL_KC_C = 6,
PUGL_KC_D = 7,
PUGL_KC_E = 8,
PUGL_KC_F = 9,
PUGL_KC_G = 10,
PUGL_KC_H = 11,
PUGL_KC_I = 12,
PUGL_KC_J = 13,
PUGL_KC_K = 14,
PUGL_KC_L = 15,
PUGL_KC_M = 16,
PUGL_KC_N = 17,
PUGL_KC_O = 18,
PUGL_KC_P = 19,
PUGL_KC_Q = 20,
PUGL_KC_R = 21,
PUGL_KC_S = 22,
PUGL_KC_T = 23,
PUGL_KC_U = 24,
PUGL_KC_V = 25,
PUGL_KC_W = 26,
PUGL_KC_X = 27,
PUGL_KC_Y = 28,
PUGL_KC_Z = 29,
PUGL_KC_1 = 30,
PUGL_KC_2 = 31,
PUGL_KC_3 = 32,
PUGL_KC_4 = 33,
PUGL_KC_5 = 34,
PUGL_KC_6 = 35,
PUGL_KC_7 = 36,
PUGL_KC_8 = 37,
PUGL_KC_9 = 38,
PUGL_KC_0 = 39,
PUGL_KC_Escape = 41,
PUGL_KC_Delete = 42,
PUGL_KC_Tab = 43,
PUGL_KC_Space = 44,
PUGL_KC_Minus = 45,
PUGL_KC_Equals = 46,
PUGL_KC_LeftBracket = 47,
PUGL_KC_RightBracket = 48,
PUGL_KC_Backslash = 49,
PUGL_KC_Semicolon = 51,
PUGL_KC_Quote = 52,
PUGL_KC_Grave = 53,
PUGL_KC_Comma = 54,
PUGL_KC_Period = 55,
PUGL_KC_Slash = 56,
PUGL_KC_CapsLock = 57,
PUGL_KC_F1 = 58,
PUGL_KC_F2 = 59,
PUGL_KC_F3 = 60,
PUGL_KC_F4 = 61,
PUGL_KC_F5 = 62,
PUGL_KC_F6 = 63,
PUGL_KC_F7 = 64,
PUGL_KC_F8 = 65,
PUGL_KC_F9 = 66,
PUGL_KC_F10 = 67,
PUGL_KC_F11 = 68,
PUGL_KC_F12 = 69,
PUGL_KC_PrintScreen = 70,
PUGL_KC_ScrollLock = 71,
PUGL_KC_Pause = 72,
PUGL_KC_Insert = 73,
PUGL_KC_Home = 74,
PUGL_KC_PageUp = 75,
PUGL_KC_DeleteForward = 76,
PUGL_KC_End = 77,
PUGL_KC_PageDown = 78,
PUGL_KC_Right = 79,
PUGL_KC_Left = 80,
PUGL_KC_Down = 81,
PUGL_KC_Up = 82,
PUGL_KC_KP_NumLock = 83,
PUGL_KC_KP_Divide = 84,
PUGL_KC_KP_Multiply = 85,
PUGL_KC_KP_Subtract = 86,
PUGL_KC_KP_Add = 87,
PUGL_KC_KP_Enter = 88,
PUGL_KC_KP_1 = 89,
PUGL_KC_KP_2 = 90,
PUGL_KC_KP_3 = 91,
PUGL_KC_KP_4 = 92,
PUGL_KC_KP_5 = 93,
PUGL_KC_KP_6 = 94,
PUGL_KC_KP_7 = 95,
PUGL_KC_KP_8 = 96,
PUGL_KC_KP_9 = 97,
PUGL_KC_KP_0 = 98,
PUGL_KC_Point = 99,
PUGL_KC_NonUSBackslash = 100,
PUGL_KC_KP_Equals = 103,
PUGL_KC_F13 = 104,
PUGL_KC_F14 = 105,
PUGL_KC_F15 = 106,
PUGL_KC_F16 = 107,
PUGL_KC_F17 = 108,
PUGL_KC_F18 = 109,
PUGL_KC_F19 = 110,
PUGL_KC_F20 = 111,
PUGL_KC_F21 = 112,
PUGL_KC_F22 = 113,
PUGL_KC_F23 = 114,
PUGL_KC_F24 = 115,
PUGL_KC_Help = 117,
PUGL_KC_Menu = 118,
PUGL_KC_Mute = 127,
PUGL_KC_SysReq = 154,
PUGL_KC_Return = 158,
PUGL_KC_KP_Clear = 216,
PUGL_KC_KP_Decimal = 220,
PUGL_KC_LeftControl = 224,
PUGL_KC_LeftShift = 225,
PUGL_KC_LeftAlt = 226,
PUGL_KC_LeftGUI = 227,
PUGL_KC_RightControl = 228,
PUGL_KC_RightShift = 229,
PUGL_KC_RightAlt = 230,
PUGL_KC_RightGUI = 231
/* Zero, does not correspond to any key. */
PUGL_KC_None = 0,
PUGL_KC_A = 4,
PUGL_KC_B = 5,
PUGL_KC_C = 6,
PUGL_KC_D = 7,
PUGL_KC_E = 8,
PUGL_KC_F = 9,
PUGL_KC_G = 10,
PUGL_KC_H = 11,
PUGL_KC_I = 12,
PUGL_KC_J = 13,
PUGL_KC_K = 14,
PUGL_KC_L = 15,
PUGL_KC_M = 16,
PUGL_KC_N = 17,
PUGL_KC_O = 18,
PUGL_KC_P = 19,
PUGL_KC_Q = 20,
PUGL_KC_R = 21,
PUGL_KC_S = 22,
PUGL_KC_T = 23,
PUGL_KC_U = 24,
PUGL_KC_V = 25,
PUGL_KC_W = 26,
PUGL_KC_X = 27,
PUGL_KC_Y = 28,
PUGL_KC_Z = 29,
PUGL_KC_1 = 30,
PUGL_KC_2 = 31,
PUGL_KC_3 = 32,
PUGL_KC_4 = 33,
PUGL_KC_5 = 34,
PUGL_KC_6 = 35,
PUGL_KC_7 = 36,
PUGL_KC_8 = 37,
PUGL_KC_9 = 38,
PUGL_KC_0 = 39,
PUGL_KC_Escape = 41,
PUGL_KC_Delete = 42,
PUGL_KC_Tab = 43,
PUGL_KC_Space = 44,
PUGL_KC_Minus = 45,
PUGL_KC_Equals = 46,
PUGL_KC_LeftBracket = 47,
PUGL_KC_RightBracket = 48,
PUGL_KC_Backslash = 49,
PUGL_KC_Semicolon = 51,
PUGL_KC_Quote = 52,
PUGL_KC_Grave = 53,
PUGL_KC_Comma = 54,
PUGL_KC_Period = 55,
PUGL_KC_Slash = 56,
PUGL_KC_CapsLock = 57,
PUGL_KC_F1 = 58,
PUGL_KC_F2 = 59,
PUGL_KC_F3 = 60,
PUGL_KC_F4 = 61,
PUGL_KC_F5 = 62,
PUGL_KC_F6 = 63,
PUGL_KC_F7 = 64,
PUGL_KC_F8 = 65,
PUGL_KC_F9 = 66,
PUGL_KC_F10 = 67,
PUGL_KC_F11 = 68,
PUGL_KC_F12 = 69,
PUGL_KC_PrintScreen = 70,
PUGL_KC_ScrollLock = 71,
PUGL_KC_Pause = 72,
PUGL_KC_Insert = 73,
PUGL_KC_Home = 74,
PUGL_KC_PageUp = 75,
PUGL_KC_DeleteForward = 76,
PUGL_KC_End = 77,
PUGL_KC_PageDown = 78,
PUGL_KC_Right = 79,
PUGL_KC_Left = 80,
PUGL_KC_Down = 81,
PUGL_KC_Up = 82,
PUGL_KC_KP_NumLock = 83,
PUGL_KC_KP_Divide = 84,
PUGL_KC_KP_Multiply = 85,
PUGL_KC_KP_Subtract = 86,
PUGL_KC_KP_Add = 87,
PUGL_KC_KP_Enter = 88,
PUGL_KC_KP_1 = 89,
PUGL_KC_KP_2 = 90,
PUGL_KC_KP_3 = 91,
PUGL_KC_KP_4 = 92,
PUGL_KC_KP_5 = 93,
PUGL_KC_KP_6 = 94,
PUGL_KC_KP_7 = 95,
PUGL_KC_KP_8 = 96,
PUGL_KC_KP_9 = 97,
PUGL_KC_KP_0 = 98,
PUGL_KC_Point = 99,
PUGL_KC_NonUSBackslash = 100,
PUGL_KC_KP_Equals = 103,
PUGL_KC_F13 = 104,
PUGL_KC_F14 = 105,
PUGL_KC_F15 = 106,
PUGL_KC_F16 = 107,
PUGL_KC_F17 = 108,
PUGL_KC_F18 = 109,
PUGL_KC_F19 = 110,
PUGL_KC_F20 = 111,
PUGL_KC_F21 = 112,
PUGL_KC_F22 = 113,
PUGL_KC_F23 = 114,
PUGL_KC_F24 = 115,
PUGL_KC_Help = 117,
PUGL_KC_Menu = 118,
PUGL_KC_Mute = 127,
PUGL_KC_SysReq = 154,
PUGL_KC_Return = 158,
PUGL_KC_KP_Clear = 216,
PUGL_KC_KP_Decimal = 220,
PUGL_KC_LeftControl = 224,
PUGL_KC_LeftShift = 225,
PUGL_KC_LeftAlt = 226,
PUGL_KC_LeftGUI = 227,
PUGL_KC_RightControl = 228,
PUGL_KC_RightShift = 229,
PUGL_KC_RightAlt = 230,
PUGL_KC_RightGUI = 231
} PuglKeyCodes;

/**


+ 10
- 10
dgl/src/pugl/pugl_osx.m View File

@@ -124,22 +124,22 @@ getModifiers(PuglView* view, NSEvent* ev)
/**
Convert system specific keycodes into system independent ones (PuglKeyCodes)
*/
static unsigned
static unsigned
scancodeToHID(unsigned scancode)
{
static const unsigned char KEYCODE_MACOS_TO_HID[128] = {
4,22,7,9,11,10,29,27,6,25,0,5,20,26,8,21,28,23,30,31,32,33,35,34,46,38,36,
45,37,39,48,18,24,47,12,19,158,15,13,52,14,51,49,54,56,17,16,55,43,44,53,42,
0,41,231,227,225,57,226,224,229,230,228,0,108,220,0,85,0,87,0,216,0,0,127,
84,88,0,86,109,110,103,98,89,90,91,92,93,94,95,111,96,97,0,0,0,62,63,64,60,
65,66,0,68,0,104,107,105,0,67,0,69,0,106,117,74,75,76,61,77,59,78,58,80,79,
81,82,0
4,22,7,9,11,10,29,27,6,25,0,5,20,26,8,21,28,23,30,31,32,33,35,34,46,38,36,
45,37,39,48,18,24,47,12,19,158,15,13,52,14,51,49,54,56,17,16,55,43,44,53,42,
0,41,231,227,225,57,226,224,229,230,228,0,108,220,0,85,0,87,0,216,0,0,127,
84,88,0,86,109,110,103,98,89,90,91,92,93,94,95,111,96,97,0,0,0,62,63,64,60,
65,66,0,68,0,104,107,105,0,67,0,69,0,106,117,74,75,76,61,77,59,78,58,80,79,
81,82,0
};

if (scancode >= 128)
return 0;
if (scancode >= 128)
return 0;

return KEYCODE_MACOS_TO_HID[scancode];
return KEYCODE_MACOS_TO_HID[scancode];
}

static int


+ 11
- 11
dgl/src/pugl/pugl_win.cpp View File

@@ -384,20 +384,20 @@ static unsigned
keycodeToHID(unsigned keycode)
{
static const unsigned char KEYCODE_WINDOWS_TO_HID[256] = {
0,41,30,31,32,33,34,35,36,37,38,39,45,46,42,43,20,26,8,21,23,28,24,12,18,19,
47,48,158,224,4,22,7,9,10,11,13,14,15,51,52,53,225,49,29,27,6,25,5,17,16,54,
55,56,229,0,226,0,57,58,59,60,61,62,63,64,65,66,67,72,71,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,68,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,70,230,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,74,82,75,0,80,0,79,0,77,81,78,73,76,0,0,0,0,0,0,0,227,231,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,41,30,31,32,33,34,35,36,37,38,39,45,46,42,43,20,26,8,21,23,28,24,12,18,19,
47,48,158,224,4,22,7,9,10,11,13,14,15,51,52,53,225,49,29,27,6,25,5,17,16,54,
55,56,229,0,226,0,57,58,59,60,61,62,63,64,65,66,67,72,71,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,68,69,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,70,230,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,74,82,75,0,80,0,79,0,77,81,78,73,76,0,0,0,0,0,0,0,227,231,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

if (keycode >= 256)
return 0;
if (keycode >= 256)
return 0;
return KEYCODE_WINDOWS_TO_HID[keycode];
return KEYCODE_WINDOWS_TO_HID[keycode];
}

static LRESULT


+ 15
- 15
dgl/src/pugl/pugl_x11.c View File

@@ -493,29 +493,29 @@ static unsigned
scancodeToHID(unsigned scancode)
{
static const unsigned char KEYCODE_LINUX_TO_HID[256] = {
0,41,30,31,32,33,34,35,36,37,38,39,45,46,42,43,20,26,8,21,23,28,24,12,18,19,
47,48,158,224,4,22,7,9,10,11,13,14,15,51,52,53,225,49,29,27,6,25,5,17,16,54,
55,56,229,85,226,44,57,58,59,60,61,62,63,64,65,66,67,83,71,95,96,97,86,92,
93,94,87,89,90,91,98,99,0,0,100,68,69,0,0,0,0,0,0,0,88,228,84,154,230,0,74,
82,75,80,79,77,81,78,73,76,0,0,0,0,0,103,0,72,0,0,0,0,0,227,231,0,0,0,0,0,0,
0,0,0,0,0,0,118,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,104,105,106,107,108,109,110,111,112,113,114,115,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
0,41,30,31,32,33,34,35,36,37,38,39,45,46,42,43,20,26,8,21,23,28,24,12,18,19,
47,48,158,224,4,22,7,9,10,11,13,14,15,51,52,53,225,49,29,27,6,25,5,17,16,54,
55,56,229,85,226,44,57,58,59,60,61,62,63,64,65,66,67,83,71,95,96,97,86,92,
93,94,87,89,90,91,98,99,0,0,100,68,69,0,0,0,0,0,0,0,88,228,84,154,230,0,74,
82,75,80,79,77,81,78,73,76,0,0,0,0,0,103,0,72,0,0,0,0,0,227,231,0,0,0,0,0,0,
0,0,0,0,0,0,118,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,104,105,106,107,108,109,110,111,112,113,114,115,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
};

//On Linux, the keycodes are offset by KEYCODE_EVDEV_OFFSET when they are sent by evdev
static const unsigned KEYCODE_EVDEV_OFFSET = 8;

if (scancode < KEYCODE_EVDEV_OFFSET)
return 0;
if (scancode < KEYCODE_EVDEV_OFFSET)
return 0;
scancode -= KEYCODE_EVDEV_OFFSET;

if (scancode >= 256)
return 0;
if (scancode >= 256)
return 0;

return KEYCODE_LINUX_TO_HID[scancode];
return KEYCODE_LINUX_TO_HID[scancode];
}

static void


Loading…
Cancel
Save