aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
Diffstat (limited to 'backends/events')
-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);