From 582e75d3da77a38199a6b7ded7b85e2ea54f233d Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Sat, 9 Feb 2013 01:03:06 +0100 Subject: [PATCH 1/4] Use scancodes instead of localized key (#729) The options dialog still shows localized keys, but the config files use US-Layout keys (when loading default files) and scancodes when saving player changes. --- src/control/C4PlayerControl.cpp | 1 + src/control/C4PlayerControl.h | 2 +- src/gui/C4KeyboardInput.cpp | 405 +++++++++++--------------------- src/platform/C4Window.h | 129 ++++------ src/platform/C4WindowGTK.cpp | 19 +- src/platform/C4WindowWin32.cpp | 35 ++- 6 files changed, 219 insertions(+), 372 deletions(-) diff --git a/src/control/C4PlayerControl.cpp b/src/control/C4PlayerControl.cpp index fc8884222..b700fad87 100644 --- a/src/control/C4PlayerControl.cpp +++ b/src/control/C4PlayerControl.cpp @@ -306,6 +306,7 @@ bool C4PlayerControlAssignment::ResolveRefs(C4PlayerControlAssignmentSet *pParen else if (*szKeyName == '$') { // this is a scan code. re-resolve in case keyboard layout changed. + // is this still relevant? rKeyComboItem.Key = C4KeyCodeEx::GetKeyByScanCode(szKeyName); } } diff --git a/src/control/C4PlayerControl.h b/src/control/C4PlayerControl.h index b25456ba1..c6ffc99fd 100644 --- a/src/control/C4PlayerControl.h +++ b/src/control/C4PlayerControl.h @@ -156,7 +156,7 @@ private: StdCopyStrBuf sKeyName; void CompileFunc(StdCompiler *pComp); void UpdateKeyName(); - bool operator ==(const KeyComboItem &cmp) const { return sKeyName==cmp.sKeyName; } + bool operator ==(const KeyComboItem &cmp) const { return Key==cmp.Key; } }; typedef std::vector KeyComboVec; KeyComboVec KeyCombo; diff --git a/src/gui/C4KeyboardInput.cpp b/src/gui/C4KeyboardInput.cpp index 5e58d4cc9..89ddac6f1 100644 --- a/src/gui/C4KeyboardInput.cpp +++ b/src/gui/C4KeyboardInput.cpp @@ -34,7 +34,9 @@ #ifdef USE_X11 #include -#include // XConvertCase +#include +#include +#include #endif #include @@ -109,228 +111,111 @@ struct C4KeyCodeMapEntry const char *szShortName; }; -#ifdef _WIN32 -const C4KeyCodeMapEntry KeyCodeMap [] = -{ - { VK_CANCEL , "Cancel" , NULL }, - - { VK_BACK , "BackSpace" , NULL }, - { VK_TAB , "Tab" , NULL }, - { VK_CLEAR , "Clear" , NULL }, - { VK_RETURN , "Return" , NULL }, - - { VK_SHIFT , "KeyShift" , "Shift" }, - { VK_CONTROL , "KeyControl" , "Control" }, - { VK_MENU , "Alt" , NULL }, - { VK_PAUSE , "Pause" , NULL }, - - { VK_CAPITAL , "Capital" , NULL }, - { VK_KANA , "Kana" , NULL }, - { VK_HANGEUL , "Hangeul" , NULL }, - { VK_HANGUL , "Hangul" , NULL }, - { VK_JUNJA , "Junja" , NULL }, - { VK_FINAL , "Final" , NULL }, - { VK_HANJA , "Hanja" , NULL }, - { VK_KANJI , "Kanji" , NULL }, - { VK_ESCAPE , "Escape" , "Esc" }, - { VK_ESCAPE , "Esc" ,NULL }, - { VK_CONVERT , "Convert" , NULL }, - { VK_NONCONVERT , "Noconvert" , NULL }, - { VK_ACCEPT , "Accept" , NULL }, - { VK_MODECHANGE , "Modechange" , NULL }, - - { VK_SPACE , "Space" , "Sp" }, - - { VK_PRIOR , "Prior" , NULL }, - { VK_NEXT , "Next" , NULL }, - { VK_END , "End" , NULL }, - { VK_HOME , "Home" , NULL }, - { VK_LEFT , "Left" , NULL }, - { VK_UP , "Up" , NULL }, - { VK_RIGHT , "Right" , NULL }, - { VK_DOWN , "Down" , NULL }, - { VK_SELECT , "Select" , NULL }, - { VK_PRINT , "Print" , NULL }, - { VK_EXECUTE , "Execute" , NULL }, - { VK_SNAPSHOT , "Snapshot" , NULL }, - { VK_INSERT , "Insert" , "Ins" }, - { VK_DELETE , "Delete" , "Del" }, - { VK_HELP , "Help" , NULL }, - - { '0' , "0" , NULL }, - { '1' , "1" , NULL }, - { '2' , "2" , NULL }, - { '3' , "3" , NULL }, - { '4' , "4" , NULL }, - { '5' , "5" , NULL }, - { '6' , "6" , NULL }, - { '7' , "7" , NULL }, - { '8' , "8" , NULL }, - { '9' , "9" , NULL }, - - { 'A' , "A" , NULL }, - { 'B' , "B" , NULL }, - { 'C' , "C" , NULL }, - { 'D' , "D" , NULL }, - { 'E' , "E" , NULL }, - { 'F' , "F" , NULL }, - { 'G' , "G" , NULL }, - { 'H' , "H" , NULL }, - { 'I' , "I" , NULL }, - { 'J' , "J" , NULL }, - { 'K' , "K" , NULL }, - { 'L' , "L" , NULL }, - { 'M' , "M" , NULL }, - { 'N' , "N" , NULL }, - { 'O' , "O" , NULL }, - { 'P' , "P" , NULL }, - { 'Q' , "Q" , NULL }, - { 'R' , "R" , NULL }, - { 'S' , "S" , NULL }, - { 'T' , "T" , NULL }, - { 'U' , "U" , NULL }, - { 'V' , "V" , NULL }, - { 'W' , "W" , NULL }, - { 'X' , "X" , NULL }, - { 'Y' , "Y" , NULL }, - { 'Z' , "Z" , NULL }, - { VK_OEM_COMMA , "Comma" , NULL }, - { VK_OEM_PERIOD , "Period" , NULL }, - { VK_OEM_7 , "Apostrophe", NULL }, - - { VK_LWIN , "WinLeft" , NULL }, - { VK_RWIN , "WinRight" , NULL }, - { VK_APPS , "Apps" , NULL }, - - { VK_NUMPAD0 , "Num0" , "N0" }, - { VK_NUMPAD1 , "Num1" , "N1" }, - { VK_NUMPAD2 , "Num2" , "N2" }, - { VK_NUMPAD3 , "Num3" , "N3" }, - { VK_NUMPAD4 , "Num4" , "N4" }, - { VK_NUMPAD5 , "Num5" , "N5" }, - { VK_NUMPAD6 , "Num6" , "N6" }, - { VK_NUMPAD7 , "Num7" , "N7" }, - { VK_NUMPAD8 , "Num8" , "N8" }, - { VK_NUMPAD9 , "Num9" , "N9" }, - { VK_MULTIPLY , "Multiply" , "N*" }, - { VK_ADD , "Add" , "N+" }, - { VK_SEPARATOR , "Separator" , "NSep" }, - { VK_SUBTRACT , "Subtract" , "N-" }, - { VK_DECIMAL , "Decimal" , "N," }, - { VK_DIVIDE , "Divide" , "N/" }, - { VK_F1 , "F1" , NULL }, - { VK_F2 , "F2" , NULL }, - { VK_F3 , "F3" , NULL }, - { VK_F4 , "F4" , NULL }, - { VK_F5 , "F5" , NULL }, - { VK_F6 , "F6" , NULL }, - { VK_F7 , "F7" , NULL }, - { VK_F8 , "F8" , NULL }, - { VK_F9 , "F9" , NULL }, - { VK_F10 , "F10" , NULL }, - { VK_F11 , "F11" , NULL }, - { VK_F12 , "F12" , NULL }, - { VK_F13 , "F13" , NULL }, - { VK_F14 , "F14" , NULL }, - { VK_F15 , "F15" , NULL }, - { VK_F16 , "F16" , NULL }, - { VK_F17 , "F17" , NULL }, - { VK_F18 , "F18" , NULL }, - { VK_F19 , "F19" , NULL }, - { VK_F20 , "F20" , NULL }, - { VK_F21 , "F21" , NULL }, - { VK_F22 , "F22" , NULL }, - { VK_F23 , "F23" , NULL }, - { VK_F24 , "F24" , NULL }, - { VK_NUMLOCK , "NumLock" , "NLock" }, - { VK_SCROLL , "Scroll" , NULL }, - - { VK_PROCESSKEY , "PROCESSKEY" , NULL }, - -#if defined VK_SLEEP && defined VK_OEM_NEC_EQUAL - { VK_SLEEP , "Sleep" , NULL }, - - { VK_OEM_NEC_EQUAL , "OEM_NEC_EQUAL" , NULL }, - - { VK_OEM_FJ_JISHO , "OEM_FJ_JISHO" , NULL }, - { VK_OEM_FJ_MASSHOU , "OEM_FJ_MASSHOU" , NULL }, - { VK_OEM_FJ_TOUROKU , "OEM_FJ_TOUROKU" , NULL }, - { VK_OEM_FJ_LOYA , "OEM_FJ_LOYA" , NULL }, - { VK_OEM_FJ_ROYA , "OEM_FJ_ROYA" , NULL }, - - { VK_BROWSER_BACK , "BROWSER_BACK" , NULL }, - { VK_BROWSER_FORWARD , "BROWSER_FORWARD" , NULL }, - { VK_BROWSER_REFRESH , "BROWSER_REFRESH" , NULL }, - { VK_BROWSER_STOP , "BROWSER_STOP" , NULL }, - { VK_BROWSER_SEARCH , "BROWSER_SEARCH" , NULL }, - { VK_BROWSER_FAVORITES , "BROWSER_FAVORITES" , NULL }, - { VK_BROWSER_HOME , "BROWSER_HOME" , NULL }, - - { VK_VOLUME_MUTE , "VOLUME_MUTE" , NULL }, - { VK_VOLUME_DOWN , "VOLUME_DOWN" , NULL }, - { VK_VOLUME_UP , "VOLUME_UP" , NULL }, - { VK_MEDIA_NEXT_TRACK , "MEDIA_NEXT_TRACK" , NULL }, - { VK_MEDIA_PREV_TRACK , "MEDIA_PREV_TRACK" , NULL }, - { VK_MEDIA_STOP , "MEDIA_STOP" , NULL }, - { VK_MEDIA_PLAY_PAUSE , "MEDIA_PLAY_PAUSE" , NULL }, - { VK_LAUNCH_MAIL , "LAUNCH_MAIL" , NULL }, - { VK_LAUNCH_MEDIA_SELECT , "LAUNCH_MEDIA_SELECT" , NULL }, - { VK_LAUNCH_APP1 , "LAUNCH_APP1" , NULL }, - { VK_LAUNCH_APP2 , "LAUNCH_APP2" , NULL }, - - { VK_OEM_1 , "Comma_US" , "Ü" }, // German hax - { VK_OEM_PLUS , "OEM +" , "+" }, - { VK_OEM_COMMA , "OEM ," , "," }, - { VK_OEM_MINUS , "OEM -" , "-" }, - { VK_OEM_PERIOD , "OEM ." , "." }, - { VK_OEM_2 , "OEM 2" , "2" }, - { VK_OEM_3 , "OEM Ö" , "Ö" }, // German hax - { VK_OEM_4 , "OEM 4" , "4" }, - { VK_OEM_5 , "OEM 5" , "5" }, - { VK_OEM_6 , "OEM 6" , "6" }, - { VK_OEM_7 , "OEM Ä" , "Ä" }, // German hax - { VK_OEM_8 , "OEM 8" , "8" }, - { VK_OEM_AX , "AX" , "AX" }, - { VK_OEM_102 , "Less" , "<" }, // German hax - { VK_OEM_102 , "Backslash", NULL }, // German hax - { VK_ICO_HELP , "Help" , "Help" }, - { VK_ICO_00 , "ICO_00" , "00" }, - - { VK_ICO_CLEAR , "ICO_CLEAR" , NULL }, - - { VK_PACKET , "PACKET" , NULL }, - - { VK_OEM_RESET , "OEM_RESET" , NULL }, - { VK_OEM_JUMP , "OEM_JUMP" , NULL }, - { VK_OEM_PA1 , "OEM_PA1" , NULL }, - { VK_OEM_PA2 , "OEM_PA2" , NULL }, - { VK_OEM_PA3 , "OEM_PA3" , NULL }, - { VK_OEM_WSCTRL , "OEM_WSCTRL" , NULL }, - { VK_OEM_CUSEL , "OEM_CUSEL" , NULL }, - { VK_OEM_ATTN , "OEM_ATTN" , NULL }, - { VK_OEM_FINISH , "OEM_FINISH" , NULL }, - { VK_OEM_COPY , "OEM_COPY" , NULL }, - { VK_OEM_AUTO , "OEM_AUTO" , NULL }, - { VK_OEM_ENLW , "OEM_ENLW" , NULL }, - { VK_OEM_BACKTAB , "OEM_BACKTAB" , NULL }, -#endif - - { VK_ATTN , "ATTN" , NULL }, - { VK_CRSEL , "CRSEL" , NULL }, - { VK_EXSEL , "EXSEL" , NULL }, - { VK_EREOF , "EREOF" , NULL }, - { VK_PLAY , "PLAY" , NULL }, - { VK_ZOOM , "ZOOM" , NULL }, - { VK_NONAME , "NONAME" , NULL }, - { VK_PA1 , "PA1" , NULL }, - { VK_OEM_CLEAR , "OEM_CLEAR" , NULL }, - - { KEY_Any, "Any" , NULL}, - { KEY_Default, "None", NULL}, - { KEY_Undefined, NULL, NULL } +#if defined(USE_WIN32_WINDOWS) || defined(USE_X11) +const C4KeyCodeMapEntry KeyCodeMap[] = { + {1, "Escape", "Esc"}, + {2, "1", NULL}, + {3, "2", NULL}, + {4, "3", NULL}, + {5, "4", NULL}, + {6, "5", NULL}, + {7, "6", NULL}, + {8, "7", NULL}, + {9, "8", NULL}, + {10, "9", NULL}, + {11, "0", NULL}, + {12, "Minus", "-"}, + {13, "Equal", "="}, + {14, "BackSpace", NULL}, + {15, "Tab", NULL}, + {16, "Q", NULL}, + {17, "W", NULL}, + {18, "E", NULL}, + {19, "R", NULL}, + {20, "T", NULL}, + {21, "Y", NULL}, + {22, "U", NULL}, + {23, "I", NULL}, + {24, "O", NULL}, + {25, "P", NULL}, + {26, "LeftBracket", "["}, + {27, "RightBracket", "]"}, + {28, "Return", "Ret"}, + {29, "LeftControl", "LCtrl"}, + {30, "A", NULL}, + {31, "S", NULL}, + {32, "D", NULL}, + {33, "F", NULL}, + {34, "G", NULL}, + {35, "H", NULL}, + {36, "J", NULL}, + {37, "K", NULL}, + {38, "L", NULL}, + {39, "Semicolon", ";"}, + {40, "Apostrophe", "'"}, + {42, "LeftShift", "LShift"}, + {43, "Backslash", "\\"}, + {44, "Z", NULL}, + {45, "X", NULL}, + {46, "C", NULL}, + {47, "V", NULL}, + {48, "B", NULL}, + {49, "N", NULL}, + {50, "M", NULL}, + {51, "Comma", ","}, + {52, "Period", "."}, + {53, "Slash", "/"}, + {54, "RightShift", "RShift"}, + {55, "Multiply", "N*"}, + {56, "LeftAlt", "LAlt"}, + {57, "Space", "Sp"}, + {58, "Capslock", NULL}, + {59, "F1", NULL}, + {60, "F2", NULL}, + {61, "F3", NULL}, + {62, "F4", NULL}, + {63, "F5", NULL}, + {64, "F6", NULL}, + {65, "F7", NULL}, + {66, "F8", NULL}, + {67, "F9", NULL}, + {68, "F10", NULL}, + {69, "NumLock", "NLock"}, + {71, "Num7", "N7"}, + {72, "Num8", "N8"}, + {73, "Num9", "N9"}, + {74, "Subtract", "N-"}, + {75, "Num4", "N4"}, + {76, "Num5", "N5"}, + {77, "Num6", "N6"}, + {78, "Add", "N+"}, + {79, "Num1", "N1"}, + {80, "Num2", "N2"}, + {81, "Num3", "N3"}, + {82, "Num0", "N0"}, + {83, "Decimal", "N,"}, + {86, "|<>", NULL}, + {87, "F11", NULL}, + {88, "F12", NULL}, + {96, "NumReturn", "NRet"}, + {97, "RightControl", "RCtrl"}, + {98, "Divide", "N/"}, + {100, "RightAlt", "RAlt"}, + {102, "Home", NULL}, + {103, "Up", NULL}, + {104, "PageUp", NULL}, + {105, "Left", NULL}, + {106, "Right", NULL}, + {107, "End", NULL}, + {108, "Down", NULL}, + {109, "PageDown", NULL}, + {110, "Insert", "Ins"}, + {111, "Delete", "Del"}, + {119, "Pause", NULL}, + {125, "LeftWin", "LWin"}, + {127, "Menu", NULL}, + {0x00, NULL, NULL} }; -#elif defined(USE_X11) -#include #elif defined(USE_COCOA) #include "CocoaKeycodeMap.h" #endif @@ -340,17 +225,7 @@ C4KeyCode C4KeyCodeEx::GetKeyByScanCode(const char *scan_code) // scan code is in hex format unsigned int scan_code_int; if (sscanf(scan_code, "$%x", &scan_code_int) != 1) return KEY_Undefined; - // resolve using OS function -#ifdef _WIN32 - return MapVirtualKey(scan_code_int, 1 /* MAPVK_VSC_TO_VK */); // MAPVK_VSC_TO_VK is undefined due to some bug on some MinGW versions -#elif USE_X11 - Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default()); - return XKeycodeToKeysym(dpy, scan_code_int, 0); -#else - // cannot resolve scan codes - assert(false); - return KEY_Undefined; -#endif + return scan_code_int; } C4KeyCode C4KeyCodeEx::String2KeyCode(const StdStrBuf &sName) @@ -454,29 +329,16 @@ C4KeyCode C4KeyCodeEx::String2KeyCode(const StdStrBuf &sName) } } -#if defined(_WIN32) || defined(USE_COCOA) +#if defined(USE_WIN32_WINDOWS) || defined(USE_COCOA) || defined(USE_X11) // query map const C4KeyCodeMapEntry *pCheck = KeyCodeMap; - while (pCheck->szName) - if (SEqualNoCase(sName.getData(), pCheck->szName)) break; else ++pCheck; - return pCheck->wCode; -#elif defined(USE_X11) - KeySym result = XStringToKeysym(sName.getData()); - // Some keysysm strings start with a lowercase letter, so also check that. - if (!result) - { - StdCopyStrBuf sName2(sName); - sName2.ToLowerCase(); - result = XStringToKeysym(sName2.getData()); - if(!result) - return KEY_Undefined; + while (pCheck->szName) { + if (SEqualNoCase(sName.getData(), pCheck->szName)) { + return(pCheck->wCode); + } + ++pCheck; } - - // Use the lowercase keysym in case there is a difference because this - // is what's reported for actual key presses. - KeySym lower, upper; - XConvertCase(result, &lower, &upper); - return lower; + return KEY_Undefined; #elif defined(USE_SDL_MAINLOOP) for (C4KeyCode k = 0; k < SDLK_LAST; ++k) { @@ -551,6 +413,11 @@ StdStrBuf C4KeyCodeEx::KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bool } } + // it's a keyboard key + if (!fHumanReadable) { + // for config files and such: dump scancode + return FormatString("$%x", static_cast(wCode)); + } #if defined(_WIN32) || defined(USE_COCOA) // TODO: Works? @@ -563,19 +430,33 @@ StdStrBuf C4KeyCodeEx::KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bool // Name.SetLength(res); // return Name; - // query map - const C4KeyCodeMapEntry *pCheck = KeyCodeMap; - while (pCheck->szName) - if (wCode == pCheck->wCode) return StdStrBuf((pCheck->szShortName && fShort) ? pCheck->szShortName : pCheck->szName); else ++pCheck; - // not found: Compose as direct code - return FormatString("\\x%x", static_cast(wCode)); + wchar_t buf[100]; + int len = GetKeyNameText(wCode<<16, buf, 100); + if (len > 0) { + // buf is nullterminated name + return StdStrBuf(buf); + } #elif defined(USE_X11) - return StdStrBuf(XKeysymToString(wCode)); + Display * const dpy = gdk_x11_display_get_xdisplay(gdk_display_get_default()); + KeySym keysym = (KeySym)XkbKeycodeToKeysym(dpy,wCode+8,0,0); + char* name = NULL; + if (keysym != NoSymbol) { // is the keycode without shift modifiers mapped to a symbol? + #if defined(USE_GTK3) + name = gtk_accelerator_get_label_with_keycode(dpy, keysym, wCode+8, (GdkModifierType)0); + #else + name = gtk_accelerator_get_label(keysym, (GdkModifierType)0); + #endif + } + if (name) { // is there a string representation of the keysym? + // prevent memleak + StdStrBuf buf; + buf.Take(name); + return buf; + } #elif defined(USE_SDL_MAINLOOP) return StdStrBuf(getKeyName(wCode).c_str()); -#else - return StdStrBuf("unknown"); #endif + return FormatString("$%x", static_cast(wCode)); } StdStrBuf C4KeyCodeEx::ToString(bool fHumanReadable, bool fShort) const diff --git a/src/platform/C4Window.h b/src/platform/C4Window.h index 53beb4d0b..81d6573c5 100644 --- a/src/platform/C4Window.h +++ b/src/platform/C4Window.h @@ -29,93 +29,48 @@ #include -#ifdef USE_WIN32_WINDOWS -#include -#define K_ALT VK_MENU -#define K_ESCAPE VK_ESCAPE -#define K_PAUSE VK_PAUSE -#define K_TAB VK_TAB -#define K_RETURN VK_RETURN -#define K_DELETE VK_DELETE -#define K_INSERT VK_INSERT -#define K_BACK VK_BACK -#define K_SPACE VK_SPACE -#define K_F1 VK_F1 -#define K_F2 VK_F2 -#define K_F3 VK_F3 -#define K_F4 VK_F4 -#define K_F5 VK_F5 -#define K_F6 VK_F6 -#define K_F7 VK_F7 -#define K_F8 VK_F8 -#define K_F9 VK_F9 -#define K_F10 VK_F10 -#define K_F11 VK_F11 -#define K_F12 VK_F12 -#define K_ADD VK_ADD -#define K_SUBTRACT VK_SUBTRACT -#define K_MULTIPLY VK_MULTIPLY -#define K_UP VK_UP -#define K_DOWN VK_DOWN -#define K_LEFT VK_LEFT -#define K_RIGHT VK_RIGHT -#define K_HOME VK_HOME -#define K_END VK_END -#define K_SCROLL VK_SCROLL -#define K_MENU VK_APPS -#define K_PAGEUP VK_PRIOR -#define K_PAGEDOWN VK_NEXT -#define KEY_A ((WORD) 'A') // select all in GUI-editbox -#define KEY_C ((WORD) 'C') // copy in GUI-editbox -#define KEY_I ((WORD) 'I') // console mode control key -#define KEY_M ((WORD) 'M') // console mode control key -#define KEY_T ((WORD) 'T') // console mode control key -#define KEY_V ((WORD) 'V') // paste in GUI-editbox -#define KEY_W ((WORD) 'W') // console mode control key -#define KEY_X ((WORD) 'X') // cut from GUI-editbox -#elif defined(USE_X11) -#include -#define K_F1 XK_F1 -#define K_F2 XK_F2 -#define K_F3 XK_F3 -#define K_F4 XK_F4 -#define K_F5 XK_F5 -#define K_F6 XK_F6 -#define K_F7 XK_F7 -#define K_F8 XK_F8 -#define K_F9 XK_F9 -#define K_F10 XK_F10 -#define K_F11 XK_F11 -#define K_F12 XK_F12 -#define K_ADD XK_KP_Add -#define K_SUBTRACT XK_KP_Subtract -#define K_MULTIPLY XK_KP_Multiply -#define K_ESCAPE XK_Escape -#define K_PAUSE XK_Pause -#define K_TAB XK_Tab -#define K_RETURN XK_Return -#define K_DELETE XK_Delete -#define K_INSERT XK_Insert -#define K_BACK XK_BackSpace -#define K_SPACE XK_space -#define K_UP XK_Up -#define K_DOWN XK_Down -#define K_LEFT XK_Left -#define K_RIGHT XK_Right -#define K_HOME XK_Home -#define K_END XK_End -#define K_SCROLL XK_Scroll_Lock -#define K_MENU XK_Menu -#define K_PAGEUP XK_Page_Up -#define K_PAGEDOWN XK_Page_Down -#define KEY_A XK_a // select all in GUI-editbox -#define KEY_C XK_c // copy in GUI-editbox -#define KEY_I XK_i // console mode control key -#define KEY_M XK_m // console mode control key -#define KEY_T XK_t // console mode control key -#define KEY_V XK_v // paste in GUI-editbox -#define KEY_W XK_w // console mode control key -#define KEY_X XK_x // cut from GUI-editbox +#if defined(USE_WIN32_WINDOWS) || defined(USE_X11) +#define K_F1 59 +#define K_F2 60 +#define K_F3 61 +#define K_F4 62 +#define K_F5 63 +#define K_F6 64 +#define K_F7 65 +#define K_F8 66 +#define K_F9 67 +#define K_F10 68 +#define K_F11 87 +#define K_F12 88 +#define K_ADD 78 +#define K_SUBTRACT 74 +#define K_MULTIPLY 55 +#define K_ESCAPE 1 +#define K_PAUSE 119 +#define K_TAB 15 +#define K_RETURN 28 +#define K_DELETE 111 +#define K_INSERT 110 +#define K_BACK 14 +#define K_SPACE 57 +#define K_UP 103 +#define K_DOWN 108 +#define K_LEFT 105 +#define K_RIGHT 106 +#define K_HOME 102 +#define K_END 107 +#define K_SCROLL 70 +#define K_MENU 127 +#define K_PAGEUP 104 +#define K_PAGEDOWN 109 +#define KEY_A 30 // select all in GUI-editbox +#define KEY_C 46 // copy in GUI-editbox +#define KEY_I 23 // console mode control key +#define KEY_M 50 // console mode control key +#define KEY_T 20 // console mode control key +#define KEY_V 47 // paste in GUI-editbox +#define KEY_W 17 // console mode control key +#define KEY_X 45 // cut from GUI-editbox #elif defined(USE_SDL_MAINLOOP) #include #define K_F1 SDLK_F1 diff --git a/src/platform/C4WindowGTK.cpp b/src/platform/C4WindowGTK.cpp index bb898769f..ba3515841 100644 --- a/src/platform/C4WindowGTK.cpp +++ b/src/platform/C4WindowGTK.cpp @@ -224,16 +224,18 @@ static gboolean OnDelete(GtkWidget* widget, GdkEvent* event, gpointer data) static gboolean OnKeyPress(GtkWidget* widget, GdkEventKey* event, gpointer data) { C4Window* wnd = static_cast(data); - DWORD key = XKeycodeToKeysym(GDK_WINDOW_XDISPLAY(event->window), event->hardware_keycode, 0); - Game.DoKeyboardInput(key, KEYEV_Down, !!(event->state & GDK_MOD1_MASK), !!(event->state & GDK_CONTROL_MASK), !!(event->state & GDK_SHIFT_MASK), false, NULL); + // keycode = scancode + 8 + if (event->hardware_keycode <= 8) return false; + Game.DoKeyboardInput(event->hardware_keycode-8, KEYEV_Down, !!(event->state & GDK_MOD1_MASK), !!(event->state & GDK_CONTROL_MASK), !!(event->state & GDK_SHIFT_MASK), false, NULL); wnd->CharIn(event->string); // FIXME: Use GtkIMContext somehow return true; } static gboolean OnKeyRelease(GtkWidget* widget, GdkEventKey* event, gpointer user_data) { - DWORD key = XKeycodeToKeysym(GDK_WINDOW_XDISPLAY(event->window), event->hardware_keycode, 0); - Game.DoKeyboardInput(key, KEYEV_Up, !!(event->state & GDK_MOD1_MASK), !!(event->state & GDK_CONTROL_MASK), !!(event->state & GDK_SHIFT_MASK), false, NULL); + // keycode = scancode + 8 + if (event->hardware_keycode <= 8) return false; + Game.DoKeyboardInput(event->hardware_keycode-8, KEYEV_Up, !!(event->state & GDK_MOD1_MASK), !!(event->state & GDK_CONTROL_MASK), !!(event->state & GDK_SHIFT_MASK), false, NULL); return true; } @@ -285,16 +287,15 @@ static gboolean OnKeyPressStatic(GtkWidget* widget, GdkEventKey* event, gpointer static_cast(user_data)->cvp->TogglePlayerLock(); return true; } - - DWORD key = XKeycodeToKeysym(GDK_WINDOW_XDISPLAY(event->window), event->hardware_keycode, 0); - Console.EditCursor.KeyDown(key, event->state); + if (event->hardware_keycode <= 8) return false; + Console.EditCursor.KeyDown(event->hardware_keycode - 8, event->state); return false; } static gboolean OnKeyReleaseStatic(GtkWidget* widget, GdkEventKey* event, gpointer user_data) { - DWORD key = XKeycodeToKeysym(GDK_WINDOW_XDISPLAY(event->window), event->hardware_keycode, 0); - Console.EditCursor.KeyUp(key, event->state); + if (event->hardware_keycode <= 8) return false; + Console.EditCursor.KeyUp(event->hardware_keycode - 8, event->state); return false; } diff --git a/src/platform/C4WindowWin32.cpp b/src/platform/C4WindowWin32.cpp index 8f3cbabda..81340a614 100644 --- a/src/platform/C4WindowWin32.cpp +++ b/src/platform/C4WindowWin32.cpp @@ -64,6 +64,9 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l p.x = GET_X_LPARAM(lParam); p.y = GET_Y_LPARAM(lParam); + // compute scancode + C4KeyCode scancode = (((unsigned int)lParam) >> 16) & 0xFF; + // Process message switch (uMsg) { @@ -128,16 +131,16 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l Application.MusicSystem.NotifySuccess(); return true; case WM_KEYUP: - if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) + if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) return 0; break; case WM_KEYDOWN: - if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; break; case WM_SYSKEYDOWN: if (wParam == 18) break; - if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; break; case WM_CHAR: @@ -214,6 +217,9 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa if (!(cvp=::Viewports.GetViewport(hwnd))) return DefWindowProcW(hwnd, uMsg, wParam, lParam); + // compute scancode + C4KeyCode scancode = (((unsigned int)lParam) >> 16) & 0xFF; + // Process message switch (uMsg) { @@ -229,19 +235,19 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - default: - if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; break; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - } break; //--------------------------------------------------------------------------------------------------------------------------- case WM_KEYUP: - if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, NULL)) return 0; break; //------------------------------------------------------------------------------------------------------------ case WM_SYSKEYDOWN: if (wParam == 18) break; - if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), NULL)) return 0; break; //---------------------------------------------------------------------------------------------------------------------------------- case WM_DESTROY: @@ -384,16 +390,16 @@ LRESULT APIENTRY ViewportWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPa switch (uMsg) { case WM_KEYDOWN: - Console.EditCursor.KeyDown(wParam, dwKeyState); + Console.EditCursor.KeyDown(scancode, dwKeyState); break; case WM_KEYUP: - Console.EditCursor.KeyUp(wParam, dwKeyState); + Console.EditCursor.KeyUp(scancode, dwKeyState); break; case WM_SYSKEYDOWN: - Console.EditCursor.KeyDown(wParam, dwKeyState); + Console.EditCursor.KeyDown(scancode, dwKeyState); break; case WM_SYSKEYUP: - Console.EditCursor.KeyUp(wParam, dwKeyState); + Console.EditCursor.KeyUp(scancode, dwKeyState); break; //---------------------------------------------------------------------------------------------------------------------------------- case WM_LBUTTONDOWN: @@ -425,21 +431,24 @@ LRESULT APIENTRY DialogWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPara p.x = GET_X_LPARAM(lParam); p.y = GET_Y_LPARAM(lParam); + // compute scancode + C4KeyCode scancode = (((unsigned int)lParam) >> 16) & 0xFF; + // Process message switch (uMsg) { //--------------------------------------------------------------------------------------------------------------------------- case WM_KEYDOWN: - if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0; break; //--------------------------------------------------------------------------------------------------------------------------- case WM_KEYUP: - if (Game.DoKeyboardInput(wParam, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, pDlg)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Up, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, false, pDlg)) return 0; break; //------------------------------------------------------------------------------------------------------------ case WM_SYSKEYDOWN: if (wParam == 18) break; - if (Game.DoKeyboardInput(wParam, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0; + if (Game.DoKeyboardInput(scancode, KEYEV_Down, !!(lParam & 0x20000000), GetKeyState(VK_CONTROL) < 0, GetKeyState(VK_SHIFT) < 0, !!(lParam & 0x40000000), pDlg)) return 0; break; //---------------------------------------------------------------------------------------------------------------------------------- case WM_DESTROY: From 346842470d663e60815dcc742c774895ff5aeabb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Sun, 24 Mar 2013 18:33:01 +0100 Subject: [PATCH 2/4] Clean up some superfluous includes --- src/editor/C4ConsoleX11.cpp | 32 -------------------------------- src/editor/C4ViewportWindow.cpp | 3 --- src/gui/C4GuiDialogs.cpp | 10 ---------- src/gui/C4KeyboardInput.cpp | 1 - 4 files changed, 46 deletions(-) delete mode 100644 src/editor/C4ConsoleX11.cpp diff --git a/src/editor/C4ConsoleX11.cpp b/src/editor/C4ConsoleX11.cpp deleted file mode 100644 index 7d1a0708b..000000000 --- a/src/editor/C4ConsoleX11.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * OpenClonk, http://www.openclonk.org - * - * Copyright (c) 2006 Armin Burgmeier - * Copyright (c) 2009 Günther Brammer - * Copyright (c) 2010 Martin Plicht - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -namespace -{ - const DWORD OFN_HIDEREADONLY = 1 << 0; - const DWORD OFN_OVERWRITEPROMPT = 1 << 1; - const DWORD OFN_FILEMUSTEXIST = 1 << 2; - const DWORD OFN_ALLOWMULTISELECT = 1 << 3; - - const DWORD OFN_EXPLORER = 0; // ignored -} -#ifdef USE_X11 -#include -#include -#endif diff --git a/src/editor/C4ViewportWindow.cpp b/src/editor/C4ViewportWindow.cpp index ce9d370c6..0d66a8c98 100644 --- a/src/editor/C4ViewportWindow.cpp +++ b/src/editor/C4ViewportWindow.cpp @@ -37,10 +37,7 @@ #include #ifdef USE_X11 -#include #ifdef WITH_DEVELOPER_MODE -#include -#include #include #endif #endif diff --git a/src/gui/C4GuiDialogs.cpp b/src/gui/C4GuiDialogs.cpp index 0ce6e1300..f8f00856c 100644 --- a/src/gui/C4GuiDialogs.cpp +++ b/src/gui/C4GuiDialogs.cpp @@ -41,16 +41,6 @@ #include #include -#ifdef _WIN32 -#include "resource.h" -#endif - -#ifdef USE_X11 -#define None Die_XLib_Die -#include -#undef None -#endif - namespace C4GUI { diff --git a/src/gui/C4KeyboardInput.cpp b/src/gui/C4KeyboardInput.cpp index 89ddac6f1..52b675b36 100644 --- a/src/gui/C4KeyboardInput.cpp +++ b/src/gui/C4KeyboardInput.cpp @@ -33,7 +33,6 @@ #include #ifdef USE_X11 -#include #include #include #include From 71d9e3c9e332481e07ccc84e61dd629a828d74cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Sun, 24 Mar 2013 22:10:11 +0100 Subject: [PATCH 3/4] editor: Recognize pressing shift and alt in viewport again --- src/editor/C4EditCursor.cpp | 12 ++++-------- src/platform/C4Window.h | 16 ++++++++++++++++ src/platform/C4WindowMac.mm | 4 ++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/editor/C4EditCursor.cpp b/src/editor/C4EditCursor.cpp index 821eb0882..9c0f849a2 100644 --- a/src/editor/C4EditCursor.cpp +++ b/src/editor/C4EditCursor.cpp @@ -376,11 +376,9 @@ bool C4EditCursor::LeftButtonUp(DWORD dwKeyState) bool C4EditCursor::KeyDown(C4KeyCode KeyCode, DWORD dwKeyState) { - C4KeyCodeEx kcx(KeyCode); - // alt check bool fAltIsDown = (dwKeyState & MK_ALT) != 0; - fAltIsDown = fAltIsDown || (kcx.ToString(false, false) == "Alt" || kcx.ToString(false, false) == "Alt_L" || kcx.ToString(false, false) == "Alt_R"); + fAltIsDown = fAltIsDown || KeyCode == K_ALT_L || KeyCode == K_ALT_R; if (fAltIsDown != fAltWasDown) { if ((fAltWasDown = fAltIsDown)) @@ -391,7 +389,7 @@ bool C4EditCursor::KeyDown(C4KeyCode KeyCode, DWORD dwKeyState) // shift check bool fShiftIsDown = (dwKeyState & MK_SHIFT) != 0; - fShiftIsDown = fShiftIsDown || (kcx.ToString(false, false) == "Shift" || kcx.ToString(false, false) == "Shift_L" || kcx.ToString(false, false) == "Shift_R"); + fShiftIsDown = fShiftIsDown || KeyCode == K_SHIFT_L || KeyCode == K_SHIFT_R; if(fShiftIsDown != fShiftWasDown) fShiftWasDown = fShiftIsDown; @@ -400,11 +398,9 @@ bool C4EditCursor::KeyDown(C4KeyCode KeyCode, DWORD dwKeyState) bool C4EditCursor::KeyUp(C4KeyCode KeyCode, DWORD dwKeyState) { - C4KeyCodeEx kcx(KeyCode); - // alt check bool fAltIsDown = (dwKeyState & MK_ALT) != 0; - fAltIsDown = fAltIsDown && !(kcx.ToString(false, false) == "Alt" || kcx.ToString(false, false) == "Alt_L" || kcx.ToString(false, false) == "Alt_R"); + fAltIsDown = fAltIsDown && !( KeyCode == K_ALT_L || KeyCode == K_ALT_R); if (fAltIsDown != fAltWasDown) { if ((fAltWasDown = fAltIsDown)) @@ -415,7 +411,7 @@ bool C4EditCursor::KeyUp(C4KeyCode KeyCode, DWORD dwKeyState) // shift check bool fShiftIsDown = (dwKeyState & MK_SHIFT) != 0; - fShiftIsDown = fShiftIsDown && !(kcx.ToString(false, false) == "Shift" || kcx.ToString(false, false) == "Shift_L" || kcx.ToString(false, false) == "Shift_R"); + fShiftIsDown = fShiftIsDown && !(KeyCode == K_SHIFT_L || KeyCode == K_SHIFT_R); if(fShiftIsDown != fShiftWasDown) fShiftWasDown = fShiftIsDown; diff --git a/src/platform/C4Window.h b/src/platform/C4Window.h index 81d6573c5..027f76037 100644 --- a/src/platform/C4Window.h +++ b/src/platform/C4Window.h @@ -30,6 +30,10 @@ #include #if defined(USE_WIN32_WINDOWS) || defined(USE_X11) +#define K_SHIFT_L 42 +#define K_SHIFT_R 54 +#define K_ALT_L 56 +#define K_ALT_R 100 #define K_F1 59 #define K_F2 60 #define K_F3 61 @@ -73,6 +77,10 @@ #define KEY_X 45 // cut from GUI-editbox #elif defined(USE_SDL_MAINLOOP) #include +#define K_SHIFT_L SDLK_LSHIFT +#define K_SHIFT_R SDLK_RSHIFT +#define K_ALT_L SDLK_LALT +#define K_ALT_R SDLK_RALT #define K_F1 SDLK_F1 #define K_F2 SDLK_F2 #define K_F3 SDLK_F3 @@ -115,6 +123,10 @@ #define KEY_X SDLK_x #define KEY_A SDLK_a #elif defined(USE_CONSOLE) +#define K_SHIFT_L 0 +#define K_SHIFT_R 0 +#define K_ALT_L 0 +#define K_ALT_R 0 #define K_F1 0 #define K_F2 0 #define K_F3 0 @@ -160,6 +172,10 @@ #import "ObjectiveCAssociated.h" // declare as extern variables and initialize them in StdMacWindow.mm so as to not include objc headers const int CocoaKeycodeOffset = 300; +extern int K_SHIFT_L; +extern int K_SHIFT_R; +extern int K_ALT_L; +extern int K_ALT_R; extern int K_F1; extern int K_F2; extern int K_F3; diff --git a/src/platform/C4WindowMac.mm b/src/platform/C4WindowMac.mm index d1a116f60..fec4a2224 100644 --- a/src/platform/C4WindowMac.mm +++ b/src/platform/C4WindowMac.mm @@ -134,6 +134,10 @@ bool C4Window::ReInit(C4AbstractApp* pApp) return true; } +int K_SHIFT_L; // FIXME +int K_SHIFT_R; +int K_ALT_L; +int K_ALT_R; int K_F1 = 122 + CocoaKeycodeOffset; int K_F2 = 120 + CocoaKeycodeOffset; int K_F3 = 99 + CocoaKeycodeOffset; From 50eb1b6a762c9b321fdfef7bdf0fd62b4b1b0743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnther=20Brammer?= Date: Sun, 24 Mar 2013 22:30:39 +0100 Subject: [PATCH 4/4] Since internal keycodes are now scancodes, they do not need to be resolved --- src/control/C4PlayerControl.cpp | 6 ------ src/gui/C4KeyboardInput.h | 3 ++- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/control/C4PlayerControl.cpp b/src/control/C4PlayerControl.cpp index b700fad87..e9a4d504c 100644 --- a/src/control/C4PlayerControl.cpp +++ b/src/control/C4PlayerControl.cpp @@ -303,12 +303,6 @@ bool C4PlayerControlAssignment::ResolveRefs(C4PlayerControlAssignmentSet *pParen is_key_reference = true; szKeyName +=4; } - else if (*szKeyName == '$') - { - // this is a scan code. re-resolve in case keyboard layout changed. - // is this still relevant? - rKeyComboItem.Key = C4KeyCodeEx::GetKeyByScanCode(szKeyName); - } } if (is_key_reference) { diff --git a/src/gui/C4KeyboardInput.h b/src/gui/C4KeyboardInput.h index 34741228b..25018cef0 100644 --- a/src/gui/C4KeyboardInput.h +++ b/src/gui/C4KeyboardInput.h @@ -198,7 +198,6 @@ struct C4KeyCodeEx // helpers static C4KeyShiftState String2KeyShift(const StdStrBuf &sName); - static C4KeyCode GetKeyByScanCode(const char *scan_code); static C4KeyCode String2KeyCode(const StdStrBuf &sName); static StdStrBuf KeyCode2String(C4KeyCode wCode, bool fHumanReadable, bool fShort); StdStrBuf ToString(bool fHumanReadable, bool fShort) const; @@ -221,6 +220,8 @@ struct C4KeyCodeEx : Key(Key), dwShift(Shift), fRepeated(fIsRepeated) {} bool IsRepeated() const { return fRepeated; } +private: + static C4KeyCode GetKeyByScanCode(const char *scan_code); }; // extra data associated with a key event