[PATCH evdev] Remove AUTO feature of middle mouse button emulation.
Peter Hutterer
peter.hutterer at who-t.net
Fri May 28 00:01:12 PDT 2010
The AUTO feature was the default, MB emulation was on until a middle mouse
button was pressed. MB emulation however results in a delay of the first
press, causing minor annoyances to the users.
Disable the feature by default unless the device has no middle button.
Note that the restrictions of the PS/2 protocol result in all mice having
the middle mouse button bit set, so it's not a particularly reliable
indicator whether the device needs the emulation.
There's not a lot of two-button mice around anymore though, so arguably we
should start caring about more important things.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
man/evdev.man | 5 ++---
src/emuMB.c | 56 ++++++++++++++++++++------------------------------------
src/evdev.c | 2 --
src/evdev.h | 2 +-
4 files changed, 23 insertions(+), 42 deletions(-)
diff --git a/man/evdev.man b/man/evdev.man
index 49ab12c..bb8a83c 100644
--- a/man/evdev.man
+++ b/man/evdev.man
@@ -76,9 +76,8 @@ indicating that the next button pressed is to be
.BI "Option \*qEmulate3Buttons\*q \*q" boolean \*q
Enable/disable the emulation of the third (middle) mouse button for mice
which only have two physical buttons. The third button is emulated by
-pressing both buttons simultaneously. Default: off for touchscreens, otherwise
-on until a middle mouse button event is registered. Property: "Evdev Middle
-Button Emulation".
+pressing both buttons simultaneously. Default: off unless no middle
+button was detected. Property: "Evdev Middle Button Emulation".
.TP 7
.BI "Option \*qEmulate3Timeout\*q \*q" integer \*q
Sets the timeout (in milliseconds) that the driver waits before deciding
diff --git a/src/emuMB.c b/src/emuMB.c
index c33ea8e..7528fbe 100644
--- a/src/emuMB.c
+++ b/src/emuMB.c
@@ -43,12 +43,6 @@
#include <evdev-properties.h>
-enum {
- MBEMU_DISABLED = 0,
- MBEMU_ENABLED,
- MBEMU_AUTO
-};
-
#ifdef HAVE_PROPERTIES
static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
static Atom prop_mbtimeout = 0; /* Middle button timeout property */
@@ -232,11 +226,6 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
if (!pEvdev->emulateMB.enabled)
return ret;
- if (button == 2) {
- EvdevMBEmuEnable(pInfo, FALSE);
- return ret;
- }
-
/* don't care about other buttons */
if (button != 1 && button != 3)
return ret;
@@ -310,21 +299,26 @@ void
EvdevMBEmuPreInit(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
-
- if (pEvdev->flags & EVDEV_TOUCHSCREEN)
- pEvdev->emulateMB.enabled = MBEMU_DISABLED;
- else
- pEvdev->emulateMB.enabled = MBEMU_AUTO;
-
- if (xf86FindOption(pInfo->options, "Emulate3Buttons"))
- {
- pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
- "Emulate3Buttons",
- MBEMU_ENABLED);
- xf86Msg(X_INFO, "%s: Forcing middle mouse button emulation %s.\n",
- pInfo->name, (pEvdev->emulateMB.enabled) ? "on" : "off");
- }
-
+ int dflt;
+
+
+ /* the PS/2 protocol doesn't allow button detection so the kernel simply
+ * sets LMR as always present.
+ * On actual three-button mice this is annoying as the left mouse button
+ * will suffer from a delay until the middle mouse button is pressed.
+ *
+ * There's not a lot of two-button mice around anymore, so disable MB
+ * emulation by default for all devices that have a middle button (even
+ * though this _will_ give false positives).
+ */
+
+ dflt = !TestBit(BTN_MIDDLE, pEvdev->key_bitmask);
+
+ pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
+ "Emulate3Buttons",
+ dflt);
+ xf86Msg(X_INFO, "%s: Middle mouse button emulation %s.\n",
+ pInfo->name, (pEvdev->emulateMB.enabled) ? "on" : "off");
pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,
"Emulate3Timeout", 50);
}
@@ -352,16 +346,6 @@ EvdevMBEmuFinalize(InputInfoPtr pInfo)
}
-/* Enable/disable middle mouse button emulation. */
-void
-EvdevMBEmuEnable(InputInfoPtr pInfo, BOOL enable)
-{
- EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
- if (pEvdev->emulateMB.enabled == MBEMU_AUTO)
- pEvdev->emulateMB.enabled = enable;
-}
-
-
#ifdef HAVE_PROPERTIES
static int
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
diff --git a/src/evdev.c b/src/evdev.c
index bd92d91..ac475b7 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -747,8 +747,6 @@ EvdevReadInput(InputInfoPtr pInfo)
}
}
-#define TestBit(bit, array) ((array[(bit) / LONG_BITS]) & (1L << ((bit) % LONG_BITS)))
-
static void
EvdevPtrCtrlProc(DeviceIntPtr device, PtrCtrl *ctrl)
{
diff --git a/src/evdev.h b/src/evdev.h
index 8c89f83..8ed1299 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -80,6 +80,7 @@
#define MAX_VALUATORS 36
#endif
+#define TestBit(bit, array) ((array[(bit) / LONG_BITS]) & (1L << ((bit) % LONG_BITS)))
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 5
typedef struct {
@@ -214,7 +215,6 @@ void EvdevMBEmuBlockHandler(pointer, struct timeval**, pointer);
void EvdevMBEmuPreInit(InputInfoPtr);
void EvdevMBEmuOn(InputInfoPtr);
void EvdevMBEmuFinalize(InputInfoPtr);
-void EvdevMBEmuEnable(InputInfoPtr, BOOL);
/* Mouse Wheel emulation */
void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
--
1.6.5.2
More information about the xorg-devel
mailing list