[Scummvm-git-logs] scummvm master -> bfef3da347490d4caaf2ced4b8dd70a40fc47531

rsn8887 rsn8887 at users.noreply.github.com
Tue Feb 13 20:32:21 CET 2018


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bfef3da347 PSP2: Implement three-finger drag as right-mouse button drag


Commit: bfef3da347490d4caaf2ced4b8dd70a40fc47531
    https://github.com/scummvm/scummvm/commit/bfef3da347490d4caaf2ced4b8dd70a40fc47531
Author: rsn8887 (rsn8887 at users.noreply.github.com)
Date: 2018-02-13T13:32:04-06:00

Commit Message:
PSP2: Implement three-finger drag as right-mouse button drag

Changed paths:
    backends/events/psp2sdl/psp2sdl-events.cpp
    backends/events/psp2sdl/psp2sdl-events.h


diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp
index 0b7f741..5b0b607 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 eee862d..2f27208 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);





More information about the Scummvm-git-logs mailing list