From 7cee8f685480ca81c1277b61daf4130b91f6e28d Mon Sep 17 00:00:00 2001 From: rxi Date: Sat, 24 Sep 2016 23:45:59 +0100 Subject: [PATCH] Changed love.keyboard.isDown() to accept string args --- src/keyboard.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/keyboard.c b/src/keyboard.c index fe6a88f..184ab71 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -85,6 +85,7 @@ void keyboard_deinit(void) { */ const char *scancodeMap[] = { + [ 0] = "?", [ 1] = "escape", [ 2] = "1", [ 3] = "2", @@ -217,9 +218,14 @@ const char *scancodeMap[] = { int l_keyboard_isDown(lua_State *L) { - int code = luaL_checknumber(L, 1); - if (code < 0 || code >= KEYBOARD_KEY_MAX) return 0; - lua_pushboolean(L, keyboard_keyStates[code]); + int n = lua_gettop(L); + int res = 0; + int i; + for (i = 1; i <= n; i++) { + int code = luaL_checkoption(L, 1, NULL, scancodeMap); + res |= keyboard_keyStates[code]; + } + lua_pushboolean(L, res); return 1; }