Joystick woes: in case anybody else might have this prob

For discussion of ports to POSIX based systems, especially using GNUStep.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
caracal
Deadly
Deadly
Posts: 205
Joined: Wed Jun 25, 2008 11:31 am
Location: The Desert, USA
Contact:

Joystick woes: in case anybody else might have this prob

Post by caracal » Sun May 16, 2010 9:59 pm

This may be totally irrelevant, since I haven't really seen anybody else complaining about it, or any problem much like it, but I have at long last resolved a problem I'd had since 2008 with my Logitech Attack3 joystick. I mentioned it here back then, and somebody else came out and said they had the same problem, but we couldn't gather enough details, or interest from other parties, to get anywhere with it.

Problem first manifested itself in 2008 (under oolite 1.72.x, probably Linux 2.4.something) as: Hitting the "Precision Toggle" button (which I'd mapped to button 11 or something) caused an instant continuous full-left yaw. Eventually got that sorted by stabbing around randomly in my oolite joystick and keystroke configurations until it went away, so no helpful info there.

Last month, resumed playing oolite, and saw all sorts of issues, like during a dogfight sometimes my window manager (openbox) would simply switch desktops, leaving oolite behind, and my ass to get shot off. Finally tracked that one down to the fact that my joystick was driving my mouse cursor, even outside of oolite, as well as doing joysticky things in oolite. I would also get streams of spurious "Triple-Click-Button-6" and suchlike events in other apps like emacs and mplayer. Fixed it, more or less, by adding

Code: Select all

Option "AutoAddDevices" "false"
to the "ServerLayout" section of xorg.conf. Since I had a rather old xorg.conf, it still had explicit configuration for my keyboard and mouse, so I thought all I had to do was add an explicit InputDevice section for the joystick too, and make sure it included

Code: Select all

Option "SendCoreEvents" "false"
I'm sure there's some magic udev configuration you can do to tell it either to not auto-add the joystick, or else to turn off core events in the auto-added joystick devices, but I was never able to find it.

However! While that fixed the joystick-as-mouse problem, it left me with a very strange behavior: After I'd restart my X server, everything would be fine until I played oolite. After that, for some reason I was never able to track down, my screensaver stopped blanking my screen. I mean, I know "why": the X server was somehow seeing a continuous stream of input events, so it thought the workstation was never idle. I wrote a short python script that revealed that the idle time never rose higher than about 500 milliseconds before getting set back to zero. But try as I might, with that script, and with the xinput and xev utilities, I was never able to see what those events were. They all said, "Events? There are no events!" But the screensaver sure thought there were.

Fast forward a week or three, and I'm working on a programming project of my own, in which I get interested in how x.org actually delivers joystick events. I go looking, and find out ... it doesn't! Or at least it doesn't document them anywhere that I could find. Apparently, if you want X input events from your joystick, you make sure they get sent as core pointer events, at which point they look just like mouse events. I guess if one wishes to use a joystick correctly in a Linux app, one opens /dev/js0 (or /dev/input/js0) and reads movement and button events as short data packets. The X server isn't involved at all in that process.

So today, I removed the explicit "Joystick0" input device from my xorg.conf, and voila! Oolite still works great with the joystick, and no more non-increasing screensaver idle times. Still have the "don't auto-add devices" in there, sigh, but at least now the screen will blank.

If this helps anybody, I'll be delighted. If anybody wants to come forward and tell me what a dunderhead I am for overlooking some obvious web page that documents all this stuff, I'll be embarrassed but still delighted. But it cost me a decent measure of time and pain, so I figured I'd throw it out here in case it might help or amuse someone else.

Post Reply