From 287b7f7dac2433d8d284f2d4f68737c634692d29 Mon Sep 17 00:00:00 2001 From: Thorsten Otto Date: Thu, 21 Mar 2024 12:53:16 +0100 Subject: [PATCH] Fix keyboard handling for SDL1 A lot of scancodes in SDL1 are > 256. The current code assumed in a lot of places that they are less than 256, causing eg. ctrl-key combination not to work. Also the the sdl_keymap array for translating keysyms to ascii was only suitable for SDL2. --- common/gadget.cpp | 2 +- common/sdl_keymap.h | 265 -------- common/wwkeyboard.cpp | 286 +++++++-- common/wwkeyboard.h | 1259 +++++++++++++++----------------------- redalert/conquer.cpp | 10 +- redalert/edit.cpp | 7 +- redalert/ending.cpp | 2 +- redalert/mapedit.cpp | 6 +- redalert/menus.cpp | 2 +- redalert/msglist.cpp | 16 +- redalert/options.cpp | 98 +-- tiberiandawn/conquer.cpp | 10 +- tiberiandawn/edit.cpp | 9 +- tiberiandawn/mapedit.cpp | 6 +- tiberiandawn/msgbox.cpp | 5 +- tiberiandawn/msglist.cpp | 19 +- tiberiandawn/options.cpp | 100 +-- 17 files changed, 862 insertions(+), 1240 deletions(-) delete mode 100644 common/sdl_keymap.h diff --git a/common/gadget.cpp b/common/gadget.cpp index 647aab60..401596bf 100644 --- a/common/gadget.cpp +++ b/common/gadget.cpp @@ -526,7 +526,7 @@ KeyNumType GadgetClass::Input(void) ** know the position of the mouse at the exact instant when the click occurred ** rather the the mouse position at the time we get around to this function. */ - if (((key & 0xFF) == KN_LMOUSE) || ((key & 0xFF) == KN_RMOUSE)) { + if (((key & KN_SCANCODE_MASK) == KN_LMOUSE) || ((key & KN_SCANCODE_MASK) == KN_RMOUSE)) { mousex = Keyboard->MouseQX; mousey = Keyboard->MouseQY; } else { diff --git a/common/sdl_keymap.h b/common/sdl_keymap.h deleted file mode 100644 index d4aef21a..00000000 --- a/common/sdl_keymap.h +++ /dev/null @@ -1,265 +0,0 @@ -/* -** Standard US ANSI keyboard layout for SDL -*/ - -// covers all ASCII characters producible from a standard ANSI/ISO keyboard -#define KEYMAP_SIZE 105 - -static KeyASCIIType sdl_keymap[KEYMAP_SIZE * 2] = { - // 0 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_a, - KA_b, - KA_c, - KA_d, - KA_e, - KA_f, - - // 10 - KA_g, - KA_h, - KA_i, - KA_j, - KA_k, - KA_l, - KA_m, - KA_n, - KA_o, - KA_p, - - // 20 - KA_q, - KA_r, - KA_s, - KA_t, - KA_u, - KA_v, - KA_w, - KA_x, - KA_y, - KA_z, - - // 30 - KA_1, - KA_2, - KA_3, - KA_4, - KA_5, - KA_6, - KA_7, - KA_8, - KA_9, - KA_0, - - // 40 - KA_RETURN, - KA_ESC, - KA_BACKSPACE, - KA_TAB, - KA_SPACE, - KA_MINUS, - KA_EQUAL, - KA_LBRACKET, - KA_RBRACKET, - KA_BACKSLASH, - - // 50 - KA_NONE, - KA_SEMICOLON, - KA_SQUOTE, - KA_GRAVE, - KA_COMMA, - KA_PERIOD, - KA_SLASH, - KA_NONE, - KA_NONE, - KA_NONE, - - // 60 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - - // 70 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - - // 80 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_SLASH, - KA_ASTERISK, - KA_MINUS, - KA_PLUS, - KA_RETURN, - KA_1, - - // 90 - KA_2, - KA_3, - KA_4, - KA_5, - KA_6, - KA_7, - KA_8, - KA_9, - KA_0, - KA_PERIOD, - - // 100 - KA_BACKSLASH, // ISO - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - - /* - ** Shifted keys - */ - - // 0 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_A, - KA_B, - KA_C, - KA_D, - KA_E, - KA_F, - - // 10 - KA_G, - KA_H, - KA_I, - KA_J, - KA_K, - KA_L, - KA_M, - KA_N, - KA_O, - KA_P, - - // 20 - KA_Q, - KA_R, - KA_S, - KA_T, - KA_U, - KA_V, - KA_W, - KA_X, - KA_Y, - KA_Z, - - // 30 - KA_EXCLAMATION, - KA_AT, - KA_POUND, - KA_DOLLAR, - KA_PERCENT, - KA_CARROT, - KA_AMPER, - KA_ASTERISK, - KA_LPAREN, - KA_RPAREN, - - // 40 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_UNDERLINE, - KA_PLUS, - KA_LBRACE, - KA_RBRACE, - KA_BAR, - - // 50 - KA_NONE, - KA_COLON, - KA_DQUOTE, - KA_TILDA, - KA_LESS_THAN, - KA_GREATER_THAN, - KA_QUESTION, - KA_NONE, - KA_NONE, - KA_NONE, - - // 60 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - - // 70 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - - // 80 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - - // 90 - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE, - - // 100 - KA_BAR, // ISO - KA_NONE, - KA_NONE, - KA_NONE, - KA_NONE}; diff --git a/common/wwkeyboard.cpp b/common/wwkeyboard.cpp index 8020d1f2..7ea796da 100644 --- a/common/wwkeyboard.cpp +++ b/common/wwkeyboard.cpp @@ -59,7 +59,6 @@ #include #ifdef SDL_BUILD #include -#include "sdl_keymap.h" #endif #include "settings.h" @@ -136,7 +135,7 @@ unsigned short WWKeyboardClass::Buff_Get(void) *=============================================================================================*/ bool WWKeyboardClass::Is_Mouse_Key(unsigned short key) { - key &= 0xFF; + key &= KN_SCANCODE_MASK; return (key == KN_LMOUSE || key == KN_MMOUSE || key == KN_RMOUSE); } @@ -223,18 +222,18 @@ bool WWKeyboardClass::Put_Key_Message(unsigned short vk_key, bool release) */ if (!Is_Mouse_Key(vk_key)) { if (Down(KN_LSHIFT) || Down(KN_RSHIFT) || Down(KN_CAPSLOCK) || Down(KN_NUMLOCK)) { - vk_key |= WWKEY_SHIFT_BIT; + vk_key |= KN_SHIFT_BIT; } if (Down(KN_LCTRL) || Down(KN_RCTRL)) { - vk_key |= WWKEY_CTRL_BIT; + vk_key |= KN_CTRL_BIT; } if (Down(KN_LALT) || Down(KN_RALT)) { - vk_key |= WWKEY_ALT_BIT; + vk_key |= KN_ALT_BIT; } } if (release) { - vk_key |= WWKEY_RLS_BIT; + vk_key |= KN_RLSE_BIT; } /* @@ -296,10 +295,155 @@ KeyASCIIType WWKeyboardClass::To_ASCII(unsigned short key) /* ** Released keys never translate into an ASCII value. */ - if (key & WWKEY_RLS_BIT) { + if (key & KN_RLSE_BIT) { return KA_NONE; } +#if defined(SDL_BUILD) + key &= KN_SCANCODE_MASK; // drop all mods + bool shift = (SDL_GetModState() & KMOD_SHIFT) != 0; + + switch (key) { + case KN_A: + return shift ? KA_A : KA_a; + case KN_B: + return shift ? KA_B : KA_b; + case KN_C: + return shift ? KA_C : KA_c; + case KN_D: + return shift ? KA_D : KA_d; + case KN_E: + return shift ? KA_E : KA_e; + case KN_F: + return shift ? KA_F : KA_f; + case KN_G: + return shift ? KA_G : KA_g; + case KN_H: + return shift ? KA_H : KA_h; + case KN_I: + return shift ? KA_I : KA_i; + case KN_J: + return shift ? KA_J : KA_j; + case KN_K: + return shift ? KA_K : KA_k; + case KN_L: + return shift ? KA_L : KA_l; + case KN_M: + return shift ? KA_M : KA_m; + case KN_N: + return shift ? KA_N : KA_n; + case KN_O: + return shift ? KA_O : KA_o; + case KN_P: + return shift ? KA_P : KA_p; + case KN_Q: + return shift ? KA_Q : KA_q; + case KN_R: + return shift ? KA_R : KA_r; + case KN_S: + return shift ? KA_S : KA_s; + case KN_T: + return shift ? KA_T : KA_t; + case KN_U: + return shift ? KA_U : KA_u; + case KN_V: + return shift ? KA_V : KA_v; + case KN_W: + return shift ? KA_W : KA_w; + case KN_X: + return shift ? KA_X : KA_x; + case KN_Y: + return shift ? KA_Y : KA_y; + case KN_Z: + return shift ? KA_Z : KA_z; + + // FIXME: remaining mappings may only be valid for Standard US ANSI keyboard layout + case KN_1: + return shift ? KA_EXCLAMATION : KA_1; + case KN_2: + return shift ? KA_AT : KA_2; + case KN_3: + return shift ? KA_HASH : KA_3; + case KN_4: + return shift ? KA_DOLLAR : KA_4; + case KN_5: + return shift ? KA_PERCENT : KA_5; + case KN_6: + return shift ? KA_CARET : KA_6; + case KN_7: + return shift ? KA_AMPER : KA_7; + case KN_8: + return shift ? KA_ASTERISK : KA_8; + case KN_9: + return shift ? KA_LPAREN : KA_9; + case KN_0: + return shift ? KA_RPAREN : KA_0; + case KN_RETURN: + return shift ? KA_NONE : KA_RETURN; + case KN_ESC: + return shift ? KA_NONE : KA_ESC; + case KN_BACKSPACE: + return shift ? KA_NONE : KA_BACKSPACE; + case KN_TAB: + return shift ? KA_NONE : KA_TAB; + case KN_SPACE: + return shift ? KA_NONE : KA_SPACE; + case KN_MINUS: + return shift ? KA_UNDERLINE : KA_MINUS; + case KN_EQUAL: + return shift ? KA_PLUS : KA_EQUAL; + case KN_LBRACKET: + return shift ? KA_LBRACE : KA_LBRACKET; + case KN_RBRACKET: + return shift ? KA_RBRACE : KA_RBRACKET; + case KN_BACKSLASH: + return shift ? KA_BAR : KA_BACKSLASH; + case KN_SEMICOLON: + return shift ? KA_COLON : KA_SEMICOLON; + case KN_SQUOTE: + return shift ? KA_DQUOTE : KA_SQUOTE; + case KN_GRAVE: + return shift ? KA_TILDA : KA_GRAVE; + case KN_COMMA: + return shift ? KA_LESS_THAN : KA_COMMA; + case KN_PERIOD: + return shift ? KA_GREATER_THAN : KA_PERIOD; + case KN_SLASH: + return shift ? KA_QUESTION : KA_SLASH; + case KN_KEYPAD_SLASH: + return shift ? KA_NONE : KA_SLASH; + case KN_KEYPAD_ASTERISK: + return shift ? KA_NONE : KA_ASTERISK; + case KN_KEYPAD_MINUS: + return shift ? KA_NONE : KA_MINUS; + case KN_KEYPAD_PLUS: + return shift ? KA_NONE : KA_PLUS; + case KN_E_END: + return shift ? KA_NONE : KA_1; + case KN_E_DOWN: + return shift ? KA_NONE : KA_2; + case KN_E_PGDN: + return shift ? KA_NONE : KA_3; + case KN_E_LEFT: + return shift ? KA_NONE : KA_4; + case KN_SELECT: + return shift ? KA_NONE : KA_5; + case KN_E_RIGHT: + return shift ? KA_NONE : KA_6; + case KN_E_HOME: + return shift ? KA_NONE : KA_7; + case KN_E_UP: + return shift ? KA_NONE : KA_8; + case KN_E_PGUP: + return shift ? KA_NONE : KA_9; + case KN_E_INSERT: + return shift ? KA_NONE : KA_0; + case KN_E_DELETE: + return shift ? KA_NONE : KA_PERIOD; + } + + return KA_NONE; +#elif defined(_WIN32) /* ** Ask windows to translate the key into an ASCII equivalent. */ @@ -307,48 +451,34 @@ KeyASCIIType WWKeyboardClass::To_ASCII(unsigned short key) int result = 1; int scancode = 0; -#if defined(SDL_BUILD) - key &= 0xFF; // drop all mods - - if (key > ARRAY_SIZE(sdl_keymap) / 2 - 1) { - return KA_NONE; - } - - if (SDL_GetModState() & KMOD_SHIFT) { - return sdl_keymap[key + ARRAY_SIZE(sdl_keymap) / 2]; - } else { - return sdl_keymap[key]; - } -#elif defined(_WIN32) /* ** Set the KeyState buffer to reflect the shift bits stored in the key value. */ - if (key & WWKEY_SHIFT_BIT) { + if (key & KN_SHIFT_BIT) { KeyState[VK_SHIFT] = 0x80; } - if (key & WWKEY_CTRL_BIT) { + if (key & KN_CTRL_BIT) { KeyState[VK_CONTROL] = 0x80; } - if (key & WWKEY_ALT_BIT) { + if (key & KN_ALT_BIT) { KeyState[VK_MENU] = 0x80; } - scancode = MapVirtualKeyA(key & 0xFF, 0); - result = ToAscii((UINT)(key & 0xFF), (UINT)scancode, (PBYTE)KeyState, (LPWORD)buffer, (UINT)0); + scancode = MapVirtualKeyA(key & KN_SCANCODE_MASK, 0); + result = ToAscii((UINT)(key & KN_SCANCODE_MASK), (UINT)scancode, (PBYTE)KeyState, (LPWORD)buffer, (UINT)0); /* ** Restore the KeyState buffer back to pristine condition. */ - if (key & WWKEY_SHIFT_BIT) { + if (key & KN_SHIFT_BIT) { KeyState[VK_SHIFT] = 0; } - if (key & WWKEY_CTRL_BIT) { + if (key & KN_CTRL_BIT) { KeyState[VK_CONTROL] = 0; } - if (key & WWKEY_ALT_BIT) { + if (key & KN_ALT_BIT) { KeyState[VK_MENU] = 0; } -#endif /* ** If Windows could not perform the translation as expected, then @@ -359,6 +489,7 @@ KeyASCIIType WWKeyboardClass::To_ASCII(unsigned short key) } return (KeyASCIIType)(buffer[0]); +#endif } /*********************************************************************************************** @@ -552,20 +683,48 @@ void WWKeyboardClass::Fill_Buffer_From_System(void) break; case SDL_KEYDOWN: #ifdef SDL2_BUILD + switch (event.key.keysym.scancode) { + case SDL_SCANCODE_KP_ENTER: + event.key.keysym.scancode = SDL_SCANCODE_RETURN; + break; + } Put_Key_Message(event.key.keysym.scancode, false); #else - Put_Key_Message(event.key.keysym.sym, false); + switch (event.key.keysym.sym) { + case SDLK_KP_ENTER: + event.key.keysym.sym = SDLK_RETURN; + break; + } + if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) { + /* Switching to full screen is handled in the key up event */ + } else { + Put_Key_Message(event.key.keysym.sym, false); + } #endif break; case SDL_KEYUP: #ifdef SDL2_BUILD - if (event.key.keysym.scancode == SDL_SCANCODE_RETURN && Down(VK_MENU)) { + switch (event.key.keysym.scancode) { + case SDL_SCANCODE_KP_ENTER: + event.key.keysym.scancode = SDL_SCANCODE_RETURN; + break; + } + if (event.key.keysym.scancode == SDL_SCANCODE_RETURN && Down(KN_LALT)) { Toggle_Video_Fullscreen(); } else { Put_Key_Message(event.key.keysym.scancode, true); } #else - Put_Key_Message(event.key.keysym.sym, true); + switch (event.key.keysym.sym) { + case SDLK_KP_ENTER: + event.key.keysym.sym = SDLK_RETURN; + break; + } + if (event.key.keysym.sym == SDLK_RETURN && (event.key.keysym.mod & KMOD_ALT)) { + Toggle_Video_Fullscreen(); + } else { + Put_Key_Message(event.key.keysym.sym, true); + } #endif break; case SDL_MOUSEMOTION: @@ -578,20 +737,29 @@ void WWKeyboardClass::Fill_Buffer_From_System(void) switch (event.button.button) { case SDL_BUTTON_LEFT: default: - key = VK_LBUTTON; + key = KN_LMOUSE; break; +#ifdef __MINT__ + /* MiNT SDL port may have a bug in the gem driver, + reporting right button presses as button 2 (SDL_BUTTON_MIDDLE) */ case SDL_BUTTON_RIGHT: - key = VK_RBUTTON; + case SDL_BUTTON_MIDDLE: + key = KN_RMOUSE; + break; +#else + case SDL_BUTTON_RIGHT: + key = KN_RMOUSE; break; case SDL_BUTTON_MIDDLE: - key = VK_MBUTTON; + key = KN_MMOUSE; break; +#endif #ifdef SDL1_BUILD case SDL_BUTTON_WHEELUP: - key = VK_MOUSEWHEEL_UP; + key = KN_MOUSEWHEEL_UP; break; case SDL_BUTTON_WHEELDOWN: - key = VK_MOUSEWHEEL_DOWN; + key = KN_MOUSEWHEEL_DOWN; break; #endif } @@ -624,9 +792,9 @@ void WWKeyboardClass::Fill_Buffer_From_System(void) break; case SDL_MOUSEWHEEL: if (event.wheel.y > 0) { // scroll up - Put_Key_Message(VK_MOUSEWHEEL_UP, false); + Put_Key_Message(KN_MOUSEWHEEL_UP, false); } else if (event.wheel.y < 0) { // scroll down - Put_Key_Message(VK_MOUSEWHEEL_DOWN, false); + Put_Key_Message(KN_MOUSEWHEEL_DOWN, false); } break; case SDL_CONTROLLERDEVICEREMOVED: @@ -785,11 +953,11 @@ void WWKeyboardClass::Handle_Controller_Button_Event(const SDL_ControllerButtonE switch (button.button) { case SDL_CONTROLLER_BUTTON_A: mousePress = true; - key = VK_LBUTTON; + key = KN_LMOUSE; break; case SDL_CONTROLLER_BUTTON_B: mousePress = true; - key = VK_RBUTTON; + key = KN_RMOUSE; break; case SDL_CONTROLLER_BUTTON_X: keyboardPress = true; @@ -949,7 +1117,7 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** Press of the left mouse button. */ case WM_LBUTTONDOWN: - Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_LMOUSE, LOWORD(lParam), HIWORD(lParam)); processed = true; break; @@ -957,7 +1125,7 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** Release of the left mouse button. */ case WM_LBUTTONUP: - Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_LMOUSE, LOWORD(lParam), HIWORD(lParam), true); processed = true; break; @@ -966,10 +1134,10 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** just a rapid click of the left button twice. */ case WM_LBUTTONDBLCLK: - Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam)); - Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true); - Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam)); - Put_Mouse_Message(VK_LBUTTON, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_LMOUSE, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_LMOUSE, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_LMOUSE, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_LMOUSE, LOWORD(lParam), HIWORD(lParam), true); processed = true; break; @@ -977,7 +1145,7 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** Press of the middle mouse button. */ case WM_MBUTTONDOWN: - Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_MMOUSE, LOWORD(lParam), HIWORD(lParam)); processed = true; break; @@ -985,7 +1153,7 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** Release of the middle mouse button. */ case WM_MBUTTONUP: - Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_MMOUSE, LOWORD(lParam), HIWORD(lParam), true); processed = true; break; @@ -994,10 +1162,10 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** regular middle button clicks. */ case WM_MBUTTONDBLCLK: - Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam)); - Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true); - Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam)); - Put_Mouse_Message(VK_MBUTTON, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_MMOUSE, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_MMOUSE, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_MMOUSE, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_MMOUSE, LOWORD(lParam), HIWORD(lParam), true); processed = true; break; @@ -1005,7 +1173,7 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** Right mouse button press. */ case WM_RBUTTONDOWN: - Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_RMOUSE, LOWORD(lParam), HIWORD(lParam)); processed = true; break; @@ -1013,7 +1181,7 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** Right mouse button release. */ case WM_RBUTTONUP: - Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_RMOUSE, LOWORD(lParam), HIWORD(lParam), true); processed = true; break; @@ -1022,10 +1190,10 @@ bool WWKeyboardClass::Message_Handler(HWND window, UINT message, UINT wParam, LO ** into being just two regular right button clicks. */ case WM_RBUTTONDBLCLK: - Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam)); - Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true); - Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam)); - Put_Mouse_Message(VK_RBUTTON, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_RMOUSE, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_RMOUSE, LOWORD(lParam), HIWORD(lParam), true); + Put_Mouse_Message(KN_RMOUSE, LOWORD(lParam), HIWORD(lParam)); + Put_Mouse_Message(KN_RMOUSE, LOWORD(lParam), HIWORD(lParam), true); processed = true; break; diff --git a/common/wwkeyboard.h b/common/wwkeyboard.h index a18c047a..759c2d12 100644 --- a/common/wwkeyboard.h +++ b/common/wwkeyboard.h @@ -43,501 +43,6 @@ #include #endif -typedef enum -{ - WWKEY_SHIFT_BIT = 0x100, - WWKEY_CTRL_BIT = 0x200, - WWKEY_ALT_BIT = 0x400, - WWKEY_RLS_BIT = 0x800, - WWKEY_VK_BIT = 0x1000, - WWKEY_DBL_BIT = 0x2000, - WWKEY_BTN_BIT = 0x8000, -} WWKey_Type; - -#ifdef SDL1_BUILD -#include -#define VK_NONE SDLK_UNKNOWN -#define VK_LBUTTON 0x01 -#define VK_RBUTTON 0x02 -#define VK_MBUTTON 0x03 -#define VK_MOUSEWHEEL_UP 0x04 -#define VK_MOUSEWHEEL_DOWN 0x05 -#define VK_BACK SDLK_BACKSPACE -#define VK_TAB SDLK_TAB -#define VK_CLEAR SDLK_CLEAR -#define VK_RETURN SDLK_RETURN -#define VK_SHIFT SDLK_LSHIFT -#define VK_CONTROL SDLK_LCTRL -#define VK_MENU SDLK_LALT -#define VK_PAUSE SDLK_PAUSE -#define VK_CAPITAL SDLK_CAPSLOCK -#define VK_ESCAPE SDLK_ESCAPE -#define VK_SPACE SDLK_SPACE -#define VK_PRIOR SDLK_PAGEUP -#define VK_NEXT SDLK_PAGEDOWN -#define VK_END SDLK_END -#define VK_HOME SDLK_HOME -#define VK_LEFT SDLK_LEFT -#define VK_UP SDLK_UP -#define VK_RIGHT SDLK_RIGHT -#define VK_DOWN SDLK_DOWN -#define VK_SELECT SDLK_UNKNOWN //SELECT -#define VK_PRINT SDLK_PRINT -#define VK_INSERT SDLK_INSERT -#define VK_DELETE SDLK_DELETE -#define VK_NUMPAD0 SDLK_KP0 -#define VK_NUMPAD1 SDLK_KP1 -#define VK_NUMPAD2 SDLK_KP2 -#define VK_NUMPAD3 SDLK_KP3 -#define VK_NUMPAD4 SDLK_KP4 -#define VK_NUMPAD5 SDLK_KP5 -#define VK_NUMPAD6 SDLK_KP6 -#define VK_NUMPAD7 SDLK_KP7 -#define VK_NUMPAD8 SDLK_KP8 -#define VK_NUMPAD9 SDLK_KP9 -#define VK_MULTIPLY SDLK_KP_MULTIPLY -#define VK_ADD SDLK_KP_PLUS -#define VK_SUBTRACT SDLK_KP_MINUS -#define VK_DIVIDE SDLK_KP_DIVIDE -#define VK_0 SDLK_0 -#define VK_1 SDLK_1 -#define VK_2 SDLK_2 -#define VK_3 SDLK_3 -#define VK_4 SDLK_4 -#define VK_5 SDLK_5 -#define VK_6 SDLK_6 -#define VK_7 SDLK_7 -#define VK_8 SDLK_8 -#define VK_9 SDLK_9 -#define VK_A SDLK_a -#define VK_B SDLK_b -#define VK_C SDLK_c -#define VK_D SDLK_d -#define VK_E SDLK_e -#define VK_F SDLK_f -#define VK_G SDLK_g -#define VK_H SDLK_h -#define VK_I SDLK_i -#define VK_J SDLK_j -#define VK_K SDLK_k -#define VK_L SDLK_l -#define VK_M SDLK_m -#define VK_N SDLK_n -#define VK_O SDLK_o -#define VK_P SDLK_p -#define VK_Q SDLK_q -#define VK_R SDLK_r -#define VK_S SDLK_s -#define VK_T SDLK_t -#define VK_U SDLK_u -#define VK_V SDLK_v -#define VK_W SDLK_w -#define VK_X SDLK_x -#define VK_Y SDLK_y -#define VK_Z SDLK_z -#define VK_F1 SDLK_F1 -#define VK_F2 SDLK_F2 -#define VK_F3 SDLK_F3 -#define VK_F4 SDLK_F4 -#define VK_F5 SDLK_F5 -#define VK_F6 SDLK_F6 -#define VK_F7 SDLK_F7 -#define VK_F8 SDLK_F8 -#define VK_F9 SDLK_F9 -#define VK_F10 SDLK_F10 -#define VK_F11 SDLK_F11 -#define VK_F12 SDLK_F12 -#define VK_NUMLOCK SDLK_NUMLOCK -#define VK_SCROLL SDLK_SCROLLOCK -#define VK_NONE_BA SDLK_SEMICOLON -#define VK_NONE_BB SDLK_EQUALS -#define VK_NONE_BC SDLK_COMMA -#define VK_NONE_BD SDLK_MINUS -#define VK_NONE_BE SDLK_PERIOD -#define VK_NONE_BF SDLK_SLASH -#define VK_NONE_C0 SDLK_UNKNOWN //GRAVE -#define VK_NONE_DB SDLK_LEFTBRACKET -#define VK_NONE_DC SDLK_BACKSLASH -#define VK_NONE_DD SDLK_RIGHTBRACKET -#define VK_NONE_DE SDLK_UNKNOWN //APOSTROPHE - -#elif defined(SDL2_BUILD) - -#include - -#define VK_NONE SDL_SCANCODE_UNKNOWN - -#define VK_LBUTTON 0x01 -#define VK_RBUTTON 0x02 -#define VK_MBUTTON 0x03 - -#define VK_BACK SDL_SCANCODE_BACKSPACE -#define VK_TAB SDL_SCANCODE_TAB -#define VK_CLEAR SDL_SCANCODE_CLEAR -#define VK_RETURN SDL_SCANCODE_RETURN -#define VK_SHIFT SDL_SCANCODE_LSHIFT -#define VK_CONTROL SDL_SCANCODE_LCTRL -#define VK_MENU SDL_SCANCODE_LALT -#define VK_PAUSE SDL_SCANCODE_PAUSE -#define VK_CAPITAL SDL_SCANCODE_CAPSLOCK -#define VK_ESCAPE SDL_SCANCODE_ESCAPE -#define VK_SPACE SDL_SCANCODE_SPACE -#define VK_PRIOR SDL_SCANCODE_PAGEUP -#define VK_NEXT SDL_SCANCODE_PAGEDOWN -#define VK_END SDL_SCANCODE_END -#define VK_HOME SDL_SCANCODE_HOME -#define VK_LEFT SDL_SCANCODE_LEFT -#define VK_UP SDL_SCANCODE_UP -#define VK_RIGHT SDL_SCANCODE_RIGHT -#define VK_DOWN SDL_SCANCODE_DOWN -#define VK_SELECT SDL_SCANCODE_SELECT -#define VK_PRINT SDL_SCANCODE_PRINTSCREEN -#define VK_INSERT SDL_SCANCODE_INSERT -#define VK_DELETE SDL_SCANCODE_DELETE -#define VK_NUMPAD0 SDL_SCANCODE_KP_0 -#define VK_NUMPAD1 SDL_SCANCODE_KP_1 -#define VK_NUMPAD2 SDL_SCANCODE_KP_2 -#define VK_NUMPAD3 SDL_SCANCODE_KP_3 -#define VK_NUMPAD4 SDL_SCANCODE_KP_4 -#define VK_NUMPAD5 SDL_SCANCODE_KP_5 -#define VK_NUMPAD6 SDL_SCANCODE_KP_6 -#define VK_NUMPAD7 SDL_SCANCODE_KP_7 -#define VK_NUMPAD8 SDL_SCANCODE_KP_8 -#define VK_NUMPAD9 SDL_SCANCODE_KP_9 -#define VK_MULTIPLY SDL_SCANCODE_KP_MULTIPLY -#define VK_ADD SDL_SCANCODE_KP_PLUS -#define VK_SUBTRACT SDL_SCANCODE_KP_MINUS -#define VK_DIVIDE SDL_SCANCODE_KP_DIVIDE -#define VK_0 SDL_SCANCODE_0 -#define VK_1 SDL_SCANCODE_1 -#define VK_2 SDL_SCANCODE_2 -#define VK_3 SDL_SCANCODE_3 -#define VK_4 SDL_SCANCODE_4 -#define VK_5 SDL_SCANCODE_5 -#define VK_6 SDL_SCANCODE_6 -#define VK_7 SDL_SCANCODE_7 -#define VK_8 SDL_SCANCODE_8 -#define VK_9 SDL_SCANCODE_9 -#define VK_A SDL_SCANCODE_A -#define VK_B SDL_SCANCODE_B -#define VK_C SDL_SCANCODE_C -#define VK_D SDL_SCANCODE_D -#define VK_E SDL_SCANCODE_E -#define VK_F SDL_SCANCODE_F -#define VK_G SDL_SCANCODE_G -#define VK_H SDL_SCANCODE_H -#define VK_I SDL_SCANCODE_I -#define VK_J SDL_SCANCODE_J -#define VK_K SDL_SCANCODE_K -#define VK_L SDL_SCANCODE_L -#define VK_M SDL_SCANCODE_M -#define VK_N SDL_SCANCODE_N -#define VK_O SDL_SCANCODE_O -#define VK_P SDL_SCANCODE_P -#define VK_Q SDL_SCANCODE_Q -#define VK_R SDL_SCANCODE_R -#define VK_S SDL_SCANCODE_S -#define VK_T SDL_SCANCODE_T -#define VK_U SDL_SCANCODE_U -#define VK_V SDL_SCANCODE_V -#define VK_W SDL_SCANCODE_W -#define VK_X SDL_SCANCODE_X -#define VK_Y SDL_SCANCODE_Y -#define VK_Z SDL_SCANCODE_Z -#define VK_F1 SDL_SCANCODE_F1 -#define VK_F2 SDL_SCANCODE_F2 -#define VK_F3 SDL_SCANCODE_F3 -#define VK_F4 SDL_SCANCODE_F4 -#define VK_F5 SDL_SCANCODE_F5 -#define VK_F6 SDL_SCANCODE_F6 -#define VK_F7 SDL_SCANCODE_F7 -#define VK_F8 SDL_SCANCODE_F8 -#define VK_F9 SDL_SCANCODE_F9 -#define VK_F10 SDL_SCANCODE_F10 -#define VK_F11 SDL_SCANCODE_F11 -#define VK_F12 SDL_SCANCODE_F12 -#define VK_NUMLOCK SDL_SCANCODE_NUMLOCKCLEAR -#define VK_SCROLL SDL_SCANCODE_SCROLLLOCK -#define VK_NONE_BA SDL_SCANCODE_SEMICOLON -#define VK_NONE_BB SDL_SCANCODE_EQUALS -#define VK_NONE_BC SDL_SCANCODE_COMMA -#define VK_NONE_BD SDL_SCANCODE_MINUS -#define VK_NONE_BE SDL_SCANCODE_PERIOD -#define VK_NONE_BF SDL_SCANCODE_SLASH -#define VK_NONE_C0 SDL_SCANCODE_GRAVE -#define VK_NONE_DB SDL_SCANCODE_LEFTBRACKET -#define VK_NONE_DC SDL_SCANCODE_BACKSLASH -#define VK_NONE_DD SDL_SCANCODE_RIGHTBRACKET -#define VK_NONE_DE SDL_SCANCODE_APOSTROPHE -#define VK_MOUSEWHEEL_DOWN 0xFD -#define VK_MOUSEWHEEL_UP 0xFE - -#else - -#define VK_NONE 0x00 -#define VK_LBUTTON 0x01 -#define VK_RBUTTON 0x02 -#define VK_CANCEL 0x03 -#define VK_MBUTTON 0x04 -#define VK_NONE_05 0x05 -#define VK_NONE_06 0x06 -#define VK_NONE_07 0x07 -#define VK_BACK 0x08 -#define VK_TAB 0x09 -#define VK_NONE_0A 0x0A -#define VK_NONE_0B 0x0B -#define VK_CLEAR 0x0C -#define VK_RETURN 0x0D -#define VK_NONE_0E 0x0E -#define VK_NONE_0F 0x0F -#define VK_SHIFT 0x10 -#define VK_CONTROL 0x11 -#define VK_MENU 0x12 -#define VK_PAUSE 0x13 -#define VK_CAPITAL 0x14 -#define VK_NONE_15 0x15 -#define VK_NONE_16 0x16 -#define VK_NONE_17 0x17 -#define VK_NONE_18 0x18 -#define VK_NONE_19 0x19 -#define VK_NONE_1A 0x1A -#define VK_ESCAPE 0x1B -#define VK_NONE_1C 0x1C -#define VK_NONE_1D 0x1D -#define VK_NONE_1E 0x1E -#define VK_NONE_1F 0x1F -#define VK_SPACE 0x20 -#define VK_PRIOR 0x21 -#define VK_NEXT 0x22 -#define VK_END 0x23 -#define VK_HOME 0x24 -#define VK_LEFT 0x25 -#define VK_UP 0x26 -#define VK_RIGHT 0x27 -#define VK_DOWN 0x28 -#define VK_SELECT 0x29 -#define VK_PRINT 0x2A -#define VK_EXECUTE 0x2B -#define VK_SNAPSHOT 0x2C -#define VK_INSERT 0x2D -#define VK_DELETE 0x2E -#define VK_HELP 0x2F -#define VK_0 0x30 -#define VK_1 0x31 -#define VK_2 0x32 -#define VK_3 0x33 -#define VK_4 0x34 -#define VK_5 0x35 -#define VK_6 0x36 -#define VK_7 0x37 -#define VK_8 0x38 -#define VK_9 0x39 -#define VK_NONE_3B 0x3B -#define VK_NONE_3C 0x3C -#define VK_NONE_3D 0x3D -#define VK_NONE_3E 0x3E -#define VK_NONE_3F 0x3F -#define VK_NONE_40 0x40 -#define VK_A 0x41 -#define VK_B 0x42 -#define VK_C 0x43 -#define VK_D 0x44 -#define VK_E 0x45 -#define VK_F 0x46 -#define VK_G 0x47 -#define VK_H 0x48 -#define VK_I 0x49 -#define VK_J 0x4A -#define VK_K 0x4B -#define VK_L 0x4C -#define VK_M 0x4D -#define VK_N 0x4E -#define VK_O 0x4F -#define VK_P 0x50 -#define VK_Q 0x51 -#define VK_R 0x52 -#define VK_S 0x53 -#define VK_T 0x54 -#define VK_U 0x55 -#define VK_V 0x56 -#define VK_W 0x57 -#define VK_X 0x58 -#define VK_Y 0x59 -#define VK_Z 0x5A -#define VK_NONE_5B 0x5B -#define VK_NONE_5C 0x5C -#define VK_NONE_5D 0x5D -#define VK_NONE_5E 0x5E -#define VK_NONE_5F 0x5F -#define VK_NUMPAD0 0x60 -#define VK_NUMPAD1 0x61 -#define VK_NUMPAD2 0x62 -#define VK_NUMPAD3 0x63 -#define VK_NUMPAD4 0x64 -#define VK_NUMPAD5 0x65 -#define VK_NUMPAD6 0x66 -#define VK_NUMPAD7 0x67 -#define VK_NUMPAD8 0x68 -#define VK_NUMPAD9 0x69 -#define VK_MULTIPLY 0x6A -#define VK_ADD 0x6B -#define VK_SEPARATOR 0x6C -#define VK_SUBTRACT 0x6D -#define VK_DECIMAL 0x6E -#define VK_DIVIDE 0x6F -#define VK_F1 0x70 -#define VK_F2 0x71 -#define VK_F3 0x72 -#define VK_F4 0x73 -#define VK_F5 0x74 -#define VK_F6 0x75 -#define VK_F7 0x76 -#define VK_F8 0x77 -#define VK_F9 0x78 -#define VK_F10 0x79 -#define VK_F11 0x7A -#define VK_F12 0x7B -#define VK_F13 0x7C -#define VK_F14 0x7D -#define VK_F15 0x7E -#define VK_F16 0x7F -#define VK_F17 0x80 -#define VK_F18 0x81 -#define VK_F19 0x82 -#define VK_F20 0x83 -#define VK_F21 0x84 -#define VK_F22 0x85 -#define VK_F23 0x86 -#define VK_F24 0x87 -#define VK_NONE_88 0x88 -#define VK_NONE_89 0x89 -#define VK_NONE_8A 0x8A -#define VK_NONE_8B 0x8B -#define VK_NONE_8C 0x8C -#define VK_NONE_8D 0x8D -#define VK_NONE_8E 0x8E -#define VK_NONE_8F 0x8F -#define VK_NUMLOCK 0x90 -#define VK_SCROLL 0x91 -#define VK_NONE_92 0x92 -#define VK_NONE_93 0x93 -#define VK_NONE_94 0x94 -#define VK_NONE_95 0x95 -#define VK_NONE_96 0x96 -#define VK_NONE_97 0x97 -#define VK_NONE_98 0x98 -#define VK_NONE_99 0x99 -#define VK_NONE_9A 0x9A -#define VK_NONE_9B 0x9B -#define VK_NONE_9C 0x9C -#define VK_NONE_9D 0x9D -#define VK_NONE_9E 0x9E -#define VK_NONE_9F 0x9F -#define VK_NONE_A0 0xA0 -#define VK_NONE_A1 0xA1 -#define VK_NONE_A2 0xA2 -#define VK_NONE_A3 0xA3 -#define VK_NONE_A4 0xA4 -#define VK_NONE_A5 0xA5 -#define VK_NONE_A6 0xA6 -#define VK_NONE_A7 0xA7 -#define VK_NONE_A8 0xA8 -#define VK_NONE_A9 0xA9 -#define VK_NONE_AA 0xAA -#define VK_NONE_AB 0xAB -#define VK_NONE_AC 0xAC -#define VK_NONE_AD 0xAD -#define VK_NONE_AE 0xAE -#define VK_NONE_AF 0xAF -#define VK_NONE_B0 0xB0 -#define VK_NONE_B1 0xB1 -#define VK_NONE_B2 0xB2 -#define VK_NONE_B3 0xB3 -#define VK_NONE_B4 0xB4 -#define VK_NONE_B5 0xB5 -#define VK_NONE_B6 0xB6 -#define VK_NONE_B7 0xB7 -#define VK_NONE_B8 0xB8 -#define VK_NONE_B9 0xB9 -#define VK_NONE_BA 0xBA // ; -#define VK_NONE_BB 0xBB // = -#define VK_NONE_BC 0xBC // , -#define VK_NONE_BD 0xBD // - -#define VK_NONE_BE 0xBE // . -#define VK_NONE_BF 0xBF // / -#define VK_NONE_C0 0xC0 // ` -#define VK_NONE_C1 0xC1 -#define VK_NONE_C2 0xC2 -#define VK_NONE_C3 0xC3 -#define VK_NONE_C4 0xC4 -#define VK_NONE_C5 0xC5 -#define VK_NONE_C6 0xC6 -#define VK_NONE_C7 0xC7 -#define VK_NONE_C8 0xC8 -#define VK_NONE_C9 0xC9 -#define VK_NONE_CA 0xCA -#define VK_NONE_CB 0xCB -#define VK_NONE_CC 0xCC -#define VK_NONE_CD 0xCD -#define VK_NONE_CE 0xCE -#define VK_NONE_CF 0xCF -#define VK_NONE_D0 0xD0 -#define VK_NONE_D1 0xD1 -#define VK_NONE_D2 0xD2 -#define VK_NONE_D3 0xD3 -#define VK_NONE_D4 0xD4 -#define VK_NONE_D5 0xD5 -#define VK_NONE_D6 0xD6 -#define VK_NONE_D7 0xD7 -#define VK_NONE_D8 0xD8 -#define VK_NONE_D9 0xD9 -#define VK_NONE_DA 0xDA -#define VK_NONE_DB 0xDB // [ -#define VK_NONE_DC 0xDC // '\' -#define VK_NONE_DD 0xDD // ] -#define VK_NONE_DE 0xDE // ' -#define VK_NONE_DF 0xDF -#define VK_NONE_E0 0xE0 -#define VK_NONE_E1 0xE1 -#define VK_NONE_E2 0xE2 -#define VK_NONE_E3 0xE3 -#define VK_NONE_E4 0xE4 -#define VK_NONE_E5 0xE5 -#define VK_NONE_E6 0xE6 -#define VK_NONE_E7 0xE7 -#define VK_NONE_E8 0xE8 -#define VK_NONE_E9 0xE9 -#define VK_NONE_EA 0xEA -#define VK_NONE_EB 0xEB -#define VK_NONE_EC 0xEC -#define VK_NONE_ED 0xED -#define VK_NONE_EE 0xEE -#define VK_NONE_EF 0xEF -#define VK_NONE_F0 0xF0 -#define VK_NONE_F1 0xF1 -#define VK_NONE_F2 0xF2 -#define VK_NONE_F3 0xF3 -#define VK_NONE_F4 0xF4 -#define VK_NONE_F5 0xF5 -#define VK_NONE_F6 0xF6 -#define VK_NONE_F7 0xF7 -#define VK_NONE_F8 0xF8 -#define VK_NONE_F9 0xF9 -#define VK_NONE_FA 0xFA -#define VK_NONE_FB 0xFB -#define VK_NONE_FC 0xFC -#define VK_MOUSEWHEEL_DOWN 0xFD -#define VK_MOUSEWHEEL_UP 0xFE -#define VK_NONE_FF 0xFF - -#endif // !SDL_BUILD - -#define VK_UPLEFT VK_HOME -#define VK_UPRIGHT VK_PRIOR -#define VK_DOWNLEFT VK_END -#define VK_DOWNRIGHT VK_NEXT -#define VK_ALT VK_MENU - typedef enum KeyASCIIType : unsigned short { // @@ -553,298 +58,512 @@ typedef enum KeyASCIIType : unsigned short KA_SETX = 25, KA_SETY = 26, - KA_SPACE = 32, /* */ - KA_EXCLAMATION, /* ! */ - KA_DQUOTE, /* " */ - KA_POUND, /* # */ - KA_DOLLAR, /* $ */ - KA_PERCENT, /* % */ - KA_AMPER, /* & */ - KA_SQUOTE, /* ' */ - KA_LPAREN, /* ( */ - KA_RPAREN, /* ) */ - KA_ASTERISK, /* * */ - KA_PLUS, /* + */ - KA_COMMA, /* , */ - KA_MINUS, /* - */ - KA_PERIOD, /* . */ - KA_SLASH, /* / */ - - KA_0, - KA_1, - KA_2, - KA_3, - KA_4, - KA_5, - KA_6, - KA_7, - KA_8, - KA_9, - KA_COLON, /* : */ - KA_SEMICOLON, /* ; */ - KA_LESS_THAN, /* < */ - KA_EQUAL, /* = */ - KA_GREATER_THAN, /* > */ - KA_QUESTION, /* ? */ - - KA_AT, /* @ */ - KA_A, /* A */ - KA_B, /* B */ - KA_C, /* C */ - KA_D, /* D */ - KA_E, /* E */ - KA_F, /* F */ - KA_G, /* G */ - KA_H, /* H */ - KA_I, /* I */ - KA_J, /* J */ - KA_K, /* K */ - KA_L, /* L */ - KA_M, /* M */ - KA_N, /* N */ - KA_O, /* O */ - - KA_P, /* P */ - KA_Q, /* Q */ - KA_R, /* R */ - KA_S, /* S */ - KA_T, /* T */ - KA_U, /* U */ - KA_V, /* V */ - KA_W, /* W */ - KA_X, /* X */ - KA_Y, /* Y */ - KA_Z, /* Z */ - KA_LBRACKET, /* [ */ - KA_BACKSLASH, /* \ */ - KA_RBRACKET, /* ] */ - KA_CARROT, /* ^ */ - KA_UNDERLINE, /* _ */ - - KA_GRAVE, /* ` */ - KA_a, /* a */ - KA_b, /* b */ - KA_c, /* c */ - KA_d, /* d */ - KA_e, /* e */ - KA_f, /* f */ - KA_g, /* g */ - KA_h, /* h */ - KA_i, /* i */ - KA_j, /* j */ - KA_k, /* k */ - KA_l, /* l */ - KA_m, /* m */ - KA_n, /* n */ - KA_o, /* o */ - - KA_p, /* p */ - KA_q, /* q */ - KA_r, /* r */ - KA_s, /* s */ - KA_t, /* t */ - KA_u, /* u */ - KA_v, /* v */ - KA_w, /* w */ - KA_x, /* x */ - KA_y, /* y */ - KA_z, /* z */ - KA_LBRACE, /* { */ - KA_BAR, /* | */ - KA_RBRACE, /* ] */ - KA_TILDA, /* ~ */ + KA_SPACE = ' ', + KA_EXCLAMATION = '!', + KA_DQUOTE = '"', + KA_HASH = '#', + KA_DOLLAR = '$', + KA_PERCENT = '%', + KA_AMPER = '&', + KA_SQUOTE = '\'', + KA_LPAREN = '(', + KA_RPAREN = ')', + KA_ASTERISK = '*', + KA_PLUS = '+', + KA_COMMA = ',', + KA_MINUS = '-', + KA_PERIOD = '.', + KA_SLASH = '/', + + KA_0 = '0', + KA_1 = '1', + KA_2 = '2', + KA_3 = '3', + KA_4 = '4', + KA_5 = '5', + KA_6 = '6', + KA_7 = '7', + KA_8 = '8', + KA_9 = '9', + KA_COLON = ':', + KA_SEMICOLON = ';', + KA_LESS_THAN = '<', + KA_EQUAL = '=', + KA_GREATER_THAN = '>', + KA_QUESTION = '?', + + KA_AT = '@', + KA_A = 'A', + KA_B = 'B', + KA_C = 'C', + KA_D = 'D', + KA_E = 'E', + KA_F = 'F', + KA_G = 'G', + KA_H = 'H', + KA_I = 'I', + KA_J = 'J', + KA_K = 'K', + KA_L = 'L', + KA_M = 'M', + KA_N = 'N', + KA_O = 'O', + + KA_P = 'P', + KA_Q = 'Q', + KA_R = 'R', + KA_S = 'S', + KA_T = 'T', + KA_U = 'U', + KA_V = 'V', + KA_W = 'W', + KA_X = 'X', + KA_Y = 'Y', + KA_Z = 'Z', + KA_LBRACKET = '[', + KA_BACKSLASH = '\\', + KA_RBRACKET = ']', + KA_CARET = '^', + KA_UNDERLINE = '_', + + KA_GRAVE = '`', + KA_a = 'a', + KA_b = 'b', + KA_c = 'c', + KA_d = 'd', + KA_e = 'e', + KA_f = 'f', + KA_g = 'g', + KA_h = 'h', + KA_i = 'i', + KA_j = 'j', + KA_k = 'k', + KA_l = 'l', + KA_m = 'm', + KA_n = 'n', + KA_o = 'o', + + KA_p = 'p', + KA_q = 'q', + KA_r = 'r', + KA_s = 's', + KA_t = 't', + KA_u = 'u', + KA_v = 'v', + KA_w = 'w', + KA_x = 'x', + KA_y = 'y', + KA_z = 'z', + KA_LBRACE = '{', + KA_BAR = '|', + KA_RBRACE = '}', + KA_TILDA = '~', -#ifdef SDL_BUILD KA_ESC = 0x1B, KA_EXTEND = 0x1B, KA_RETURN = 0x0D, KA_BACKSPACE = 0x08, KA_TAB = 0x09, KA_DELETE = 0x7F, -#else - KA_ESC = VK_ESCAPE, - KA_EXTEND = VK_ESCAPE, - KA_RETURN = VK_RETURN, - KA_BACKSPACE = VK_BACK, - KA_TAB = VK_TAB, - KA_DELETE = VK_DELETE, /* */ -#endif - KA_INSERT = VK_INSERT, /* */ - KA_PGDN = VK_NEXT, /* */ - KA_DOWNRIGHT = VK_NEXT, - KA_DOWN = VK_DOWN, /* */ - KA_END = VK_END, /* */ - KA_DOWNLEFT = VK_END, - KA_RIGHT = VK_RIGHT, /* */ - KA_KEYPAD5 = VK_SELECT, /* NUMERIC KEY PAD <5> */ - KA_LEFT = VK_LEFT, /* */ - KA_PGUP = VK_PRIOR, /* */ - KA_UPRIGHT = VK_PRIOR, - KA_UP = VK_UP, /* */ - KA_HOME = VK_HOME, /* */ - KA_UPLEFT = VK_HOME, - KA_F12 = VK_F12, - KA_F11 = VK_F11, - KA_F10 = VK_F10, - KA_F9 = VK_F9, - KA_F8 = VK_F8, - KA_F7 = VK_F7, - KA_F6 = VK_F6, - KA_F5 = VK_F5, - KA_F4 = VK_F4, - KA_F3 = VK_F3, - KA_F2 = VK_F2, - KA_F1 = VK_F1, - KA_LMOUSE = VK_LBUTTON, - KA_RMOUSE = VK_RBUTTON, - - KA_SHIFT_BIT = WWKEY_SHIFT_BIT, - KA_CTRL_BIT = WWKEY_CTRL_BIT, - KA_ALT_BIT = WWKEY_ALT_BIT, - KA_RLSE_BIT = WWKEY_RLS_BIT, } KeyASCIIType; +#if defined(SDL1_BUILD) + +#include + typedef enum KeyNumType : unsigned short { - KN_NONE = 0, - - KN_0 = VK_0, - KN_1 = VK_1, - KN_2 = VK_2, - KN_3 = VK_3, - KN_4 = VK_4, - KN_5 = VK_5, - KN_6 = VK_6, - KN_7 = VK_7, - KN_8 = VK_8, - KN_9 = VK_9, - KN_A = VK_A, - KN_B = VK_B, - KN_BACKSLASH = VK_NONE_DC, - KN_BACKSPACE = VK_BACK, - KN_C = VK_C, - KN_CAPSLOCK = VK_CAPITAL, - KN_CENTER = VK_CLEAR, - KN_COMMA = VK_NONE_BC, - KN_D = VK_D, - KN_DELETE = VK_DELETE, - KN_DOWN = VK_DOWN, - KN_DOWNLEFT = VK_END, - KN_DOWNRIGHT = VK_NEXT, - KN_E = VK_E, - KN_END = VK_END, - KN_EQUAL = VK_NONE_BB, - KN_ESC = VK_ESCAPE, - KN_E_DELETE = VK_DELETE, - KN_E_DOWN = VK_NUMPAD2, - KN_E_END = VK_NUMPAD1, - KN_E_HOME = VK_NUMPAD7, - KN_E_INSERT = VK_INSERT, - KN_E_LEFT = VK_NUMPAD4, - KN_E_PGDN = VK_NUMPAD3, - KN_E_PGUP = VK_NUMPAD9, - KN_E_RIGHT = VK_NUMPAD6, - KN_E_UP = VK_NUMPAD8, - KN_F = VK_F, - KN_F1 = VK_F1, - KN_F10 = VK_F10, - KN_F11 = VK_F11, - KN_F12 = VK_F12, - KN_F2 = VK_F2, - KN_F3 = VK_F3, - KN_F4 = VK_F4, - KN_F5 = VK_F5, - KN_F6 = VK_F6, - KN_F7 = VK_F7, - KN_F8 = VK_F8, - KN_F9 = VK_F9, - KN_G = VK_G, - KN_GRAVE = VK_NONE_C0, - KN_H = VK_H, - KN_HOME = VK_HOME, - KN_I = VK_I, - KN_INSERT = VK_INSERT, - KN_J = VK_J, - KN_K = VK_K, - KN_KEYPAD_ASTERISK = VK_MULTIPLY, - KN_KEYPAD_MINUS = VK_SUBTRACT, - KN_KEYPAD_PLUS = VK_ADD, - KN_KEYPAD_RETURN = VK_RETURN, - KN_KEYPAD_SLASH = VK_DIVIDE, - KN_L = VK_L, - KN_LALT = VK_MENU, - KN_LBRACKET = VK_NONE_DB, - KN_LCTRL = VK_CONTROL, - KN_LEFT = VK_LEFT, - KN_LMOUSE = VK_LBUTTON, - KN_LSHIFT = VK_SHIFT, - KN_M = VK_M, - KN_MINUS = VK_NONE_BD, - KN_MMOUSE = VK_MBUTTON, - KN_N = VK_N, - KN_NUMLOCK = VK_NUMLOCK, - KN_O = VK_O, - KN_P = VK_P, - KN_PAUSE = VK_PAUSE, - KN_PERIOD = VK_NONE_BE, - KN_PGDN = VK_NEXT, - KN_PGUP = VK_PRIOR, - KN_PRNTSCRN = VK_PRINT, - KN_Q = VK_Q, - KN_R = VK_R, -#ifdef SDL2_BUILD - KN_RALT = SDL_SCANCODE_RALT, -#elif defined(SDL1_BUILD) + KN_NONE = SDLK_UNKNOWN, + + KN_0 = SDLK_0, + KN_1 = SDLK_1, + KN_2 = SDLK_2, + KN_3 = SDLK_3, + KN_4 = SDLK_4, + KN_5 = SDLK_5, + KN_6 = SDLK_6, + KN_7 = SDLK_7, + KN_8 = SDLK_8, + KN_9 = SDLK_9, + KN_A = SDLK_a, + KN_B = SDLK_b, + KN_BACKSLASH = SDLK_BACKSLASH, + KN_BACKSPACE = SDLK_BACKSPACE, + KN_C = SDLK_c, + KN_CAPSLOCK = SDLK_CAPSLOCK, + KN_CENTER = SDLK_CLEAR, + KN_COMMA = SDLK_COMMA, + KN_D = SDLK_d, + KN_DELETE = SDLK_DELETE, + KN_DOWN = SDLK_DOWN, + KN_E = SDLK_e, + KN_END = SDLK_END, + KN_EQUAL = SDLK_EQUALS, + KN_ESC = SDLK_ESCAPE, + KN_E_DELETE = SDLK_KP0, + KN_E_DOWN = SDLK_KP2, + KN_E_END = SDLK_KP1, + KN_E_HOME = SDLK_KP7, + KN_E_INSERT = SDLK_KP_PERIOD, + KN_E_LEFT = SDLK_KP4, + KN_E_PGDN = SDLK_KP3, + KN_E_PGUP = SDLK_KP9, + KN_E_RIGHT = SDLK_KP6, + KN_E_UP = SDLK_KP8, + KN_SELECT = SDLK_KP5, + KN_F = SDLK_f, + KN_F1 = SDLK_F1, + KN_F10 = SDLK_F10, + KN_F11 = SDLK_F11, + KN_F12 = SDLK_F12, + KN_F2 = SDLK_F2, + KN_F3 = SDLK_F3, + KN_F4 = SDLK_F4, + KN_F5 = SDLK_F5, + KN_F6 = SDLK_F6, + KN_F7 = SDLK_F7, + KN_F8 = SDLK_F8, + KN_F9 = SDLK_F9, + KN_G = SDLK_g, + KN_GRAVE = SDLK_BACKQUOTE, + KN_H = SDLK_h, + KN_HOME = SDLK_HOME, + KN_I = SDLK_i, + KN_INSERT = SDLK_INSERT, + KN_J = SDLK_j, + KN_K = SDLK_k, + KN_KEYPAD_ASTERISK = SDLK_KP_MULTIPLY, + KN_KEYPAD_MINUS = SDLK_KP_MINUS, + KN_KEYPAD_PLUS = SDLK_KP_PLUS, + KN_KEYPAD_SLASH = SDLK_KP_DIVIDE, + KN_L = SDLK_l, + KN_LALT = SDLK_LALT, + KN_LBRACKET = SDLK_LEFTBRACKET, + KN_LCTRL = SDLK_LCTRL, + KN_LEFT = SDLK_LEFT, + KN_LSHIFT = SDLK_LSHIFT, + KN_M = SDLK_m, + KN_MINUS = SDLK_MINUS, + KN_N = SDLK_n, + KN_NUMLOCK = SDLK_NUMLOCK, + KN_O = SDLK_o, + KN_P = SDLK_p, + KN_PAUSE = SDLK_PAUSE, + KN_PERIOD = SDLK_PERIOD, + KN_PGDN = SDLK_PAGEDOWN, + KN_PGUP = SDLK_PAGEUP, + KN_PRNTSCRN = SDLK_PRINT, + KN_Q = SDLK_q, + KN_R = SDLK_r, KN_RALT = SDLK_RALT, -#else - KN_RALT = VK_MENU, -#endif - KN_RBRACKET = VK_NONE_DD, -#ifdef SDL2_BUILD - KN_RCTRL = SDL_SCANCODE_RCTRL, -#elif defined(SDL1_BUILD) + KN_RBRACKET = SDLK_RIGHTBRACKET, KN_RCTRL = SDLK_RCTRL, -#else - KN_RCTRL = VK_CONTROL, -#endif - KN_RETURN = VK_RETURN, - KN_RIGHT = VK_RIGHT, - KN_RMOUSE = VK_RBUTTON, -#ifdef SDL2_BUILD - KN_RSHIFT = SDL_SCANCODE_RSHIFT, -#elif defined(SDL1_BUILD) + KN_RETURN = SDLK_RETURN, + KN_RIGHT = SDLK_RIGHT, KN_RSHIFT = SDLK_RSHIFT, + KN_S = SDLK_s, + KN_SCROLLLOCK = SDLK_SCROLLOCK, + KN_SEMICOLON = SDLK_SEMICOLON, + KN_SLASH = SDLK_SLASH, + KN_SPACE = SDLK_SPACE, + KN_SQUOTE = SDLK_QUOTE, + KN_T = SDLK_t, + KN_TAB = SDLK_TAB, + KN_U = SDLK_u, + KN_UP = SDLK_UP, + KN_V = SDLK_v, + KN_W = SDLK_w, + KN_X = SDLK_x, + KN_Y = SDLK_y, + KN_Z = SDLK_z, + + KN_KEYPAD_RETURN = KN_RETURN, + KN_UPLEFT = KN_HOME, + KN_UPRIGHT = KN_PGUP, + KN_DOWNLEFT = KN_END, + KN_DOWNRIGHT = KN_PGDN, + + KN_LMOUSE = 0x01, + KN_RMOUSE = 0x02, + KN_MMOUSE = 0x03, + KN_MOUSEWHEEL_UP = 0x04, + KN_MOUSEWHEEL_DOWN = 0x05, + + KN_SHIFT_BIT = 0x200, + KN_CTRL_BIT = 0x400, + KN_ALT_BIT = 0x800, + KN_RLSE_BIT = 0x1000, + KN_VK_BIT = 0x4000, + KN_BUTTON = 0x8000, +} KeyNumType; + +#elif defined(SDL2_BUILD) + +#include + +typedef enum KeyNumType : unsigned short +{ + KN_NONE = SDL_SCANCODE_UNKNOWN, + + KN_0 = SDL_SCANCODE_0, + KN_1 = SDL_SCANCODE_1, + KN_2 = SDL_SCANCODE_2, + KN_3 = SDL_SCANCODE_3, + KN_4 = SDL_SCANCODE_4, + KN_5 = SDL_SCANCODE_5, + KN_6 = SDL_SCANCODE_6, + KN_7 = SDL_SCANCODE_7, + KN_8 = SDL_SCANCODE_8, + KN_9 = SDL_SCANCODE_9, + KN_A = SDL_SCANCODE_A, + KN_B = SDL_SCANCODE_B, + KN_BACKSLASH = SDL_SCANCODE_BACKSLASH, + KN_BACKSPACE = SDL_SCANCODE_BACKSPACE, + KN_C = SDL_SCANCODE_C, + KN_CAPSLOCK = SDL_SCANCODE_CAPSLOCK, + KN_CENTER = SDL_SCANCODE_CLEAR, + KN_COMMA = SDL_SCANCODE_COMMA, + KN_D = SDL_SCANCODE_D, + KN_DELETE = SDL_SCANCODE_DELETE, + KN_DOWN = SDL_SCANCODE_DOWN, + KN_E = SDL_SCANCODE_E, + KN_END = SDL_SCANCODE_END, + KN_EQUAL = SDL_SCANCODE_EQUALS, + KN_ESC = SDL_SCANCODE_ESCAPE, + KN_E_DELETE = SDL_SCANCODE_KP_PERIOD, + KN_E_DOWN = SDL_SCANCODE_KP_2, + KN_E_END = SDL_SCANCODE_KP_1, + KN_E_HOME = SDL_SCANCODE_KP_7, + KN_E_INSERT = SDL_SCANCODE_KP_0, + KN_E_LEFT = SDL_SCANCODE_KP_4, + KN_E_PGDN = SDL_SCANCODE_KP_3, + KN_E_PGUP = SDL_SCANCODE_KP_9, + KN_E_RIGHT = SDL_SCANCODE_KP_6, + KN_E_UP = SDL_SCANCODE_KP_8, + KN_SELECT = SDL_SCANCODE_SELECT, + KN_F = SDL_SCANCODE_F, + KN_F1 = SDL_SCANCODE_F1, + KN_F10 = SDL_SCANCODE_F10, + KN_F11 = SDL_SCANCODE_F11, + KN_F12 = SDL_SCANCODE_F12, + KN_F2 = SDL_SCANCODE_F2, + KN_F3 = SDL_SCANCODE_F3, + KN_F4 = SDL_SCANCODE_F4, + KN_F5 = SDL_SCANCODE_F5, + KN_F6 = SDL_SCANCODE_F6, + KN_F7 = SDL_SCANCODE_F7, + KN_F8 = SDL_SCANCODE_F8, + KN_F9 = SDL_SCANCODE_F9, + KN_G = SDL_SCANCODE_G, + KN_GRAVE = SDL_SCANCODE_GRAVE, + KN_H = SDL_SCANCODE_H, + KN_HOME = SDL_SCANCODE_HOME, + KN_I = SDL_SCANCODE_I, + KN_INSERT = SDL_SCANCODE_INSERT, + KN_J = SDL_SCANCODE_J, + KN_K = SDL_SCANCODE_K, + KN_KEYPAD_ASTERISK = SDL_SCANCODE_KP_MULTIPLY, + KN_KEYPAD_MINUS = SDL_SCANCODE_KP_MINUS, + KN_KEYPAD_PLUS = SDL_SCANCODE_KP_PLUS, + KN_KEYPAD_SLASH = SDL_SCANCODE_KP_DIVIDE, + KN_L = SDL_SCANCODE_L, + KN_LALT = SDL_SCANCODE_LALT, + KN_LBRACKET = SDL_SCANCODE_LEFTBRACKET, + KN_LCTRL = SDL_SCANCODE_LCTRL, + KN_LEFT = SDL_SCANCODE_LEFT, + KN_LSHIFT = SDL_SCANCODE_LSHIFT, + KN_M = SDL_SCANCODE_M, + KN_MINUS = SDL_SCANCODE_MINUS, + KN_N = SDL_SCANCODE_N, + KN_NUMLOCK = SDL_SCANCODE_NUMLOCKCLEAR, + KN_O = SDL_SCANCODE_O, + KN_P = SDL_SCANCODE_P, + KN_PAUSE = SDL_SCANCODE_PAUSE, + KN_PERIOD = SDL_SCANCODE_PERIOD, + KN_PGDN = SDL_SCANCODE_PAGEDOWN, + KN_PGUP = SDL_SCANCODE_PAGEUP, + KN_PRNTSCRN = SDL_SCANCODE_PRINTSCREEN, + KN_Q = SDL_SCANCODE_Q, + KN_R = SDL_SCANCODE_R, + KN_RALT = SDL_SCANCODE_RALT, + KN_RBRACKET = SDL_SCANCODE_RIGHTBRACKET, + KN_RCTRL = SDL_SCANCODE_RCTRL, + KN_RETURN = SDL_SCANCODE_RETURN, + KN_RIGHT = SDL_SCANCODE_RIGHT, + KN_RSHIFT = SDL_SCANCODE_RSHIFT, + KN_S = SDL_SCANCODE_S, + KN_SCROLLLOCK = SDL_SCANCODE_SCROLLLOCK, + KN_SEMICOLON = SDL_SCANCODE_SEMICOLON, + KN_SLASH = SDL_SCANCODE_SLASH, + KN_SPACE = SDL_SCANCODE_SPACE, + KN_SQUOTE = SDL_SCANCODE_APOSTROPHE, + KN_T = SDL_SCANCODE_T, + KN_TAB = SDL_SCANCODE_TAB, + KN_U = SDL_SCANCODE_U, + KN_UP = SDL_SCANCODE_UP, + KN_V = SDL_SCANCODE_V, + KN_W = SDL_SCANCODE_W, + KN_X = SDL_SCANCODE_X, + KN_Y = SDL_SCANCODE_Y, + KN_Z = SDL_SCANCODE_Z, + + KN_KEYPAD_RETURN = KN_RETURN, + KN_UPLEFT = KN_HOME, + KN_UPRIGHT = KN_PGUP, + KN_DOWNLEFT = KN_END, + KN_DOWNRIGHT = KN_PGDN, + + KN_LMOUSE = 0x01, + KN_RMOUSE = 0x02, + KN_MMOUSE = 0x03, + KN_MOUSEWHEEL_UP = 0xFE, + KN_MOUSEWHEEL_DOWN = 0xFD, + + KN_SHIFT_BIT = 0x200, + KN_CTRL_BIT = 0x400, + KN_ALT_BIT = 0x800, + KN_RLSE_BIT = 0x1000, + KN_VK_BIT = 0x4000, + KN_BUTTON = 0x8000, +} KeyNumType; + #else - KN_RSHIFT = VK_SHIFT, -#endif - KN_S = VK_S, - KN_SCROLLLOCK = VK_SCROLL, - KN_SEMICOLON = VK_NONE_BA, - KN_SLASH = VK_NONE_BF, - KN_SPACE = VK_SPACE, - KN_SQUOTE = VK_NONE_DE, - KN_T = VK_T, - KN_TAB = VK_TAB, - KN_U = VK_U, - KN_UP = VK_UP, - KN_UPLEFT = VK_HOME, - KN_UPRIGHT = VK_PRIOR, - KN_V = VK_V, - KN_W = VK_W, - KN_X = VK_X, - KN_Y = VK_Y, - KN_Z = VK_Z, - - KN_SHIFT_BIT = WWKEY_SHIFT_BIT, - KN_CTRL_BIT = WWKEY_CTRL_BIT, - KN_ALT_BIT = WWKEY_ALT_BIT, - KN_RLSE_BIT = WWKEY_RLS_BIT, - KN_BUTTON = WWKEY_BTN_BIT, - - KN_MOUSEWHEEL_UP = VK_MOUSEWHEEL_UP, - KN_MOUSEWHEEL_DOWN = VK_MOUSEWHEEL_DOWN, + +// these should match VK_* values from winuser.h + +typedef enum KeyNumType : unsigned short +{ + KN_NONE = 0x00, + + KN_0 = 0x30, + KN_1 = 0x31, + KN_2 = 0x32, + KN_3 = 0x33, + KN_4 = 0x34, + KN_5 = 0x35, + KN_6 = 0x36, + KN_7 = 0x37, + KN_8 = 0x38, + KN_9 = 0x39, + KN_A = 0x41, + KN_B = 0x42, + KN_BACKSLASH = 0xDC, // '\' + KN_BACKSPACE = 0x08, + KN_C = 0x43, + KN_CAPSLOCK = 0x14, + KN_CENTER = 0x0C, + KN_COMMA = 0xBC, // , + KN_D = 0x44, + KN_DELETE = 0x2E, + KN_DOWN = 0x28, + KN_E = 0x45, + KN_END = 0x23, + KN_EQUAL = 0xBB, // = + KN_ESC = 0x1B, + KN_E_DELETE = 0x6C, + KN_E_DOWN = 0x62, + KN_E_END = 0x61, + KN_E_HOME = 0x67, + KN_E_INSERT = 0x60, + KN_E_LEFT = 0x64, + KN_E_PGDN = 0x63, + KN_E_PGUP = 0x69, + KN_E_RIGHT = 0x66, + KN_E_UP = 0x68, + KN_SELECT = 0x29, + KN_F = 0x46, + KN_F1 = 0x70, + KN_F2 = 0x70, + KN_F3 = 0x72, + KN_F4 = 0x73, + KN_F5 = 0x74, + KN_F6 = 0x75, + KN_F7 = 0x76, + KN_F8 = 0x77, + KN_F9 = 0x78, + KN_F10 = 0x79, + KN_F11 = 0x7A, + KN_F12 = 0x7B, + KN_G = 0x47, + KN_GRAVE = 0xC0, // ` + KN_H = 0x48, + KN_HOME = 0x24, + KN_I = 0x49, + KN_INSERT = 0x2D, + KN_J = 0x4A, + KN_K = 0x4B, + KN_KEYPAD_ASTERISK = 0x6A, + KN_KEYPAD_MINUS = 0x6D, + KN_KEYPAD_PLUS = 0x6B, + KN_KEYPAD_SLASH = 0x6F, + KN_L = 0x4C, + KN_LALT = 0x12, + KN_LBRACKET = 0xDB, // [ + KN_LCTRL = 0x11, + KN_LEFT = 0x25, + KN_LSHIFT = 0x10, + KN_M = 0x4D, + KN_MINUS = 0xBD, // - + KN_N = 0x4E, + KN_NUMLOCK = 0x90, + KN_O = 0x4F, + KN_P = 0x50, + KN_PAUSE = 0x13, + KN_PERIOD = 0xBE, // . + KN_PGDN = 0x22, + KN_PGUP = 0x21, + KN_PRNTSCRN = 0x2A, + KN_Q = 0x51, + KN_R = 0x52, + KN_RALT = 0x12, + KN_RBRACKET = 0xDD, // ] + KN_RCTRL = 0x11, + KN_RETURN = 0x0D, + KN_RIGHT = 0x27, + KN_RSHIFT = 0x10, + KN_S = 0x53, + KN_SCROLLLOCK = 0x91, + KN_SEMICOLON = 0xBA, // ; + KN_SLASH = 0x2F, // / + KN_SPACE = 0x20, + KN_SQUOTE = 0xDE, // ' + KN_T = 0x54, + KN_TAB = 0x09, + KN_U = 0x55, + KN_UP = 0x26, + KN_V = 0x56, + KN_W = 0x57, + KN_X = 0x58, + KN_Y = 0x59, + KN_Z = 0x5A, + + KN_KEYPAD_RETURN = KN_RETURN, + KN_UPLEFT = KN_HOME, + KN_UPRIGHT = KN_PGUP, + KN_DOWNLEFT = KN_END, + KN_DOWNRIGHT = KN_PGDN, + + KN_LMOUSE = 0x01, + KN_RMOUSE = 0x02, + KN_MMOUSE = 0x04, + KN_MOUSEWHEEL_UP = 0xFE, + KN_MOUSEWHEEL_DOWN = 0xFD, + + KN_SHIFT_BIT = 0x200, + KN_CTRL_BIT = 0x400, + KN_ALT_BIT = 0x800, + KN_RLSE_BIT = 0x1000, + KN_VK_BIT = 0x4000, + KN_BUTTON = 0x8000, } KeyNumType; +#endif + +// +// scancode values from both SDL1 & SDL2 may have values up to 511 +// +#define KN_SCANCODE_MASK 0x1ff + typedef enum ScrollDirType : unsigned char { SDIR_N = 0, diff --git a/redalert/conquer.cpp b/redalert/conquer.cpp index 37c578b9..e1dea6d5 100644 --- a/redalert/conquer.cpp +++ b/redalert/conquer.cpp @@ -472,8 +472,8 @@ void Keyboard_Process(KeyNumType& input) ** The VK_BIT must be stripped from the "plain" value of the key so that a comparison to ** KN_1, for example, will yield TRUE if in fact the "1" key was pressed. */ - KeyNumType plain = KeyNumType(input & ~(WWKEY_SHIFT_BIT | WWKEY_ALT_BIT | WWKEY_CTRL_BIT | WWKEY_VK_BIT)); - KeyNumType key = KeyNumType(input & ~WWKEY_VK_BIT); + KeyNumType plain = KeyNumType(input & ~(KN_SHIFT_BIT | KN_ALT_BIT | KN_CTRL_BIT | KN_VK_BIT)); + KeyNumType key = KeyNumType(input & ~KN_VK_BIT); #ifdef CHEAT_KEYS @@ -531,11 +531,11 @@ void Keyboard_Process(KeyNumType& input) ** CTRL or ALT key is held down. */ int action = 0; - if (input & WWKEY_SHIFT_BIT) + if (input & KN_SHIFT_BIT) action = 1; - if (input & WWKEY_ALT_BIT) + if (input & KN_ALT_BIT) action = 3; - if (input & WWKEY_CTRL_BIT) + if (input & KN_CTRL_BIT) action = 2; /* diff --git a/redalert/edit.cpp b/redalert/edit.cpp index 9f6278f8..858bb75f 100644 --- a/redalert/edit.cpp +++ b/redalert/edit.cpp @@ -253,9 +253,9 @@ int EditClass::Action(unsigned flags, KeyNumType& key) /* ** Allow numeric keypad presses to map to ascii numbers */ - if ((key & WWKEY_VK_BIT) && ascii >= '0' && ascii <= '9') { + if ((key & KN_VK_BIT) && ascii >= '0' && ascii <= '9') { - key = (KeyNumType)(key & ~WWKEY_VK_BIT); + key = (KeyNumType)(key & ~KN_VK_BIT); if ((!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) { if (Handle_Key(ascii)) { flags &= ~KEYBOARD; @@ -266,8 +266,7 @@ int EditClass::Action(unsigned flags, KeyNumType& key) /* ** Filter out all special keys except return and backspace */ - if ((!(key & WWKEY_VK_BIT) && ascii >= ' ' && ascii <= 255) || key == KN_RETURN - || key == KN_BACKSPACE) { + if ((!(key & KN_VK_BIT) && ascii >= ' ' && ascii <= 255) || key == KN_RETURN || key == KN_BACKSPACE) { if ((!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) { if (Handle_Key(Keyboard->To_ASCII(key))) { diff --git a/redalert/ending.cpp b/redalert/ending.cpp index a0f778d1..8eef57cf 100644 --- a/redalert/ending.cpp +++ b/redalert/ending.cpp @@ -119,7 +119,7 @@ void Nod_Ending(void) Clear_KeyBuffer(); } else { int key = Keyboard->Get(); - if ((key & 0xFF) == KN_LMOUSE && !(key & KN_RLSE_BIT)) { + if ((key & KN_SCANCODE_MASK) == KN_LMOUSE && !(key & KN_RLSE_BIT)) { int mousex = MouseQX; int mousey = MouseQY; if (mousey >= 22 && mousey <= 177) { diff --git a/redalert/mapedit.cpp b/redalert/mapedit.cpp index 59fa8d92..9d8740a0 100644 --- a/redalert/mapedit.cpp +++ b/redalert/mapedit.cpp @@ -927,8 +927,8 @@ void MapEditClass::AI(KeyNumType& input, int x, int y) ** If there's a current cell, place the flag & waypoint there. */ if (CurrentCell != 0) { - waypt_idx = (Keyboard->To_ASCII((KeyNumType)(input & 0xff)) - KA_1); - // waypt_idx = (KN_To_KA(input & 0xff) - KA_1); + waypt_idx = (Keyboard->To_ASCII((KeyNumType)(input & KN_SCANCODE_MASK)) - KA_1); + // waypt_idx = (KN_To_KA(input & KN_SCANCODE_MASK) - KA_1); house = (HousesType)(HOUSE_MULTI1 + waypt_idx); if (HouseClass::As_Pointer(house)) { HouseClass::As_Pointer(house)->Flag_Attach(CurrentCell, true); @@ -940,7 +940,7 @@ void MapEditClass::AI(KeyNumType& input, int x, int y) ** waypoint. */ if (CurrentObject[0] != 0) { - waypt_idx = (Keyboard->To_ASCII((KeyNumType)(input & 0xff)) - KA_1); + waypt_idx = (Keyboard->To_ASCII((KeyNumType)(input & KN_SCANCODE_MASK)) - KA_1); house = (HousesType)(HOUSE_MULTI1 + waypt_idx); if (HouseClass::As_Pointer(house) && CurrentObject[0]->What_Am_I() == RTTI_UNIT) { HouseClass::As_Pointer(house)->Flag_Attach((UnitClass*)CurrentObject[0], true); diff --git a/redalert/menus.cpp b/redalert/menus.cpp index 6e966a8f..06efd7d4 100644 --- a/redalert/menus.cpp +++ b/redalert/menus.cpp @@ -235,7 +235,7 @@ int Check_Menu(int menu, char const* text[], char*, int field, int index) UnknownKey = 0; if (Keyboard->Check()) { /* mask off all but release bit */ - key = (Keyboard->Get() & ~(WWKEY_SHIFT_BIT | WWKEY_ALT_BIT | WWKEY_CTRL_BIT)); + key = (Keyboard->Get() & ~(KN_SHIFT_BIT | KN_ALT_BIT | KN_CTRL_BIT)); } /* diff --git a/redalert/msglist.cpp b/redalert/msglist.cpp index 044be8ba..9fab5860 100644 --- a/redalert/msglist.cpp +++ b/redalert/msglist.cpp @@ -1003,17 +1003,17 @@ int MessageListClass::Input(KeyNumType& input) /* ** Allow numeric keypad presses to map to ascii numbers */ - if ((input & WWKEY_VK_BIT) && ascii >= '0' && ascii <= '9') { + if ((input & KN_VK_BIT) && ascii >= '0' && ascii <= '9') { - input = (KeyNumType)(input & ~WWKEY_VK_BIT); + input = (KeyNumType)(input & ~KN_VK_BIT); } else { /* ** Filter out all special keys except return, escape and backspace */ - if ((!(input & WWKEY_VK_BIT) && !(input & KN_BUTTON) && ascii >= ' ' && ascii <= 127) - || (input & 0xff) == (KN_RETURN & 0xff) || (input & 0xff) == (KN_BACKSPACE & 0xff) - || (input & 0xff) == (KN_ESC & 0xff)) { + if ((!(input & KN_VK_BIT) && !(input & KN_BUTTON) && ascii >= ' ' && ascii <= 127) + || (input & KN_SCANCODE_MASK) == (KN_RETURN) || (input & KN_SCANCODE_MASK) == (KN_BACKSPACE) + || (input & KN_SCANCODE_MASK) == (KN_ESC)) { // ascii = (KeyASCIIType)(Keyboard->To_ASCII(input)); } else { @@ -1026,7 +1026,7 @@ int MessageListClass::Input(KeyNumType& input) //.................................................................. // ESC = abort message //.................................................................. - case KA_ESC & 0xff: + case KA_ESC: Remove_Edit(); retcode = 2; input = KN_NONE; @@ -1038,7 +1038,7 @@ int MessageListClass::Input(KeyNumType& input) // onto this one after we send it; then, they won't be mushed // together. //.................................................................. - case KA_RETURN & 0xff: + case KA_RETURN: if (EditCurPos == EditInitPos) { retcode = 0; input = KN_NONE; @@ -1057,7 +1057,7 @@ int MessageListClass::Input(KeyNumType& input) //.................................................................. // BACKSPACE = remove a character //.................................................................. - case KA_BACKSPACE & 0xff: + case KA_BACKSPACE: if (EditCurPos > EditInitPos) { EditCurPos--; EditBuf[EditCurPos] = 0; diff --git a/redalert/options.cpp b/redalert/options.cpp index 2b84e670..987ad985 100644 --- a/redalert/options.cpp +++ b/redalert/options.cpp @@ -635,55 +635,55 @@ void OptionsClass::Load_Settings(void) KeyTeam9 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam9", KeyTeam9); KeyTeam10 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam10", KeyTeam10); - KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~WWKEY_VK_BIT); - KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~WWKEY_VK_BIT); - KeyForceAttack1 = (KeyNumType)(KeyForceAttack1 & ~WWKEY_VK_BIT); - KeyForceAttack2 = (KeyNumType)(KeyForceAttack2 & ~WWKEY_VK_BIT); - KeySelect1 = (KeyNumType)(KeySelect1 & ~WWKEY_VK_BIT); - KeySelect2 = (KeyNumType)(KeySelect2 & ~WWKEY_VK_BIT); - KeyScatter = (KeyNumType)(KeyScatter & ~WWKEY_VK_BIT); - KeyStop = (KeyNumType)(KeyStop & ~WWKEY_VK_BIT); - KeyGuard = (KeyNumType)(KeyGuard & ~WWKEY_VK_BIT); - KeyNext = (KeyNumType)(KeyNext & ~WWKEY_VK_BIT); - KeyPrevious = (KeyNumType)(KeyPrevious & ~WWKEY_VK_BIT); - KeyFormation = (KeyNumType)(KeyFormation & ~WWKEY_VK_BIT); - KeyHome1 = (KeyNumType)(KeyHome1 & ~WWKEY_VK_BIT); - KeyHome2 = (KeyNumType)(KeyHome2 & ~WWKEY_VK_BIT); - KeyBase = (KeyNumType)(KeyBase & ~WWKEY_VK_BIT); - KeyResign = (KeyNumType)(KeyResign & ~WWKEY_VK_BIT); - KeyAlliance = (KeyNumType)(KeyAlliance & ~WWKEY_VK_BIT); - KeyBookmark1 = (KeyNumType)(KeyBookmark1 & ~WWKEY_VK_BIT); - KeyBookmark2 = (KeyNumType)(KeyBookmark2 & ~WWKEY_VK_BIT); - KeyBookmark3 = (KeyNumType)(KeyBookmark3 & ~WWKEY_VK_BIT); - KeyBookmark4 = (KeyNumType)(KeyBookmark4 & ~WWKEY_VK_BIT); - KeySelectView = (KeyNumType)(KeySelectView & ~WWKEY_VK_BIT); - KeyRepair = (KeyNumType)(KeyRepair & ~WWKEY_VK_BIT); - KeyRepairOn = (KeyNumType)(KeyRepairOn & ~WWKEY_VK_BIT); - KeyRepairOff = (KeyNumType)(KeyRepairOff & ~WWKEY_VK_BIT); - KeySell = (KeyNumType)(KeySell & ~WWKEY_VK_BIT); - KeySellOn = (KeyNumType)(KeySellOn & ~WWKEY_VK_BIT); - KeySellOff = (KeyNumType)(KeySellOff & ~WWKEY_VK_BIT); - KeyMap = (KeyNumType)(KeyMap & ~WWKEY_VK_BIT); - KeySidebarUp = (KeyNumType)(KeySidebarUp & ~WWKEY_VK_BIT); - KeySidebarDown = (KeyNumType)(KeySidebarDown & ~WWKEY_VK_BIT); - KeyOption1 = (KeyNumType)(KeyOption1 & ~WWKEY_VK_BIT); - KeyOption2 = (KeyNumType)(KeyOption2 & ~WWKEY_VK_BIT); - KeyScrollLeft = (KeyNumType)(KeyScrollLeft & ~WWKEY_VK_BIT); - KeyScrollRight = (KeyNumType)(KeyScrollRight & ~WWKEY_VK_BIT); - KeyScrollUp = (KeyNumType)(KeyScrollUp & ~WWKEY_VK_BIT); - KeyScrollDown = (KeyNumType)(KeyScrollDown & ~WWKEY_VK_BIT); - KeyQueueMove1 = (KeyNumType)(KeyQueueMove1 & ~WWKEY_VK_BIT); - KeyQueueMove2 = (KeyNumType)(KeyQueueMove2 & ~WWKEY_VK_BIT); - KeyTeam1 = (KeyNumType)(KeyTeam1 & ~WWKEY_VK_BIT); - KeyTeam2 = (KeyNumType)(KeyTeam2 & ~WWKEY_VK_BIT); - KeyTeam3 = (KeyNumType)(KeyTeam3 & ~WWKEY_VK_BIT); - KeyTeam4 = (KeyNumType)(KeyTeam4 & ~WWKEY_VK_BIT); - KeyTeam5 = (KeyNumType)(KeyTeam5 & ~WWKEY_VK_BIT); - KeyTeam6 = (KeyNumType)(KeyTeam6 & ~WWKEY_VK_BIT); - KeyTeam7 = (KeyNumType)(KeyTeam7 & ~WWKEY_VK_BIT); - KeyTeam8 = (KeyNumType)(KeyTeam8 & ~WWKEY_VK_BIT); - KeyTeam9 = (KeyNumType)(KeyTeam9 & ~WWKEY_VK_BIT); - KeyTeam10 = (KeyNumType)(KeyTeam10 & ~WWKEY_VK_BIT); + KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~KN_VK_BIT); + KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~KN_VK_BIT); + KeyForceAttack1 = (KeyNumType)(KeyForceAttack1 & ~KN_VK_BIT); + KeyForceAttack2 = (KeyNumType)(KeyForceAttack2 & ~KN_VK_BIT); + KeySelect1 = (KeyNumType)(KeySelect1 & ~KN_VK_BIT); + KeySelect2 = (KeyNumType)(KeySelect2 & ~KN_VK_BIT); + KeyScatter = (KeyNumType)(KeyScatter & ~KN_VK_BIT); + KeyStop = (KeyNumType)(KeyStop & ~KN_VK_BIT); + KeyGuard = (KeyNumType)(KeyGuard & ~KN_VK_BIT); + KeyNext = (KeyNumType)(KeyNext & ~KN_VK_BIT); + KeyPrevious = (KeyNumType)(KeyPrevious & ~KN_VK_BIT); + KeyFormation = (KeyNumType)(KeyFormation & ~KN_VK_BIT); + KeyHome1 = (KeyNumType)(KeyHome1 & ~KN_VK_BIT); + KeyHome2 = (KeyNumType)(KeyHome2 & ~KN_VK_BIT); + KeyBase = (KeyNumType)(KeyBase & ~KN_VK_BIT); + KeyResign = (KeyNumType)(KeyResign & ~KN_VK_BIT); + KeyAlliance = (KeyNumType)(KeyAlliance & ~KN_VK_BIT); + KeyBookmark1 = (KeyNumType)(KeyBookmark1 & ~KN_VK_BIT); + KeyBookmark2 = (KeyNumType)(KeyBookmark2 & ~KN_VK_BIT); + KeyBookmark3 = (KeyNumType)(KeyBookmark3 & ~KN_VK_BIT); + KeyBookmark4 = (KeyNumType)(KeyBookmark4 & ~KN_VK_BIT); + KeySelectView = (KeyNumType)(KeySelectView & ~KN_VK_BIT); + KeyRepair = (KeyNumType)(KeyRepair & ~KN_VK_BIT); + KeyRepairOn = (KeyNumType)(KeyRepairOn & ~KN_VK_BIT); + KeyRepairOff = (KeyNumType)(KeyRepairOff & ~KN_VK_BIT); + KeySell = (KeyNumType)(KeySell & ~KN_VK_BIT); + KeySellOn = (KeyNumType)(KeySellOn & ~KN_VK_BIT); + KeySellOff = (KeyNumType)(KeySellOff & ~KN_VK_BIT); + KeyMap = (KeyNumType)(KeyMap & ~KN_VK_BIT); + KeySidebarUp = (KeyNumType)(KeySidebarUp & ~KN_VK_BIT); + KeySidebarDown = (KeyNumType)(KeySidebarDown & ~KN_VK_BIT); + KeyOption1 = (KeyNumType)(KeyOption1 & ~KN_VK_BIT); + KeyOption2 = (KeyNumType)(KeyOption2 & ~KN_VK_BIT); + KeyScrollLeft = (KeyNumType)(KeyScrollLeft & ~KN_VK_BIT); + KeyScrollRight = (KeyNumType)(KeyScrollRight & ~KN_VK_BIT); + KeyScrollUp = (KeyNumType)(KeyScrollUp & ~KN_VK_BIT); + KeyScrollDown = (KeyNumType)(KeyScrollDown & ~KN_VK_BIT); + KeyQueueMove1 = (KeyNumType)(KeyQueueMove1 & ~KN_VK_BIT); + KeyQueueMove2 = (KeyNumType)(KeyQueueMove2 & ~KN_VK_BIT); + KeyTeam1 = (KeyNumType)(KeyTeam1 & ~KN_VK_BIT); + KeyTeam2 = (KeyNumType)(KeyTeam2 & ~KN_VK_BIT); + KeyTeam3 = (KeyNumType)(KeyTeam3 & ~KN_VK_BIT); + KeyTeam4 = (KeyNumType)(KeyTeam4 & ~KN_VK_BIT); + KeyTeam5 = (KeyNumType)(KeyTeam5 & ~KN_VK_BIT); + KeyTeam6 = (KeyNumType)(KeyTeam6 & ~KN_VK_BIT); + KeyTeam7 = (KeyNumType)(KeyTeam7 & ~KN_VK_BIT); + KeyTeam8 = (KeyNumType)(KeyTeam8 & ~KN_VK_BIT); + KeyTeam9 = (KeyNumType)(KeyTeam9 & ~KN_VK_BIT); + KeyTeam10 = (KeyNumType)(KeyTeam10 & ~KN_VK_BIT); } /*********************************************************************************************** diff --git a/tiberiandawn/conquer.cpp b/tiberiandawn/conquer.cpp index 413c3ce5..cf74406a 100644 --- a/tiberiandawn/conquer.cpp +++ b/tiberiandawn/conquer.cpp @@ -426,8 +426,8 @@ void Keyboard_Process(KeyNumType& input) ** Use WWKEY values because KN values have WWKEY_KN_BIT or'd in with them ** and we need WWKEY_KN_BIT to still be set if it is. */ - KeyNumType plain = (KeyNumType)(input & ~(WWKEY_SHIFT_BIT | WWKEY_ALT_BIT | WWKEY_CTRL_BIT)); - KeyNumType key = KeyNumType(input & ~WWKEY_VK_BIT); + KeyNumType plain = (KeyNumType)(input & ~(KN_SHIFT_BIT | KN_ALT_BIT | KN_CTRL_BIT)); + KeyNumType key = KeyNumType(input & ~KN_VK_BIT); #ifdef CHEAT_KEYS @@ -481,11 +481,11 @@ void Keyboard_Process(KeyNumType& input) ** CTRL or ALT key is held down. */ int action = 0; - if (input & WWKEY_SHIFT_BIT) + if (input & KN_SHIFT_BIT) action = 1; - if (input & WWKEY_ALT_BIT) + if (input & KN_ALT_BIT) action = 3; - if (input & WWKEY_CTRL_BIT) + if (input & KN_CTRL_BIT) action = 2; /* diff --git a/tiberiandawn/edit.cpp b/tiberiandawn/edit.cpp index eb868c9d..fda540a1 100644 --- a/tiberiandawn/edit.cpp +++ b/tiberiandawn/edit.cpp @@ -252,8 +252,8 @@ int EditClass::Action(unsigned flags, KeyNumType& key) /* ** Allow numeric keypad presses to map to ascii numbers */ - if ((key & WWKEY_VK_BIT) && ascii >= '0' && ascii <= '9') { - key = (KeyNumType)(key & ~WWKEY_VK_BIT); + if ((key & KN_VK_BIT) && ascii >= '0' && ascii <= '9') { + key = (KeyNumType)(key & ~KN_VK_BIT); if ((!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) { if (Handle_Key(ascii)) { @@ -267,8 +267,7 @@ int EditClass::Action(unsigned flags, KeyNumType& key) /* ** Filter out all special keys except return and backspace */ - if ((!(key & WWKEY_VK_BIT) && ascii >= ' ' && ascii <= 127) || key == KN_RETURN - || key == KN_BACKSPACE) { + if ((!(key & KN_VK_BIT) && ascii >= ' ' && ascii <= 127) || key == KN_RETURN || key == KN_BACKSPACE) { if ((!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))) { if (Handle_Key(Keyboard->To_ASCII(key))) { @@ -277,7 +276,7 @@ int EditClass::Action(unsigned flags, KeyNumType& key) } } } else { - // if (key & WWKEY_RLS_BIT){ + // if (key & KN_RLSE_BIT){ // if ( (!(flags & LEFTRELEASE)) && (!(flags & RIGHTRELEASE))){ flags &= ~KEYBOARD; key = KN_NONE; diff --git a/tiberiandawn/mapedit.cpp b/tiberiandawn/mapedit.cpp index 04708fb3..08384c77 100644 --- a/tiberiandawn/mapedit.cpp +++ b/tiberiandawn/mapedit.cpp @@ -964,7 +964,7 @@ void MapEditClass::AI(KeyNumType& input, int x, int y) case ((int)KN_Y | (int)KN_ALT_BIT): case ((int)KN_Z | (int)KN_ALT_BIT): if (CurrentCell != 0) { - waypt_idx = Keyboard->To_ASCII(input & 0xff) - KA_a; + waypt_idx = Keyboard->To_ASCII(input & KN_SCANCODE_MASK) - KA_a; /*............................................................... Unflag cell for this waypoint if there is one ...............................................................*/ @@ -993,7 +993,7 @@ void MapEditClass::AI(KeyNumType& input, int x, int y) If there's a current cell, place the flag & waypoint there. ------------------------------------------------------------------*/ if (CurrentCell != 0) { - waypt_idx = (Keyboard->To_ASCII(input & 0xff) - KA_1); + waypt_idx = (Keyboard->To_ASCII(input & KN_SCANCODE_MASK) - KA_1); house = (HousesType)(HOUSE_MULTI1 + waypt_idx); if (HouseClass::As_Pointer(house)) { HouseClass::As_Pointer(house)->Flag_Attach(CurrentCell, true); @@ -1004,7 +1004,7 @@ void MapEditClass::AI(KeyNumType& input, int x, int y) waypoint. ------------------------------------------------------------------*/ if (CurrentObject[0] != 0) { - waypt_idx = (Keyboard->To_ASCII(input & 0xff) - KA_1); + waypt_idx = (Keyboard->To_ASCII(input & KN_SCANCODE_MASK) - KA_1); house = (HousesType)(HOUSE_MULTI1 + waypt_idx); if (HouseClass::As_Pointer(house) && CurrentObject[0]->What_Am_I() == RTTI_UNIT) { HouseClass::As_Pointer(house)->Flag_Attach((UnitClass*)CurrentObject[0], true); diff --git a/tiberiandawn/msgbox.cpp b/tiberiandawn/msgbox.cpp index fb74f871..7f657469 100644 --- a/tiberiandawn/msgbox.cpp +++ b/tiberiandawn/msgbox.cpp @@ -387,10 +387,11 @@ int WWMessageBox::Process(const char* msg, const char* b1txt, const char* b2txt, */ default: #ifdef NEVER - if (b1char == toupper(Keyboard->To_ASCII((KeyNumType)(input & 0xFF)))) { + if (b1char == toupper(Keyboard->To_ASCII((KeyNumType)(input & KN_SCANCODE_MASK)))) { selection = BUTTON_1; pressed = true; - } else if (b2txt != NULL && b2char == toupper(Keyboard->To_ASCII((KeyNumType)(input & 0xFF)))) { + } else if (b2txt != NULL + && b2char == toupper(Keyboard->To_ASCII((KeyNumType)(input & KN_SCANCODE_MASK)))) { selection = BUTTON_2; pressed = true; } diff --git a/tiberiandawn/msglist.cpp b/tiberiandawn/msglist.cpp index 01b705dd..8c44af78 100644 --- a/tiberiandawn/msglist.cpp +++ b/tiberiandawn/msglist.cpp @@ -627,17 +627,18 @@ int MessageListClass::Input(KeyNumType& input) /* ** Allow numeric keypad presses to map to ascii numbers */ - if ((input & WWKEY_VK_BIT) && ascii >= '0' && ascii <= '9') { + if ((input & KN_VK_BIT) && ascii >= '0' && ascii <= '9') { - input = (KeyNumType)(input & ~WWKEY_VK_BIT); + input = (KeyNumType)(input & ~KN_VK_BIT); } else { /* ** Filter out all special keys except return, escape and backspace */ - if ((!(input & WWKEY_VK_BIT) && !(input & KN_BUTTON) && ascii >= ' ' && ascii <= 127) - || (input & 0xff) == (KN_RETURN & 0xff) || (input & 0xff) == (KN_BACKSPACE & 0xff) - || (input & 0xff) == (KN_ESC & 0xff)) { + if ((!(input & KN_VK_BIT) && !(input & KN_BUTTON) && ascii >= ' ' && ascii <= 127) + || (input & KN_SCANCODE_MASK) == (KN_RETURN & KN_SCANCODE_MASK) + || (input & KN_SCANCODE_MASK) == (KN_BACKSPACE & KN_SCANCODE_MASK) + || (input & KN_SCANCODE_MASK) == (KN_ESC & KN_SCANCODE_MASK)) { // ascii = (KeyASCIIType)(Keyboard->To_ASCII(input)); } else { @@ -650,7 +651,7 @@ int MessageListClass::Input(KeyNumType& input) /*------------------------------------------------------------------ ESC = abort message ------------------------------------------------------------------*/ - case KA_ESC & 0xff: + case KA_ESC: EditLabel->UserData = 1; // force it to be removed input = KN_NONE; break; @@ -658,7 +659,7 @@ int MessageListClass::Input(KeyNumType& input) /*------------------------------------------------------------------ RETURN = send the message ------------------------------------------------------------------*/ - case KA_RETURN & 0xff: + case KA_RETURN: EditLabel->UserData = 1; // force it to be removed retcode = 3; input = KN_NONE; @@ -667,7 +668,7 @@ int MessageListClass::Input(KeyNumType& input) /*------------------------------------------------------------------ BACKSPACE = remove a character ------------------------------------------------------------------*/ - case KA_BACKSPACE & 0xff: + case KA_BACKSPACE: if (EditCurPos > EditInitPos) { EditCurPos--; EditBuf[EditCurPos] = 0; @@ -683,7 +684,7 @@ int MessageListClass::Input(KeyNumType& input) ------------------------------------------------------------------*/ default: if ((EditCurPos - EditInitPos) < (MaxChars - 1)) { - if (!(input & WWKEY_VK_BIT) && ascii >= ' ' && ascii <= 127) { + if (!(input & KN_VK_BIT) && ascii >= ' ' && ascii <= 127) { EditBuf[EditCurPos] = ascii; EditCurPos++; retcode = 1; diff --git a/tiberiandawn/options.cpp b/tiberiandawn/options.cpp index c4206a04..09ce813b 100644 --- a/tiberiandawn/options.cpp +++ b/tiberiandawn/options.cpp @@ -629,55 +629,55 @@ void OptionsClass::Load_Settings(void) KeyTeam9 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam9", KeyTeam9); KeyTeam10 = (KeyNumType)ini.Get_Int(HotkeyName, "KeyTeam10", KeyTeam10); - KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~WWKEY_VK_BIT); - KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~WWKEY_VK_BIT); - KeyForceAttack1 = (KeyNumType)(KeyForceAttack1 & ~WWKEY_VK_BIT); - KeyForceAttack2 = (KeyNumType)(KeyForceAttack2 & ~WWKEY_VK_BIT); - KeySelect1 = (KeyNumType)(KeySelect1 & ~WWKEY_VK_BIT); - KeySelect2 = (KeyNumType)(KeySelect2 & ~WWKEY_VK_BIT); - KeyScatter = (KeyNumType)(KeyScatter & ~WWKEY_VK_BIT); - KeyStop = (KeyNumType)(KeyStop & ~WWKEY_VK_BIT); - KeyGuard = (KeyNumType)(KeyGuard & ~WWKEY_VK_BIT); - KeyNext = (KeyNumType)(KeyNext & ~WWKEY_VK_BIT); - KeyPrevious = (KeyNumType)(KeyPrevious & ~WWKEY_VK_BIT); - KeyFormation = (KeyNumType)(KeyFormation & ~WWKEY_VK_BIT); - KeyHome1 = (KeyNumType)(KeyHome1 & ~WWKEY_VK_BIT); - KeyHome2 = (KeyNumType)(KeyHome2 & ~WWKEY_VK_BIT); - KeyBase = (KeyNumType)(KeyBase & ~WWKEY_VK_BIT); - KeyResign = (KeyNumType)(KeyResign & ~WWKEY_VK_BIT); - KeyAlliance = (KeyNumType)(KeyAlliance & ~WWKEY_VK_BIT); - KeyBookmark1 = (KeyNumType)(KeyBookmark1 & ~WWKEY_VK_BIT); - KeyBookmark2 = (KeyNumType)(KeyBookmark2 & ~WWKEY_VK_BIT); - KeyBookmark3 = (KeyNumType)(KeyBookmark3 & ~WWKEY_VK_BIT); - KeyBookmark4 = (KeyNumType)(KeyBookmark4 & ~WWKEY_VK_BIT); - KeySelectView = (KeyNumType)(KeySelectView & ~WWKEY_VK_BIT); - KeyRepair = (KeyNumType)(KeyRepair & ~WWKEY_VK_BIT); - KeyRepairOn = (KeyNumType)(KeyRepairOn & ~WWKEY_VK_BIT); - KeyRepairOff = (KeyNumType)(KeyRepairOff & ~WWKEY_VK_BIT); - KeySell = (KeyNumType)(KeySell & ~WWKEY_VK_BIT); - KeySellOn = (KeyNumType)(KeySellOn & ~WWKEY_VK_BIT); - KeySellOff = (KeyNumType)(KeySellOff & ~WWKEY_VK_BIT); - KeyMap = (KeyNumType)(KeyMap & ~WWKEY_VK_BIT); - KeySidebarUp = (KeyNumType)(KeySidebarUp & ~WWKEY_VK_BIT); - KeySidebarDown = (KeyNumType)(KeySidebarDown & ~WWKEY_VK_BIT); - KeyOption1 = (KeyNumType)(KeyOption1 & ~WWKEY_VK_BIT); - KeyOption2 = (KeyNumType)(KeyOption2 & ~WWKEY_VK_BIT); - KeyScrollLeft = (KeyNumType)(KeyScrollLeft & ~WWKEY_VK_BIT); - KeyScrollRight = (KeyNumType)(KeyScrollRight & ~WWKEY_VK_BIT); - KeyScrollUp = (KeyNumType)(KeyScrollUp & ~WWKEY_VK_BIT); - KeyScrollDown = (KeyNumType)(KeyScrollDown & ~WWKEY_VK_BIT); - KeyQueueMove1 = (KeyNumType)(KeyQueueMove1 & ~WWKEY_VK_BIT); - KeyQueueMove2 = (KeyNumType)(KeyQueueMove2 & ~WWKEY_VK_BIT); - KeyTeam1 = (KeyNumType)(KeyTeam1 & ~WWKEY_VK_BIT); - KeyTeam2 = (KeyNumType)(KeyTeam2 & ~WWKEY_VK_BIT); - KeyTeam3 = (KeyNumType)(KeyTeam3 & ~WWKEY_VK_BIT); - KeyTeam4 = (KeyNumType)(KeyTeam4 & ~WWKEY_VK_BIT); - KeyTeam5 = (KeyNumType)(KeyTeam5 & ~WWKEY_VK_BIT); - KeyTeam6 = (KeyNumType)(KeyTeam6 & ~WWKEY_VK_BIT); - KeyTeam7 = (KeyNumType)(KeyTeam7 & ~WWKEY_VK_BIT); - KeyTeam8 = (KeyNumType)(KeyTeam8 & ~WWKEY_VK_BIT); - KeyTeam9 = (KeyNumType)(KeyTeam9 & ~WWKEY_VK_BIT); - KeyTeam10 = (KeyNumType)(KeyTeam10 & ~WWKEY_VK_BIT); + KeyForceMove1 = (KeyNumType)(KeyForceMove1 & ~KN_VK_BIT); + KeyForceMove2 = (KeyNumType)(KeyForceMove2 & ~KN_VK_BIT); + KeyForceAttack1 = (KeyNumType)(KeyForceAttack1 & ~KN_VK_BIT); + KeyForceAttack2 = (KeyNumType)(KeyForceAttack2 & ~KN_VK_BIT); + KeySelect1 = (KeyNumType)(KeySelect1 & ~KN_VK_BIT); + KeySelect2 = (KeyNumType)(KeySelect2 & ~KN_VK_BIT); + KeyScatter = (KeyNumType)(KeyScatter & ~KN_VK_BIT); + KeyStop = (KeyNumType)(KeyStop & ~KN_VK_BIT); + KeyGuard = (KeyNumType)(KeyGuard & ~KN_VK_BIT); + KeyNext = (KeyNumType)(KeyNext & ~KN_VK_BIT); + KeyPrevious = (KeyNumType)(KeyPrevious & ~KN_VK_BIT); + KeyFormation = (KeyNumType)(KeyFormation & ~KN_VK_BIT); + KeyHome1 = (KeyNumType)(KeyHome1 & ~KN_VK_BIT); + KeyHome2 = (KeyNumType)(KeyHome2 & ~KN_VK_BIT); + KeyBase = (KeyNumType)(KeyBase & ~KN_VK_BIT); + KeyResign = (KeyNumType)(KeyResign & ~KN_VK_BIT); + KeyAlliance = (KeyNumType)(KeyAlliance & ~KN_VK_BIT); + KeyBookmark1 = (KeyNumType)(KeyBookmark1 & ~KN_VK_BIT); + KeyBookmark2 = (KeyNumType)(KeyBookmark2 & ~KN_VK_BIT); + KeyBookmark3 = (KeyNumType)(KeyBookmark3 & ~KN_VK_BIT); + KeyBookmark4 = (KeyNumType)(KeyBookmark4 & ~KN_VK_BIT); + KeySelectView = (KeyNumType)(KeySelectView & ~KN_VK_BIT); + KeyRepair = (KeyNumType)(KeyRepair & ~KN_VK_BIT); + KeyRepairOn = (KeyNumType)(KeyRepairOn & ~KN_VK_BIT); + KeyRepairOff = (KeyNumType)(KeyRepairOff & ~KN_VK_BIT); + KeySell = (KeyNumType)(KeySell & ~KN_VK_BIT); + KeySellOn = (KeyNumType)(KeySellOn & ~KN_VK_BIT); + KeySellOff = (KeyNumType)(KeySellOff & ~KN_VK_BIT); + KeyMap = (KeyNumType)(KeyMap & ~KN_VK_BIT); + KeySidebarUp = (KeyNumType)(KeySidebarUp & ~KN_VK_BIT); + KeySidebarDown = (KeyNumType)(KeySidebarDown & ~KN_VK_BIT); + KeyOption1 = (KeyNumType)(KeyOption1 & ~KN_VK_BIT); + KeyOption2 = (KeyNumType)(KeyOption2 & ~KN_VK_BIT); + KeyScrollLeft = (KeyNumType)(KeyScrollLeft & ~KN_VK_BIT); + KeyScrollRight = (KeyNumType)(KeyScrollRight & ~KN_VK_BIT); + KeyScrollUp = (KeyNumType)(KeyScrollUp & ~KN_VK_BIT); + KeyScrollDown = (KeyNumType)(KeyScrollDown & ~KN_VK_BIT); + KeyQueueMove1 = (KeyNumType)(KeyQueueMove1 & ~KN_VK_BIT); + KeyQueueMove2 = (KeyNumType)(KeyQueueMove2 & ~KN_VK_BIT); + KeyTeam1 = (KeyNumType)(KeyTeam1 & ~KN_VK_BIT); + KeyTeam2 = (KeyNumType)(KeyTeam2 & ~KN_VK_BIT); + KeyTeam3 = (KeyNumType)(KeyTeam3 & ~KN_VK_BIT); + KeyTeam4 = (KeyNumType)(KeyTeam4 & ~KN_VK_BIT); + KeyTeam5 = (KeyNumType)(KeyTeam5 & ~KN_VK_BIT); + KeyTeam6 = (KeyNumType)(KeyTeam6 & ~KN_VK_BIT); + KeyTeam7 = (KeyNumType)(KeyTeam7 & ~KN_VK_BIT); + KeyTeam8 = (KeyNumType)(KeyTeam8 & ~KN_VK_BIT); + KeyTeam9 = (KeyNumType)(KeyTeam9 & ~KN_VK_BIT); + KeyTeam10 = (KeyNumType)(KeyTeam10 & ~KN_VK_BIT); char workbuf[128]; @@ -957,4 +957,4 @@ void OptionsClass::Fixup_Palette(void) const int OptionsClass::Normalize_Sound(int volume) const { return (Fixed_To_Cardinal(volume, Volume)); -} \ No newline at end of file +}