aboutsummaryrefslogtreecommitdiff
path: root/backends/keymapper
diff options
context:
space:
mode:
authorTarek Soliman2012-03-01 06:29:44 -0600
committerTarek Soliman2012-03-02 20:48:50 -0600
commitc0a215282d12872cf32fb24f9067216c0f869b96 (patch)
treef55b1c3591ebc7c094b78c32f3d714d45e942da7 /backends/keymapper
parentd12f21b31db2985faeb2e2a6b9b09cd210f82c34 (diff)
downloadscummvm-rg350-c0a215282d12872cf32fb24f9067216c0f869b96.tar.gz
scummvm-rg350-c0a215282d12872cf32fb24f9067216c0f869b96.tar.bz2
scummvm-rg350-c0a215282d12872cf32fb24f9067216c0f869b96.zip
KEYMAPPER: Add delays for *UP events coming from non-keys
Delayed entries are in a queue where each entry stores how many milliseconds should pass based on the last entry.
Diffstat (limited to 'backends/keymapper')
-rw-r--r--backends/keymapper/keymapper.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/backends/keymapper/keymapper.cpp b/backends/keymapper/keymapper.cpp
index 99bcb44179..dcb021f2d8 100644
--- a/backends/keymapper/keymapper.cpp
+++ b/backends/keymapper/keymapper.cpp
@@ -25,9 +25,14 @@
#ifdef ENABLE_KEYMAPPER
#include "common/config-manager.h"
+#include "common/system.h"
namespace Common {
+// These magic numbers are provided by fuzzie and WebOS
+static const uint32 kDelayKeyboardEventMillis = 250;
+static const uint32 kDelayMouseEventMillis = 50;
+
void Keymapper::Domain::addKeymap(Keymap *map) {
iterator it = find(map->getName());
@@ -281,9 +286,9 @@ Action *Keymapper::getAction(const KeyState& key) {
List<Event> Keymapper::executeAction(const Action *action, IncomingEventType incomingType) {
List<Event> mappedEvents;
List<Event>::const_iterator it;
-
+ Event evt;
for (it = action->events.begin(); it != action->events.end(); ++it) {
- Event evt = Event(*it);
+ evt = Event(*it);
EventType convertedType = convertDownToUp(evt.type);
// hardware keys need to send up instead when they are up
@@ -294,15 +299,23 @@ List<Event> Keymapper::executeAction(const Action *action, IncomingEventType inc
}
evt.mouse = _eventMan->getMousePos();
- mappedEvents.push_back(evt);
+
+ // Check if the event is coming from a non-key hardware event
+ // that is mapped to a key event
+ if (incomingType == kIncomingNonKey && convertedType != EVENT_INVALID)
+ // WORKAROUND: Delay the down events coming from non-key hardware events
+ // with a zero delay. This is to prevent DOWN1 DOWN2 UP1 UP2.
+ addDelayedEvent(0, evt);
+ else
+ mappedEvents.push_back(evt);
// non-keys need to send up as well
- // TODO: implement a way to add a delay
- if (incomingType == kIncomingNonKey) {
- if (convertedType == EVENT_INVALID)
- continue; // don't send any non-down-converted events on up they were already sent on down
+ if (incomingType == kIncomingNonKey && convertedType != EVENT_INVALID) {
+ // WORKAROUND: Delay the up events coming from non-key hardware events
+ // This is for engines that run scripts that check on key being down
evt.type = convertedType;
- mappedEvents.push_back(evt);
+ const uint32 delay = (convertedType == EVENT_KEYUP ? kDelayKeyboardEventMillis : kDelayMouseEventMillis);
+ addDelayedEvent(delay, evt);
}
}
return mappedEvents;