From c3a57954aab1243861001f9341021c0a3cc6d099 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Fri, 29 Dec 2017 15:44:42 +0300 Subject: [PATCH] no message --- src/keycodes.c | 298 ++++++++++++++++++++++++------------------------- src/luaapi.c | 4 +- src/studio.c | 6 +- src/tic.h | 1 + 4 files changed, 154 insertions(+), 155 deletions(-) diff --git a/src/keycodes.c b/src/keycodes.c index cb0430f..c5d9fc6 100644 --- a/src/keycodes.c +++ b/src/keycodes.c @@ -1,7 +1,7 @@ -[0] = UnkCode, -[1] = UnkCode, -[2] = UnkCode, -[3] = UnkCode, +[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, @@ -48,7 +48,7 @@ [SDL_SCANCODE_LEFTBRACKET] = tic_key_leftbracket, [SDL_SCANCODE_RIGHTBRACKET] = tic_key_rightbracket, [SDL_SCANCODE_BACKSLASH] = tic_key_backslash, -[50] = UnkCode, +[50] = tic_key_unknown, [SDL_SCANCODE_SEMICOLON] = tic_key_semicolon, [SDL_SCANCODE_APOSTROPHE] = tic_key_apostrophe, [SDL_SCANCODE_GRAVE] = tic_key_grave, @@ -68,9 +68,9 @@ [SDL_SCANCODE_F10] = tic_key_f10, [SDL_SCANCODE_F11] = tic_key_f11, [SDL_SCANCODE_F12] = tic_key_f12, -[70] = UnkCode, -[71] = UnkCode, -[72] = UnkCode, +[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, @@ -81,147 +81,147 @@ [SDL_SCANCODE_LEFT] = tic_key_left, [SDL_SCANCODE_DOWN] = tic_key_down, [SDL_SCANCODE_UP] = tic_key_up, -[83] = UnkCode, -[84] = UnkCode, -[85] = UnkCode, -[86] = UnkCode, -[87] = UnkCode, -[88] = UnkCode, -[89] = UnkCode, -[90] = UnkCode, -[91] = UnkCode, -[92] = UnkCode, -[93] = UnkCode, -[94] = UnkCode, -[95] = UnkCode, -[96] = UnkCode, -[97] = UnkCode, -[98] = UnkCode, -[99] = UnkCode, -[100] = UnkCode, -[101] = UnkCode, -[102] = UnkCode, -[103] = UnkCode, -[104] = UnkCode, -[105] = UnkCode, -[106] = UnkCode, -[107] = UnkCode, -[108] = UnkCode, -[109] = UnkCode, -[110] = UnkCode, -[111] = UnkCode, -[112] = UnkCode, -[113] = UnkCode, -[114] = UnkCode, -[115] = UnkCode, -[116] = UnkCode, -[117] = UnkCode, -[118] = UnkCode, -[119] = UnkCode, -[120] = UnkCode, -[121] = UnkCode, -[122] = UnkCode, -[123] = UnkCode, -[124] = UnkCode, -[125] = UnkCode, -[126] = UnkCode, -[127] = UnkCode, -[128] = UnkCode, -[129] = UnkCode, -[130] = UnkCode, -[131] = UnkCode, -[132] = UnkCode, -[133] = UnkCode, -[134] = UnkCode, -[135] = UnkCode, -[136] = UnkCode, -[137] = UnkCode, -[138] = UnkCode, -[139] = UnkCode, -[140] = UnkCode, -[141] = UnkCode, -[142] = UnkCode, -[143] = UnkCode, -[144] = UnkCode, -[145] = UnkCode, -[146] = UnkCode, -[147] = UnkCode, -[148] = UnkCode, -[149] = UnkCode, -[150] = UnkCode, -[151] = UnkCode, -[152] = UnkCode, -[153] = UnkCode, -[154] = UnkCode, -[155] = UnkCode, -[156] = UnkCode, -[157] = UnkCode, -[158] = UnkCode, -[159] = UnkCode, -[160] = UnkCode, -[161] = UnkCode, -[162] = UnkCode, -[163] = UnkCode, -[164] = UnkCode, -[165] = UnkCode, -[166] = UnkCode, -[167] = UnkCode, -[168] = UnkCode, -[169] = UnkCode, -[170] = UnkCode, -[171] = UnkCode, -[172] = UnkCode, -[173] = UnkCode, -[174] = UnkCode, -[175] = UnkCode, -[176] = UnkCode, -[177] = UnkCode, -[178] = UnkCode, -[179] = UnkCode, -[180] = UnkCode, -[181] = UnkCode, -[182] = UnkCode, -[183] = UnkCode, -[184] = UnkCode, -[185] = UnkCode, -[186] = UnkCode, -[187] = UnkCode, -[188] = UnkCode, -[189] = UnkCode, -[190] = UnkCode, -[191] = UnkCode, -[192] = UnkCode, -[193] = UnkCode, -[194] = UnkCode, -[195] = UnkCode, -[196] = UnkCode, -[197] = UnkCode, -[198] = UnkCode, -[199] = UnkCode, -[200] = UnkCode, -[201] = UnkCode, -[202] = UnkCode, -[203] = UnkCode, -[204] = UnkCode, -[205] = UnkCode, -[206] = UnkCode, -[207] = UnkCode, -[208] = UnkCode, -[209] = UnkCode, -[210] = UnkCode, -[211] = UnkCode, -[212] = UnkCode, -[213] = UnkCode, -[214] = UnkCode, -[215] = UnkCode, -[216] = UnkCode, -[217] = UnkCode, -[218] = UnkCode, -[219] = UnkCode, -[220] = UnkCode, -[221] = UnkCode, -[222] = UnkCode, -[223] = UnkCode, +[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, \ No newline at end of file diff --git a/src/luaapi.c b/src/luaapi.c index ba035b3..c3b60d2 100644 --- a/src/luaapi.c +++ b/src/luaapi.c @@ -794,9 +794,9 @@ static s32 lua_key(lua_State* lua) if (top == 1) { - u8 index = getLuaNumber(lua, 1); + u8 index = getLuaNumber(lua, 1)+1; - if(index != 0xff) + if(index > tic_key_unknown) { for(s32 i = 0; i < COUNT_OF(input->keyboard.keys); i++) { diff --git a/src/studio.c b/src/studio.c index c13fdbb..9b6e540 100644 --- a/src/studio.c +++ b/src/studio.c @@ -1904,20 +1904,18 @@ static void processMouseInput() static void processKeyboardInput() { - enum{UnkCode = 0xff}; - static const u8 KeyboardCodes[] = { #include "keycodes.c" }; tic80_input* input = &studio.tic->ram.input; - input->keyboard.data = SDL_FOURCC(UnkCode, UnkCode, UnkCode, UnkCode); + input->keyboard.data = 0; studio.keyboard = SDL_GetKeyboardState(NULL); for(s32 i = 0, c = 0; i < COUNT_OF(KeyboardCodes) && c < COUNT_OF(input->keyboard.keys); i++) - if(studio.keyboard[i] && KeyboardCodes[i] != UnkCode) + if(studio.keyboard[i] && KeyboardCodes[i] > tic_key_unknown) input->keyboard.keys[c++] = KeyboardCodes[i]; } diff --git a/src/tic.h b/src/tic.h index baa23a7..9ad5e94 100644 --- a/src/tic.h +++ b/src/tic.h @@ -419,6 +419,7 @@ typedef union enum { + tic_key_unknown, tic_key_up, tic_key_down, tic_key_left,