repak shawahb
dry humor for cactus farmers

^

   

rsw@jfet.org


blogroll

       
Sat, 30 May 2009

mouserx

My old work mouse, a borrowed-ish MS Intellimouse Explorer 3.0A, had this odd habit of causing X to crash every once in a while. I don't know how this is possible, I only know that it had to do with the scroll wheel and it was very hard to reproduce. (OK, I can't say 100% for sure that it was actually the mouse, but the frequency of crashing with the same usage model dropped to zero abruptly after switching, which is good enough for me until I find a counterexample.) It may be that the thing is dying and somehow exposing a flaw in the xorg evdev driver.

All of that is beside the point. I went out and bought a new mouse, which was a frustratingly difficult task: apparently everyone likes their mouse wheel to feel like rotting fruit, whereas I want positive, LOUD clicks like the nearly unused Logitech bottom-of-the-line optical mouse connected to positron. Aside: I really ought to do something other than VGA mode on a text console considering I spent the $80 on an 8800GT when I rebuilt positron last year, right? Oh well.

So, because I wasn't particularly happy with any of the scroll wheels, but because I did still want a new mouse for work, I bought a $10 GearHead LM6000U laser mouse—if I can't be happy, at least I can be cheap. Laser mice, as far as I can tell, all use much higher resolution imagers than their diode-equipped optical siblings. As a result, when I move my mouse an inch, my optical mouse registers a 400-pixel movement, but the laser sees 1600 pixels go by. This is great, except that my fine motor skills haven't magically improved by 4x just because I spent a Hamilton at Fry's. So just turn down the mouse sensitivity, right? Well, kind of...

X has an interesting way of doing mouse sensitivity. Basically, you say xset m <accel> <thresh>, and when your mouse moves more than thresh pixels in a "short period of time" (probably one or two mouse refresh intervals, but I'm too lazy to find out for sure), the movement rate is multiplied by accel. But what if you want to slow down the pointer instead? Well, accel can be a fraction (yes, you specify a fraction, not a float), and thresh can be set to 1, and then all mouse movements end up slower. But then you lose the whole long distance movement acceleration thing which is really the point of this setting.

Well, now that we know that, we have to look a little more closely at the way X interacts with the mouse driver. In most modern implementations, e.g., default Debian behavior, X gets input device information from hald via the evdev module and sets up your pointers, ignoring any InputDevice sections in xorg.conf. While this is all soft and friendly, evdev is still a bit sparse in terms of configurability.

The other option is to use the traditional mouse module, wherein you can specify mouse resolution and, more importantly, mouse sensitivity. To convince X to do this, however, you first have to tell it to ignore hald-detected devices, like so:

Section "ServerFlags"
        Option          "AllowEmptyInput" "false"
        Option          "AutoAddDevices" "false"
        Option          "AutoEnableDevices" "false"
EndSection

AllowEmptyInput disables the kbd and mouse drivers; AutoAddDevices is the setting that tells X to talk to hald. You don't actually need the third line; I just put it in there out of spite. You can see more about all of these options in the xorg.conf(5) manpage.

Now that X isn't autoconfiguring your mouse and keyboard, you're going to have to specify them manually... but you can handle that. The point for us is to enable the use of the mouse driver in an InputDevice section pointing to our nifty high-resolution mouse so that we can take advantage of that driver's greater configurability:

Section "InputDevice"
	Identifier	"Mouse1"
	Driver		"mouse"
	Option		"Device" "/dev/input/mice"
	Option		"CorePointer"
	Option		"Resolution" "1600"
	Option		"Sensitivity" "0.25"
	Option		"Protocol" "Auto"
	Option		"Emulate3Buttons" "no"
	Option		"ZAxisMapping" "4 5"
EndSection

Now our nifty mouse is running at its maximum resolution, but we're scaling down the movements by a factor of four so it feels the same as the old mouse. This means that there are 4x the number of mapped mouse motion pixels in the same distance across the screen, i.e., you have higher precision control over your mouse pointer by a factor of 4 (no claims here about the practical limit of such things... if you don't think you need this, why did you bother buying a laser mouse?). It also means that we can go back to our friend xset and use the long distance accelerator function.

One caveat (this one bit me!): you cannot have two different pointer devices set at two different sensitivities. Don't complain to me, that's how xorg works. If you have multiple pointing devices, the highest (numerically greatest) sensitivity setting provided will be used, meaning if you have another mouse and have forgotten to set the sensitivity option in its InputDevice section, the above snippet will seem not to work because the default sensitivity is 1.0.

Another comment: for various reasons (basically I want firefox to work correctly), I run gnome-settings-daemon even though I use fvwm2 and abhor desktop environments. If you use a desktop environment like gnome or KDE, it will very likely override your xset settings with the settings from whatever crappy mouse config applet you use. If you don't want this to happen, at least in gnome, you can use gconf-editor to set desktop / gnome / peripherals / mouse / motion_acceleration and desktop / gnome / peripherals / mouse / motion_threshold to -1; this will apparently prevent gnome from screwing with your settings. Then, of course, just call xset at login from your .xsession (or whatever you call it) file. Or just use your crapplet to set it up and get off my lawn.

(Lest you point and laugh at my fvwm2 use: come back and talk to me when your windowmanager's configuration file is written in a turing-complete scripting language.)


[ permalink | 0 comments (add one you lazy bastard!) ]

writebacks (add one you lazy bastard!)




post a comment:

Save name/email/&c
Name:
URL/Email: [http://... or mailto:you@wherever] (optional)
Title: (optional)
Comments:
Key:
(Required)