aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorD G Turner2014-04-20 03:31:50 +0100
committerD G Turner2014-04-22 05:29:54 +0100
commite07a224a9a899055dc2b95b23e7740e250a748a1 (patch)
treea3a073c90ffd4cd03025b024e1c7d6347ad99c1e
parent5e6d05c816ce5dce1f9d4273f53cfd1369a908e3 (diff)
downloadscummvm-rg350-e07a224a9a899055dc2b95b23e7740e250a748a1.tar.gz
scummvm-rg350-e07a224a9a899055dc2b95b23e7740e250a748a1.tar.bz2
scummvm-rg350-e07a224a9a899055dc2b95b23e7740e250a748a1.zip
VKEYBD: Modify code to open vkeybd on long press of middle mouse button.
This should massively reduce any chance of a conflict with mouse usage in games and is still easy for a person with mobility issues to perform.
-rw-r--r--common/EventMapper.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/common/EventMapper.cpp b/common/EventMapper.cpp
index de1907d141..36feedf726 100644
--- a/common/EventMapper.cpp
+++ b/common/EventMapper.cpp
@@ -31,11 +31,24 @@ List<Event> DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) {
List<Event> events;
Event mappedEvent;
#ifdef ENABLE_VKEYBD
+ // Trigger virtual keyboard on long press of more than 1 second
+ // of middle mouse button.
+ const uint32 vkeybdTime = 1000;
+
+ static bool vkeybd = false;
+ static uint32 vkeybdThen = 0;
+
+ if (ev.type == EVENT_MBUTTONDOWN) {
+ vkeybdThen = g_system->getMillis();
+ }
+
if (ev.type == EVENT_MBUTTONUP) {
- mappedEvent.type = EVENT_VIRTUAL_KEYBOARD;
+ if ((g_system->getMillis() - vkeybdThen) >= vkeybdTime) {
+ mappedEvent.type = EVENT_VIRTUAL_KEYBOARD;
- // Avoid blocking event from engine.
- addDelayedEvent(100, ev);
+ // Avoid blocking event from engine.
+ addDelayedEvent(100, ev);
+ }
}
#endif