diff --git a/src/modules/keyboard/sdl/Keyboard.cpp b/src/modules/keyboard/sdl/Keyboard.cpp index 61b04161a..30b13bc8e 100644 --- a/src/modules/keyboard/sdl/Keyboard.cpp +++ b/src/modules/keyboard/sdl/Keyboard.cpp @@ -31,14 +31,15 @@ namespace sdl return "love.keyboard.sdl"; } - bool Keyboard::isDown(Key key) const + bool Keyboard::isDown(Key * keylist) const { SDLKey k; - - if(keys.find(key, k)) + Uint8 * keystate = SDL_GetKeyState(0); + + for (Key key = *keylist; key != KEY_MAX_ENUM; key = *(++keylist)) { - Uint8 * keystate = SDL_GetKeyState(0); - return keystate[(unsigned)k] == 1; + if (keys.find(key, k) && keystate[(unsigned)k] == 1) + return true; } return false; diff --git a/src/modules/keyboard/sdl/Keyboard.h b/src/modules/keyboard/sdl/Keyboard.h index af807942b..4183ee7e0 100644 --- a/src/modules/keyboard/sdl/Keyboard.h +++ b/src/modules/keyboard/sdl/Keyboard.h @@ -46,7 +46,7 @@ namespace sdl * @param key A key identifier. * @return boolean **/ - bool isDown(Key key) const; + bool isDown(Key * keylist) const; /** * Enables key repeating. @@ -78,4 +78,4 @@ namespace sdl } // keyboard } // love -#endif // LOVE_KEYBOARD_SDL_KEYBOARD_H \ No newline at end of file +#endif // LOVE_KEYBOARD_SDL_KEYBOARD_H diff --git a/src/modules/keyboard/sdl/wrap_Keyboard.cpp b/src/modules/keyboard/sdl/wrap_Keyboard.cpp index 6987f6d81..e7bb06893 100644 --- a/src/modules/keyboard/sdl/wrap_Keyboard.cpp +++ b/src/modules/keyboard/sdl/wrap_Keyboard.cpp @@ -31,16 +31,18 @@ namespace sdl int w_isDown(lua_State * L) { Keyboard::Key k; - - if(Keyboard::getConstant(luaL_checkstring(L, 1), k)) + unsigned int num = lua_gettop(L); + Keyboard::Key * keylist = new Keyboard::Key[num+1]; + unsigned int counter = 0; + + for (unsigned int i = 0; i < num; i++) { - luax_pushboolean(L, instance->isDown(k)); + if(Keyboard::getConstant(luaL_checkstring(L, i+1), k)) + keylist[counter++] = k; } - else - { - luax_pushboolean(L, false); - } - + keylist[counter] = Keyboard::KEY_MAX_ENUM; + + luax_pushboolean(L, instance->isDown(keylist)); return 1; }