diff options
-rw-r--r-- | common/EventMapper.cpp | 19 |
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 |