From e07a224a9a899055dc2b95b23e7740e250a748a1 Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 20 Apr 2014 03:31:50 +0100 Subject: 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. --- common/EventMapper.cpp | 19 ++++++++++++++++--- 1 file 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 DefaultEventMapper::mapEvent(const Event &ev, EventSource *source) { List 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 -- cgit v1.2.3