Wednesday, September 10, 2014

Classics: Enable third button chord for a mouse

Three-button emulation used to be a necessity in a world of two-button mice.  In today's world of many-buttoned mice, a lot of people don't even deal with button chording anymore.  While some people like myself are simply accustomed or more comfortable with the chords, i can certainly imagine that the ubiquity of shitty loose mouse wheels might lead someone to a similar conclusion in the modern era.  Where to start?  What do i use?  Use xinput.

List your devices and find the right device name:
delicious@bacon:~/bin$ xinput | grep pointer
⎡ Virtual core pointer                        id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
⎜   ↳ Kensington      Kensington Expert Mouse     id=8    [slave  pointer  (2)]
⎜   ↳ Wacom Graphire3 stylus                      id=9    [slave  pointer  (2)]
⎜   ↳ Wacom Graphire3 eraser                      id=11    [slave  pointer  (2)]
⎜   ↳ Wacom Graphire3 cursor                      id=12    [slave  pointer  (2)]

List the device properties:
delicious@bacon:~/bin$ xinput --list-props "Kensington      Kensington Expert Mouse"
Device 'Kensington      Kensington Expert Mouse':
    Device Enabled (146):    1
    Coordinate Transformation Matrix (148):    1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    Device Accel Profile (268):    0
    Device Accel Constant Deceleration (269):    1.000000
    Device Accel Adaptive Deceleration (270):    1.000000
    Device Accel Velocity Scaling (271):    10.000000
    Device Product ID (262):    1149, 4128
    Device Node (263):    "/dev/input/event3"
    Evdev Axis Inversion (272):    0, 0
    Evdev Axes Swap (274):    0
    Axis Labels (275):    "Rel X" (156), "Rel Y" (157), "Rel Vert Wheel" (267)
    Button Labels (276):    "Button Left" (149), "Button Middle" (150), "Button Right" (151), "Button Wheel Up" (152), "Button Wheel Down" (153), "Button Horiz Wheel Left" (154), "Button Horiz Wheel Right" (155), "Button Side" (266), "Button Unknown" (265), "Button Unknown" (265), "Button Unknown" (265), "Button Unknown" (265)
    Evdev Middle Button Emulation (277):    0

    Evdev Middle Button Timeout (278):    50
    Evdev Third Button Emulation (279):    0
    Evdev Third Button Emulation Timeout (280):    1000
    Evdev Third Button Emulation Button (281):    3
    Evdev Third Button Emulation Threshold (282):    20
    Evdev Wheel Emulation (283):    0
    Evdev Wheel Emulation Axes (284):    0, 0, 4, 5
    Evdev Wheel Emulation Inertia (285):    10
    Evdev Wheel Emulation Timeout (286):    200
    Evdev Wheel Emulation Button (287):    4
    Evdev Drag Lock Buttons (288):    0

We're looking for middle button emulation here, but notice that there are a lot of things that can be configured here.  From this, we could remap the buttons entirely, change acceleration, flip axes, even change the way the mouse maps to the total display area in a multihead system.  ... but since all we're after is this one thing, let's set that.  From the xinput manual:
--set-prop [--type=atom|float|int] [--format=8|16|32] device property value [...]
therefore:
xinput --set-prop --type=int --format=8 "Kensington      Kensington Expert Mouse" 277 1
Check the property status for the change.  Of course, these settings won't last through a session change, so stick it in a startup events script or something.  If this doesn't work, i would recommend getting angry and maybe exploring the nuances of your most creative swears.

No comments:

Post a Comment