Re: [AD] Windows mouse patch

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On Sun, 2004-12-05 at 09:44 +0100, Evert Glebbeek wrote:

> I don't think your patch should break anything, so I think I'm going
> to include it as a last-minute fix into the WIP.
> 

No, doesn't break anything, but also didn't fix the problem. The real
problem apparently was, the acceleration is based on the accelerated
values, effectively making the mouse accelerate exponentially. Attached
is the fix, against current CVS. Now I'm wondering if I'm the only one
to notice this, or there will be complaints from users of 4.1.17.. :)

-- 
Elias Pschernig
Index: src/win/wmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wmouse.c,v
retrieving revision 1.40
diff -u -p -r1.40 wmouse.c
--- src/win/wmouse.c	5 Dec 2004 08:56:32 -0000	1.40
+++ src/win/wmouse.c	5 Dec 2004 10:28:03 -0000
@@ -209,8 +209,8 @@ static char* dinput_err_str(long err)
  */
 static void mouse_dinput_handle_event(int ofs, int data)
 {
-   static int last_mickeyx = 0;
-   static int last_mickeyy = 0;
+   static int last_data_x = 0;
+   static int last_data_y = 0;
    static int last_was_x = 0;
    int mag;
 
@@ -219,9 +219,11 @@ static void mouse_dinput_handle_event(in
       case DIMOFS_X:
          if (!gfx_driver || !gfx_driver->windowed) {
             if (last_was_x)
-               last_mickeyy = 0;
+               last_data_y = 0;
+            last_data_x = data;
+            last_was_x = 1;
             if (mouse_accel_mult) {
-               mag = last_mickeyx*last_mickeyx + last_mickeyy*last_mickeyy;
+               mag = last_data_x*last_data_x + last_data_y*last_data_y;
                if (mag >= mouse_accel_thr2)
                   data *= (mouse_accel_mult<<1);
                else if (mag >= mouse_accel_thr1) 
@@ -229,17 +231,17 @@ static void mouse_dinput_handle_event(in
             }
 
             dinput_x += data;
-            last_mickeyx = data;
-            last_was_x = 1;
          }
          break;
 
       case DIMOFS_Y:
          if (!gfx_driver || !gfx_driver->windowed) {
             if (!last_was_x)
-               last_mickeyx = 0;
+               last_data_x = 0;
+            last_data_y = data;
+            last_was_x = 0;
             if (mouse_accel_mult) {
-               mag = last_mickeyx*last_mickeyx + last_mickeyy*last_mickeyy;
+               mag = last_data_x*last_data_x + last_data_y*last_data_y;
                if (mag >= mouse_accel_thr2)
                   data *= (mouse_accel_mult<<1);
                else if (mag >= mouse_accel_thr1) 
@@ -247,8 +249,6 @@ static void mouse_dinput_handle_event(in
             }
 
             dinput_y += data;
-            last_mickeyy = data;
-            last_was_x = 0;
          }
          break;
 


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/