diff options
Diffstat (limited to 'backends/events/webossdl/webossdl-events.cpp')
-rw-r--r-- | backends/events/webossdl/webossdl-events.cpp | 74 |
1 files changed, 66 insertions, 8 deletions
diff --git a/backends/events/webossdl/webossdl-events.cpp b/backends/events/webossdl/webossdl-events.cpp index 78021965c2..e1db808035 100644 --- a/backends/events/webossdl/webossdl-events.cpp +++ b/backends/events/webossdl/webossdl-events.cpp @@ -30,26 +30,84 @@ #include "backends/events/webossdl/webossdl-events.h" +static int mouseButton = 0; + +// WebOS devices only have a shift key and a ctrl key. There is also an alt +// key (the orange key) but this is already processed by WebOS to change the +// mode of the keys so ScummVM must not use this key as a modifier. +void WebOSSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) { + event.kbd.flags = 0; + + if (mod & KMOD_SHIFT) + event.kbd.flags |= Common::KBD_SHIFT; + if (mod & KMOD_CTRL) + event.kbd.flags |= Common::KBD_CTRL; +} + +// Capture Shift and Control to decide the active mouse button bool WebOSSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { + int sym = ev.key.keysym.sym; switch (ev.type) { - case SDL_KEYDOWN:{ - if (ev.key.keysym.sym == 231) { - printf("metatap down\n"); + case SDL_KEYDOWN: + if (sym == 304) { + mouseButton = 1; + return true; + } + else if (sym == 305) { + mouseButton = 2; return true; } break; - } - case SDL_KEYUP: { - if (ev.key.keysym.sym == 231) { - printf("metatap up\n"); + case SDL_KEYUP: + if (sym == 304 || sym == 305) { + mouseButton = 0; return true; } break; - } } // Invoke parent implementation of this method return SdlEventSource::remapKey(ev, event); } +bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { + // Simulate right mouse button + if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 1) { + event.type = Common::EVENT_RBUTTONDOWN; + fillMouseEvent(event, ev.button.x, ev.button.y); + printf("rbutton down\n"); + return true; + } + + // Simulate middle mouse button + if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 2) { + event.type = Common::EVENT_MBUTTONDOWN; + fillMouseEvent(event, ev.button.x, ev.button.y); + printf("rbutton down\n"); + return true; + } + + // Invoke parent implementation of this method + return SdlEventSource::handleMouseButtonDown(ev, event); +} + +bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { + // Simulate right mouse button + if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 1) { + event.type = Common::EVENT_RBUTTONUP; + fillMouseEvent(event, ev.button.x, ev.button.y); + return true; + } + + // Simulate right mouse button + if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 2) { + event.type = Common::EVENT_MBUTTONUP; + fillMouseEvent(event, ev.button.x, ev.button.y); + return true; + } + + // Invoke parent implementation of this method + return SdlEventSource::handleMouseButtonUp(ev, event); +} + #endif |