Joystick HAT problem
Taylor Richards
mtrs at bellsouth.net
Mon Jan 20 16:16:14 EST 2003
Since I haven't been able to get the HAT on my joystick to work in FS1/2
I finally decided to figure out why. As it turns out SDL doesn't see a
HAT on the joystick. I'm guessing that's because the iforce driver
doesn't report one. The iforce driver reports the HAT as a set of axes
instead of, in my case, an eight point HAT. I'm using a Logitech
WingMan Force with the iforce driver from a RedHat 8.0 kernel
(2.4.18-19.8.0). If anyone is using the iforce driver from any kernel
or distribution that does/doesn't work fine with you joystick please let
me know what joystick you have and iforce driver version.
In the meantime I came up with the attached fix which works fine for
me. If there is an easier way to get the same result please let me
know. I'm not sure if this will work flawlessly for everyone since
which set of axes is for the HAT is probably different between joystick
models (ie. if you don't have a throttle).
Taylor
--
Taylor Richards <mtrs at bellsouth.net>
-------------- next part --------------
--- ../../../freespace2/src/io/joy-unix.cpp 2002-06-16 20:28:52.000000000 -0400
+++ src/io/joy-unix.cpp 2003-01-20 13:39:49.000000000 -0500
@@ -306,6 +306,7 @@
state = SDL_JoystickGetButton(sdljoy, i);
}
} else {
+#ifndef JOY_HAT_IS_AXIS
switch (i) {
case JOY_HATBACK:
state = (hat & SDL_HAT_DOWN) ? 1 : 0;
@@ -322,6 +323,24 @@
default:
break;
}
+#else
+ switch (i) {
+ case JOY_HATBACK:
+ state = (SDL_JoystickGetAxis(sdljoy, 4) > 0 ) ? 1 : 0;
+ break;
+ case JOY_HATFORWARD:
+ state = (SDL_JoystickGetAxis(sdljoy, 4) < 0 ) ? 1 : 0;
+ break;
+ case JOY_HATLEFT:
+ state = (SDL_JoystickGetAxis(sdljoy, 3) < 0 ) ? 1 : 0;
+ break;
+ case JOY_HATRIGHT:
+ state = (SDL_JoystickGetAxis(sdljoy, 3) > 0 ) ? 1 : 0;
+ break;
+ default:
+ break;
+ }
+#endif
}
if (state != joy_buttons[i].actual_state) {
More information about the freespace2
mailing list