Use Scancodes for key events

This commit is contained in:
Dimitris Panokostas 2017-01-23 22:09:20 +01:00
parent 4d63808ffc
commit 5ce842c745
3 changed files with 75 additions and 75 deletions

View file

@ -60,64 +60,64 @@
* Virtual Key for (A) button * Virtual Key for (A) button
* default: HOME (278) * default: HOME (278)
*/ */
#define VK_A SDLK_HOME #define VK_A SDL_SCANCODE_HOME
/* /*
* Virtual Key for (B) button * Virtual Key for (B) button
* default: END (279) * default: END (279)
*/ */
#define VK_B SDLK_END #define VK_B SDL_SCANCODE_END
/* /*
* Virtual Key for (X) button * Virtual Key for (X) button
* default: PAGEDOWN (281) * default: PAGEDOWN (281)
*/ */
#define VK_X SDLK_PAGEDOWN #define VK_X SDL_SCANCODE_PAGEDOWN
/* /*
* Virtual Key for (Y) button * Virtual Key for (Y) button
* default: PAGEUP (280) * default: PAGEUP (280)
*/ */
#define VK_Y SDLK_PAGEUP #define VK_Y SDL_SCANCODE_PAGEUP
/* /*
* Virtual Key for (Left shoulder) button * Virtual Key for (Left shoulder) button
* default: RSHIFT (303) * default: RSHIFT (303)
*/ */
#define VK_L SDLK_RSHIFT #define VK_L SDL_SCANCODE_RSHIFT
/* /*
* Virtual Key for (Right shoulder) button * Virtual Key for (Right shoulder) button
* default: RCTRL (305) * default: RCTRL (305)
*/ */
#define VK_R SDLK_RCTRL #define VK_R SDL_SCANCODE_RCTRL
/* /*
* Virtual Key for (up) button * Virtual Key for (up) button
* default: UP (273) * default: UP (273)
*/ */
#define VK_UP SDLK_UP #define VK_UP SDL_SCANCODE_UP
/* /*
* Virtual Key for (down) button * Virtual Key for (down) button
* default: DOWN (274) * default: DOWN (274)
*/ */
#define VK_DOWN SDLK_DOWN #define VK_DOWN SDL_SCANCODE_DOWN
/* /*
* Virtual Key for (right) button * Virtual Key for (right) button
* default: RIGHT (275) * default: RIGHT (275)
*/ */
#define VK_RIGHT SDLK_RIGHT #define VK_RIGHT SDL_SCANCODE_RIGHT
/* /*
* Virtual Key for (left) button * Virtual Key for (left) button
* default: LEFT (276) * default: LEFT (276)
*/ */
#define VK_LEFT SDLK_LEFT #define VK_LEFT SDL_SCANCODE_LEFT
/* /*
* Virtual Key for (ESC) button * Virtual Key for (ESC) button
* default: ESC (27) * default: ESC (27)
*/ */
#define VK_ESCAPE SDLK_ESCAPE #define VK_ESCAPE SDL_SCANCODE_ESCAPE

View file

@ -823,10 +823,10 @@ int handle_msgpump (void)
break; break;
} }
switch(rEvent.key.keysym.sym) switch(rEvent.key.keysym.scancode)
{ {
#ifdef CAPSLOCK_DEBIAN_WORKAROUND #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 // Treat CAPSLOCK as a toggle. If on, set off and vice/versa
ioctl(0, KDGKBLED, &kbd_flags); ioctl(0, KDGKBLED, &kbd_flags);
ioctl(0, KDGETLED, &kbd_led_status); ioctl(0, KDGETLED, &kbd_led_status);
@ -849,17 +849,17 @@ int handle_msgpump (void)
break; break;
#endif #endif
case SDLK_LSHIFT: // Shift key case SDL_SCANCODE_LSHIFT: // Shift key
inputdevice_do_keyboard(AK_LSH, 1); inputdevice_do_keyboard(AK_LSH, 1);
break; break;
case VK_L: // Left shoulder button // case VK_L: // Left shoulder button
case VK_R: // Right shoulder button // case VK_R: // Right shoulder button
if(currprefs.input_tablet > TABLET_OFF) // if(currprefs.input_tablet > TABLET_OFF)
{ // {
// Holding left or right shoulder button -> stylus does right mousebutton // // Holding left or right shoulder button -> stylus does right mousebutton
doStylusRightClick = 1; // doStylusRightClick = 1;
} // }
// Fall through... // Fall through...
default: default:
@ -882,41 +882,41 @@ int handle_msgpump (void)
else else
modifier = rEvent.key.keysym.mod; modifier = rEvent.key.keysym.mod;
keycode = translate_pandora_keys(rEvent.key.keysym.sym, &modifier); // keycode = translate_pandora_keys(rEvent.key.keysym.sym, &modifier);
if(keycode) // if(keycode)
{ // {
if(modifier == KMOD_SHIFT) // if(modifier == KMOD_SHIFT)
inputdevice_do_keyboard(AK_LSH, 1); // inputdevice_do_keyboard(AK_LSH, 1);
else // else
inputdevice_do_keyboard(AK_LSH, 0); // inputdevice_do_keyboard(AK_LSH, 0);
//
inputdevice_do_keyboard(keycode, 1); // inputdevice_do_keyboard(keycode, 1);
} // }
else // else
{ // {
if (keyboard_type == KEYCODE_UNK) // if (keyboard_type == KEYCODE_UNK)
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1); // inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 1);
else // else
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1); inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 1);
} // }
break; break;
} }
break; break;
case SDL_KEYUP: 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); inputdevice_do_keyboard(AK_LSH, 0);
break; break;
case VK_L: // Left shoulder button // case VK_L: // Left shoulder button
case VK_R: // Right shoulder button // case VK_R: // Right shoulder button
if(currprefs.input_tablet > TABLET_OFF) // if(currprefs.input_tablet > TABLET_OFF)
{ // {
// Release left or right shoulder button -> stylus does left mousebutton // // Release left or right shoulder button -> stylus does left mousebutton
doStylusRightClick = 0; // doStylusRightClick = 0;
} // }
// Fall through... // Fall through...
default: default:
@ -947,9 +947,9 @@ int handle_msgpump (void)
} }
else else
{ {
if (keyboard_type == KEYCODE_UNK) // if (keyboard_type == KEYCODE_UNK)
inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0); // inputdevice_translatekeycode(0, rEvent.key.keysym.sym, 0);
else // else
inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0); inputdevice_translatekeycode(0, rEvent.key.keysym.scancode, 0);
} }
break; break;

