diff options
author | Max Horn | 2002-09-30 12:56:59 +0000 |
---|---|---|
committer | Max Horn | 2002-09-30 12:56:59 +0000 |
commit | 8f7e3119bfc02d31f4129d16ae1032fbc11bd8de (patch) | |
tree | 73372a0379ae25b46936cec41f50a51e994153f1 /gui/newgui.cpp | |
parent | 4fc67f55c0212807f89a260315d59b6ba8deb30a (diff) | |
download | scummvm-rg350-8f7e3119bfc02d31f4129d16ae1032fbc11bd8de.tar.gz scummvm-rg350-8f7e3119bfc02d31f4129d16ae1032fbc11bd8de.tar.bz2 scummvm-rg350-8f7e3119bfc02d31f4129d16ae1032fbc11bd8de.zip |
fixed key repeat in NewGui; made the launcher game list non-editable
svn-id: r5052
Diffstat (limited to 'gui/newgui.cpp')
-rw-r--r-- | gui/newgui.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 8b82e5b8a5..aed586fe04 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -25,9 +25,7 @@ #ifdef _MSC_VER - # pragma warning( disable : 4068 ) // unknown pragma - #endif @@ -44,6 +42,14 @@ * - ... */ +enum { + kDoubleClickDelay = 500, // milliseconds + kCursorAnimateDelay = 500, + + kKeyRepeatInitialDelay = 400, + kKeyRepeatSustainDelay = 100, +}; + // Built-in font static byte guifont[] = { 0,0,99,1,226,8,4,8,6,8,6,0,0,0,0,0,0,0,0,0,0,0,8,2,1,8,0,0,0,0,0,0,0,0,0,0,0,0,4,3,7,8,7,7,8,4,5,5,8,7,4,7,3,8,7,7,7,7,8,7,7,7,7,7,3,4,7,5,7,7,8,7,7,7,7,7,7,7,7,5,7,7, @@ -126,6 +132,8 @@ void NewGui::runLoop() _system->update_screen(); + uint32 time = _system->get_msecs(); + while (_system->poll_event(&event)) { switch(event.event_code) { case OSystem::EVENT_KEYDOWN: @@ -134,8 +142,7 @@ void NewGui::runLoop() // init continuous event stream _currentKeyDown = event.kbd.ascii; _currentKeyDownFlags = event.kbd.flags; - _keyRepeatEvenCount = 1; - _keyRepeatLoopCount = 0; + _keyRepeatTime = time + kKeyRepeatInitialDelay; break; case OSystem::EVENT_KEYUP: activeDialog->handleKeyUp((byte)event.kbd.ascii, event.kbd.flags); @@ -150,7 +157,6 @@ void NewGui::runLoop() // We don'event distinguish between mousebuttons (for now at least) case OSystem::EVENT_LBUTTONDOWN: case OSystem::EVENT_RBUTTONDOWN: { - uint32 time = _system->get_msecs(); if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay) && ABS(_lastClick.x - event.mouse.x) < 3 && ABS(_lastClick.y - event.mouse.y) < 3) { @@ -174,17 +180,12 @@ void NewGui::runLoop() // check if event should be sent again (keydown) if (_currentKeyDown != 0) { - // if only fired once, wait longer - if ( _keyRepeatLoopCount >= ((_keyRepeatEvenCount > 1) ? 2 : 4) ) - // ^ loops to wait first event - // ^ loops to wait after first event + if (_keyRepeatTime < time) { // fire event activeDialog->handleKeyDown(_currentKeyDown, _currentKeyDownFlags); - _keyRepeatEvenCount++; - _keyRepeatLoopCount = 0; + _keyRepeatTime = time + kKeyRepeatSustainDelay; } - _keyRepeatLoopCount++; } // Delay for a moment |