src/joystick/linux/SDL_sysjoystick.c
changeset 6845 e14535915e3e
parent 6844 e09997fb33cc
child 6852 424a6a791947
--- a/src/joystick/linux/SDL_sysjoystick.c	Mon Feb 11 16:45:24 2013 -0800
+++ b/src/joystick/linux/SDL_sysjoystick.c	Mon Feb 11 16:51:00 2013 -0800
@@ -668,13 +668,13 @@
                 } else {
                     joystick->hwdata->abs_correct[i].used = 1;
                     joystick->hwdata->abs_correct[i].coef[0] =
-                        (absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat;
+                        (absinfo.maximum + absinfo.minimum) - 2 * absinfo.flat;
                     joystick->hwdata->abs_correct[i].coef[1] =
-                        (absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat;
-                    t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat);
+                        (absinfo.maximum + absinfo.minimum) + 2 * absinfo.flat;
+                    t = ((absinfo.maximum - absinfo.minimum) - 4 * absinfo.flat);
                     if (t != 0) {
                         joystick->hwdata->abs_correct[i].coef[2] =
-                            (1 << 29) / t;
+                            (1 << 28) / t;
                     } else {
                         joystick->hwdata->abs_correct[i].coef[2] = 0;
                     }
@@ -815,6 +815,7 @@
 
     correct = &joystick->hwdata->abs_correct[which];
     if (correct->used) {
+        value *= 2;
         if (value > correct->coef[0]) {
             if (value < correct->coef[1]) {
                 return 0;
@@ -824,7 +825,7 @@
             value -= correct->coef[0];
         }
         value *= correct->coef[2];
-        value >>= 14;
+        value >>= 13;
     }
 
     /* Clamp and return */