Mercurial > sdl-ios-xcode
comparison src/joystick/linux/SDL_sysjoystick.c @ 5084:4c3c2599559b SDL-1.2
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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 24 Jan 2011 14:31:32 -0800 |
parents | 42012a6afb5b |
children | f521f8739611 |
comparison
equal
deleted
inserted
replaced
5079:8c88cae7911e | 5084:4c3c2599559b |
---|---|
698 if ( i == ABS_HAT0X ) { | 698 if ( i == ABS_HAT0X ) { |
699 i = ABS_HAT3Y; | 699 i = ABS_HAT3Y; |
700 continue; | 700 continue; |
701 } | 701 } |
702 if ( test_bit(i, absbit) ) { | 702 if ( test_bit(i, absbit) ) { |
703 int values[6]; | 703 struct input_absinfo absinfo; |
704 | 704 |
705 if ( ioctl(fd, EVIOCGABS(i), values) < 0 ) | 705 if ( ioctl(fd, EVIOCGABS(i), &absinfo) < 0 ) |
706 continue; | 706 continue; |
707 #ifdef DEBUG_INPUT_EVENTS | 707 #ifdef DEBUG_INPUT_EVENTS |
708 printf("Joystick has absolute axis: %x\n", i); | 708 printf("Joystick has absolute axis: %x\n", i); |
709 printf("Values = { %d, %d, %d, %d, %d }\n", | 709 printf("Values = { %d, %d, %d, %d, %d }\n", |
710 values[0], values[1], | 710 absinfo.value, absinfo.minimum, |
711 values[2], values[3], values[4]); | 711 absinfo.maximum, absinfo.fuzz, absinfo.flat); |
712 #endif /* DEBUG_INPUT_EVENTS */ | 712 #endif /* DEBUG_INPUT_EVENTS */ |
713 joystick->hwdata->abs_map[i] = joystick->naxes; | 713 joystick->hwdata->abs_map[i] = joystick->naxes; |
714 if ( values[1] == values[2] ) { | 714 if ( absinfo.minimum == absinfo.maximum ) { |
715 joystick->hwdata->abs_correct[i].used = 0; | 715 joystick->hwdata->abs_correct[i].used = 0; |
716 } else { | 716 } else { |
717 joystick->hwdata->abs_correct[i].used = 1; | 717 joystick->hwdata->abs_correct[i].used = 1; |
718 joystick->hwdata->abs_correct[i].coef[0] = | 718 joystick->hwdata->abs_correct[i].coef[0] = |
719 (values[2] + values[1]) / 2 - values[4]; | 719 (absinfo.maximum + absinfo.minimum) / 2 - values[4]; |
720 joystick->hwdata->abs_correct[i].coef[1] = | 720 joystick->hwdata->abs_correct[i].coef[1] = |
721 (values[2] + values[1]) / 2 + values[4]; | 721 (absinfo.maximum + absinfo.minimum) / 2 + values[4]; |
722 t = ((values[2] - values[1]) / 2 - 2 * values[4]); | 722 t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * values[4]); |
723 if ( t != 0 ) { | 723 if ( t != 0 ) { |
724 joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t; | 724 joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t; |
725 } else { | 725 } else { |
726 joystick->hwdata->abs_correct[i].coef[2] = 0; | 726 joystick->hwdata->abs_correct[i].coef[2] = 0; |
727 } | 727 } |