wnd's weblog

X.org, USB-mouse, udev, and SDL

21 Oct 2007 20:33:21 Linux

Mouse pointer would misbehave in Linux, particularly in some games. Apparently this is an unfortunate outcome of many moving parts. Who thought dealing with a mouse pointer can be this complicated?

I was bored. I was a litle tired, but I didn’t feel like hitting the bed just yet. My significant other was watching show jumping, and basically I felt like watching something – something other than show jumping. Instead, I decided to play a bit of rRootage. The game didn’t last for long. I was, and would still, be stuck at level 7B on first game mode. Sigh. Hey, tonight I would continue Penumbra Episode 1…

I’m not sure about the dates anymore, but I think it all started around the time Debian switched X.org. Every now and then when I started my computer (read: finished playing, and rebooted back to Linux), X.org would not find my mouse, and refuse to start. I would then log in, sudo to edit /etc/X11/xorg.conf, and change my mouse device from event2 to event3, or vice versa. Then maybe year, or half a year ago the problem vanished, and I was glad.

About a month ago I, once again, finished playing, rebooted back to Linux, logged in, and realised my mouse didn’t move. I opened an XTerm, and took a look at the log. “No mouse found”? Since when did X start without a mouse? Heck, it wouldn’t even accept symlink to mouse event device! I changed the event device again, and everything started working. Suddenly I got an idea. Now that X doesn’t complain about missing mouse, would it accept configuration with two mouses if the other was missing? I soon discovered it would. My problem was once again solved. For now.

When demo-client of Enemy Territory: Quake Wars was released for GNU/Linux, I downloaded the file while still at work so that I could try it as soon as I got home. Installing the demo didn’t bring any big surprises – the installer would run with 32-bit compatibility libraries, but the game wouldn’t without full 32-bit chroot. Naturally I already had that ready for games such as UT2004/Alien Swarm and Neverwinter Nights. I started the demo… and my mouse was totally weird. I could move the cursor, but it would soon jump back to where it was a few moments ago. Eventually I managed to create an account, log in, and start a game. The mouse wouldn’t be any better in-game. It actually reminded me of mouse in Savage, but as bad as it was here, it wasn’t as bad as with Savage. I figured this was yet-another mouse event related problem, similar to Adobe’s Flashplayer mouse click bug, and it would be fixed soon. I quit the game and decided to check back later.

Like I mentioned earlier, I decided to play Penumbra Episode 1 tonight. Unlike before, however, the mouse wouldn’t cooperate. It wouldn’t cooperate at all. In fact, it would behave just like it did with ET:QW. This would no longer be a problem with ET:QW alone. In fact, this problem would also appear in UT2004! Something’s not right.

I searched Google for “linux games jumpy mouse”, and got a bunch of hits. Against all the odds, some of the hits actually looked promising. Particulary the ninth hit on linuxworld.com. “My rodent refused to behave, and the cursor shook and stuttered across the screen in a manner that made the game nearly unplayable.” That would describe my problem precisely! I exported the thing, and tried UT2004 again. Problem solved!

So, my mouse would work again. What did I learn? Well X sucks for starters, that’s for sure. Why won’t it accept a symlink created by udev as mouse device? I know, it would be far too convenient to have X use semi-static device filename such as usb-Logitech_USB-PS.2_Optical_Mouse-mouse instead of event2, which would change to adapt fluctuations in earth radiation. No, I didn’t learn anything useful, I didn’t even learn what caused the problem. My best guess is that SDL got confused of two configured mice, even though only one was operational. However I figured one more reason why GNU/Linux isn’t exactly ready for general population. If something as simple as mouse configuration can be a big problem such as this, what are the other problems like? I’m all for Linux games, I would love to play my favourite games without having to boot to Windows. WineX and Cedega are not the answer, only a temporary solution.

Update: 1 Nov 2007 16:01:55 +0200

Having more than one entry for a single mouse doesn’t help. When I booted back to Linux last night, X was missing a mouse again. Sigh. Apart from that, GDM also decided that system default language is actually Finnish. I suppose choosing default locale with dpkg-reconfigure locales isn’t enough for GDM. Oh give me a break…