summaryrefslogtreecommitdiff
blob: d18b398e89742016aa000a3fa34e812d189bcc85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
diff -u -r1.13 -r1.14
--- SDL12/src/joystick/linux/SDL_sysjoystick.c	2004/01/04 16:49:18	1.13
+++ SDL12/src/joystick/linux/SDL_sysjoystick.c	2004/03/05 15:09:18	1.14
@@ -22,7 +22,7 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: 1.2.7-joystick.patch,v 1.1 2004/06/07 07:48:05 mr_bones_ Exp $";
+ "@(#) $Id: 1.2.7-joystick.patch,v 1.1 2004/06/07 07:48:05 mr_bones_ Exp $";
 #endif
 
 /* This is the system specific header for the SDL joystick API */
@@ -383,7 +383,7 @@
 
 static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd)
 {
-	int i;
+	int i, t;
 	unsigned long keybit[40];
 	unsigned long absbit[40];
 	unsigned long relbit[40];
@@ -436,12 +436,18 @@
 				    joystick->hwdata->abs_correct[i].used = 0;
 				} else {
 				    joystick->hwdata->abs_correct[i].used = 1;
-				    joystick->hwdata->abs_correct[i].coef[0] =
-					(values[2] + values[1]) / 2 - values[4];
-				    joystick->hwdata->abs_correct[i].coef[1] =
-					(values[2] + values[1]) / 2 + values[4];
-				    joystick->hwdata->abs_correct[i].coef[2] =
-					(1 << 29) / ((values[2] - values[1]) / 2 - 2 * values[4]);
+				    t = (2 - values[4]);
+				    if ( t != 0 ) {
+				        joystick->hwdata->abs_correct[i].coef[0] = (values[2] + values[1]) / t;
+				    }
+				    t = (2 + values[4]);
+				    if ( t != 0 ) {
+				        joystick->hwdata->abs_correct[i].coef[1] = (values[2] + values[1]) / t;
+				    }
+				    t = ((values[2] - values[1]) / 2 - 2 * values[4]);
+				    if ( t != 0 ) {
+					joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
+				    }
 				}
 				++joystick->naxes;
 			}