View file

@ -436,35 +436,35 @@ static void read_joystick(void)
// First handle fake joystick from pandora... // First handle fake joystick from pandora...
if (currprefs.jports[joyid].id == JSEM_JOYS) if (currprefs.jports[joyid].id == JSEM_JOYS)
{ {
// const Uint8 *keystate = SDL_GetKeyboardState(NULL); const Uint8 *keystate = SDL_GetKeyboardState(NULL);
// if (!keystate[VK_R]) if (!keystate[VK_R])
// { // Right shoulder + dPad -> cursor keys { // Right shoulder + dPad -> cursor keys
// int axis = (keystate[VK_LEFT] ? -32767 : (keystate[VK_RIGHT] ? 32767 : 0)); int axis = (keystate[VK_LEFT] ? -32767 : (keystate[VK_RIGHT] ? 32767 : 0));
// if (!joyXviaCustom) if (!joyXviaCustom)
// setjoystickstate(0, 0, axis, 32767); setjoystickstate(0, 0, axis, 32767);
// axis = (keystate[VK_UP] ? -32767 : (keystate[VK_DOWN] ? 32767 : 0)); axis = (keystate[VK_UP] ? -32767 : (keystate[VK_DOWN] ? 32767 : 0));
// if (!joyYviaCustom) if (!joyYviaCustom)
// setjoystickstate(0, 1, axis, 32767); setjoystickstate(0, 1, axis, 32767);
// } }
// if (!joyButXviaCustom[0]) if (!joyButXviaCustom[0])
// setjoybuttonstate(0, 0, keystate[VK_X]); setjoybuttonstate(0, 0, keystate[VK_X]);
// if (!joyButXviaCustom[1]) if (!joyButXviaCustom[1])
// setjoybuttonstate(0, 1, keystate[VK_B]); setjoybuttonstate(0, 1, keystate[VK_B]);
// if (!joyButXviaCustom[2]) if (!joyButXviaCustom[2])
// setjoybuttonstate(0, 2, keystate[VK_A]); setjoybuttonstate(0, 2, keystate[VK_A]);
// if (!joyButXviaCustom[3]) if (!joyButXviaCustom[3])
// setjoybuttonstate(0, 3, keystate[VK_Y]); setjoybuttonstate(0, 3, keystate[VK_Y]);
int cd32_start = 0, cd32_ffw = 0, cd32_rwd = 0; int cd32_start = 0, cd32_ffw = 0, cd32_rwd = 0;
// if (keystate[SDLK_LALT]) { // Pandora Start button if (keystate[SDL_SCANCODE_LALT]) { // Pandora Start button
// if (keystate[VK_L]) // Left shoulder if (keystate[VK_L]) // Left shoulder
// cd32_rwd = 1; cd32_rwd = 1;
// else if (keystate[VK_R]) // Right shoulder else if (keystate[VK_R]) // Right shoulder
// cd32_ffw = 1; cd32_ffw = 1;
// else else
// cd32_start = 1; cd32_start = 1;
// } }
if (!joyButXviaCustom[6]) if (!joyButXviaCustom[6])
setjoybuttonstate(0, 6, cd32_start); setjoybuttonstate(0, 6, cd32_start);
if (!joyButXviaCustom[5]) if (!joyButXviaCustom[5])