From d9873febb51c0fac5086f62900c0ca963aa91c3f Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Wed, 21 Dec 2016 10:14:04 -0600 Subject: [PATCH] VITA: fixed analog mouse control deadzone and responsiveness --- src/custom.cpp | 30 +++++++++++++++--------------- src/od-joy.cpp | 8 ++++---- src/sdlgfx.cpp | 20 ++++++++++---------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/custom.cpp b/src/custom.cpp index 60d2e2c..b4628aa 100755 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -2092,7 +2092,7 @@ static _INLINE_ void mousehack_setdontcare (void) write_log ("Don't care mouse mode set\n"); mousestate = dont_care_mouse; - lastspr0x = lastmx; lastspr0y = lastmy; + lastspr0x = lastmx/16; lastspr0y = lastmy/16; mstepx = defstepx; mstepy = defstepy; } @@ -2114,16 +2114,16 @@ static _INLINE_ uae_u32 mousehack_helper (void) { /* @@@ This isn't completely right, it doesn't deal with virtual screen sizes larger than physical very well. */ - if (lastmy >= PREFS_GFX_HEIGHT) - lastmy = PREFS_GFX_HEIGHT - 1; + if (lastmy/16 >= PREFS_GFX_HEIGHT) + lastmy = 16 * (PREFS_GFX_HEIGHT - 1); if (lastmy < 0) lastmy = 0; if (lastmx < 0) lastmx = 0; - if (lastmx >= PREFS_GFX_WIDTH) - lastmx = PREFS_GFX_WIDTH - 1; - mouseypos = coord_native_to_amiga_y (lastmy) << 1; - mousexpos = coord_native_to_amiga_x (lastmx); + if (lastmx/16 >= PREFS_GFX_WIDTH) + lastmx = 16 * (PREFS_GFX_WIDTH - 1); + mouseypos = coord_native_to_amiga_y (lastmy/16) << 1; + mousexpos = coord_native_to_amiga_x (lastmx/16); } switch (_68k_dreg (0)) { @@ -2171,8 +2171,8 @@ static _INLINE_ void do_mouse_hack (void) switch (mousestate) { case normal_mouse: - diffx = lastmx - lastsampledmx; - diffy = lastmy - lastsampledmy; + diffx = lastmx/16 - lastsampledmx; + diffy = lastmy/16 - lastsampledmy; if (!newmousecounters) { if (diffx > 127) @@ -2190,10 +2190,10 @@ static _INLINE_ void do_mouse_hack (void) break; case dont_care_mouse: - diffx = adjust (((lastmx - lastspr0x) * mstepx) >> 16); - diffy = adjust (((lastmy - lastspr0y) * mstepy) >> 16); - lastspr0x = lastmx; - lastspr0y = lastmy; + diffx = adjust (((lastmx/16 - lastspr0x) * mstepx) >> 16); + diffy = adjust (((lastmy/16 - lastspr0y) * mstepy) >> 16); + lastspr0x = lastmx/16; + lastspr0y = lastmy/16; mouse_x += diffx; mouse_y += diffy; break; @@ -2205,8 +2205,8 @@ static _INLINE_ void do_mouse_hack (void) if (sprvbfl && (sprvbfl-- > 1)) { int stylusxpos, stylusypos; - stylusxpos = coord_native_to_amiga_x (lastmx); - stylusypos = coord_native_to_amiga_y (lastmy) << 1; + stylusxpos = coord_native_to_amiga_x (lastmx/16); + stylusypos = coord_native_to_amiga_y (lastmy/16) << 1; if(stylusxpos != spr0x || stylusypos != spr0y) { diffx = (stylusxpos - spr0x); diff --git a/src/od-joy.cpp b/src/od-joy.cpp index b12b6a1..88a2849 100755 --- a/src/od-joy.cpp +++ b/src/od-joy.cpp @@ -98,8 +98,8 @@ void read_joystick(int nr, unsigned int *dir, int *button) } #endif */ - int mouseScale = mainMenu_mouseMultiplier * 4; - if (mouseScale > 99) + int mouseScale = mainMenu_mouseMultiplier * 4 * 16; + if (mouseScale > (99*16)) mouseScale /= 100; #ifdef USE_UAE4ALL_VKBD @@ -115,7 +115,7 @@ void read_joystick(int nr, unsigned int *dir, int *button) #endif { if (buttonY) - mouseScale = mainMenu_mouseMultiplier; + mouseScale = mainMenu_mouseMultiplier * 16; #if defined(PANDORA) || defined(ANDROIDSDL) if (dpadLeft) #else @@ -204,7 +204,7 @@ void read_joystick(int nr, unsigned int *dir, int *button) { analogY=0; } - if (analogX != 0 && analogY != 0 ) + if (analogX != 0 || analogY != 0 ) { //max movement is mouseScale. //that way, when in one of the other mouse modes, diff --git a/src/sdlgfx.cpp b/src/sdlgfx.cpp index 881907a..a43191a 100755 --- a/src/sdlgfx.cpp +++ b/src/sdlgfx.cpp @@ -763,27 +763,27 @@ void handle_events (void) mouse_state = true; if(gp2xButtonRemappingOn) { - lastmx = rEvent.motion.x*2 - mainMenu_stylusOffset + moved_x + stylusAdjustX >> 1; - lastmy = rEvent.motion.y*2 - mainMenu_stylusOffset + moved_y + stylusAdjustY >> 1; + lastmx = 16 * (rEvent.motion.x*2 - mainMenu_stylusOffset + moved_x + stylusAdjustX >> 1); + lastmy = 16 * (rEvent.motion.y*2 - mainMenu_stylusOffset + moved_y + stylusAdjustY >> 1); //mouseMoving = 1; } else if(slow_mouse) { - lastmx += rEvent.motion.xrel; - lastmy += rEvent.motion.yrel; + lastmx += 16 * rEvent.motion.xrel; + lastmy += 16 * rEvent.motion.yrel; if(rEvent.motion.x == 0) - lastmx -= 2; + lastmx -= 2*16; if(rEvent.motion.y == 0) - lastmy -= 2; + lastmy -= 2*16; if(rEvent.motion.x == visibleAreaWidth-1) - lastmx += 2; + lastmx += 2*16; if(rEvent.motion.y == mainMenu_displayedLines-1) - lastmy += 2; + lastmy += 2*16; } else { - int mouseScale = mainMenu_mouseMultiplier * 4; - if (mouseScale > 99) + int mouseScale = mainMenu_mouseMultiplier * 4 *16; + if (mouseScale > 99*16) mouseScale /= 100; lastmx += rEvent.motion.xrel * mouseScale;