evdev mouse emulation code

Ailin Nemui ailin.nemui at gmail.com
Tue Jan 20 02:04:30 PST 2015


recently I've been gifted with/annoyed by a Toshiba laptop with a
nipple-mouse and two buttons only. This has some consequences;

either middle-mouse emulation but no scroll-emulation;
or scroll-emulation on right button, but then: no middle mouse
emulation, not possible to right-click drag (resizing windows,
context-menus in git, etc.)
or scroll-emulation on left button, but then:  no middle mouse
emulation, not possible to select text, move windows or left-button

There are several related bugs, some also with some patches:
https://bugs.freedesktop.org/show_bug.cgi?id=39174 to have wheel emu on
emulated middle mouse
https://bugs.freedesktop.org/show_bug.cgi?id=58763 explaining the status
https://bugs.freedesktop.org/show_bug.cgi?id=2065 using the wheel
emulation from another mouse
https://bugs.freedesktop.org/show_bug.cgi?id=70780 patch to do this on a
synaptics hardcoded for IBM trackpoints

Since I'm now affected by this and would like to fix it, some things I'd
like to look into is either like #39174 to support the wheel emulation
through emulated middle button, and/or put the wheel emulation on left
mouse button, but *pass through* movement so that move/text
selection/dnd still work (similar to the button emulation for
single-button mice), but also make sure that middle-mouse emulation can

Being new to Xorg, I've attached a PoC to pass through the movement
operations, which works and restores the ability to move windows etc,
but still doesn't give middle-mouse emulation because that is snatched
away by the wheel emulation code.

I'd appreciate any input how I should proceed to evolve the code which
would eventually be acceptable for merge into the driver.


diff -pru a/src/emuWheel.c b/src/emuWheel.c
--- a/src/emuWheel.c    2014-05-13 07:38:52.000000000 +0200
+++ b/src/emuWheel.c    2015-01-19 17:10:54.366213413 +0100
@@ -66,6 +66,9 @@ EvdevWheelEmuFilterButton(InputInfoPtr p
     /* Check for EmulateWheelButton */
     if (pEvdev->emulateWheel.button == button) {
+       if (pEvdev->emulateWheel.button_state == value)
+           return FALSE;
        pEvdev->emulateWheel.button_state = value;
         if (value)
@@ -110,8 +113,11 @@ EvdevWheelEmuFilterMotion(InputInfoPtr p
         if (pEvdev->emulateWheel.button)
             int ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
-            if (ms > 0)
+            if (ms > 0) {
+                 EvdevPostButtonEvent(pInfo, pEvdev->emulateWheel.button, BUTTON_PRESS);
+                 pEvdev->emulateWheel.button_state = 0;
+                 return FALSE;
-                 return TRUE;
+           }
        if(pEv->type == EV_ABS) {

More information about the xorg mailing list