To take full advantage of your new and semi-ugly mouse, you'll need a kernel that supports
evdev
. Check whether you have it:
modprobe evdev
If you get
FATAL: Module evdev not found., it doesn't exist as a module, but maybe, it's compiled into the kernel proper. If your kernel remembers the configuration it was built with, try
zcat /proc/config.gz|grep EVDEV
. If it doesn't, but you have the kernel sources you built from, then I really don't have to tell you this, but something like
grep EVDEV /usr/src/linux/.config
should do the trick. If your kernel does not support
evdev
, you cannot proceed. Get a kernel that does, or give up.
You'll also need an
Xserver that supports
evdev
. Reasonably new versions of
X.org
do, but the
evdev
-driver may be in a separate package that you'll need to have installed (
x11-input-evdev on SuSE).
Now that that's out of the way, let's assume your mouse is connected via USB.
# cat /proc/cat /proc/bus/input/devices
...
I: Bus=0003 Vendor=045e Product=008c Version=0056
N: Name="Microsoft Microsoft Wireless Optical Mouse® 1.0A" (name)
P: Phys=usb-0000:00:10.0-2/input0 (phys device)
H: Handlers=mouse0 event2 evbug (/dev/input/event2)
B: EV=7
B: KEY=1f0000 0 0 0 0 0 0 0 0
B: REL=1c3
We'll use these data for
/etc/X11/XF86Config:
Section "InputDevice"
Identifier "Mouse[1]"
Driver "evdev"
Option "Buttons" "7"
Option "ZAxisMapping" "6 7 5 4"
Option "Device" "/dev/input/event2"
Option "Dev Name" "Microsoft Microsoft Wireless Optical Mouse 1.0A"
Option "Dev Phys" "usb-0000:00:10.0-2/input0"
Option "Emulate3Buttons" "no"
EndSection
This should give you a mouse with three buttons, and a scroll- and tilt-wheel once you restart X. The thumb-buttons (8,9) are still ignored in all apps though. I had special plans for them, so I seized them using
imwheel
:
imwheel -k -b "89"
. (This can go into whichever of
~/.xsession and
~/.xinitrc you have so you don't have to type it everytime you log in.) I want the buttons to react to the application I'm using them in, though — time for some
~/.imwheelrc magic:
"screen"
Control_L, Button5, Control_L|a|n
Control_L, Button4, Control_L|a|p
".*"
None, Button5, Button2
None, Button4, Button2
Control_L, Button5, Alt_L|Left
Control_L, Button4, Alt_L|Right
Shift_L, Button5, Button1|Home
Shift_L, Button4, Button1|End
The left bit is what keys (shift, alternate, control, ...) have to be pressed in combination with the mouse-button(s) in the middle for us to emit the buttons and/or keys on the right, so the first line means, if
Button5
is pressed while the left
control
key is held, emit
control
,
a and
n. (The
screen
program will switch to the next terminal upon seeing
^A^N.)
So our thumb-buttons (8,9) are (4,5) inside
imwheel
. Yeah, WTF.
The first section is for the
screen
program (which multiplexes terminals, giving your "several shell in one window"): when in
screen
and the left
Control
key is pressed, make the thumb-buttons switch to the previous/next shell, respectively.
The last section matches anything else, it's the fallback: with no modifiers (
shift, control, alt, ...
), the thumb-buttons (4,5) should act like button 2 (the middle button / scroll-wheel) and paste the selection. I always found it awkward to "click" using the mouse-wheel, and on my logitech, the thumb-button was a button "2" (same as clicking the middle-button/wheel), so I'll stick with what I'm used to.
If used with the left
control
key,
Alt
plus the left resp. right cursor-key should be emitted: this will make
control
+ thumb-button go forward/backward in most web-browser's page-history.
Finally, if used with shift, we want to go the the top/bottom of the page. To do this, we emit
button1
to focus the area under the mouse (just in case) as well as
Home
or
End
, respectively.
If you also wish to use the tilt-wheel from within
imwheel
, call it like so:
imwheel -k -b 8967
To use tilting the wheel as an alternative way of changing terminals in
screen
, add lines for the
left
and
right
events:
"screen"
Control_L, Button5, Control_L|a|n
Control_L, Button4, Control_L|a|p
None, Left, Control_L|a|n
None, Right, Control_L|a|p
Since 8,9 in
X
are 4,5 inside of
imwheel
, they're 6,7 inside of
xemacs
. Sure, we could make a special case for
xemacs
in
~/.imwheelrc, but just for practice, here goes (
~/.xemacs/init.el snippet):
;; mouse-wheel: scroll
(global-set-key 'button4 'scroll-down-command)
(global-set-key 'button5 'scroll-up-command)
;; tilt-wheel: go to previous/next buffer
;; ERC (emacs Internet Relay Chat) users may prefer binding
;; erc-track-switch-buffer
(global-set-key 'button6 'switch-to-previous-buffer)
(global-set-key 'button7 'switch-to-next-buffer)
Finally, to modify what the tilt-wheel does in
Mozilla/Firefox
, open
about:config and change the
mousewheel.horizscroll group of settings.
Unfortunately,
previous tab/next tab
is not an option in those settings, so to do that, we'll have to once more modify
~/.imwheelrc:
"[Gg]aleon(-bin)?"
None, Left, Control_L|Page_Up
None, Right, Control_L|Page_Down
Voilà tout, enjoy your mouse like a true kitty!
CodeForFoodAndHonor on : New hardware toy
Tatiana Azundris on : Evoluent VerticalMouse 2, linux, xemacs, and x.org