src/joystick/darwin/SDL_sysjoystick.c
changeset 2287 15a242fca6c4
parent 2120 2c835d58faad
child 2295 dbc6d1893869
     1.1 --- a/src/joystick/darwin/SDL_sysjoystick.c	Sat Dec 29 19:29:20 2007 +0000
     1.2 +++ b/src/joystick/darwin/SDL_sysjoystick.c	Sat Dec 29 19:45:09 2007 +0000
     1.3 @@ -770,7 +770,7 @@
     1.4  {
     1.5      recDevice *device = joystick->hwdata;
     1.6      recElement *element;
     1.7 -    SInt32 value;
     1.8 +    SInt32 value, range;
     1.9      int i;
    1.10  
    1.11      if (device->removed) {      /* device was unplugged; ignore it. */
    1.12 @@ -818,10 +818,11 @@
    1.13      while (element) {
    1.14          Uint8 pos = 0;
    1.15  
    1.16 -        value = HIDGetElementValue(device, element);
    1.17 -        if (element->max == 3)  /* 4 position hatswitch - scale up value */
    1.18 +        range = (element->max - element->min + 1);
    1.19 +        value = HIDGetElementValue(device, element) - element->min;
    1.20 +        if (range == 4)  /* 4 position hatswitch - scale up value */
    1.21              value *= 2;
    1.22 -        else if (element->max != 7)     /* Neither a 4 nor 8 positions - fall back to default position (centered) */
    1.23 +        else if (range != 8)     /* Neither a 4 nor 8 positions - fall back to default position (centered) */
    1.24              value = -1;
    1.25          switch (value) {
    1.26          case 0: