src/joystick/linux/SDL_sysjoystick.c
changeset 8053 495f4a047be1
parent 7916 8f16728ce87b
child 8093 b43765095a6f
     1.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Fri Dec 06 08:24:00 2013 -0800
     1.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Fri Dec 06 09:13:31 2013 -0800
     1.3 @@ -509,10 +509,11 @@
     1.4              if (test_bit(i, absbit)) {
     1.5                  struct input_absinfo absinfo;
     1.6  
     1.7 -                if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0)
     1.8 +                if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
     1.9                      continue;
    1.10 +                }
    1.11  #ifdef DEBUG_INPUT_EVENTS
    1.12 -                printf("Joystick has absolute axis: %x\n", i);
    1.13 +                printf("Joystick has absolute axis: 0x%.2x\n", i);
    1.14                  printf("Values = { %d, %d, %d, %d, %d }\n",
    1.15                         absinfo.value, absinfo.minimum, absinfo.maximum,
    1.16                         absinfo.fuzz, absinfo.flat);
    1.17 @@ -539,9 +540,17 @@
    1.18          }
    1.19          for (i = ABS_HAT0X; i <= ABS_HAT3Y; i += 2) {
    1.20              if (test_bit(i, absbit) || test_bit(i + 1, absbit)) {
    1.21 +                struct input_absinfo absinfo;
    1.22 +
    1.23 +                if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
    1.24 +                    continue;
    1.25 +                }
    1.26  #ifdef DEBUG_INPUT_EVENTS
    1.27                  printf("Joystick has hat %d\n", (i - ABS_HAT0X) / 2);
    1.28 -#endif
    1.29 +                printf("Values = { %d, %d, %d, %d, %d }\n",
    1.30 +                       absinfo.value, absinfo.minimum, absinfo.maximum,
    1.31 +                       absinfo.fuzz, absinfo.flat);
    1.32 +#endif /* DEBUG_INPUT_EVENTS */
    1.33                  ++joystick->nhats;
    1.34              }
    1.35          }