From: Toni Wilen Date: Mon, 24 Jan 2022 19:00:58 +0000 (+0200) Subject: Possible mouse counter overflow fix. X-Git-Tag: 4910~11 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=0027bcff91ce5a458c77c8cd8b8134f2d0a36240;p=francis%2Fwinuae.git Possible mouse counter overflow fix. --- diff --git a/inputdevice.cpp b/inputdevice.cpp index 93424b64..573c66dc 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -2952,15 +2952,6 @@ int magicmouse_alive (void) return mouseedge_alive > 0; } -STATIC_INLINE int adjust (int val) -{ - if (val > 127) - return 127; - else if (val < -127) - return -127; - return val; -} - static int getbuttonstate (int joy, int button) { return (joybutton[joy] & (1 << button)) ? 1 : 0; @@ -2970,13 +2961,13 @@ static int pc_mouse_buttons[MAX_JPORTS]; static int getvelocity (int num, int subnum, int pct) { - int val; - int v; - if (pct > 1000) pct = 1000; - val = mouse_delta[num][subnum]; - v = val * pct / 1000; + if (pct < 0) { + pct = 0; + } + int val = mouse_delta[num][subnum]; + int v = val * pct / 1000; if (!v) { if (val < -maxvpos / 2) v = -2; @@ -3112,10 +3103,14 @@ static void mouseupdate (int pct, bool vsync) mouse_x[i] &= MOUSEXY_MAX - 1; } - if (mouse_frame_y[i] - mouse_y[i] > max) + if (mouse_frame_y[i] - mouse_y[i] > max) { mouse_y[i] = mouse_frame_y[i] - max; - if (mouse_frame_y[i] - mouse_y[i] < -max) + mouse_y[i] &= MOUSEXY_MAX - 1; + } + if (mouse_frame_y[i] - mouse_y[i] < -max) { mouse_y[i] = mouse_frame_y[i] + max; + mouse_y[i] &= MOUSEXY_MAX - 1; + } } if (!vsync) { @@ -3138,18 +3133,14 @@ static void mouseupdate (int pct, bool vsync) } } - } -static int input_vpos, input_frame; +static uae_u32 prev_input_vpos, input_frame, prev_input_frame; extern int vpos; static void readinput (void) { - uae_u32 totalvpos; - int diff; - - totalvpos = input_frame * current_maxvpos () + vpos; - diff = totalvpos - input_vpos; + int max = current_maxvpos(); + int diff = (input_frame * max + vpos) - (prev_input_frame * max + prev_input_vpos); if (diff > 0) { if (diff < 10) { mouseupdate (0, false); @@ -3157,8 +3148,8 @@ static void readinput (void) mouseupdate (diff * 1000 / current_maxvpos (), false); } } - input_vpos = totalvpos; - + prev_input_frame = input_frame; + prev_input_vpos = vpos; } static void joymousecounter (int joy) @@ -9029,6 +9020,10 @@ void setmousestate (int mouse, int axis, int data, int isabs) return; } } + + *mouse_p = (*mouse_p) - (*oldm_p); + *oldm_p = 0; + v = (int)d; fract[mouse][axis] += d - v; diff = (int)fract[mouse][axis];