diff options
author | Max Horn | 2002-07-18 14:47:25 +0000 |
---|---|---|
committer | Max Horn | 2002-07-18 14:47:25 +0000 |
commit | 4968bc7a212584c231f04f262b198313e9d69ac7 (patch) | |
tree | 69d2417feb437d2dd5a1ac0c5ff11c0f83cde717 /newgui.cpp | |
parent | 5317b473b2f41f30c0d89b9e8ffab40aa2d34672 (diff) | |
download | scummvm-rg350-4968bc7a212584c231f04f262b198313e9d69ac7.tar.gz scummvm-rg350-4968bc7a212584c231f04f262b198313e9d69ac7.tar.bz2 scummvm-rg350-4968bc7a212584c231f04f262b198313e9d69ac7.zip |
painelf's key repeat patch
svn-id: r4586
Diffstat (limited to 'newgui.cpp')
-rw-r--r-- | newgui.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/newgui.cpp b/newgui.cpp index e03829b3f9..9b0ac54662 100644 --- a/newgui.cpp +++ b/newgui.cpp @@ -39,7 +39,8 @@ NewGui::NewGui(Scumm *s) : _s(s), _use_alpha_blending(true), _need_redraw(false),_prepare_for_gui(true), - _pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0) + _pauseDialog(0), _saveLoadDialog(0), _aboutDialog(0), _optionsDialog(0), + _currentKeyDown(0) { } @@ -115,9 +116,18 @@ void NewGui::loop() switch(t.event_code) { case OSystem::EVENT_KEYDOWN: activeDialog->handleKeyDown(t.kbd.ascii, t.kbd.flags); + + // init continuous event stream + _currentKeyDown = t.kbd.ascii; + _currentKeyDownFlags = t.kbd.flags; + _eventFiredCount = 1; + _loopCount = 0; break; case OSystem::EVENT_KEYUP: activeDialog->handleKeyUp(t.kbd.ascii, t.kbd.flags); + if (t.kbd.ascii == _currentKeyDown) + // only stop firing events if it's the current key + _currentKeyDown = 0; break; case OSystem::EVENT_MOUSEMOVE: activeDialog->handleMouseMoved(t.mouse.x - activeDialog->_x, t.mouse.y - activeDialog->_y, 0); @@ -137,6 +147,22 @@ void NewGui::loop() _eventList.clear(); } + // check if event should be sent again (keydown) + if (_currentKeyDown != 0) + { + // if only fired once, wait longer + if ( _loopCount >= ((_eventFiredCount > 1) ? 2 : 4) ) + // ^ loops to wait first event + // ^ loops to wait after first event + { + // fire event + activeDialog->handleKeyDown(_currentKeyDown, _currentKeyDownFlags); + _eventFiredCount++; + _loopCount = 0; + } + _loopCount++; + } + _s->drawDirtyScreenParts(); } |