Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Fixed bug #478
Browse files Browse the repository at this point in the history
Take the min and max values into account.
  • Loading branch information
slouken committed Dec 29, 2007
1 parent 73cfb17 commit b48f3e1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/joystick/darwin/SDL_sysjoystick.c
Expand Up @@ -770,7 +770,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
{
recDevice *device = joystick->hwdata;
recElement *element;
SInt32 value;
SInt32 value, range;
int i;

if (device->removed) { /* device was unplugged; ignore it. */
Expand Down Expand Up @@ -818,10 +818,11 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
while (element) {
Uint8 pos = 0;

value = HIDGetElementValue(device, element);
if (element->max == 3) /* 4 position hatswitch - scale up value */
range = (element->max - element->min + 1);
value = HIDGetElementValue(device, element) - element->min;
if (range == 4) /* 4 position hatswitch - scale up value */
value *= 2;
else if (element->max != 7) /* Neither a 4 nor 8 positions - fall back to default position (centered) */
else if (range != 8) /* Neither a 4 nor 8 positions - fall back to default position (centered) */
value = -1;
switch (value) {
case 0:
Expand Down

0 comments on commit b48f3e1

Please sign in to comment.