Skip to content

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 ad42f61 commit ee74a22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions docs.html
Expand Up @@ -79,6 +79,9 @@ <H3> Mac OS X Notes </H3>
<P>
Improved trackpad scrolling support.
</P>
<P>
Fixed joystick hat reporting for certain joysticks.
</P>
</BLOCKQUOTE>

<IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
Expand Down
9 changes: 5 additions & 4 deletions src/joystick/darwin/SDL_sysjoystick.c
Expand Up @@ -727,7 +727,7 @@ void 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 @@ -780,10 +780,11 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{
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)
{
Expand Down

0 comments on commit ee74a22

Please sign in to comment.