no message
This commit is contained in:
parent
e9dc8d9cde
commit
80b39cd626
315
src/keycodes.inl
315
src/keycodes.inl
|
@ -1,82 +1,233 @@
|
|||
[tic_key_unknown] = SDLK_UNKNOWN,
|
||||
[tic_key_a] = SDLK_a,
|
||||
[tic_key_b] = SDLK_b,
|
||||
[tic_key_c] = SDLK_c,
|
||||
[tic_key_d] = SDLK_d,
|
||||
[tic_key_e] = SDLK_e,
|
||||
[tic_key_f] = SDLK_f,
|
||||
[tic_key_g] = SDLK_g,
|
||||
[tic_key_h] = SDLK_h,
|
||||
[tic_key_i] = SDLK_i,
|
||||
[tic_key_j] = SDLK_j,
|
||||
[tic_key_k] = SDLK_k,
|
||||
[tic_key_l] = SDLK_l,
|
||||
[tic_key_m] = SDLK_m,
|
||||
[tic_key_n] = SDLK_n,
|
||||
[tic_key_o] = SDLK_o,
|
||||
[tic_key_p] = SDLK_p,
|
||||
[tic_key_q] = SDLK_q,
|
||||
[tic_key_r] = SDLK_r,
|
||||
[tic_key_s] = SDLK_s,
|
||||
[tic_key_t] = SDLK_t,
|
||||
[tic_key_u] = SDLK_u,
|
||||
[tic_key_v] = SDLK_v,
|
||||
[tic_key_w] = SDLK_w,
|
||||
[tic_key_x] = SDLK_x,
|
||||
[tic_key_y] = SDLK_y,
|
||||
[tic_key_z] = SDLK_z,
|
||||
|
||||
[tic_key_0] = SDLK_0,
|
||||
[tic_key_1] = SDLK_1,
|
||||
[tic_key_2] = SDLK_2,
|
||||
[tic_key_3] = SDLK_3,
|
||||
[tic_key_4] = SDLK_4,
|
||||
[tic_key_5] = SDLK_5,
|
||||
[tic_key_6] = SDLK_6,
|
||||
[tic_key_7] = SDLK_7,
|
||||
[tic_key_8] = SDLK_8,
|
||||
[tic_key_9] = SDLK_9,
|
||||
|
||||
[tic_key_minus] = SDLK_MINUS,
|
||||
[tic_key_equals] = SDLK_EQUALS,
|
||||
[tic_key_leftbracket] = SDLK_LEFTBRACKET,
|
||||
[tic_key_rightbracket] = SDLK_RIGHTBRACKET,
|
||||
[tic_key_backslash] = SDLK_BACKSLASH,
|
||||
[tic_key_semicolon] = SDLK_SEMICOLON,
|
||||
[tic_key_apostrophe] = SDLK_QUOTE,
|
||||
[tic_key_grave] = SDLK_BACKQUOTE,
|
||||
[tic_key_comma] = SDLK_COMMA,
|
||||
[tic_key_period] = SDLK_PERIOD,
|
||||
[tic_key_slash] = SDLK_SLASH,
|
||||
[tic_key_space] = SDLK_SPACE,
|
||||
[tic_key_tab] = SDLK_TAB,
|
||||
[tic_key_return] = SDLK_RETURN,
|
||||
[tic_key_backspace] = SDLK_BACKSPACE,
|
||||
[tic_key_delete] = SDLK_DELETE,
|
||||
[tic_key_insert] = SDLK_INSERT,
|
||||
[tic_key_pageup] = SDLK_PAGEUP,
|
||||
[tic_key_pagedown] = SDLK_PAGEDOWN,
|
||||
[tic_key_home] = SDLK_HOME,
|
||||
[tic_key_end] = SDLK_END,
|
||||
[tic_key_up] = SDLK_UP,
|
||||
[tic_key_down] = SDLK_DOWN,
|
||||
[tic_key_left] = SDLK_LEFT,
|
||||
[tic_key_right] = SDLK_RIGHT,
|
||||
[tic_key_capslock] = SDLK_CAPSLOCK,
|
||||
[tic_key_ctrl] = SDLK_LCTRL,
|
||||
[tic_key_shift] = SDLK_LSHIFT,
|
||||
[tic_key_alt] = SDLK_LALT,
|
||||
[tic_key_escape] = SDLK_ESCAPE,
|
||||
|
||||
[tic_key_f1] = SDLK_F1,
|
||||
[tic_key_f2] = SDLK_F2,
|
||||
[tic_key_f3] = SDLK_F3,
|
||||
[tic_key_f4] = SDLK_F4,
|
||||
[tic_key_f5] = SDLK_F5,
|
||||
[tic_key_f6] = SDLK_F6,
|
||||
[tic_key_f7] = SDLK_F7,
|
||||
[tic_key_f8] = SDLK_F8,
|
||||
[tic_key_f9] = SDLK_F9,
|
||||
[tic_key_f10] = SDLK_F10,
|
||||
[tic_key_f11] = SDLK_F11,
|
||||
[tic_key_f12] = SDLK_F12,
|
||||
[0] = tic_key_unknown,
|
||||
[1] = tic_key_unknown,
|
||||
[2] = tic_key_unknown,
|
||||
[3] = tic_key_unknown,
|
||||
[SDL_SCANCODE_A] = tic_key_a,
|
||||
[SDL_SCANCODE_B] = tic_key_b,
|
||||
[SDL_SCANCODE_C] = tic_key_c,
|
||||
[SDL_SCANCODE_D] = tic_key_d,
|
||||
[SDL_SCANCODE_E] = tic_key_e,
|
||||
[SDL_SCANCODE_F] = tic_key_f,
|
||||
[SDL_SCANCODE_G] = tic_key_g,
|
||||
[SDL_SCANCODE_H] = tic_key_h,
|
||||
[SDL_SCANCODE_I] = tic_key_i,
|
||||
[SDL_SCANCODE_J] = tic_key_j,
|
||||
[SDL_SCANCODE_K] = tic_key_k,
|
||||
[SDL_SCANCODE_L] = tic_key_l,
|
||||
[SDL_SCANCODE_M] = tic_key_m,
|
||||
[SDL_SCANCODE_N] = tic_key_n,
|
||||
[SDL_SCANCODE_O] = tic_key_o,
|
||||
[SDL_SCANCODE_P] = tic_key_p,
|
||||
[SDL_SCANCODE_Q] = tic_key_q,
|
||||
[SDL_SCANCODE_R] = tic_key_r,
|
||||
[SDL_SCANCODE_S] = tic_key_s,
|
||||
[SDL_SCANCODE_T] = tic_key_t,
|
||||
[SDL_SCANCODE_U] = tic_key_u,
|
||||
[SDL_SCANCODE_V] = tic_key_v,
|
||||
[SDL_SCANCODE_W] = tic_key_w,
|
||||
[SDL_SCANCODE_X] = tic_key_x,
|
||||
[SDL_SCANCODE_Y] = tic_key_y,
|
||||
[SDL_SCANCODE_Z] = tic_key_z,
|
||||
[SDL_SCANCODE_1] = tic_key_1,
|
||||
[SDL_SCANCODE_2] = tic_key_2,
|
||||
[SDL_SCANCODE_3] = tic_key_3,
|
||||
[SDL_SCANCODE_4] = tic_key_4,
|
||||
[SDL_SCANCODE_5] = tic_key_5,
|
||||
[SDL_SCANCODE_6] = tic_key_6,
|
||||
[SDL_SCANCODE_7] = tic_key_7,
|
||||
[SDL_SCANCODE_8] = tic_key_8,
|
||||
[SDL_SCANCODE_9] = tic_key_9,
|
||||
[SDL_SCANCODE_0] = tic_key_0,
|
||||
[SDL_SCANCODE_RETURN] = tic_key_return,
|
||||
[SDL_SCANCODE_ESCAPE] = tic_key_escape,
|
||||
[SDL_SCANCODE_AC_BACK] = tic_key_escape,
|
||||
[SDL_SCANCODE_BACKSPACE] = tic_key_backspace,
|
||||
[SDL_SCANCODE_TAB] = tic_key_tab,
|
||||
[SDL_SCANCODE_SPACE] = tic_key_space,
|
||||
[SDL_SCANCODE_MINUS] = tic_key_minus,
|
||||
[SDL_SCANCODE_EQUALS] = tic_key_equals,
|
||||
[SDL_SCANCODE_LEFTBRACKET] = tic_key_leftbracket,
|
||||
[SDL_SCANCODE_RIGHTBRACKET] = tic_key_rightbracket,
|
||||
[SDL_SCANCODE_BACKSLASH] = tic_key_backslash,
|
||||
[50] = tic_key_unknown,
|
||||
[SDL_SCANCODE_SEMICOLON] = tic_key_semicolon,
|
||||
[SDL_SCANCODE_APOSTROPHE] = tic_key_apostrophe,
|
||||
[SDL_SCANCODE_GRAVE] = tic_key_grave,
|
||||
[SDL_SCANCODE_COMMA] = tic_key_comma,
|
||||
[SDL_SCANCODE_PERIOD] = tic_key_period,
|
||||
[SDL_SCANCODE_SLASH] = tic_key_slash,
|
||||
[SDL_SCANCODE_CAPSLOCK] = tic_key_capslock,
|
||||
[SDL_SCANCODE_F1] = tic_key_f1,
|
||||
[SDL_SCANCODE_F2] = tic_key_f2,
|
||||
[SDL_SCANCODE_F3] = tic_key_f3,
|
||||
[SDL_SCANCODE_F4] = tic_key_f4,
|
||||
[SDL_SCANCODE_F5] = tic_key_f5,
|
||||
[SDL_SCANCODE_F6] = tic_key_f6,
|
||||
[SDL_SCANCODE_F7] = tic_key_f7,
|
||||
[SDL_SCANCODE_F8] = tic_key_f8,
|
||||
[SDL_SCANCODE_F9] = tic_key_f9,
|
||||
[SDL_SCANCODE_F10] = tic_key_f10,
|
||||
[SDL_SCANCODE_F11] = tic_key_f11,
|
||||
[SDL_SCANCODE_F12] = tic_key_f12,
|
||||
[70] = tic_key_unknown,
|
||||
[71] = tic_key_unknown,
|
||||
[72] = tic_key_unknown,
|
||||
[SDL_SCANCODE_INSERT] = tic_key_insert,
|
||||
[SDL_SCANCODE_HOME] = tic_key_home,
|
||||
[SDL_SCANCODE_PAGEUP] = tic_key_pageup,
|
||||
[SDL_SCANCODE_DELETE] = tic_key_delete,
|
||||
[SDL_SCANCODE_END] = tic_key_end,
|
||||
[SDL_SCANCODE_PAGEDOWN] = tic_key_pagedown,
|
||||
[SDL_SCANCODE_RIGHT] = tic_key_right,
|
||||
[SDL_SCANCODE_LEFT] = tic_key_left,
|
||||
[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,
|
||||
|
|
45
src/system.c
45
src/system.c
|
@ -396,7 +396,7 @@ static void processMouse()
|
|||
|
||||
static void processKeyboard()
|
||||
{
|
||||
static const u32 KeyboardCodes[tic_keys_count] =
|
||||
static const u8 KeyboardCodes[] =
|
||||
{
|
||||
#include "keycodes.inl"
|
||||
};
|
||||
|
@ -404,37 +404,22 @@ static void processKeyboard()
|
|||
tic80_input* input = &platform.studio->tic->ram.input;
|
||||
input->keyboard.data = 0;
|
||||
|
||||
enum{BufSize = COUNT_OF(input->keyboard.keys)};
|
||||
|
||||
s32 c = 0;
|
||||
{
|
||||
SDL_Keymod mod = SDL_GetModState();
|
||||
if(mod & KMOD_SHIFT) input->keyboard.keys[c++] = tic_key_shift;
|
||||
if(mod & (KMOD_CTRL | KMOD_GUI)) input->keyboard.keys[c++] = tic_key_ctrl;
|
||||
if(mod & KMOD_ALT) input->keyboard.keys[c++] = tic_key_alt;
|
||||
if(mod & KMOD_CAPS) input->keyboard.keys[c++] = tic_key_capslock;
|
||||
}
|
||||
|
||||
const u8* keyboard = SDL_GetKeyboardState(NULL);
|
||||
|
||||
enum{BufSize = COUNT_OF(input->keyboard.keys)};
|
||||
|
||||
s32 c = 0;
|
||||
{
|
||||
SDL_Keymod mod = SDL_GetModState();
|
||||
if(mod & KMOD_RSHIFT) input->keyboard.keys[c++] = tic_key_shift;
|
||||
if(mod & (KMOD_RCTRL | KMOD_GUI)) input->keyboard.keys[c++] = tic_key_ctrl;
|
||||
if(mod & KMOD_RALT) input->keyboard.keys[c++] = tic_key_alt;
|
||||
if(mod & KMOD_CAPS) input->keyboard.keys[c++] = tic_key_capslock;
|
||||
}
|
||||
|
||||
for(s32 i = 0; i < SDL_NUM_SCANCODES && c < BufSize; i++)
|
||||
{
|
||||
if(keyboard[i])
|
||||
{
|
||||
SDL_Keycode keycode = i == SDL_SCANCODE_AC_BACK
|
||||
? SDLK_ESCAPE
|
||||
: SDL_GetKeyFromScancode(i);
|
||||
|
||||
for(s32 k = 0; k < COUNT_OF(KeyboardCodes); k++)
|
||||
{
|
||||
if(KeyboardCodes[k] == keycode)
|
||||
{
|
||||
input->keyboard.keys[c++] = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for(s32 i = 0; i < COUNT_OF(KeyboardCodes) && c < COUNT_OF(input->keyboard.keys); i++)
|
||||
if(keyboard[i] && KeyboardCodes[i] > tic_key_unknown)
|
||||
input->keyboard.keys[c++] = KeyboardCodes[i];
|
||||
}
|
||||
|
||||
#if !defined(__EMSCRIPTEN__) && !defined(__MACOSX__)
|
||||
|
|
Loading…
Reference in New Issue