From 5ce842c74523e5746f3bbbb35ad70da5f593f850 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Mon, 23 Jan 2017 22:09:20 +0100 Subject: [PATCH] Use Scancodes for key events --- src/osdep/config.h | 22 +++++------ src/osdep/pandora.cpp | 76 ++++++++++++++++++------------------- src/osdep/pandora_input.cpp | 52 ++++++++++++------------- 3 files changed, 75 insertions(+), 75 deletions(-) diff --git a/src/osdep/config.h b/src/osdep/config.h index 38d4d070..e0528f87 100644 --- a/src/osdep/config.h +++ b/src/osdep/config.h @@ -60,64 +60,64 @@ * Virtual Key for (A) button * default: HOME (278) */ -#define VK_A SDLK_HOME +#define VK_A SDL_SCANCODE_HOME /* * Virtual Key for (B) button * default: END (279) */ -#define VK_B SDLK_END +#define VK_B SDL_SCANCODE_END /* * Virtual Key for (X) button * default: PAGEDOWN (281) */ -#define VK_X SDLK_PAGEDOWN +#define VK_X SDL_SCANCODE_PAGEDOWN /* * Virtual Key for (Y) button * default: PAGEUP (280) */ -#define VK_Y SDLK_PAGEUP +#define VK_Y SDL_SCANCODE_PAGEUP /* * Virtual Key for (Left shoulder) button * default: RSHIFT (303) */ -#define VK_L SDLK_RSHIFT +#define VK_L SDL_SCANCODE_RSHIFT /* * Virtual Key for (Right shoulder) button * default: RCTRL (305) */ -#define VK_R SDLK_RCTRL +#define VK_R SDL_SCANCODE_RCTRL /* * Virtual Key for (up) button * default: UP (273) */ -#define VK_UP SDLK_UP +#define VK_UP SDL_SCANCODE_UP /* * Virtual Key for (down) button * default: DOWN (274) */ -#define VK_DOWN SDLK_DOWN +#define VK_DOWN SDL_SCANCODE_DOWN /* * Virtual Key for (right) button * default: RIGHT (275) */ -#define VK_RIGHT SDLK_RIGHT +#define VK_RIGHT SDL_SCANCODE_RIGHT /* * Virtual Key for (left) button * default: LEFT (276) */ -#define VK_LEFT SDLK_LEFT +#define VK_LEFT SDL_SCANCODE_LEFT /* * Virtual Key for (ESC) button * default: ESC (27) */ -#define VK_ESCAPE SDLK_ESCAPE +#define VK_ESCAPE SDL_SCANCODE_ESCAPE diff --git a/src/osdep/pandora.cpp b/src/osdep/pandora.cpp index 454ba786..0822f77b 100644 --- a/src/osdep/pandora.cpp +++ b/src/osdep/pandora.cpp @@ -823,10 +823,10 @@ int handle_msgpump (void) break; } - switch(rEvent.key.keysym.sym) + switch(rEvent.key.keysym.scancode) { #ifdef CAPSLOCK_DEBIAN_WORKAROUND - case SDLK_CAPSLOCK: // capslock + case SDL_SCANCODE_CAPSLOCK: // capslock // Treat CAPSLOCK as a toggle. If on, set off and vice/versa ioctl(0, KDGKBLED, &kbd_flags); ioctl(0, KDGETLED, &kbd_led_status); @@ -849,17 +849,17 @@ int handle_msgpump (void) break; #endif - case SDLK_LSHIFT: // Shift key + case SDL_SCANCODE_LSHIFT: // Shift key inputdevice_do_keyboard(AK_LSH, 1); break; - case VK_L: // Left shoulder button - case VK_R: // Right shoulder button - if(currprefs.input_tablet > TABLET_OFF) - { - // Holding left or right shoulder button -> stylus does right mousebutton - doStylusRightClick = 1; - } +// case VK_L: // Left shoulder button +// case VK_R: // Right shoulder button +// if(currprefs.input_tablet > TABLET_OFF) +// { +// // Holding left or right shoulder button -> stylus does right mousebutton +// doStylusRightClick = 1; +// } // Fall through... default: @@ -882,41 +882,41 @@ int handle_msgpump (void) else modifier = rEvent.key.keysym.mod; - keycode = translate_pandora_keys(rEvent.key.keysym.sym, &modifier); - if(keycode) - { - if(modifier == KMOD_SHIFT) - inputdevice_do_keyboard(AK_LSH, 1); - else - inputdevice_do_keyboard(AK_LSH, 0); - - inputdevice_do_keyboard(keycode, 1); - } - else - { - if (keyboard_type == KEYCODE_UNK) - inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1); - else +// keycode = translate_pandora_keys(rEvent.key.keysym.sym, &modifier); +// if(keycode) +// { +// if(modifier == KMOD_SHIFT) +// inputdevice_do_keyboard(AK_LSH, 1); +// else +// inputdevice_do_keyboard(AK_LSH, 0); +// +// inputdevice_do_keyboard(keycode, 1); +// } +// else +// { +// if (keyboard_type == KEYCODE_UNK) +// inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1); +// else inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1); - } +// } break; } break; case SDL_KEYUP: - switch(rEvent.key.keysym.sym) + switch(rEvent.key.keysym.scancode) { - case SDLK_LSHIFT: // Shift key + case SDL_SCANCODE_LSHIFT: // Shift key inputdevice_do_keyboard(AK_LSH, 0); break; - case VK_L: // Left shoulder button - case VK_R: // Right shoulder button - if(currprefs.input_tablet > TABLET_OFF) - { - // Release left or right shoulder button -> stylus does left mousebutton - doStylusRightClick = 0; - } +// case VK_L: // Left shoulder button +// case VK_R: // Right shoulder button +// if(currprefs.input_tablet > TABLET_OFF) +// { +// // Release left or right shoulder button -> stylus does left mousebutton +// doStylusRightClick = 0; +// } // Fall through... default: @@ -947,9 +947,9 @@ int handle_msgpump (void) } else { - if (keyboard_type == KEYCODE_UNK) - inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0); - else +// if (keyboard_type == KEYCODE_UNK) +// inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0); +// else inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0); } break; diff --git a/src/osdep/pandora_input.cpp b/src/osdep/pandora_input.cpp index e7d38b34..84f18b7a 100644 --- a/src/osdep/pandora_input.cpp +++ b/src/osdep/pandora_input.cpp @@ -436,35 +436,35 @@ static void read_joystick(void) // First handle fake joystick from pandora... if (currprefs.jports[joyid].id == JSEM_JOYS) { -// const Uint8 *keystate = SDL_GetKeyboardState(NULL); + const Uint8 *keystate = SDL_GetKeyboardState(NULL); -// if (!keystate[VK_R]) -// { // Right shoulder + dPad -> cursor keys -// int axis = (keystate[VK_LEFT] ? -32767 : (keystate[VK_RIGHT] ? 32767 : 0)); -// if (!joyXviaCustom) -// setjoystickstate(0, 0, axis, 32767); -// axis = (keystate[VK_UP] ? -32767 : (keystate[VK_DOWN] ? 32767 : 0)); -// if (!joyYviaCustom) -// setjoystickstate(0, 1, axis, 32767); -// } -// if (!joyButXviaCustom[0]) -// setjoybuttonstate(0, 0, keystate[VK_X]); -// if (!joyButXviaCustom[1]) -// setjoybuttonstate(0, 1, keystate[VK_B]); -// if (!joyButXviaCustom[2]) -// setjoybuttonstate(0, 2, keystate[VK_A]); -// if (!joyButXviaCustom[3]) -// setjoybuttonstate(0, 3, keystate[VK_Y]); + if (!keystate[VK_R]) + { // Right shoulder + dPad -> cursor keys + int axis = (keystate[VK_LEFT] ? -32767 : (keystate[VK_RIGHT] ? 32767 : 0)); + if (!joyXviaCustom) + setjoystickstate(0, 0, axis, 32767); + axis = (keystate[VK_UP] ? -32767 : (keystate[VK_DOWN] ? 32767 : 0)); + if (!joyYviaCustom) + setjoystickstate(0, 1, axis, 32767); + } + if (!joyButXviaCustom[0]) + setjoybuttonstate(0, 0, keystate[VK_X]); + if (!joyButXviaCustom[1]) + setjoybuttonstate(0, 1, keystate[VK_B]); + if (!joyButXviaCustom[2]) + setjoybuttonstate(0, 2, keystate[VK_A]); + if (!joyButXviaCustom[3]) + setjoybuttonstate(0, 3, keystate[VK_Y]); int cd32_start = 0, cd32_ffw = 0, cd32_rwd = 0; -// if (keystate[SDLK_LALT]) { // Pandora Start button -// if (keystate[VK_L]) // Left shoulder -// cd32_rwd = 1; -// else if (keystate[VK_R]) // Right shoulder -// cd32_ffw = 1; -// else -// cd32_start = 1; -// } + if (keystate[SDL_SCANCODE_LALT]) { // Pandora Start button + if (keystate[VK_L]) // Left shoulder + cd32_rwd = 1; + else if (keystate[VK_R]) // Right shoulder + cd32_ffw = 1; + else + cd32_start = 1; + } if (!joyButXviaCustom[6]) setjoybuttonstate(0, 6, cd32_start); if (!joyButXviaCustom[5])