From 07c65851ba7bb19f9b64638ea3e9b8e3f41eb9cd Mon Sep 17 00:00:00 2001 From: Patrick Desaulniers Date: Mon, 26 Aug 2019 17:46:08 -0400 Subject: [PATCH] Adjustments to keycode support --- dgl/src/pugl/{COPYING => COPYING.keycode} | 0 dgl/src/pugl/pugl_osx.m | 2 +- dgl/src/pugl/pugl_win.cpp | 2 +- dgl/src/pugl/pugl_x11.c | 7 +++++-- 4 files changed, 7 insertions(+), 4 deletions(-) rename dgl/src/pugl/{COPYING => COPYING.keycode} (100%) diff --git a/dgl/src/pugl/COPYING b/dgl/src/pugl/COPYING.keycode similarity index 100% rename from dgl/src/pugl/COPYING rename to dgl/src/pugl/COPYING.keycode diff --git a/dgl/src/pugl/pugl_osx.m b/dgl/src/pugl/pugl_osx.m index 0bc54534..5662079e 100644 --- a/dgl/src/pugl/pugl_osx.m +++ b/dgl/src/pugl/pugl_osx.m @@ -127,7 +127,7 @@ getModifiers(PuglView* view, NSEvent* ev) static unsigned scancodeToHID(unsigned scancode) { - const unsigned char KEYCODE_MACOS_TO_HID[128] = { + 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, diff --git a/dgl/src/pugl/pugl_win.cpp b/dgl/src/pugl/pugl_win.cpp index 1e03f483..50e03986 100644 --- a/dgl/src/pugl/pugl_win.cpp +++ b/dgl/src/pugl/pugl_win.cpp @@ -383,7 +383,7 @@ setModifiers(PuglView* view) static unsigned keycodeToHID(unsigned keycode) { - const unsigned char KEYCODE_WINDOWS_TO_HID[256] = { + 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, diff --git a/dgl/src/pugl/pugl_x11.c b/dgl/src/pugl/pugl_x11.c index e80105af..62274c25 100644 --- a/dgl/src/pugl/pugl_x11.c +++ b/dgl/src/pugl/pugl_x11.c @@ -492,7 +492,7 @@ setModifiers(PuglView* view, unsigned xstate, unsigned xtime) static unsigned scancodeToHID(unsigned scancode) { - const unsigned char KEYCODE_LINUX_TO_HID[256] = { + 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, @@ -505,8 +505,11 @@ scancodeToHID(unsigned scancode) }; //On Linux, the keycodes are offset by KEYCODE_EVDEV_OFFSET when they are sent by evdev - const unsigned KEYCODE_EVDEV_OFFSET = 8; + static const unsigned KEYCODE_EVDEV_OFFSET = 8; + if (scancode < KEYCODE_EVDEV_OFFSET) + return 0; + scancode -= KEYCODE_EVDEV_OFFSET; if (scancode >= 256)