Skip to content

Commit

Permalink
EVENTS: Allow disabling repeat event generation
Browse files Browse the repository at this point in the history
  • Loading branch information
bgK committed Nov 19, 2017
1 parent 7539a77 commit 7d811d3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backends/events/default/default-events.cpp
Expand Up @@ -40,7 +40,8 @@ DefaultEventManager::DefaultEventManager(Common::EventSource *boss) :
_modifierState(0),
_shouldQuit(false),
_shouldRTL(false),
_confirmExitDialogActive(false) {
_confirmExitDialogActive(false),
_shouldGenerateKeyRepeatEvents(true) {

assert(boss);

Expand Down Expand Up @@ -84,7 +85,9 @@ void DefaultEventManager::init() {
bool DefaultEventManager::pollEvent(Common::Event &event) {
_dispatcher.dispatch();

handleKeyRepeat();
if (_shouldGenerateKeyRepeatEvents) {
handleKeyRepeat();
}

if (_eventQueue.empty()) {
return false;
Expand Down
12 changes: 12 additions & 0 deletions backends/events/default/default-events.h
Expand Up @@ -67,6 +67,7 @@ class DefaultEventManager : public Common::EventManager, Common::EventObserver {
kKeyRepeatSustainDelay = 100
};

bool _shouldGenerateKeyRepeatEvents;
Common::KeyState _currentKeyDown;
uint32 _keyRepeatTime;

Expand Down Expand Up @@ -95,6 +96,17 @@ class DefaultEventManager : public Common::EventManager, Common::EventObserver {
// this, please talk to tsoliman and/or LordHoto.
virtual Common::Keymapper *getKeymapper() { return _keymapper; }
#endif

/**
* Controls whether repeated key down events are generated while a key is pressed
*
* Backends that generate their own keyboard repeat events should disable this.
*
* @param generateKeyRepeatEvents
*/
void setGenerateKeyRepeatEvents(bool generateKeyRepeatEvents) {
_shouldGenerateKeyRepeatEvents = generateKeyRepeatEvents;
}
};

#endif

0 comments on commit 7d811d3

Please sign in to comment.