diff options
Diffstat (limited to 'backends/events/openpandora/op-events.cpp')
-rw-r--r-- | backends/events/openpandora/op-events.cpp | 126 |
1 files changed, 64 insertions, 62 deletions
diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index 4b67cbf432..72bc56c95d 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -24,7 +24,6 @@ /* * OpenPandora: Device Specific Event Handling. - * */ #if defined(OPENPANDORA) @@ -35,6 +34,8 @@ #include "backends/platform/openpandora/op-options.h" #include "common/translation.h" +#include "common/util.h" +#include "common/events.h" /* Quick default button states for modifiers. */ int BUTTON_STATE_L = false; @@ -50,6 +51,68 @@ OPEventSource::OPEventSource() : _buttonStateL(false){ } +/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */ + +bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { + if (ev.button.button == SDL_BUTTON_LEFT){ + if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ + event.type = Common::EVENT_RBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ + event.type = Common::EVENT_LBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ + event.type = Common::EVENT_RBUTTONDOWN; + else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; + else + event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */ + } + else if (ev.button.button == SDL_BUTTON_RIGHT) + event.type = Common::EVENT_RBUTTONDOWN; +#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN) + else if (ev.button.button == SDL_BUTTON_WHEELUP) + event.type = Common::EVENT_WHEELUP; + else if (ev.button.button == SDL_BUTTON_WHEELDOWN) + event.type = Common::EVENT_WHEELDOWN; +#endif +#if defined(SDL_BUTTON_MIDDLE) + else if (ev.button.button == SDL_BUTTON_MIDDLE) + event.type = Common::EVENT_MBUTTONDOWN; +#endif + else + return false; + + fillMouseEvent(event, ev.button.x, ev.button.y); + + return true; +} + +bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { + if (ev.button.button == SDL_BUTTON_LEFT){ + if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ + event.type = Common::EVENT_RBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ + event.type = Common::EVENT_LBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ + event.type = Common::EVENT_RBUTTONUP; + else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ + event.type = Common::EVENT_MOUSEMOVE; + else + event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */ + } + else if (ev.button.button == SDL_BUTTON_RIGHT) + event.type = Common::EVENT_RBUTTONUP; +#if defined(SDL_BUTTON_MIDDLE) + else if (ev.button.button == SDL_BUTTON_MIDDLE) + event.type = Common::EVENT_MBUTTONUP; +#endif + else + return false; + + fillMouseEvent(event, ev.button.x, ev.button.y); + + return true; +} + /* On the OpenPandora by default the ABXY and L/R Trigger buttons are returned by SDL as (A): SDLK_HOME (B): SDLK_END (X): SDLK_PAGEDOWN (Y): SDLK_PAGEUP (L): SDLK_RSHIFT (R): SDLK_RCTRL */ @@ -124,65 +187,4 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { return false; } -/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */ - -bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) { - if (ev.button.button == SDL_BUTTON_LEFT){ - if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ - event.type = Common::EVENT_RBUTTONDOWN; - else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ - event.type = Common::EVENT_LBUTTONDOWN; - else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ - event.type = Common::EVENT_RBUTTONDOWN; - else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ - event.type = Common::EVENT_MOUSEMOVE; - else - event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */ - } - else if (ev.button.button == SDL_BUTTON_RIGHT) - event.type = Common::EVENT_RBUTTONDOWN; -#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN) - else if (ev.button.button == SDL_BUTTON_WHEELUP) - event.type = Common::EVENT_WHEELUP; - else if (ev.button.button == SDL_BUTTON_WHEELDOWN) - event.type = Common::EVENT_WHEELDOWN; -#endif -#if defined(SDL_BUTTON_MIDDLE) - else if (ev.button.button == SDL_BUTTON_MIDDLE) - event.type = Common::EVENT_MBUTTONDOWN; -#endif - else - return false; - - fillMouseEvent(event, ev.button.x, ev.button.y); - - return true; -} - -bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { - if (ev.button.button == SDL_BUTTON_LEFT){ - if (BUTTON_STATE_L == true) /* BUTTON_STATE_L = Left Trigger Held, force Right Click */ - event.type = Common::EVENT_RBUTTONUP; - else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */ - event.type = Common::EVENT_LBUTTONUP; - else if (OP::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */ - event.type = Common::EVENT_RBUTTONUP; - else if (OP::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */ - event.type = Common::EVENT_MOUSEMOVE; - else - event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */ - } - else if (ev.button.button == SDL_BUTTON_RIGHT) - event.type = Common::EVENT_RBUTTONUP; -#if defined(SDL_BUTTON_MIDDLE) - else if (ev.button.button == SDL_BUTTON_MIDDLE) - event.type = Common::EVENT_MBUTTONUP; -#endif - else - return false; - - fillMouseEvent(event, ev.button.x, ev.button.y); - - return true; -} #endif |