Skip to content
Permalink
Browse files

Fixed bug #478

Take the min and max values into account.
  • Loading branch information
slouken committed Dec 29, 2007
1 parent ad42f61 commit ee74a229e064ec4579a8d7993da10d66c883b211
Showing with 8 additions and 4 deletions.
  1. +3 −0 docs.html
  2. +5 −4 src/joystick/darwin/SDL_sysjoystick.c
@@ -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%">
@@ -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. */
@@ -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)
{

0 comments on commit ee74a22

Please sign in to comment.