Fixed bug #478
Take the min and max values into account. --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%402679
This commit is contained in:
parent
feb78335ca
commit
7261caf15b
1 changed files with 5 additions and 4 deletions
|
@ -770,7 +770,7 @@ 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. */
|
||||||
|
@ -818,10 +818,11 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
|
||||||
while (element) {
|
while (element) {
|
||||||
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) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue