This commit is contained in:
Vadim Grigoruk 2018-08-23 22:38:49 +03:00
parent 8208656a77
commit 8e7b2ece48
2 changed files with 99 additions and 237 deletions

View File

@ -1,233 +1,82 @@
[0] = tic_key_unknown, [tic_key_unknown] = SDLK_UNKNOWN,
[1] = tic_key_unknown, [tic_key_a] = SDLK_a,
[2] = tic_key_unknown, [tic_key_b] = SDLK_b,
[3] = tic_key_unknown, [tic_key_c] = SDLK_c,
[SDL_SCANCODE_A] = tic_key_a, [tic_key_d] = SDLK_d,
[SDL_SCANCODE_B] = tic_key_b, [tic_key_e] = SDLK_e,
[SDL_SCANCODE_C] = tic_key_c, [tic_key_f] = SDLK_f,
[SDL_SCANCODE_D] = tic_key_d, [tic_key_g] = SDLK_g,
[SDL_SCANCODE_E] = tic_key_e, [tic_key_h] = SDLK_h,
[SDL_SCANCODE_F] = tic_key_f, [tic_key_i] = SDLK_i,
[SDL_SCANCODE_G] = tic_key_g, [tic_key_j] = SDLK_j,
[SDL_SCANCODE_H] = tic_key_h, [tic_key_k] = SDLK_k,
[SDL_SCANCODE_I] = tic_key_i, [tic_key_l] = SDLK_l,
[SDL_SCANCODE_J] = tic_key_j, [tic_key_m] = SDLK_m,
[SDL_SCANCODE_K] = tic_key_k, [tic_key_n] = SDLK_n,
[SDL_SCANCODE_L] = tic_key_l, [tic_key_o] = SDLK_o,
[SDL_SCANCODE_M] = tic_key_m, [tic_key_p] = SDLK_p,
[SDL_SCANCODE_N] = tic_key_n, [tic_key_q] = SDLK_q,
[SDL_SCANCODE_O] = tic_key_o, [tic_key_r] = SDLK_r,
[SDL_SCANCODE_P] = tic_key_p, [tic_key_s] = SDLK_s,
[SDL_SCANCODE_Q] = tic_key_q, [tic_key_t] = SDLK_t,
[SDL_SCANCODE_R] = tic_key_r, [tic_key_u] = SDLK_u,
[SDL_SCANCODE_S] = tic_key_s, [tic_key_v] = SDLK_v,
[SDL_SCANCODE_T] = tic_key_t, [tic_key_w] = SDLK_w,
[SDL_SCANCODE_U] = tic_key_u, [tic_key_x] = SDLK_x,
[SDL_SCANCODE_V] = tic_key_v, [tic_key_y] = SDLK_y,
[SDL_SCANCODE_W] = tic_key_w, [tic_key_z] = SDLK_z,
[SDL_SCANCODE_X] = tic_key_x,
[SDL_SCANCODE_Y] = tic_key_y, [tic_key_0] = SDLK_0,
[SDL_SCANCODE_Z] = tic_key_z, [tic_key_1] = SDLK_1,
[SDL_SCANCODE_1] = tic_key_1, [tic_key_2] = SDLK_2,
[SDL_SCANCODE_2] = tic_key_2, [tic_key_3] = SDLK_3,
[SDL_SCANCODE_3] = tic_key_3, [tic_key_4] = SDLK_4,
[SDL_SCANCODE_4] = tic_key_4, [tic_key_5] = SDLK_5,
[SDL_SCANCODE_5] = tic_key_5, [tic_key_6] = SDLK_6,
[SDL_SCANCODE_6] = tic_key_6, [tic_key_7] = SDLK_7,
[SDL_SCANCODE_7] = tic_key_7, [tic_key_8] = SDLK_8,
[SDL_SCANCODE_8] = tic_key_8, [tic_key_9] = SDLK_9,
[SDL_SCANCODE_9] = tic_key_9,
[SDL_SCANCODE_0] = tic_key_0, [tic_key_minus] = SDLK_MINUS,
[SDL_SCANCODE_RETURN] = tic_key_return, [tic_key_equals] = SDLK_EQUALS,
[SDL_SCANCODE_ESCAPE] = tic_key_escape, [tic_key_leftbracket] = SDLK_LEFTBRACKET,
[SDL_SCANCODE_AC_BACK] = tic_key_escape, [tic_key_rightbracket] = SDLK_RIGHTBRACKET,
[SDL_SCANCODE_BACKSPACE] = tic_key_backspace, [tic_key_backslash] = SDLK_BACKSLASH,
[SDL_SCANCODE_TAB] = tic_key_tab, [tic_key_semicolon] = SDLK_SEMICOLON,
[SDL_SCANCODE_SPACE] = tic_key_space, [tic_key_apostrophe] = SDLK_QUOTE,
[SDL_SCANCODE_MINUS] = tic_key_minus, [tic_key_grave] = SDLK_BACKQUOTE,
[SDL_SCANCODE_EQUALS] = tic_key_equals, [tic_key_comma] = SDLK_COMMA,
[SDL_SCANCODE_LEFTBRACKET] = tic_key_leftbracket, [tic_key_period] = SDLK_PERIOD,
[SDL_SCANCODE_RIGHTBRACKET] = tic_key_rightbracket, [tic_key_slash] = SDLK_SLASH,
[SDL_SCANCODE_BACKSLASH] = tic_key_backslash, [tic_key_space] = SDLK_SPACE,
[50] = tic_key_unknown, [tic_key_tab] = SDLK_TAB,
[SDL_SCANCODE_SEMICOLON] = tic_key_semicolon, [tic_key_return] = SDLK_RETURN,
[SDL_SCANCODE_APOSTROPHE] = tic_key_apostrophe, [tic_key_backspace] = SDLK_BACKSPACE,
[SDL_SCANCODE_GRAVE] = tic_key_grave, [tic_key_delete] = SDLK_DELETE,
[SDL_SCANCODE_COMMA] = tic_key_comma, [tic_key_insert] = SDLK_INSERT,
[SDL_SCANCODE_PERIOD] = tic_key_period, [tic_key_pageup] = SDLK_PAGEUP,
[SDL_SCANCODE_SLASH] = tic_key_slash, [tic_key_pagedown] = SDLK_PAGEDOWN,
[SDL_SCANCODE_CAPSLOCK] = tic_key_capslock, [tic_key_home] = SDLK_HOME,
[SDL_SCANCODE_F1] = tic_key_f1, [tic_key_end] = SDLK_END,
[SDL_SCANCODE_F2] = tic_key_f2, [tic_key_up] = SDLK_UP,
[SDL_SCANCODE_F3] = tic_key_f3, [tic_key_down] = SDLK_DOWN,
[SDL_SCANCODE_F4] = tic_key_f4, [tic_key_left] = SDLK_LEFT,
[SDL_SCANCODE_F5] = tic_key_f5, [tic_key_right] = SDLK_RIGHT,
[SDL_SCANCODE_F6] = tic_key_f6, [tic_key_capslock] = SDLK_CAPSLOCK,
[SDL_SCANCODE_F7] = tic_key_f7, [tic_key_ctrl] = SDLK_LCTRL,
[SDL_SCANCODE_F8] = tic_key_f8, [tic_key_shift] = SDLK_LSHIFT,
[SDL_SCANCODE_F9] = tic_key_f9, [tic_key_alt] = SDLK_LALT,
[SDL_SCANCODE_F10] = tic_key_f10, [tic_key_escape] = SDLK_ESCAPE,
[SDL_SCANCODE_F11] = tic_key_f11,
[SDL_SCANCODE_F12] = tic_key_f12, [tic_key_f1] = SDLK_F1,
[70] = tic_key_unknown, [tic_key_f2] = SDLK_F2,
[71] = tic_key_unknown, [tic_key_f3] = SDLK_F3,
[72] = tic_key_unknown, [tic_key_f4] = SDLK_F4,
[SDL_SCANCODE_INSERT] = tic_key_insert, [tic_key_f5] = SDLK_F5,
[SDL_SCANCODE_HOME] = tic_key_home, [tic_key_f6] = SDLK_F6,
[SDL_SCANCODE_PAGEUP] = tic_key_pageup, [tic_key_f7] = SDLK_F7,
[SDL_SCANCODE_DELETE] = tic_key_delete, [tic_key_f8] = SDLK_F8,
[SDL_SCANCODE_END] = tic_key_end, [tic_key_f9] = SDLK_F9,
[SDL_SCANCODE_PAGEDOWN] = tic_key_pagedown, [tic_key_f10] = SDLK_F10,
[SDL_SCANCODE_RIGHT] = tic_key_right, [tic_key_f11] = SDLK_F11,
[SDL_SCANCODE_LEFT] = tic_key_left, [tic_key_f12] = SDLK_F12,
[SDL_SCANCODE_DOWN] = tic_key_down,
[SDL_SCANCODE_UP] = tic_key_up,
[83] = tic_key_unknown,
[84] = tic_key_unknown,
[85] = tic_key_unknown,
[86] = tic_key_unknown,
[87] = tic_key_unknown,
[88] = tic_key_unknown,
[89] = tic_key_unknown,
[90] = tic_key_unknown,
[91] = tic_key_unknown,
[92] = tic_key_unknown,
[93] = tic_key_unknown,
[94] = tic_key_unknown,
[95] = tic_key_unknown,
[96] = tic_key_unknown,
[97] = tic_key_unknown,
[98] = tic_key_unknown,
[99] = tic_key_unknown,
[100] = tic_key_unknown,
[101] = tic_key_unknown,
[102] = tic_key_unknown,
[103] = tic_key_unknown,
[104] = tic_key_unknown,
[105] = tic_key_unknown,
[106] = tic_key_unknown,
[107] = tic_key_unknown,
[108] = tic_key_unknown,
[109] = tic_key_unknown,
[110] = tic_key_unknown,
[111] = tic_key_unknown,
[112] = tic_key_unknown,
[113] = tic_key_unknown,
[114] = tic_key_unknown,
[115] = tic_key_unknown,
[116] = tic_key_unknown,
[117] = tic_key_unknown,
[118] = tic_key_unknown,
[119] = tic_key_unknown,
[120] = tic_key_unknown,
[121] = tic_key_unknown,
[122] = tic_key_unknown,
[123] = tic_key_unknown,
[124] = tic_key_unknown,
[125] = tic_key_unknown,
[126] = tic_key_unknown,
[127] = tic_key_unknown,
[128] = tic_key_unknown,
[129] = tic_key_unknown,
[130] = tic_key_unknown,
[131] = tic_key_unknown,
[132] = tic_key_unknown,
[133] = tic_key_unknown,
[134] = tic_key_unknown,
[135] = tic_key_unknown,
[136] = tic_key_unknown,
[137] = tic_key_unknown,
[138] = tic_key_unknown,
[139] = tic_key_unknown,
[140] = tic_key_unknown,
[141] = tic_key_unknown,
[142] = tic_key_unknown,
[143] = tic_key_unknown,
[144] = tic_key_unknown,
[145] = tic_key_unknown,
[146] = tic_key_unknown,
[147] = tic_key_unknown,
[148] = tic_key_unknown,
[149] = tic_key_unknown,
[150] = tic_key_unknown,
[151] = tic_key_unknown,
[152] = tic_key_unknown,
[153] = tic_key_unknown,
[154] = tic_key_unknown,
[155] = tic_key_unknown,
[156] = tic_key_unknown,
[157] = tic_key_unknown,
[158] = tic_key_unknown,
[159] = tic_key_unknown,
[160] = tic_key_unknown,
[161] = tic_key_unknown,
[162] = tic_key_unknown,
[163] = tic_key_unknown,
[164] = tic_key_unknown,
[165] = tic_key_unknown,
[166] = tic_key_unknown,
[167] = tic_key_unknown,
[168] = tic_key_unknown,
[169] = tic_key_unknown,
[170] = tic_key_unknown,
[171] = tic_key_unknown,
[172] = tic_key_unknown,
[173] = tic_key_unknown,
[174] = tic_key_unknown,
[175] = tic_key_unknown,
[176] = tic_key_unknown,
[177] = tic_key_unknown,
[178] = tic_key_unknown,
[179] = tic_key_unknown,
[180] = tic_key_unknown,
[181] = tic_key_unknown,
[182] = tic_key_unknown,
[183] = tic_key_unknown,
[184] = tic_key_unknown,
[185] = tic_key_unknown,
[186] = tic_key_unknown,
[187] = tic_key_unknown,
[188] = tic_key_unknown,
[189] = tic_key_unknown,
[190] = tic_key_unknown,
[191] = tic_key_unknown,
[192] = tic_key_unknown,
[193] = tic_key_unknown,
[194] = tic_key_unknown,
[195] = tic_key_unknown,
[196] = tic_key_unknown,
[197] = tic_key_unknown,
[198] = tic_key_unknown,
[199] = tic_key_unknown,
[200] = tic_key_unknown,
[201] = tic_key_unknown,
[202] = tic_key_unknown,
[203] = tic_key_unknown,
[204] = tic_key_unknown,
[205] = tic_key_unknown,
[206] = tic_key_unknown,
[207] = tic_key_unknown,
[208] = tic_key_unknown,
[209] = tic_key_unknown,
[210] = tic_key_unknown,
[211] = tic_key_unknown,
[212] = tic_key_unknown,
[213] = tic_key_unknown,
[214] = tic_key_unknown,
[215] = tic_key_unknown,
[216] = tic_key_unknown,
[217] = tic_key_unknown,
[218] = tic_key_unknown,
[219] = tic_key_unknown,
[220] = tic_key_unknown,
[221] = tic_key_unknown,
[222] = tic_key_unknown,
[223] = tic_key_unknown,
[SDL_SCANCODE_LCTRL] = tic_key_ctrl,
[SDL_SCANCODE_LSHIFT] = tic_key_shift,
[SDL_SCANCODE_LALT] = tic_key_alt,
[SDL_SCANCODE_LGUI] = tic_key_ctrl,
[SDL_SCANCODE_RCTRL] = tic_key_ctrl,
[SDL_SCANCODE_RSHIFT] = tic_key_shift,
[SDL_SCANCODE_RALT] = tic_key_alt,
[SDL_SCANCODE_RGUI] = tic_key_ctrl,

