The *BSD USB HID joystick code has two serious bugs:
-
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.) -
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.)/Krister
Index: SDL_sysjoystick.c===================================================================
RCS file: /home/sdlweb/libsdl.org/cvs/SDL12/src/joystick/bsd/SDL_sysjoystick.c,v
retrieving revision 1.10
diff -u -r1.10 SDL_sysjoystick.c
— SDL_sysjoystick.c 2002/06/12 03:32:01 1.10
+++ SDL_sysjoystick.c 2002/07/18 21:31:00
@@ -332,23 +332,14 @@
case HUG_WHEEL:
naxe = JOYAXE_WHEEL;
goto scaleaxe;
-
default:
-
continue; }
scaleaxe:
v = (Sint32)hid_get_data(REP_BUF_DATA(rep),
&hitem);
-
if (v != 127) {
-
if (v < 127) {
-
v = -(256 - v);
-
v <<= 7;
-
v++;
-
} else {
-
v++;
-
v <<= 7;
-
v--;
-
}
-
} else {
-
v = 0;
-
}
-
v -= (hitem.logical_maximum + hitem.logical_minimum + 1)/2;
-
v *= 32768/((hitem.logical_maximum - hitem.logical_minimum + 1)/2); if (v != joy->axes[naxe]) { SDL_PrivateJoystickAxis(joy, naxe, v); }