Date: Thu, 18 Jul 2002 23:51:40 +0200 (MEST)
From: Krister Walfridsson Subject: [SDL] src/joystick/bsd/SDL_sysjoystick.c patch The *BSD USB HID joystick code has two serious bugs: 1. If a joystick reports unhandled hid_input usage (for example HUG_RZ or HUG_DIAL), then the last handled value will be overwritten with an arbitrary value. (Fixed in the patch below by adding a default case.) 2. The current code does only handle logical coordinates in the range 0-255, while a big part of available joysticks report -128 - 127. (This is solved in the patch below by first center the range around 0, and then stretch it to the correct range.) --HG-- extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40462
This commit is contained in:
parent
8b7ced1708
commit
fae7d836a8
1 changed files with 4 additions and 13 deletions
|
@ -332,23 +332,14 @@ SDL_SYS_JoystickUpdate(SDL_Joystick *joy)
|
||||||
case HUG_WHEEL:
|
case HUG_WHEEL:
|
||||||
naxe = JOYAXE_WHEEL;
|
naxe = JOYAXE_WHEEL;
|
||||||
goto scaleaxe;
|
goto scaleaxe;
|
||||||
|
default:
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
scaleaxe:
|
scaleaxe:
|
||||||
v = (Sint32)hid_get_data(REP_BUF_DATA(rep),
|
v = (Sint32)hid_get_data(REP_BUF_DATA(rep),
|
||||||
&hitem);
|
&hitem);
|
||||||
if (v != 127) {
|
v -= (hitem.logical_maximum + hitem.logical_minimum + 1)/2;
|
||||||
if (v < 127) {
|
v *= 32768/((hitem.logical_maximum - hitem.logical_minimum + 1)/2);
|
||||||
v = -(256 - v);
|
|
||||||
v <<= 7;
|
|
||||||
v++;
|
|
||||||
} else {
|
|
||||||
v++;
|
|
||||||
v <<= 7;
|
|
||||||
v--;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
v = 0;
|
|
||||||
}
|
|
||||||
if (v != joy->axes[naxe]) {
|
if (v != joy->axes[naxe]) {
|
||||||
SDL_PrivateJoystickAxis(joy, naxe, v);
|
SDL_PrivateJoystickAxis(joy, naxe, v);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue