aboutsummaryrefslogtreecommitdiff
path: root/backends/events/psp2sdl
diff options
context:
space:
mode:
authorrsn88872018-02-13 11:30:44 -0600
committerrsn88872018-02-13 13:32:04 -0600
commitbfef3da347490d4caaf2ced4b8dd70a40fc47531 (patch)
treeb3a26547ff6e6f6649d9bcd67bdd3bd906a813f9 /backends/events/psp2sdl
parenta5fcdb55da40592718811caee82160ca97681ff9 (diff)
downloadscummvm-rg350-bfef3da347490d4caaf2ced4b8dd70a40fc47531.tar.gz
scummvm-rg350-bfef3da347490d4caaf2ced4b8dd70a40fc47531.tar.bz2
scummvm-rg350-bfef3da347490d4caaf2ced4b8dd70a40fc47531.zip
PSP2: Implement three-finger drag as right-mouse button drag
Diffstat (limited to 'backends/events/psp2sdl')
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.cpp39
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.h10
2 files changed, 39 insertions, 10 deletions
diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp
index 0b7f741615..5b0b6074fb 100644
--- a/backends/events/psp2sdl/psp2sdl-events.cpp
+++ b/backends/events/psp2sdl/psp2sdl-events.cpp
@@ -42,7 +42,7 @@ PSP2EventSource::PSP2EventSource() {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
_finger[port][i].id = -1;
}
- _multiFingerDragging[port] = false;
+ _multiFingerDragging[port] = DRAG_NONE;
}
}
@@ -93,6 +93,13 @@ void PSP2EventSource::preprocessFingerDown(SDL_Event *event) {
convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
}
+ // make sure each finger is not reported down multiple times
+ for (int i = 0; i < MAX_NUM_FINGERS; i++) {
+ if (_finger[port][i].id == id) {
+ _finger[port][i].id = -1;
+ }
+ }
+
// we need the timestamps to decide later if the user performed a short tap (click)
// or a long tap (drag)
// we also need the last coordinates for each finger to keep track of dragging
@@ -159,11 +166,17 @@ void PSP2EventSource::preprocessFingerUp(SDL_Event *event) {
if (port == 0 && !ConfMan.getBool("frontpanel_touchpad_mode")) {
convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
}
+ Uint8 simulatedButton = 0;
+ if (_multiFingerDragging[port] == DRAG_THREE_FINGER)
+ simulatedButton = SDL_BUTTON_RIGHT;
+ else {
+ simulatedButton = SDL_BUTTON_LEFT;
+ }
event->type = SDL_MOUSEBUTTONUP;
- event->button.button = SDL_BUTTON_LEFT;
+ event->button.button = simulatedButton;
event->button.x = x;
event->button.y = y;
- _multiFingerDragging[port] = false;
+ _multiFingerDragging[port] = DRAG_NONE;
}
}
}
@@ -272,29 +285,39 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
if (numFingersDownLong >= 2) {
// starting drag, so push mouse down at current location (back)
// or location of "oldest" finger (front)
- int mouseDownX = x;
- int mouseDownY = y;
+ int mouseDownX = _km.x / MULTIPLIER;
+ int mouseDownY = _km.y / MULTIPLIER;
if (port == 0 && !ConfMan.getBool("frontpanel_touchpad_mode")) {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
+ Uint32 earliestTime = _finger[port][i].timeLastDown;
for (int j = 0; j < MAX_NUM_FINGERS; j++) {
if (_finger[port][j].id >= 0 && (i != j) ) {
- if (_finger[port][j].timeLastDown < _finger[port][i].timeLastDown) {
+ if (_finger[port][j].timeLastDown < earliestTime) {
mouseDownX = _finger[port][j].lastX;
mouseDownY = _finger[port][j].lastY;
+ earliestTime = _finger[port][j].timeLastDown;
}
}
}
+ break;
}
}
}
+ Uint8 simulatedButton = 0;
+ if (numFingersDownLong == 2) {
+ simulatedButton = SDL_BUTTON_LEFT;
+ _multiFingerDragging[port] = DRAG_TWO_FINGER;
+ } else {
+ simulatedButton = SDL_BUTTON_RIGHT;
+ _multiFingerDragging[port] = DRAG_THREE_FINGER;
+ }
SDL_Event ev;
ev.type = SDL_MOUSEBUTTONDOWN;
- ev.button.button = SDL_BUTTON_LEFT;
+ ev.button.button = simulatedButton;
ev.button.x = mouseDownX;
ev.button.y = mouseDownY;
SDL_PushEvent(&ev);
- _multiFingerDragging[port] = true;
}
}
}
diff --git a/backends/events/psp2sdl/psp2sdl-events.h b/backends/events/psp2sdl/psp2sdl-events.h
index eee862d7c7..2f27208f61 100644
--- a/backends/events/psp2sdl/psp2sdl-events.h
+++ b/backends/events/psp2sdl/psp2sdl-events.h
@@ -43,14 +43,20 @@ private:
typedef struct {
int id; // -1: no touch
- int timeLastDown;
+ Uint32 timeLastDown;
int lastX; // last known screen coordinates
int lastY; // last known screen coordinates
} Touch;
Touch _finger[SCE_TOUCH_PORT_MAX_NUM][MAX_NUM_FINGERS]; // keep track of finger status
- bool _multiFingerDragging[SCE_TOUCH_PORT_MAX_NUM]; // keep track whether we are currently drag-and-dropping
+ typedef enum DraggingType {
+ DRAG_NONE = 0,
+ DRAG_TWO_FINGER,
+ DRAG_THREE_FINGER,
+ } DraggingType;
+
+ DraggingType _multiFingerDragging[SCE_TOUCH_PORT_MAX_NUM]; // keep track whether we are currently drag-and-dropping
void preprocessFingerDown(SDL_Event *event);
void preprocessFingerUp(SDL_Event *event);