From 1503533ee6ac647f76dc23222022e7bf914821a4 Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Tue, 6 Dec 2011 21:30:31 +0100 Subject: [PATCH] Key repeat gets seconds too --- src/modules/keyboard/sdl/Keyboard.cpp | 4 ++-- src/modules/keyboard/wrap_Keyboard.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/modules/keyboard/sdl/Keyboard.cpp b/src/modules/keyboard/sdl/Keyboard.cpp index aa86110cc..33aea857c 100644 --- a/src/modules/keyboard/sdl/Keyboard.cpp +++ b/src/modules/keyboard/sdl/Keyboard.cpp @@ -57,14 +57,14 @@ namespace sdl int Keyboard::getKeyRepeatDelay() const { - int delay, interval = 0; + int delay, interval; SDL_GetKeyRepeat(&delay, &interval); return delay; } int Keyboard::getKeyRepeatInterval() const { - int delay, interval = 0; + int delay, interval; SDL_GetKeyRepeat(&delay, &interval); return interval; } diff --git a/src/modules/keyboard/wrap_Keyboard.cpp b/src/modules/keyboard/wrap_Keyboard.cpp index 64fa5f99c..2a8af6974 100644 --- a/src/modules/keyboard/wrap_Keyboard.cpp +++ b/src/modules/keyboard/wrap_Keyboard.cpp @@ -58,14 +58,17 @@ namespace keyboard return 0; } - instance->setKeyRepeat(luaL_optint(L, 1, Keyboard::DEFAULT), luaL_optint(L, 2, Keyboard::DEFAULT)); + lua_Number delay = luaL_optnumber(L, 1, Keyboard::DEFAULT) * 1000 + 0.5; + lua_Number interval = luaL_optnumber(L, 2, Keyboard::DEFAULT) * 1000 + 0.5; + + instance->setKeyRepeat((int) delay, (int) interval); return 0; } int w_getKeyRepeat(lua_State * L) { - lua_pushnumber(L, instance->getKeyRepeatDelay()); - lua_pushnumber(L, instance->getKeyRepeatInterval()); + lua_pushnumber(L, (lua_Number) instance->getKeyRepeatDelay() * 0.001); + lua_pushnumber(L, (lua_Number) instance->getKeyRepeatInterval() * 0.001); return 2; }