convert windows scancodes to linux scancodes where they differ; make linux compile

scancodes-fix
Tobias Zwick 2013-05-26 15:13:02 +02:00
parent 120cff1262
commit 3cbd53bada
2 changed files with 53 additions and 14 deletions

View File

@ -102,13 +102,15 @@
#define K_SCROLL 70
#define K_SUBTRACT 74
#define K_ADD 78
#define K_86 86 // also backslash?
#define K_86 86
#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
@ -125,14 +127,9 @@
#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
@ -145,9 +142,8 @@
#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
@ -162,8 +158,8 @@
#define K_DIVIDE 98
#define K_ALT_R 100
#define K_CONTROL_R ???
#define K_NUM_RETURN ???
#define K_CONTROL_R 99999 // todo
#define K_NUM_RETURN 99999 // todo
#define K_HOME 102
#define K_UP 103
@ -175,11 +171,12 @@
#define K_PAGEDOWN 109
#define K_INSERT 110
#define K_DELETE 111
#define K_WIN_L ???
#define K_WIN_R ???
#define K_WIN_L 99999 // todo
#define K_WIN_R 99999 // todo
#define K_MENU 127
#define K_PAUSE 119
#define K_PRINT ???
#define K_PRINT 99999 // todo
#define K_CENTER 99999 // todo
#endif

View File

@ -56,6 +56,47 @@
#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;
@ -66,6 +107,7 @@ 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)