Re: [AD] Windows mouse patch

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


On Sun, 2004-12-05 at 01:42 +0100, Evert Glebbeek wrote:

> What is odd is that the person who made the patch said that it worked fine 
> for him. Hmm... I hope this isn't one of those Win9x vs WinXP things 
> again...

Yes, it's odd.

> By all means though, revert the patch. Or, perhaps better, fix it: if a y 
> (or x) follows a y (or x), reset the x (or y) count to 0.
> 

Ah, true, should be simple. I attached an *untested* patch. I can try it
out tomorrow. It reverts the doubling of the accel factors, and fixes
the double values. Thinking about it, something is weird.. the mouse
seemed to be too fast for me in windows, but the doubled threshold
actually should have made it slower. But, well, can't think right now..
need sleep.

-- 
Elias Pschernig
Index: src/win/wmouse.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/win/wmouse.c,v
retrieving revision 1.39
diff -u -p -r1.39 wmouse.c
--- src/win/wmouse.c	4 Dec 2004 13:24:17 -0000	1.39
+++ src/win/wmouse.c	5 Dec 2004 01:18:27 -0000
@@ -93,8 +93,8 @@ static int mouse_sy = 2;
 #define MAF_DEFAULT 1                 /* mouse acceleration parameters */
 static int mouse_accel_fact = MAF_DEFAULT;
 static int mouse_accel_mult = MAF_DEFAULT;
-static int mouse_accel_thr1 = 50;     /* 50 = 5^2 *2 */
-static int mouse_accel_thr2 = 512;    /* 512 = 16^2 *2 */
+static int mouse_accel_thr1 = 5 * 5;
+static int mouse_accel_thr2 = 16 * 16;
 
 static int mouse_minx = 0;            /* mouse range */
 static int mouse_miny = 0;
@@ -211,12 +211,15 @@ static void mouse_dinput_handle_event(in
 {
    static int last_mickeyx = 0;
    static int last_mickeyy = 0;
+   static int last_was_x = 0;
    int mag;
-   
+
    switch (ofs) {
 
       case DIMOFS_X:
          if (!gfx_driver || !gfx_driver->windowed) {
+            if (last_was_x)
+               last_mickeyy = 0;
             if (mouse_accel_mult) {
                mag = last_mickeyx*last_mickeyx + last_mickeyy*last_mickeyy;
                if (mag >= mouse_accel_thr2)
@@ -227,11 +230,14 @@ 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;
             if (mouse_accel_mult) {
                mag = last_mickeyx*last_mickeyx + last_mickeyy*last_mickeyy;
                if (mag >= mouse_accel_thr2)
@@ -242,6 +248,7 @@ 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/