Commit c3300058 authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug #1080

 Markus Rathgeb      2011-01-23 14:34:23 PST

With kernel 2.6.31 the struct input_absinfo defined in linux/input.h changed.
A field "__s32 resolution" was added at the end of the struct.

Because the macro EVIOCGABS(abs) is using the struct input_absinfo, it would be
better (IMHO) to change the declaration of variable values to
"int values[sizeof(struct input_absinfo) / sizeof(int)];" or using "struct
input_absinfo" directly.
parent a2f23022
...@@ -701,25 +701,26 @@ EV_ConfigJoystick(SDL_Joystick * joystick, int fd) ...@@ -701,25 +701,26 @@ EV_ConfigJoystick(SDL_Joystick * joystick, int fd)
continue; continue;
} }
if (test_bit(i, absbit)) { if (test_bit(i, absbit)) {
int values[6]; struct input_absinfo absinfo;
if (ioctl(fd, EVIOCGABS(i), values) < 0) if (ioctl(fd, EVIOCGABS(i), values) < 0)
continue; continue;
#ifdef DEBUG_INPUT_EVENTS #ifdef DEBUG_INPUT_EVENTS
printf("Joystick has absolute axis: %x\n", i); printf("Joystick has absolute axis: %x\n", i);
printf("Values = { %d, %d, %d, %d, %d }\n", printf("Values = { %d, %d, %d, %d, %d }\n",
values[0], values[1], values[2], values[3], values[4]); absinfo.value, absinfo.minimum, absinfo.maximum,
absinfo.fuzz, absinfo.flat);
#endif /* DEBUG_INPUT_EVENTS */ #endif /* DEBUG_INPUT_EVENTS */
joystick->hwdata->abs_map[i] = joystick->naxes; joystick->hwdata->abs_map[i] = joystick->naxes;
if (values[1] == values[2]) { if (absinfo.minimum == absinfo.maximum) {
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] = joystick->hwdata->abs_correct[i].coef[0] =
(values[2] + values[1]) / 2 - values[4]; (absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat;
joystick->hwdata->abs_correct[i].coef[1] = joystick->hwdata->abs_correct[i].coef[1] =
(values[2] + values[1]) / 2 + values[4]; (absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat;
t = ((values[2] - values[1]) / 2 - 2 * values[4]); t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat);
if (t != 0) { if (t != 0) {
joystick->hwdata->abs_correct[i].coef[2] = joystick->hwdata->abs_correct[i].coef[2] =
(1 << 29) / t; (1 << 29) / t;
......
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