View File

@ -406,7 +406,7 @@ static char getKeyboardText()
static void processKeyboard() static void processKeyboard()
{ {
static const u8 KeyboardCodes[] = static const u32 KeyboardCodes[tic_keys_count] =
{ {
#include "keycodes.inl" #include "keycodes.inl"
}; };
@ -427,9 +427,22 @@ static void processKeyboard()
const u8* keyboard = SDL_GetKeyboardState(NULL); const u8* keyboard = SDL_GetKeyboardState(NULL);
for(s32 i = 0; i < COUNT_OF(KeyboardCodes) && c < COUNT_OF(input->keyboard.keys); i++) for(s32 i = 0; i < SDL_NUM_SCANCODES && c < BufSize; i++)
if(keyboard[i] && KeyboardCodes[i] > tic_key_unknown) {
input->keyboard.keys[c++] = KeyboardCodes[i]; if(keyboard[i])
{
u32 keycode = SDL_GetKeyFromScancode(i);
for(s32 k = 0; k < COUNT_OF(KeyboardCodes); k++)
{
if(KeyboardCodes[k] == keycode)
{
input->keyboard.keys[c++] = k;
break;
}
}
}
}
} }
#if !defined(__EMSCRIPTEN__) && !defined(__MACOSX__) #if !defined(__EMSCRIPTEN__) && !defined(__MACOSX__)