diff options
author | Klaus Reimer | 2011-04-06 22:43:21 +0200 |
---|---|---|
committer | Max Horn | 2011-04-12 11:05:53 +0200 |
commit | aa79a2634d94ad98e1e32aaa923c2cd9fbe99893 (patch) | |
tree | 96758526cf6fa32cc732c8088c70da81b6e0b26d /backends/events/webossdl | |
parent | 48dbbdcd74e4e0f8b21d77fb9850d348a082c03d (diff) | |
download | scummvm-rg350-aa79a2634d94ad98e1e32aaa923c2cd9fbe99893.tar.gz scummvm-rg350-aa79a2634d94ad98e1e32aaa923c2cd9fbe99893.tar.bz2 scummvm-rg350-aa79a2634d94ad98e1e32aaa923c2cd9fbe99893.zip |
WEBOS: Enable keymapper, implement FORWARD key and right+middle button clicks
Diffstat (limited to 'backends/events/webossdl')
-rw-r--r-- | backends/events/webossdl/webossdl-events.cpp | 74 | ||||
-rw-r--r-- | backends/events/webossdl/webossdl-events.h | 3 |
2 files changed, 69 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 diff --git a/backends/events/webossdl/webossdl-events.h b/backends/events/webossdl/webossdl-events.h index 77921f6f63..fc37fb8c5a 100644 --- a/backends/events/webossdl/webossdl-events.h +++ b/backends/events/webossdl/webossdl-events.h @@ -33,7 +33,10 @@ */ class WebOSSdlEventSource : public SdlEventSource { protected: + virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event); virtual bool remapKey(SDL_Event &ev, Common::Event &event); + virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event); + virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event); }; #endif |