aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
authorCameron Cawley2019-11-03 22:33:06 +0000
committerDavid Turner2019-11-30 20:50:27 +0000
commit00fecbb6e638a943c6f45cca84986ba38803ad91 (patch)
treef988c3635c90ef6aa9be0372a34bca310358dad1 /backends/events
parent54e6cf4cda16cfbb4ea5e3b728188fb837468279 (diff)
downloadscummvm-rg350-00fecbb6e638a943c6f45cca84986ba38803ad91.tar.gz
scummvm-rg350-00fecbb6e638a943c6f45cca84986ba38803ad91.tar.bz2
scummvm-rg350-00fecbb6e638a943c6f45cca84986ba38803ad91.zip
GPH/OPENPANDORA: Move ToggleTapMode() into the event manager
Diffstat (limited to 'backends/events')
-rw-r--r--backends/events/gph/gph-events.cpp43
-rw-r--r--backends/events/gph/gph-events.h4
-rw-r--r--backends/events/openpandora/op-events.cpp45
-rw-r--r--backends/events/openpandora/op-events.h3
4 files changed, 65 insertions, 30 deletions
diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp
index 18a4c6c32a..37627861b5 100644
--- a/backends/events/gph/gph-events.cpp
+++ b/backends/events/gph/gph-events.cpp
@@ -155,7 +155,20 @@ enum {
};
GPHEventSource::GPHEventSource()
- : _buttonStateL(false) {
+ : _buttonStateL(false),
+ _tapmodeLevel(TAPMODE_LEFT) {
+}
+
+void GPHEventSource::ToggleTapMode() {
+ if (_tapmodeLevel == TAPMODE_LEFT) {
+ _tapmodeLevel = TAPMODE_RIGHT;
+ } else if (_tapmodeLevel == TAPMODE_RIGHT) {
+ _tapmodeLevel = TAPMODE_HOVER;
+ } else if (_tapmodeLevel == TAPMODE_HOVER) {
+ _tapmodeLevel = TAPMODE_LEFT;
+ } else {
+ _tapmodeLevel = TAPMODE_LEFT;
+ }
}
/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */
@@ -164,11 +177,11 @@ bool GPHEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event)
if (ev.button.button == SDL_BUTTON_LEFT) {
if (_buttonStateL == true) /* _buttonStateL = Left Trigger Held, force Right Click */
event.type = Common::EVENT_RBUTTONDOWN;
- else if (GPH::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */
+ else if (_tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */
event.type = Common::EVENT_LBUTTONDOWN;
- else if (GPH::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */
+ else if (_tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */
event.type = Common::EVENT_RBUTTONDOWN;
- else if (GPH::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */
+ else if (_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. */
@@ -199,11 +212,11 @@ bool GPHEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT) {
if (_buttonStateL == true) /* _buttonStateL = Left Trigger Held, force Right Click */
event.type = Common::EVENT_RBUTTONUP;
- else if (GPH::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */
+ else if (_tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */
event.type = Common::EVENT_LBUTTONUP;
- else if (GPH::tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */
+ else if (_tapmodeLevel == TAPMODE_RIGHT) /* TAPMODE_RIGHT = Right Click Tap Mode */
event.type = Common::EVENT_RBUTTONUP;
- else if (GPH::tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */
+ else if (_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. */
@@ -383,12 +396,12 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
case BUTTON_Y:
event.type = Common::EVENT_KEYDOWN;
if (_buttonStateL == true) {
- GPH::ToggleTapMode();
- if (GPH::tapmodeLevel == TAPMODE_LEFT) {
+ ToggleTapMode();
+ if (_tapmodeLevel == TAPMODE_LEFT) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click"));
- } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
+ } else if (_tapmodeLevel == TAPMODE_RIGHT) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click"));
- } else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
+ } else if (_tapmodeLevel == TAPMODE_HOVER) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)"));
}
} else {
@@ -426,12 +439,12 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
event.type = Common::EVENT_QUIT;
break;
case BUTTON_HELP2:
- GPH::ToggleTapMode();
- if (GPH::tapmodeLevel == TAPMODE_LEFT) {
+ ToggleTapMode();
+ if (_tapmodeLevel == TAPMODE_LEFT) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click"));
- } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
+ } else if (_tapmodeLevel == TAPMODE_RIGHT) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click"));
- } else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
+ } else if (_tapmodeLevel == TAPMODE_HOVER) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)"));
}
break;
diff --git a/backends/events/gph/gph-events.h b/backends/events/gph/gph-events.h
index 507aa94828..bdcb62d8c2 100644
--- a/backends/events/gph/gph-events.h
+++ b/backends/events/gph/gph-events.h
@@ -39,6 +39,10 @@ protected:
*/
bool _buttonStateL;
+ int _tapmodeLevel;
+
+ void ToggleTapMode();
+
bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp
index fd5d2bc043..6302c15517 100644
--- a/backends/events/openpandora/op-events.cpp
+++ b/backends/events/openpandora/op-events.cpp
@@ -46,7 +46,22 @@ enum {
};
OPEventSource::OPEventSource()
- : _buttonStateL(false) {
+ : _buttonStateL(false),
+ _tapmodeLevel(TAPMODE_LEFT) {
+}
+
+void OPEventSource::ToggleTapMode() {
+ if (_tapmodeLevel == TAPMODE_LEFT) {
+ _tapmodeLevel = TAPMODE_RIGHT;
+ } else if (_tapmodeLevel == TAPMODE_RIGHT) {
+ _tapmodeLevel = TAPMODE_HOVER;
+ } else if (_tapmodeLevel == TAPMODE_HOVER) {
+ _tapmodeLevel = TAPMODE_HOVER_DPAD;
+ } else if (_tapmodeLevel == TAPMODE_HOVER_DPAD) {
+ _tapmodeLevel = TAPMODE_LEFT;
+ } else {
+ _tapmodeLevel = TAPMODE_LEFT;
+ }
}
/* Custom handleMouseButtonDown/handleMouseButtonUp to deal with 'Tap Mode' for the touchscreen */
@@ -55,13 +70,13 @@ bool OPEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT) {
if (_buttonStateL == true) /* _buttonStateL = Left Trigger Held, force Right Click */
event.type = Common::EVENT_RBUTTONDOWN;
- else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */
+ else if (_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 */
+ else if (_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 */
+ else if (_tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */
event.type = Common::EVENT_MOUSEMOVE;
- else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */
+ else if (_tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */
event.type = Common::EVENT_MOUSEMOVE;
else
event.type = Common::EVENT_LBUTTONDOWN; /* For normal mice etc. */
@@ -92,13 +107,13 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
if (ev.button.button == SDL_BUTTON_LEFT) {
if (_buttonStateL == true) /* _buttonStateL = Left Trigger Held, force Right Click */
event.type = Common::EVENT_RBUTTONUP;
- else if (OP::tapmodeLevel == TAPMODE_LEFT) /* TAPMODE_LEFT = Left Click Tap Mode */
+ else if (_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 */
+ else if (_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 */
+ else if (_tapmodeLevel == TAPMODE_HOVER) /* TAPMODE_HOVER = Hover (No Click) Tap Mode */
event.type = Common::EVENT_MOUSEMOVE;
- else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */
+ else if (_tapmodeLevel == TAPMODE_HOVER_DPAD) /* TAPMODE_HOVER_DPAD = Hover (DPad Clicks) Tap Mode */
event.type = Common::EVENT_MOUSEMOVE;
else
event.type = Common::EVENT_LBUTTONUP; /* For normal mice etc. */
@@ -125,7 +140,7 @@ bool OPEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
- if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) {
+ if (_tapmodeLevel == TAPMODE_HOVER_DPAD) {
switch (ev.key.keysym.sym) {
case SDLK_LEFT:
event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP;
@@ -166,14 +181,14 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
return true;
break;
case SDLK_PAGEUP:
- OP::ToggleTapMode();
- if (OP::tapmodeLevel == TAPMODE_LEFT) {
+ ToggleTapMode();
+ if (_tapmodeLevel == TAPMODE_LEFT) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Left Click"));
- } else if (OP::tapmodeLevel == TAPMODE_RIGHT) {
+ } else if (_tapmodeLevel == TAPMODE_RIGHT) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Right Click"));
- } else if (OP::tapmodeLevel == TAPMODE_HOVER) {
+ } else if (_tapmodeLevel == TAPMODE_HOVER) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (No Click)"));
- } else if (OP::tapmodeLevel == TAPMODE_HOVER_DPAD) {
+ } else if (_tapmodeLevel == TAPMODE_HOVER_DPAD) {
g_system->displayMessageOnOSD(_("Touchscreen 'Tap Mode' - Hover (DPad Clicks)"));
}
break;
diff --git a/backends/events/openpandora/op-events.h b/backends/events/openpandora/op-events.h
index e45ac80e2a..aebd376ada 100644
--- a/backends/events/openpandora/op-events.h
+++ b/backends/events/openpandora/op-events.h
@@ -40,6 +40,9 @@ protected:
*/
bool _buttonStateL;
+ int _tapmodeLevel;
+
+ void ToggleTapMode();
bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);