Commit b8dac674 authored by Sam Lantinga's avatar Sam Lantinga

Fixed bug #478

Take the min and max values into account.

--HG--
branch : SDL-1.2
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/branches/SDL-1.2%402678
parent 0b021f7b
...@@ -79,6 +79,9 @@ SDL 1.2.13 is a minor bug fix release. ...@@ -79,6 +79,9 @@ SDL 1.2.13 is a minor bug fix release.
<P> <P>
Improved trackpad scrolling support. Improved trackpad scrolling support.
</P> </P>
<P>
Fixed joystick hat reporting for certain joysticks.
</P>
</BLOCKQUOTE> </BLOCKQUOTE>
<IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%"> <IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
......
...@@ -727,7 +727,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) ...@@ -727,7 +727,7 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{ {
recDevice *device = joystick->hwdata; recDevice *device = joystick->hwdata;
recElement *element; recElement *element;
SInt32 value; SInt32 value, range;
int i; int i;
if (device->removed) /* device was unplugged; ignore it. */ if (device->removed) /* device was unplugged; ignore it. */
...@@ -780,10 +780,11 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) ...@@ -780,10 +780,11 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
{ {
Uint8 pos = 0; Uint8 pos = 0;
value = HIDGetElementValue(device, element); range = (element->max - element->min + 1);
if (element->max == 3) /* 4 position hatswitch - scale up value */ value = HIDGetElementValue(device, element) - element->min;
if (range == 4) /* 4 position hatswitch - scale up value */
value *= 2; 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; value = -1;
switch(value) switch(value)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment