diff options
author | Torbjörn Andersson | 2005-08-25 15:33:38 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2005-08-25 15:33:38 +0000 |
commit | 41e9aa2f2c84704712abb64f8ad2110e0eab25fe (patch) | |
tree | bb837fb446830a555d1ed092437ef65cab8d9ed2 /sword1/control.cpp | |
parent | 3140dbebc4d02f163f8fab26f11797d98c167b61 (diff) | |
download | scummvm-rg350-41e9aa2f2c84704712abb64f8ad2110e0eab25fe.tar.gz scummvm-rg350-41e9aa2f2c84704712abb64f8ad2110e0eab25fe.tar.bz2 scummvm-rg350-41e9aa2f2c84704712abb64f8ad2110e0eab25fe.zip |
Added keyboard repeating.
svn-id: r18711
Diffstat (limited to 'sword1/control.cpp')
-rw-r--r-- | sword1/control.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sword1/control.cpp b/sword1/control.cpp index 2fbc7f26dd..3793e6f022 100644 --- a/sword1/control.cpp +++ b/sword1/control.cpp @@ -43,6 +43,11 @@ namespace Sword1 { #define SAVEFILE_WRITE true #define SAVEFILE_READ false +enum { + kKeyRepeatInitialDelay = 400, + kKeyRepeatSustainDelay = 100 +}; + enum LangStrings { STR_PAUSED = 0, STR_INSERT_CD_A, @@ -167,6 +172,8 @@ Control::Control(Common::SaveFileManager *saveFileMan, ResMan *pResMan, ObjectMa _music = pMusic; _sound = pSound; _lStrings = _languageStrings + SwordEngine::_systemVars.language * 20; + _keyRepeat = 0; + _keyRepeatTime = 0; } void Control::askForCd(void) { @@ -1005,7 +1012,8 @@ void Control::doRestore(void) { void Control::delay(uint32 msecs) { OSystem::Event event; - uint32 endTime = _system->getMillis() + msecs; + uint32 now = _system->getMillis(); + uint32 endTime = now + msecs; _keyPressed = 0; //reset _mouseState = 0; @@ -1019,6 +1027,12 @@ void Control::delay(uint32 msecs) { _keyPressed = 8; else _keyPressed = (byte)event.kbd.ascii; + _keyRepeatTime = now + kKeyRepeatInitialDelay; + _keyRepeat = _keyPressed; + break; + case OSystem::EVENT_KEYUP: + _keyRepeatTime = 0; + _keyRepeat = 0; break; case OSystem::EVENT_MOUSEMOVE: _mouseX = event.mouse.x; @@ -1051,6 +1065,10 @@ void Control::delay(uint32 msecs) { break; } } + if (_keyRepeatTime && now > _keyRepeatTime) { + _keyRepeatTime += kKeyRepeatSustainDelay; + _keyPressed = _keyRepeat; + } #ifndef __PALM_OS__ _system->delayMillis(10); #endif |