aboutsummaryrefslogtreecommitdiff
path: root/backends
diff options
context:
space:
mode:
authorrsn88872018-07-15 02:01:02 -0500
committerrsn88872018-07-15 03:30:42 -0500
commiteb49ef0626bc007d0cc37957510414a566c9d032 (patch)
tree4b6c93043e555f4bf2e5fda990d7e2c179cef223 /backends
parentbe4e4ac84ebbe292680ca61ea85b4f19785c696f (diff)
downloadscummvm-rg350-eb49ef0626bc007d0cc37957510414a566c9d032.tar.gz
scummvm-rg350-eb49ef0626bc007d0cc37957510414a566c9d032.tar.bz2
scummvm-rg350-eb49ef0626bc007d0cc37957510414a566c9d032.zip
PSP2: Improve pointer response to slow finger motion
Diffstat (limited to 'backends')
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.cpp17
-rw-r--r--backends/events/psp2sdl/psp2sdl-events.h3
2 files changed, 15 insertions, 5 deletions
diff --git a/backends/events/psp2sdl/psp2sdl-events.cpp b/backends/events/psp2sdl/psp2sdl-events.cpp
index a342fa836b..4095678f1f 100644
--- a/backends/events/psp2sdl/psp2sdl-events.cpp
+++ b/backends/events/psp2sdl/psp2sdl-events.cpp
@@ -50,6 +50,9 @@ PSP2EventSource::PSP2EventSource() {
_simulatedClickStartTime[port][i] = 0;
}
}
+
+ _hiresDX = 0;
+ _hiresDY = 0;
}
bool PSP2EventSource::pollEvent(Common::Event &event) {
@@ -260,11 +263,15 @@ void PSP2EventSource::preprocessFingerMotion(SDL_Event *event) {
}
// convert touch events to relative mouse pointer events
- // Whenever an SDL_event involving the mouse is processed,
- // _km.x/y are truncated from subpixel precision to regular pixel precision.
- // Therefore, there's no need here to deal with subpixel precision in _km.x/y.
- x = (_km.x / MULTIPLIER + (event->tfinger.dx * 1.25 * speedFactor * _km.x_max));
- y = (_km.y / MULTIPLIER + (event->tfinger.dy * 1.25 * speedFactor * _km.y_max));
+ // track sub-pixel relative finger motion using the MULTIPLIER
+ _hiresDX += (event->tfinger.dx * 1.25 * speedFactor * _km.x_max * MULTIPLIER);
+ _hiresDY += (event->tfinger.dy * 1.25 * speedFactor * _km.y_max * MULTIPLIER);
+ int xRel = _hiresDX / MULTIPLIER;
+ int yRel = _hiresDY / MULTIPLIER;
+ x = (_km.x / MULTIPLIER) + xRel;
+ y = (_km.y / MULTIPLIER) + yRel;
+ _hiresDX %= MULTIPLIER;
+ _hiresDY %= MULTIPLIER;
}
if (x > _km.x_max) {
diff --git a/backends/events/psp2sdl/psp2sdl-events.h b/backends/events/psp2sdl/psp2sdl-events.h
index 1d5fdf9d50..f37d51c46b 100644
--- a/backends/events/psp2sdl/psp2sdl-events.h
+++ b/backends/events/psp2sdl/psp2sdl-events.h
@@ -65,6 +65,9 @@ private:
unsigned int _simulatedClickStartTime[SCE_TOUCH_PORT_MAX_NUM][2]; // initiation time of last simulated left or right click (zero if no click)
+ int _hiresDX; // keep track of slow, sub-pixel, finger motion across multiple frames
+ int _hiresDY;
+
void preprocessFingerDown(SDL_Event *event);
void preprocessFingerUp(SDL_Event *event);
void preprocessFingerMotion(SDL_Event *event);