Commit ea8c53b7 authored by Sam Lantinga's avatar Sam Lantinga

Avoid FPE with Linux 2.6

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40872
parent 70232856
...@@ -383,7 +383,7 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd) ...@@ -383,7 +383,7 @@ static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd)
static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd) static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd)
{ {
int i; int i, t;
unsigned long keybit[40]; unsigned long keybit[40];
unsigned long absbit[40]; unsigned long absbit[40];
unsigned long relbit[40]; unsigned long relbit[40];
...@@ -436,12 +436,18 @@ static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd) ...@@ -436,12 +436,18 @@ static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd)
joystick->hwdata->abs_correct[i].used = 0; joystick->hwdata->abs_correct[i].used = 0;
} else { } else {
joystick->hwdata->abs_correct[i].used = 1; joystick->hwdata->abs_correct[i].used = 1;
joystick->hwdata->abs_correct[i].coef[0] = t = (2 - values[4]);
(values[2] + values[1]) / 2 - values[4]; if ( t != 0 ) {
joystick->hwdata->abs_correct[i].coef[1] = joystick->hwdata->abs_correct[i].coef[0] = (values[2] + values[1]) / t;
(values[2] + values[1]) / 2 + values[4]; }
joystick->hwdata->abs_correct[i].coef[2] = t = (2 + values[4]);
(1 << 29) / ((values[2] - values[1]) / 2 - 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; ++joystick->naxes;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment