Skip to content

Commit

Permalink
PSP2: Improve pointer response to slow finger motion
Browse files Browse the repository at this point in the history
  • Loading branch information
rsn8887 committed Jul 15, 2018
1 parent be4e4ac commit eb49ef0
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 12 additions & 5 deletions backends/events/psp2sdl/psp2sdl-events.cpp
Expand Up @@ -50,6 +50,9 @@ PSP2EventSource::PSP2EventSource() {
_simulatedClickStartTime[port][i] = 0;
}
}

_hiresDX = 0;
_hiresDY = 0;
}

bool PSP2EventSource::pollEvent(Common::Event &event) {
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions backends/events/psp2sdl/psp2sdl-events.h
Expand Up @@ -65,6 +65,9 @@ class PSP2EventSource : public SdlEventSource {

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);
Expand Down

0 comments on commit eb49ef0

Please sign in to comment.