mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-05 20:41:06 +00:00
381517ffa0
git-svn-id: https://svn.eduke32.com/eduke32@7393 1a8010ca-5511-0410-912e-c29ae57300e0
263 lines
7.9 KiB
C++
263 lines
7.9 KiB
C++
|
|
#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3)
|
|
static char keytranslation[SDLK_LAST];
|
|
#else
|
|
static char keytranslation[SDL_NUM_SCANCODES];
|
|
#endif
|
|
static int32_t buildkeytranslationtable(void);
|
|
|
|
#if (SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION < 3) // SDL 1.2
|
|
static int32_t buildkeytranslationtable(void)
|
|
{
|
|
memset(keytranslation,0,sizeof(keytranslation));
|
|
|
|
#define MAP(x,y) keytranslation[x] = y
|
|
MAP(SDLK_BACKSPACE, 0xe);
|
|
MAP(SDLK_TAB, 0xf);
|
|
MAP(SDLK_RETURN, 0x1c);
|
|
MAP(SDLK_PAUSE, 0x59); // 0x1d + 0x45 + 0x9d + 0xc5
|
|
MAP(SDLK_ESCAPE, 0x1);
|
|
MAP(SDLK_SPACE, 0x39);
|
|
MAP(SDLK_EXCLAIM, 0x2); // '1'
|
|
MAP(SDLK_QUOTEDBL, 0x28); // '''
|
|
MAP(SDLK_HASH, 0x4); // '3'
|
|
MAP(SDLK_DOLLAR, 0x5); // '4'
|
|
MAP(37, 0x6); // '5' <-- where's the keysym SDL guys?
|
|
MAP(SDLK_AMPERSAND, 0x8); // '7'
|
|
MAP(SDLK_QUOTE, 0x28); // '''
|
|
MAP(SDLK_LEFTPAREN, 0xa); // '9'
|
|
MAP(SDLK_RIGHTPAREN, 0xb); // '0'
|
|
MAP(SDLK_ASTERISK, 0x9); // '8'
|
|
MAP(SDLK_PLUS, 0xd); // '='
|
|
MAP(SDLK_COMMA, 0x33);
|
|
MAP(SDLK_MINUS, 0xc);
|
|
MAP(SDLK_PERIOD, 0x34);
|
|
MAP(SDLK_SLASH, 0x35);
|
|
MAP(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);
|
|
MAP(SDLK_NUMLOCK, 0x45);
|
|
MAP(SDLK_CAPSLOCK, 0x3a);
|
|
MAP(SDLK_SCROLLOCK, 0x46);
|
|
MAP(SDLK_RSHIFT, 0x36);
|
|
MAP(SDLK_LSHIFT, 0x2a);
|
|
MAP(SDLK_RCTRL, 0x9d);
|
|
MAP(SDLK_LCTRL, 0x1d);
|
|
MAP(SDLK_RALT, 0xb8);
|
|
MAP(SDLK_LALT, 0x38);
|
|
MAP(SDLK_LSUPER, 0xdb); // win l
|
|
MAP(SDLK_RSUPER, 0xdc); // win r
|
|
MAP(SDLK_PRINT, -2); // 0xaa + 0xb7
|
|
MAP(SDLK_SYSREQ, 0x54); // alt+printscr
|
|
MAP(SDLK_BREAK, 0xb7); // ctrl+pause
|
|
MAP(SDLK_MENU, 0xdd); // win menu?
|
|
#undef MAP
|
|
|
|
return 0;
|
|
}
|
|
#else // if SDL 1.3+
|
|
static int32_t buildkeytranslationtable(void)
|
|
{
|
|
memset(keytranslation,0,sizeof(keytranslation));
|
|
|
|
#define MAP(x,y) keytranslation[x] = y
|
|
MAP(SDL_SCANCODE_BACKSPACE, 0xe);
|
|
MAP(SDL_SCANCODE_TAB, 0xf);
|
|
MAP(SDL_SCANCODE_RETURN, 0x1c);
|
|
MAP(SDL_SCANCODE_PAUSE, 0x59); // 0x1d + 0x45 + 0x9d + 0xc5
|
|
MAP(SDL_SCANCODE_ESCAPE, 0x1);
|
|
MAP(SDL_SCANCODE_SPACE, 0x39);
|
|
MAP(SDL_SCANCODE_COMMA, 0x33);
|
|
MAP(SDL_SCANCODE_NONUSBACKSLASH, 0x33);
|
|
MAP(SDL_SCANCODE_MINUS, 0xc);
|
|
MAP(SDL_SCANCODE_PERIOD, 0x34);
|
|
MAP(SDL_SCANCODE_SLASH, 0x35);
|
|
MAP(SDL_SCANCODE_0, 0xb);
|
|
MAP(SDL_SCANCODE_1, 0x2);
|
|
MAP(SDL_SCANCODE_2, 0x3);
|
|
MAP(SDL_SCANCODE_3, 0x4);
|
|
MAP(SDL_SCANCODE_4, 0x5);
|
|
MAP(SDL_SCANCODE_5, 0x6);
|
|
MAP(SDL_SCANCODE_6, 0x7);
|
|
MAP(SDL_SCANCODE_7, 0x8);
|
|
MAP(SDL_SCANCODE_8, 0x9);
|
|
MAP(SDL_SCANCODE_9, 0xa);
|
|
MAP(SDL_SCANCODE_SEMICOLON, 0x27);
|
|
MAP(SDL_SCANCODE_APOSTROPHE, 0x28);
|
|
MAP(SDL_SCANCODE_EQUALS, 0xd);
|
|
MAP(SDL_SCANCODE_LEFTBRACKET, 0x1a);
|
|
MAP(SDL_SCANCODE_BACKSLASH, 0x2b);
|
|
MAP(SDL_SCANCODE_RIGHTBRACKET, 0x1b);
|
|
MAP(SDL_SCANCODE_A, 0x1e);
|
|
MAP(SDL_SCANCODE_B, 0x30);
|
|
MAP(SDL_SCANCODE_C, 0x2e);
|
|
MAP(SDL_SCANCODE_D, 0x20);
|
|
MAP(SDL_SCANCODE_E, 0x12);
|
|
MAP(SDL_SCANCODE_F, 0x21);
|
|
MAP(SDL_SCANCODE_G, 0x22);
|
|
MAP(SDL_SCANCODE_H, 0x23);
|
|
MAP(SDL_SCANCODE_I, 0x17);
|
|
MAP(SDL_SCANCODE_J, 0x24);
|
|
MAP(SDL_SCANCODE_K, 0x25);
|
|
MAP(SDL_SCANCODE_L, 0x26);
|
|
MAP(SDL_SCANCODE_M, 0x32);
|
|
MAP(SDL_SCANCODE_N, 0x31);
|
|
MAP(SDL_SCANCODE_O, 0x18);
|
|
MAP(SDL_SCANCODE_P, 0x19);
|
|
MAP(SDL_SCANCODE_Q, 0x10);
|
|
MAP(SDL_SCANCODE_R, 0x13);
|
|
MAP(SDL_SCANCODE_S, 0x1f);
|
|
MAP(SDL_SCANCODE_T, 0x14);
|
|
MAP(SDL_SCANCODE_U, 0x16);
|
|
MAP(SDL_SCANCODE_V, 0x2f);
|
|
MAP(SDL_SCANCODE_W, 0x11);
|
|
MAP(SDL_SCANCODE_X, 0x2d);
|
|
MAP(SDL_SCANCODE_Y, 0x15);
|
|
MAP(SDL_SCANCODE_Z, 0x2c);
|
|
MAP(SDL_SCANCODE_DELETE, 0xd3);
|
|
MAP(SDL_SCANCODE_KP_0, 0x52);
|
|
MAP(SDL_SCANCODE_KP_1, 0x4f);
|
|
MAP(SDL_SCANCODE_KP_2, 0x50);
|
|
MAP(SDL_SCANCODE_KP_3, 0x51);
|
|
MAP(SDL_SCANCODE_KP_4, 0x4b);
|
|
MAP(SDL_SCANCODE_KP_5, 0x4c);
|
|
MAP(SDL_SCANCODE_KP_CLEAR, 0x4c);
|
|
MAP(SDL_SCANCODE_CLEAR, 0x4c);
|
|
MAP(SDL_SCANCODE_KP_6, 0x4d);
|
|
MAP(SDL_SCANCODE_KP_7, 0x47);
|
|
MAP(SDL_SCANCODE_KP_8, 0x48);
|
|
MAP(SDL_SCANCODE_KP_9, 0x49);
|
|
MAP(SDL_SCANCODE_KP_PERIOD, 0x53);
|
|
MAP(SDL_SCANCODE_KP_DIVIDE, 0xb5);
|
|
MAP(SDL_SCANCODE_KP_MULTIPLY, 0x37);
|
|
MAP(SDL_SCANCODE_KP_MINUS, 0x4a);
|
|
MAP(SDL_SCANCODE_KP_PLUS, 0x4e);
|
|
MAP(SDL_SCANCODE_KP_ENTER, 0x9c);
|
|
//MAP(SDL_SCANCODE_KP_EQUALS, );
|
|
MAP(SDL_SCANCODE_UP, 0xc8);
|
|
MAP(SDL_SCANCODE_DOWN, 0xd0);
|
|
MAP(SDL_SCANCODE_RIGHT, 0xcd);
|
|
MAP(SDL_SCANCODE_LEFT, 0xcb);
|
|
MAP(SDL_SCANCODE_INSERT, 0xd2);
|
|
MAP(SDL_SCANCODE_HOME, 0xc7);
|
|
MAP(SDL_SCANCODE_END, 0xcf);
|
|
MAP(SDL_SCANCODE_PAGEUP, 0xc9);
|
|
MAP(SDL_SCANCODE_PAGEDOWN, 0xd1);
|
|
MAP(SDL_SCANCODE_F1, 0x3b);
|
|
MAP(SDL_SCANCODE_F2, 0x3c);
|
|
MAP(SDL_SCANCODE_F3, 0x3d);
|
|
MAP(SDL_SCANCODE_F4, 0x3e);
|
|
MAP(SDL_SCANCODE_F5, 0x3f);
|
|
MAP(SDL_SCANCODE_F6, 0x40);
|
|
MAP(SDL_SCANCODE_F7, 0x41);
|
|
MAP(SDL_SCANCODE_F8, 0x42);
|
|
MAP(SDL_SCANCODE_F9, 0x43);
|
|
MAP(SDL_SCANCODE_F10, 0x44);
|
|
MAP(SDL_SCANCODE_F11, 0x57);
|
|
MAP(SDL_SCANCODE_F12, 0x58);
|
|
MAP(SDL_SCANCODE_NUMLOCKCLEAR, 0x45);
|
|
MAP(SDL_SCANCODE_CAPSLOCK, 0x3a);
|
|
MAP(SDL_SCANCODE_SCROLLLOCK, 0x46);
|
|
MAP(SDL_SCANCODE_RSHIFT, 0x36);
|
|
MAP(SDL_SCANCODE_LSHIFT, 0x2a);
|
|
MAP(SDL_SCANCODE_RCTRL, 0x9d);
|
|
MAP(SDL_SCANCODE_LCTRL, 0x1d);
|
|
MAP(SDL_SCANCODE_RALT, 0xb8);
|
|
MAP(SDL_SCANCODE_LALT, 0x38);
|
|
MAP(SDL_SCANCODE_LGUI, 0xdb); // win l
|
|
MAP(SDL_SCANCODE_RGUI, 0xdc); // win r
|
|
// MAP(SDL_SCANCODE_PRINTSCREEN, -2); // 0xaa + 0xb7
|
|
MAP(SDL_SCANCODE_SYSREQ, 0x54); // alt+printscr
|
|
// MAP(SDL_SCANCODE_PAUSE, 0xb7); // ctrl+pause
|
|
MAP(SDL_SCANCODE_MENU, 0xdd); // win menu?
|
|
MAP(SDL_SCANCODE_GRAVE, 0x29); // tilde
|
|
#undef MAP
|
|
|
|
return 0;
|
|
}
|
|
#endif
|