aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
authorrsn88872018-03-28 00:11:32 -0500
committerrsn88872018-03-28 00:13:32 -0500
commit880081aa2c475c0a8e7cf67a7cdbe6f53d05d1f4 (patch)
treefeabbf3565c027c8f3aa4e0f3e051238b32a7aa8 /backends/events
parent2be2339a21eb244d5122f798397efe23cffebdc7 (diff)
downloadscummvm-rg350-880081aa2c475c0a8e7cf67a7cdbe6f53d05d1f4.tar.gz
scummvm-rg350-880081aa2c475c0a8e7cf67a7cdbe6f53d05d1f4.tar.bz2
scummvm-rg350-880081aa2c475c0a8e7cf67a7cdbe6f53d05d1f4.zip
PSP2: make touch mouse clicks longer so all games receive them
Some games such as Gobliins or Dreamweb did not react to the simulated touch mouse clicks because the clicks were too short. This change ensures all games see the simulated clicks by giving each click a minimum duration of 50 ms instead of being as fast as possible.
Diffstat (limited to 'backends/events')
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.cpp48
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.h5
2 files changed, 46 insertions, 7 deletions
diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp
index a8a179d170..a342fa836b 100644
--- a/backends/events/psp2sdl/psp2sdl-events.cpp
+++ b/backends/events/psp2sdl/psp2sdl-events.cpp
@@ -44,6 +44,17 @@ PSP2EventSource::PSP2EventSource() {
}
_multiFingerDragging[port] = DRAG_NONE;
}
+
+ for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
+ for (int i = 0; i < 2; i++) {
+ _simulatedClickStartTime[port][i] = 0;
+ }
+ }
+}
+
+bool PSP2EventSource::pollEvent(Common::Event &event) {
+ finishSimulatedMouseClicks();
+ return SdlEventSource::pollEvent(event);
}
void PSP2EventSource::preprocessEvents(SDL_Event *event) {
@@ -148,8 +159,12 @@ void PSP2EventSource::preprocessFingerUp(SDL_Event *event) {
Uint8 simulatedButton = 0;
if (numFingersDown == 2) {
simulatedButton = SDL_BUTTON_RIGHT;
+ // need to raise the button later
+ _simulatedClickStartTime[port][1] = event->tfinger.timestamp;
} else if (numFingersDown == 1) {
simulatedButton = SDL_BUTTON_LEFT;
+ // need to raise the button later
+ _simulatedClickStartTime[port][0] = event->tfinger.timestamp;
if (port == 0 && !ConfMan.getBool("frontpanel_touchpad_mode")) {
convertTouchXYToGameXY(event->tfinger.x, event->tfinger.y, &x, &y);
}
@@ -159,13 +174,6 @@ void PSP2EventSource::preprocessFingerUp(SDL_Event *event) {
event->button.button = simulatedButton;
event->button.x = x;
event->button.y = y;
-
- SDL_Event ev;
- ev.type = SDL_MOUSEBUTTONUP;
- ev.button.button = simulatedButton;
- ev.button.x = x;
- ev.button.y = y;
- SDL_PushEvent(&ev);
}
}
}
@@ -424,4 +432,30 @@ void PSP2EventSource::convertTouchXYToGameXY(float touchX, float touchY, int *ga
*gameY = _km.y_max;
}
}
+
+void PSP2EventSource::finishSimulatedMouseClicks() {
+ for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
+ for (int i = 0; i < 2; i++) {
+ if (_simulatedClickStartTime[port][i] != 0) {
+ Uint32 currentTime = SDL_GetTicks();
+ if (currentTime - _simulatedClickStartTime[port][i] >= SIMULATED_CLICK_DURATION) {
+ int simulatedButton;
+ if (i == 0) {
+ simulatedButton = SDL_BUTTON_LEFT;
+ } else {
+ simulatedButton = SDL_BUTTON_RIGHT;
+ }
+ SDL_Event ev;
+ ev.type = SDL_MOUSEBUTTONUP;
+ ev.button.button = simulatedButton;
+ ev.button.x = _km.x / MULTIPLIER;
+ ev.button.y = _km.y / MULTIPLIER;
+ SDL_PushEvent(&ev);
+
+ _simulatedClickStartTime[port][i] = 0;
+ }
+ }
+ }
+ }
+}
#endif
diff --git a/backends/events/psp2sdl/psp2sdl-events.h b/backends/events/psp2sdl/psp2sdl-events.h
index 391d03dd3f..1d5fdf9d50 100644
--- a/backends/events/psp2sdl/psp2sdl-events.h
+++ b/backends/events/psp2sdl/psp2sdl-events.h
@@ -32,6 +32,7 @@
class PSP2EventSource : public SdlEventSource {
public:
PSP2EventSource();
+ bool pollEvent(Common::Event &event) override;
protected:
void preprocessEvents(SDL_Event *event) override;
private:
@@ -40,6 +41,7 @@ private:
MAX_NUM_FINGERS = 3, // number of fingers to track per panel
MAX_TAP_TIME = 250, // taps longer than this will not result in mouse click events
MAX_TAP_MOTION_DISTANCE = 10, // max distance finger motion in Vita screen pixels to be considered a tap
+ SIMULATED_CLICK_DURATION = 50, // time in ms how long simulated mouse clicks should be
}; // track three fingers per panel
typedef struct {
@@ -61,10 +63,13 @@ private:
DraggingType _multiFingerDragging[SCE_TOUCH_PORT_MAX_NUM]; // keep track whether we are currently drag-and-dropping
+ unsigned int _simulatedClickStartTime[SCE_TOUCH_PORT_MAX_NUM][2]; // initiation time of last simulated left or right click (zero if no click)
+
void preprocessFingerDown(SDL_Event *event);
void preprocessFingerUp(SDL_Event *event);
void preprocessFingerMotion(SDL_Event *event);
void convertTouchXYToGameXY(float touchX, float touchY, int *gameX, int *gameY);
+ void finishSimulatedMouseClicks(void);
};
#endif /* BACKEND_EVENTS_PSP2_H */