From 120cff12623f474371f28e36f52fc4da71fb5256 Mon Sep 17 00:00:00 2001 From: Tobias Zwick Date: Sun, 26 May 2013 15:01:23 +0200 Subject: [PATCH] convert windows scancodes to linux scancodes where they differ; make linux compile --- src/platform/C4Window.h | 25 +++++++++++--------- src/platform/C4WindowWin32.cpp | 42 ---------------------------------- 2 files changed, 14 insertions(+), 53 deletions(-) diff --git a/src/platform/C4Window.h b/src/platform/C4Window.h index 70284dc8d..ffb9c2f3f 100644 --- a/src/platform/C4Window.h +++ b/src/platform/C4Window.h @@ -102,15 +102,13 @@ #define K_SCROLL 70 #define K_SUBTRACT 74 #define K_ADD 78 -#define K_86 86 +#define K_86 86 // also backslash? #define K_F11 87 #define K_F12 88 -/* // starting from here, scancodes between windows and linux differ -// this is not used because the windows scancodes are converted to -// unix scancodes in C4WindowWin32.cpp ConvertToUnixScancode #if defined(USE_WIN32_WINDOWS) + #define K_HOME 71 #define K_UP 72 #define K_PAGEUP 73 @@ -127,9 +125,14 @@ #define K_MENU 93 #define K_PAUSE 69 // same as numlock?! #define K_PRINT 55 // same as multiply?! + #define K_ALT_R K_ALT_L // 29 56 #define K_CONTROL_R K_CONTROL_L // 29 29 #define K_NUM_RETURN K_RETURN // 28 57 + +// FIXME? + +// these are all not differed #define K_NUM7 K_HOME #define K_NUM8 K_UP #define K_NUM9 K_PAGEUP @@ -142,8 +145,9 @@ #define K_NUM0 K_INSERT #define K_DECIMAL K_DELETE #define K_DIVIDE K_SLASH + #elif defined(USE_X11) || defined(USE_CONSOLE) -*/ + #define K_NUM7 71 #define K_NUM8 72 #define K_NUM9 73 @@ -158,8 +162,8 @@ #define K_DIVIDE 98 #define K_ALT_R 100 -#define K_CONTROL_R 99999 // todo -#define K_NUM_RETURN 99999 // todo +#define K_CONTROL_R ??? +#define K_NUM_RETURN ??? #define K_HOME 102 #define K_UP 103 @@ -171,12 +175,11 @@ #define K_PAGEDOWN 109 #define K_INSERT 110 #define K_DELETE 111 -#define K_WIN_L 99999 // todo -#define K_WIN_R 99999 // todo +#define K_WIN_L ??? +#define K_WIN_R ??? #define K_MENU 127 #define K_PAUSE 119 -#define K_PRINT 99999 // todo -#define K_CENTER 99999 // todo +#define K_PRINT ??? #endif diff --git a/src/platform/C4WindowWin32.cpp b/src/platform/C4WindowWin32.cpp index 13045c990..81340a614 100644 --- a/src/platform/C4WindowWin32.cpp +++ b/src/platform/C4WindowWin32.cpp @@ -56,47 +56,6 @@ #define ConsoleDlgClassName L"C4GUIdlg" #define ConsoleDlgWindowStyle (WS_VISIBLE | WS_POPUP | WS_SYSMENU | WS_CAPTION | WS_MINIMIZEBOX) -/** Convert certain keys to unix scancodes (those that differ from unix scancodes) */ -static void ConvertToUnixScancode(WPARAM wParam, C4KeyCode *scancode) -{ - C4KeyCode &s = *scancode; - - switch(wParam) - { - case VK_HOME: s = K_HOME; break; - case VK_END: s = K_END; break; - case VK_PRIOR: s = K_PAGEUP; break; - case VK_NEXT: s = K_PAGEDOWN; break; - case VK_UP: s = K_UP; break; - case VK_DOWN: s = K_DOWN; break; - case VK_LEFT: s = K_LEFT; break; - case VK_RIGHT: s = K_RIGHT; break; - case VK_CLEAR: s = K_CENTER; break; - case VK_INSERT: s = K_INSERT; break; - case VK_DELETE: s = K_DELETE; break; - case VK_LWIN: s = K_WIN_L; break; - case VK_RWIN: s = K_WIN_R; break; - case VK_MENU: s = K_MENU; break; - case VK_PAUSE: s = K_PAUSE; break; - case VK_PRINT: s = K_PRINT; break; - case VK_RCONTROL: s = K_CONTROL_R; break; - - case VK_NUMLOCK: s = K_NUM; break; - case VK_NUMPAD1: s = K_NUM1; break; - case VK_NUMPAD2: s = K_NUM2; break; - case VK_NUMPAD3: s = K_NUM3; break; - case VK_NUMPAD4: s = K_NUM4; break; - case VK_NUMPAD5: s = K_NUM5; break; - case VK_NUMPAD6: s = K_NUM6; break; - case VK_NUMPAD7: s = K_NUM7; break; - case VK_NUMPAD8: s = K_NUM8; break; - case VK_NUMPAD9: s = K_NUM9; break; - case VK_NUMPAD0: s = K_NUM0; break; - default: - // others are fine. - } -} - LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { static bool NativeCursorShown = true; @@ -107,7 +66,6 @@ LRESULT APIENTRY FullScreenWinProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l // compute scancode C4KeyCode scancode = (((unsigned int)lParam) >> 16) & 0xFF; - ConvertToUnixScancode(wParam, &scancode); // Process message switch (uMsg)