From dd333baf389180dcec5c78c0952ab0a3854a3ac4 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 24 Jan 2018 19:50:06 +0300 Subject: [PATCH] ESC and F1-F12 disabled in game mode --- src/jsapi.c | 4 ++-- src/keycodes.c | 26 +++++++++++++------------- src/luaapi.c | 4 ++-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/jsapi.c b/src/jsapi.c index 694bcc4..9edcf64 100644 --- a/src/jsapi.c +++ b/src/jsapi.c @@ -248,7 +248,7 @@ static s32 duk_key(duk_context* duk) { tic_key key = duk_to_int(duk, 0); - if(key < tic_keys_count) + if(key < tic_key_escape) duk_push_boolean(duk, tic->api.key(tic, key)); else { @@ -273,7 +273,7 @@ static s32 duk_keyp(duk_context* duk) { tic_key key = duk_to_int(duk, 0); - if(key >= tic_keys_count) + if(key >= tic_key_escape) { duk_error(duk, DUK_ERR_ERROR, "unknown keyboard code\n"); return 0; diff --git a/src/keycodes.c b/src/keycodes.c index 447e712..8ead073 100644 --- a/src/keycodes.c +++ b/src/keycodes.c @@ -39,7 +39,7 @@ [SDL_SCANCODE_9] = tic_key_9, [SDL_SCANCODE_0] = tic_key_0, [SDL_SCANCODE_RETURN] = tic_key_return, -[SDL_SCANCODE_ESCAPE] = tic_key_unknown, +[SDL_SCANCODE_ESCAPE] = tic_key_escape, [SDL_SCANCODE_BACKSPACE] = tic_key_backspace, [SDL_SCANCODE_TAB] = tic_key_tab, [SDL_SCANCODE_SPACE] = tic_key_space, @@ -56,18 +56,18 @@ [SDL_SCANCODE_PERIOD] = tic_key_period, [SDL_SCANCODE_SLASH] = tic_key_slash, [SDL_SCANCODE_CAPSLOCK] = tic_key_capslock, -[SDL_SCANCODE_F1] = tic_key_unknown, -[SDL_SCANCODE_F2] = tic_key_unknown, -[SDL_SCANCODE_F3] = tic_key_unknown, -[SDL_SCANCODE_F4] = tic_key_unknown, -[SDL_SCANCODE_F5] = tic_key_unknown, -[SDL_SCANCODE_F6] = tic_key_unknown, -[SDL_SCANCODE_F7] = tic_key_unknown, -[SDL_SCANCODE_F8] = tic_key_unknown, -[SDL_SCANCODE_F9] = tic_key_unknown, -[SDL_SCANCODE_F10] = tic_key_unknown, -[SDL_SCANCODE_F11] = tic_key_unknown, -[SDL_SCANCODE_F12] = tic_key_unknown, +[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, diff --git a/src/luaapi.c b/src/luaapi.c index f1a7984..7cecac9 100644 --- a/src/luaapi.c +++ b/src/luaapi.c @@ -795,7 +795,7 @@ static s32 lua_key(lua_State* lua) { tic_key key = getLuaNumber(lua, 1); - if(key < tic_keys_count) + if(key < tic_key_escape) lua_pushboolean(lua, tic->api.key(tic, key)); else { @@ -827,7 +827,7 @@ static s32 lua_keyp(lua_State* lua) { tic_key key = getLuaNumber(lua, 1); - if(key >= tic_keys_count) + if(key >= tic_key_escape) { luaL_error(lua, "unknown keyboard code\n"); }