Skip to content

Commit

Permalink
Improve 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 a06f7b4 commit 1fe4c7e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -382,6 +382,7 @@ set(LDFLAGS
freetype
ssl
crypto
mikmod
)

if (BUILD_DEBUG)
Expand Down
4 changes: 4 additions & 0 deletions README.MD
Expand Up @@ -95,6 +95,10 @@ make enigma.vpk -j10

Changelog
=====
1.10

- Improve response to slow finger motion

1.09

- Improve controls with bluetooth mouse by re-compiling with latest SDL-Vita
Expand Down
43 changes: 25 additions & 18 deletions src/psp2/psp2_touch.c
Expand Up @@ -26,6 +26,8 @@ int mainMenu_touchControls = 2; // always enable rear_touch for now
extern int lastmx;
extern int lastmy;
extern int insideMenu;
static int hiresdx = 0;
static int hiresdy = 0;

enum {
MAX_NUM_FINGERS = 3, // number of fingers to track per panel
Expand Down Expand Up @@ -346,14 +348,6 @@ void psp2ProcessFingerMotion(TouchEvent *event) {
}

if (numFingersDown >= 1) {
int x = lastmx;
int y = lastmy;
int xrel = (int)(event->tfinger.dx * 960.0);
int yrel = (int)(event->tfinger.dy * 544.0);

x = lastmx + (int)(event->tfinger.dx * 960.0);
y = lastmy + (int)(event->tfinger.dy * 544.0);

// If we are starting a multi-finger drag, start holding down the mouse button
if (numFingersDown >= 2) {
if (!_multiFingerDragging[port]) {
Expand Down Expand Up @@ -404,16 +398,29 @@ void psp2ProcessFingerMotion(TouchEvent *event) {
}
}
if (updatePointer) {
if (insideMenu) {
SDL_WarpMouse(x, y);
} else {
SDL_Event ev0;
ev0.type = SDL_MOUSEMOTION;
ev0.motion.x = x;
ev0.motion.y = y;
ev0.motion.xrel = xrel;
ev0.motion.yrel = yrel;
SDL_PushEvent(&ev0);
const int slowdown = 16;
hiresdx += (int)(event->tfinger.dx * 960.0 * slowdown);
hiresdy += (int)(event->tfinger.dy * 544.0 * slowdown);
int xrel = hiresdx / slowdown;
int yrel = hiresdy / slowdown;

if (xrel || yrel) {
int x = lastmx + xrel;
int y = lastmy + yrel;
if (insideMenu) {
SDL_WarpMouse(x, y);
} else {
SDL_Event ev0;
ev0.type = SDL_MOUSEMOTION;
ev0.motion.x = x;
ev0.motion.y = y;
ev0.motion.xrel = xrel;
ev0.motion.yrel = yrel;
SDL_PushEvent(&ev0);
}

hiresdx %= slowdown;
hiresdy %= slowdown;
}
}
}
Expand Down

0 comments on commit 1fe4c7e

Please sign in to comment.