mirror of
https://github.com/love2d/love.git
synced 2026-08-15 15:51:12 +02:00
Minor code cleanup
This commit is contained in:
@@ -51,12 +51,11 @@ bool Keyboard::hasKeyRepeat() const
|
||||
|
||||
bool Keyboard::isDown(Key *keylist) const
|
||||
{
|
||||
const Uint8 *keystate = SDL_GetKeyboardState(0);
|
||||
std::map<Key, SDL_Keycode>::const_iterator it;
|
||||
const Uint8 *keystate = SDL_GetKeyboardState(nullptr);
|
||||
|
||||
for (Key key = *keylist; key != KEY_MAX_ENUM; key = *(++keylist))
|
||||
{
|
||||
it = keys.find(key);
|
||||
auto it = keys.find(key);
|
||||
if (it != keys.end() && keystate[SDL_GetScancodeFromKey(it->second)])
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
// Whether holding down a key triggers repeated key press events.
|
||||
// The real implementation is in love::event::sdl::Event::Convert.
|
||||
bool key_repeat;
|
||||
|
||||
static std::map<Key, SDL_Keycode> createKeyMap();
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace love
|
||||
namespace keyboard
|
||||
{
|
||||
|
||||
static Keyboard *instance = 0;
|
||||
static Keyboard *instance = nullptr;
|
||||
|
||||
int w_setKeyRepeat(lua_State *L)
|
||||
{
|
||||
@@ -87,7 +87,7 @@ static const luaL_Reg functions[] =
|
||||
|
||||
extern "C" int luaopen_love_keyboard(lua_State *L)
|
||||
{
|
||||
if (instance == 0)
|
||||
if (instance == nullptr)
|
||||
{
|
||||
EXCEPT_GUARD(instance = new love::keyboard::sdl::Keyboard();)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user