summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5b85e48)
raw | patch | inline | side by side (parent: 5b85e48)
author | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 1 Apr 2020 04:27:00 +0000 (08:27 +0400) | ||
committer | DeaDDooMER <deaddoomer@deadsoftware.ru> | |
Wed, 1 Apr 2020 04:27:00 +0000 (08:27 +0400) |
src/sdl2/main.c | patch | blob | history |
diff --git a/src/sdl2/main.c b/src/sdl2/main.c
index 0babe5e2859ac80569a768d8ae237335b38f29ab..42fda3e41c0910050f60518392a46825b3193f0a 100644 (file)
--- a/src/sdl2/main.c
+++ b/src/sdl2/main.c
static int sdl_to_key (int code) {
switch (code) {
- case SDLK_0: return KEY_0;
- case SDLK_1: return KEY_1;
- case SDLK_2: return KEY_2;
- case SDLK_3: return KEY_3;
- case SDLK_4: return KEY_4;
- case SDLK_5: return KEY_5;
- case SDLK_6: return KEY_6;
- case SDLK_7: return KEY_7;
- case SDLK_8: return KEY_8;
- case SDLK_9: return KEY_9;
- case SDLK_a: return KEY_A;
- case SDLK_b: return KEY_B;
- case SDLK_c: return KEY_C;
- case SDLK_d: return KEY_D;
- case SDLK_e: return KEY_E;
- case SDLK_f: return KEY_F;
- case SDLK_g: return KEY_G;
- case SDLK_h: return KEY_H;
- case SDLK_i: return KEY_I;
- case SDLK_j: return KEY_J;
- case SDLK_k: return KEY_K;
- case SDLK_l: return KEY_L;
- case SDLK_m: return KEY_M;
- case SDLK_n: return KEY_N;
- case SDLK_o: return KEY_O;
- case SDLK_p: return KEY_P;
- case SDLK_q: return KEY_Q;
- case SDLK_r: return KEY_R;
- case SDLK_s: return KEY_S;
- case SDLK_t: return KEY_T;
- case SDLK_u: return KEY_U;
- case SDLK_v: return KEY_V;
- case SDLK_w: return KEY_W;
- case SDLK_x: return KEY_X;
- case SDLK_y: return KEY_Y;
- case SDLK_z: return KEY_Z;
- case SDLK_RETURN: return KEY_RETURN;
- case SDLK_ESCAPE: return KEY_ESCAPE;
- case SDLK_BACKSPACE: return KEY_BACKSPACE;
- case SDLK_TAB: return KEY_TAB;
- case SDLK_SPACE: return KEY_SPACE;
- case SDLK_MINUS: return KEY_MINUS;
- case SDLK_EQUALS: return KEY_EQUALS;
- case SDLK_LEFTBRACKET: return KEY_LEFTBRACKET;
- case SDLK_RIGHTBRACKET: return KEY_RIGHTBRACKET;
- case SDLK_BACKSLASH: return KEY_BACKSLASH;
- case SDLK_SEMICOLON: return KEY_SEMICOLON;
- case SDLK_QUOTE: return KEY_APOSTROPHE;
- case SDLK_BACKQUOTE: return KEY_GRAVE;
- case SDLK_COMMA: return KEY_COMMA;
- case SDLK_PERIOD: return KEY_PERIOD;
- case SDLK_SLASH: return KEY_SLASH;
- case SDLK_CAPSLOCK: return KEY_CAPSLOCK;
- case SDLK_F1: return KEY_F1;
- case SDLK_F2: return KEY_F2;
- case SDLK_F3: return KEY_F3;
- case SDLK_F4: return KEY_F4;
- case SDLK_F5: return KEY_F5;
- case SDLK_F6: return KEY_F6;
- case SDLK_F7: return KEY_F7;
- case SDLK_F8: return KEY_F8;
- case SDLK_F9: return KEY_F9;
- case SDLK_F10: return KEY_F10;
- case SDLK_F11: return KEY_F11;
- case SDLK_F12: return KEY_F12;
- case SDLK_PRINTSCREEN: return KEY_PRINTSCREEN;
- case SDLK_SCROLLLOCK: return KEY_SCROLLLOCK;
- case SDLK_PAUSE: return KEY_PAUSE;
- case SDLK_INSERT: return KEY_INSERT;
- case SDLK_HOME: return KEY_HOME;
- case SDLK_PAGEUP: return KEY_PAGEUP;
- case SDLK_DELETE: return KEY_DELETE;
- case SDLK_END: return KEY_END;
- case SDLK_PAGEDOWN: return KEY_PAGEDOWN;
- case SDLK_RIGHT: return KEY_RIGHT;
- case SDLK_LEFT: return KEY_LEFT;
- case SDLK_DOWN: return KEY_DOWN;
- case SDLK_UP: return KEY_UP;
- //case SDLK_NUMLOCK: return KEY_NUMLOCK;
- case SDLK_KP_DIVIDE: return KEY_KP_DIVIDE;
- case SDLK_KP_MULTIPLY: return KEY_KP_MULTIPLY;
- case SDLK_KP_MINUS: return KEY_KP_MINUS;
- case SDLK_KP_PLUS: return KEY_KP_PLUS;
- case SDLK_KP_ENTER: return KEY_KP_ENTER;
- case SDLK_KP_0: return KEY_KP_0;
- case SDLK_KP_1: return KEY_KP_1;
- case SDLK_KP_2: return KEY_KP_2;
- case SDLK_KP_3: return KEY_KP_3;
- case SDLK_KP_4: return KEY_KP_4;
- case SDLK_KP_5: return KEY_KP_5;
- case SDLK_KP_6: return KEY_KP_6;
- case SDLK_KP_7: return KEY_KP_7;
- case SDLK_KP_8: return KEY_KP_8;
- case SDLK_KP_9: return KEY_KP_9;
- case SDLK_KP_PERIOD: return KEY_KP_PERIOD;
- case SDLK_SYSREQ: return KEY_SYSREQ;
- case SDLK_LCTRL: return KEY_LCTRL;
- case SDLK_LSHIFT: return KEY_LSHIFT;
- case SDLK_LALT: return KEY_LALT;
- //case SDLK_LSUPER: return KEY_LSUPER;
- case SDLK_RCTRL: return KEY_RCTRL;
- case SDLK_RSHIFT: return KEY_RSHIFT;
- case SDLK_RALT: return KEY_RALT;
- //case SDLK_RSUPER: return KEY_RSUPER;
+ case SDL_SCANCODE_0: return KEY_0;
+ case SDL_SCANCODE_1: return KEY_1;
+ case SDL_SCANCODE_2: return KEY_2;
+ case SDL_SCANCODE_3: return KEY_3;
+ case SDL_SCANCODE_4: return KEY_4;
+ case SDL_SCANCODE_5: return KEY_5;
+ case SDL_SCANCODE_6: return KEY_6;
+ case SDL_SCANCODE_7: return KEY_7;
+ case SDL_SCANCODE_8: return KEY_8;
+ case SDL_SCANCODE_9: return KEY_9;
+ case SDL_SCANCODE_A: return KEY_A;
+ case SDL_SCANCODE_B: return KEY_B;
+ case SDL_SCANCODE_C: return KEY_C;
+ case SDL_SCANCODE_D: return KEY_D;
+ case SDL_SCANCODE_E: return KEY_E;
+ case SDL_SCANCODE_F: return KEY_F;
+ case SDL_SCANCODE_G: return KEY_G;
+ case SDL_SCANCODE_H: return KEY_H;
+ case SDL_SCANCODE_I: return KEY_I;
+ case SDL_SCANCODE_J: return KEY_J;
+ case SDL_SCANCODE_K: return KEY_K;
+ case SDL_SCANCODE_L: return KEY_L;
+ case SDL_SCANCODE_M: return KEY_M;
+ case SDL_SCANCODE_N: return KEY_N;
+ case SDL_SCANCODE_O: return KEY_O;
+ case SDL_SCANCODE_P: return KEY_P;
+ case SDL_SCANCODE_Q: return KEY_Q;
+ case SDL_SCANCODE_R: return KEY_R;
+ case SDL_SCANCODE_S: return KEY_S;
+ case SDL_SCANCODE_T: return KEY_T;
+ case SDL_SCANCODE_U: return KEY_U;
+ case SDL_SCANCODE_V: return KEY_V;
+ case SDL_SCANCODE_W: return KEY_W;
+ case SDL_SCANCODE_X: return KEY_X;
+ case SDL_SCANCODE_Y: return KEY_Y;
+ case SDL_SCANCODE_Z: return KEY_Z;
+ case SDL_SCANCODE_RETURN: return KEY_RETURN;
+ case SDL_SCANCODE_ESCAPE: return KEY_ESCAPE;
+ case SDL_SCANCODE_BACKSPACE: return KEY_BACKSPACE;
+ case SDL_SCANCODE_TAB: return KEY_TAB;
+ case SDL_SCANCODE_SPACE: return KEY_SPACE;
+ case SDL_SCANCODE_MINUS: return KEY_MINUS;
+ case SDL_SCANCODE_EQUALS: return KEY_EQUALS;
+ case SDL_SCANCODE_LEFTBRACKET: return KEY_LEFTBRACKET;
+ case SDL_SCANCODE_RIGHTBRACKET: return KEY_RIGHTBRACKET;
+ case SDL_SCANCODE_BACKSLASH: return KEY_BACKSLASH;
+ case SDL_SCANCODE_SEMICOLON: return KEY_SEMICOLON;
+ case SDL_SCANCODE_APOSTROPHE: return KEY_APOSTROPHE;
+ case SDL_SCANCODE_GRAVE: return KEY_GRAVE;
+ case SDL_SCANCODE_COMMA: return KEY_COMMA;
+ case SDL_SCANCODE_PERIOD: return KEY_PERIOD;
+ case SDL_SCANCODE_SLASH: return KEY_SLASH;
+ case SDL_SCANCODE_CAPSLOCK: return KEY_CAPSLOCK;
+ case SDL_SCANCODE_F1: return KEY_F1;
+ case SDL_SCANCODE_F2: return KEY_F2;
+ case SDL_SCANCODE_F3: return KEY_F3;
+ case SDL_SCANCODE_F4: return KEY_F4;
+ case SDL_SCANCODE_F5: return KEY_F5;
+ case SDL_SCANCODE_F6: return KEY_F6;
+ case SDL_SCANCODE_F7: return KEY_F7;
+ case SDL_SCANCODE_F8: return KEY_F8;
+ case SDL_SCANCODE_F9: return KEY_F9;
+ case SDL_SCANCODE_F10: return KEY_F10;
+ case SDL_SCANCODE_F11: return KEY_F11;
+ case SDL_SCANCODE_F12: return KEY_F12;
+ case SDL_SCANCODE_PRINTSCREEN: return KEY_PRINTSCREEN;
+ case SDL_SCANCODE_SCROLLLOCK: return KEY_SCROLLLOCK;
+ case SDL_SCANCODE_PAUSE: return KEY_PAUSE;
+ case SDL_SCANCODE_INSERT: return KEY_INSERT;
+ case SDL_SCANCODE_HOME: return KEY_HOME;
+ case SDL_SCANCODE_PAGEUP: return KEY_PAGEUP;
+ case SDL_SCANCODE_DELETE: return KEY_DELETE;
+ case SDL_SCANCODE_END: return KEY_END;
+ case SDL_SCANCODE_PAGEDOWN: return KEY_PAGEDOWN;
+ case SDL_SCANCODE_RIGHT: return KEY_RIGHT;
+ case SDL_SCANCODE_LEFT: return KEY_LEFT;
+ case SDL_SCANCODE_DOWN: return KEY_DOWN;
+ case SDL_SCANCODE_UP: return KEY_UP;
+ case SDL_SCANCODE_NUMLOCKCLEAR: return KEY_NUMLOCK;
+ case SDL_SCANCODE_KP_DIVIDE: return KEY_KP_DIVIDE;
+ case SDL_SCANCODE_KP_MULTIPLY: return KEY_KP_MULTIPLY;
+ case SDL_SCANCODE_KP_MINUS: return KEY_KP_MINUS;
+ case SDL_SCANCODE_KP_PLUS: return KEY_KP_PLUS;
+ case SDL_SCANCODE_KP_ENTER: return KEY_KP_ENTER;
+ case SDL_SCANCODE_KP_0: return KEY_KP_0;
+ case SDL_SCANCODE_KP_1: return KEY_KP_1;
+ case SDL_SCANCODE_KP_2: return KEY_KP_2;
+ case SDL_SCANCODE_KP_3: return KEY_KP_3;
+ case SDL_SCANCODE_KP_4: return KEY_KP_4;
+ case SDL_SCANCODE_KP_5: return KEY_KP_5;
+ case SDL_SCANCODE_KP_6: return KEY_KP_6;
+ case SDL_SCANCODE_KP_7: return KEY_KP_7;
+ case SDL_SCANCODE_KP_8: return KEY_KP_8;
+ case SDL_SCANCODE_KP_9: return KEY_KP_9;
+ case SDL_SCANCODE_KP_PERIOD: return KEY_KP_PERIOD;
+ case SDL_SCANCODE_SYSREQ: return KEY_SYSREQ;
+ case SDL_SCANCODE_LCTRL: return KEY_LCTRL;
+ case SDL_SCANCODE_LSHIFT: return KEY_LSHIFT;
+ case SDL_SCANCODE_LALT: return KEY_LALT;
+ case SDL_SCANCODE_LGUI: return KEY_LSUPER;
+ case SDL_SCANCODE_RCTRL: return KEY_RCTRL;
+ case SDL_SCANCODE_RSHIFT: return KEY_RSHIFT;
+ case SDL_SCANCODE_RALT: return KEY_RALT;
+ case SDL_SCANCODE_RGUI: return KEY_RSUPER;
default: return KEY_UNKNOWN;
}
}
break;
case SDL_KEYDOWN:
case SDL_KEYUP:
- key = sdl_to_key(ev.key.keysym.sym);
+ key = sdl_to_key(ev.key.keysym.scancode);
I_press(key, ev.type == SDL_KEYDOWN);
if (h != NULL) {
(*h)(key, ev.type == SDL_KEYDOWN);