mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Compare commits
12 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
67a97afbc0 | ||
|
|
2fb95783e0 | ||
|
|
456f23cbbd | ||
|
|
ab1d9adfd3 | ||
|
|
192fdb0690 | ||
|
|
8c1058f2eb | ||
|
|
4921912374 | ||
|
|
67681097b8 | ||
|
|
1dd61111ad | ||
|
|
231061d004 | ||
|
|
425ed6017a | ||
|
|
7251e42dfb |
11
autogen.sh
11
autogen.sh
@@ -1,14 +1,17 @@
|
||||
#! /bin/sh
|
||||
|
||||
srcdir=`dirname $0`
|
||||
srcdir=`dirname "$0"`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
ORIGDIR=`pwd`
|
||||
cd $srcdir
|
||||
cd "$srcdir"
|
||||
|
||||
autoreconf -v --install || exit 1
|
||||
cd $ORIGDIR || exit $?
|
||||
cd "$ORIGDIR" || exit $?
|
||||
|
||||
git config --local --get format.subjectPrefix >/dev/null 2>&1 ||
|
||||
git config --local format.subjectPrefix "PATCH xf86-input-evdev"
|
||||
|
||||
if test -z "$NOCONFIGURE"; then
|
||||
$srcdir/configure "$@"
|
||||
exec "$srcdir"/configure "$@"
|
||||
fi
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
# Initialize Autoconf
|
||||
AC_PREREQ([2.60])
|
||||
AC_INIT([xf86-input-evdev],
|
||||
[2.10.4],
|
||||
[2.10.6],
|
||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||
[xf86-input-evdev])
|
||||
AC_CONFIG_SRCDIR([Makefile.am])
|
||||
|
||||
@@ -33,6 +33,8 @@
|
||||
#define EVDEV_PROP_MIDBUTTON "Evdev Middle Button Emulation"
|
||||
/* CARD32 */
|
||||
#define EVDEV_PROP_MIDBUTTON_TIMEOUT "Evdev Middle Button Timeout"
|
||||
/* CARD8 */
|
||||
#define EVDEV_PROP_MIDBUTTON_BUTTON "Evdev Middle Button Button"
|
||||
|
||||
/* Wheel emulation */
|
||||
/* BOOL */
|
||||
|
||||
@@ -94,6 +94,11 @@ Sets the timeout (in milliseconds) that the driver waits before deciding
|
||||
if two buttons where pressed "simultaneously" when 3 button emulation is
|
||||
enabled. Default: 50. Property: "Evdev Middle Button Timeout".
|
||||
.TP 7
|
||||
.BI "Option \*qEmulate3Button\*q \*q" integer \*q
|
||||
Specifies the physical button number to be emitted if middle button emulation
|
||||
is triggered.
|
||||
Default: 2. Property: "Evdev Middle Button Button".
|
||||
.TP 7
|
||||
.BI "Option \*qEmulateWheel\*q \*q" boolean \*q
|
||||
Enable/disable "wheel" emulation. Wheel emulation means emulating button
|
||||
press/release events when the mouse is moved while a specific real button
|
||||
@@ -283,6 +288,9 @@ value.
|
||||
.BI "Evdev Middle Button Timeout"
|
||||
1 16-bit positive value.
|
||||
.TP 7
|
||||
.BI "Evdev Middle Button Button"
|
||||
1 8-bit value, allowed range 0-32, 0 disables the button.
|
||||
.TP 7
|
||||
.BI "Evdev Wheel Emulation"
|
||||
1 boolean value (8 bit, 0 or 1).
|
||||
.TP 7
|
||||
|
||||
47
src/emuMB.c
47
src/emuMB.c
@@ -45,6 +45,7 @@
|
||||
|
||||
static Atom prop_mbemu = 0; /* Middle button emulation on/off property */
|
||||
static Atom prop_mbtimeout = 0; /* Middle button timeout property */
|
||||
static Atom prop_mbbuton = 0; /* Middle button target button property */
|
||||
/*
|
||||
* Lets create a simple finite-state machine for 3 button emulation:
|
||||
*
|
||||
@@ -185,6 +186,7 @@ EvdevMBEmuTimer(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int id;
|
||||
int mapped_id;
|
||||
|
||||
#if HAVE_THREADED_INPUT
|
||||
input_lock();
|
||||
@@ -194,7 +196,10 @@ EvdevMBEmuTimer(InputInfoPtr pInfo)
|
||||
|
||||
pEvdev->emulateMB.pending = FALSE;
|
||||
if ((id = stateTab[pEvdev->emulateMB.state][4][0]) != 0) {
|
||||
EvdevPostButtonEvent(pInfo, abs(id),
|
||||
mapped_id = abs(id);
|
||||
if (mapped_id == 2)
|
||||
mapped_id = pEvdev->emulateMB.button;
|
||||
EvdevPostButtonEvent(pInfo, mapped_id,
|
||||
(id >= 0) ? BUTTON_PRESS : BUTTON_RELEASE);
|
||||
pEvdev->emulateMB.state =
|
||||
stateTab[pEvdev->emulateMB.state][4][2];
|
||||
@@ -226,6 +231,7 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
|
||||
{
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int id;
|
||||
int mapped_id;
|
||||
int *btstate;
|
||||
int ret = FALSE;
|
||||
|
||||
@@ -244,7 +250,10 @@ EvdevMBEmuFilterEvent(InputInfoPtr pInfo, int button, BOOL press)
|
||||
|
||||
if ((id = stateTab[pEvdev->emulateMB.state][*btstate][0]) != 0)
|
||||
{
|
||||
EvdevQueueButtonEvent(pInfo, abs(id), (id >= 0));
|
||||
mapped_id = abs(id);
|
||||
if (mapped_id == 2)
|
||||
mapped_id = pEvdev->emulateMB.button;
|
||||
EvdevQueueButtonEvent(pInfo, mapped_id, (id >= 0));
|
||||
ret = TRUE;
|
||||
}
|
||||
if ((id = stateTab[pEvdev->emulateMB.state][*btstate][1]) != 0)
|
||||
@@ -301,12 +310,23 @@ void
|
||||
EvdevMBEmuPreInit(InputInfoPtr pInfo)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
int bt;
|
||||
|
||||
pEvdev->emulateMB.enabled = xf86SetBoolOption(pInfo->options,
|
||||
"Emulate3Buttons",
|
||||
FALSE);
|
||||
pEvdev->emulateMB.timeout = xf86SetIntOption(pInfo->options,
|
||||
"Emulate3Timeout", 50);
|
||||
bt = xf86SetIntOption(pInfo->options, "Emulate3Button", 2);
|
||||
if (bt < 0 || bt > EVDEV_MAXBUTTONS) {
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Invalid Emulate3Button value: %d\n",
|
||||
bt);
|
||||
xf86IDrvMsg(pInfo, X_WARNING, "Middle button emulation disabled.\n");
|
||||
|
||||
pEvdev->emulateMB.enabled = FALSE;
|
||||
}
|
||||
|
||||
pEvdev->emulateMB.button = bt;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -338,6 +358,7 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
{
|
||||
InputInfoPtr pInfo = dev->public.devicePrivate;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
int bt;
|
||||
|
||||
if (atom == prop_mbemu)
|
||||
{
|
||||
@@ -353,6 +374,18 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
|
||||
if (!checkonly)
|
||||
pEvdev->emulateMB.timeout = *((CARD32*)val->data);
|
||||
} else if (atom == prop_mbbuton)
|
||||
{
|
||||
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
bt = *((CARD8*)val->data);
|
||||
|
||||
if (bt < 0 || bt > EVDEV_MAXBUTTONS)
|
||||
return BadValue;
|
||||
|
||||
if (!checkonly)
|
||||
pEvdev->emulateMB.button = bt;
|
||||
}
|
||||
|
||||
return Success;
|
||||
@@ -390,5 +423,15 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_mbtimeout, FALSE);
|
||||
|
||||
prop_mbbuton = MakeAtom(EVDEV_PROP_MIDBUTTON_BUTTON,
|
||||
strlen(EVDEV_PROP_MIDBUTTON_BUTTON),
|
||||
TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_mbbuton, XA_INTEGER, 8, PropModeReplace, 1,
|
||||
&pEvdev->emulateMB.button, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
return;
|
||||
XISetDevicePropertyDeletable(dev, prop_mbbuton, FALSE);
|
||||
|
||||
XIRegisterPropertyHandler(dev, EvdevMBEmuSetProperty, NULL, NULL);
|
||||
}
|
||||
|
||||
27
src/evdev.c
27
src/evdev.c
@@ -551,6 +551,16 @@ EvdevProcessProximityState(InputInfoPtr pInfo)
|
||||
}
|
||||
}
|
||||
|
||||
/* Wacom's last frame resets all values to 0, including x/y.
|
||||
Skip over this. */
|
||||
if (prox_state == 0) {
|
||||
int v;
|
||||
if (valuator_mask_fetch(pEvdev->abs_vals, 0, &v) && v == 0)
|
||||
valuator_mask_unset(pEvdev->abs_vals, 0);
|
||||
if (valuator_mask_fetch(pEvdev->abs_vals, 1, &v) && v == 0)
|
||||
valuator_mask_unset(pEvdev->abs_vals, 1);
|
||||
}
|
||||
|
||||
if ((prox_state && !pEvdev->in_proximity) ||
|
||||
(!prox_state && pEvdev->in_proximity))
|
||||
{
|
||||
@@ -784,7 +794,6 @@ EvdevProcessAbsoluteMotionEvent(InputInfoPtr pInfo, struct input_event *ev)
|
||||
|
||||
if (ev->code >= ABS_MT_SLOT) {
|
||||
EvdevProcessTouchEvent(pInfo, ev);
|
||||
pEvdev->abs_queued = 1;
|
||||
} else if (!pEvdev->mt_mask) {
|
||||
map = pEvdev->abs_axis_map[ev->code];
|
||||
|
||||
@@ -906,7 +915,7 @@ EvdevPostProximityEvents(InputInfoPtr pInfo, int which)
|
||||
break;
|
||||
case EV_QUEUE_PROXIMITY:
|
||||
if (pEvdev->queue[i].val == which)
|
||||
xf86PostProximityEvent(pInfo->dev, which, 0, 0);
|
||||
xf86PostProximityEventM(pInfo->dev, which, pEvdev->old_vals);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1238,7 +1247,7 @@ EvdevCountMTAxes(EvdevPtr pEvdev, int *num_mt_axes_total,
|
||||
return;
|
||||
|
||||
/* Absolute multitouch axes: adjust mapping and axes counts. */
|
||||
for (axis = ABS_MT_SLOT; axis < ABS_MAX; axis++)
|
||||
for (axis = ABS_MT_SLOT; axis <= ABS_MAX; axis++)
|
||||
{
|
||||
int j;
|
||||
Bool skip = FALSE;
|
||||
@@ -1288,7 +1297,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
|
||||
goto out;
|
||||
|
||||
/* Find number of absolute axis, including MT ones, will decrease later. */
|
||||
for (i = 0; i < ABS_MAX; i++)
|
||||
for (i = 0; i <= ABS_MAX; i++)
|
||||
if (libevdev_has_event_code(pEvdev->dev, EV_ABS, i))
|
||||
num_axes++;
|
||||
|
||||
@@ -1456,7 +1465,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device, int num_scroll_axes)
|
||||
}
|
||||
|
||||
for (i = 0; i < num_touches; i++) {
|
||||
for (axis = ABS_MT_TOUCH_MAJOR; axis < ABS_MAX; axis++) {
|
||||
for (axis = ABS_MT_TOUCH_MAJOR; axis <= ABS_MAX; axis++) {
|
||||
if (pEvdev->abs_axis_map[axis] >= 0) {
|
||||
int val = pEvdev->mtdev ? 0 : libevdev_get_current_slot(pEvdev->dev);
|
||||
/* XXX: read initial values from mtdev when it adds support
|
||||
@@ -1669,7 +1678,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device, int num_scroll_axes)
|
||||
if (!libevdev_has_event_type(pEvdev->dev, EV_REL))
|
||||
goto out;
|
||||
|
||||
for (i = 0; i < REL_MAX; i++) {
|
||||
for (i = 0; i <= REL_MAX; i++) {
|
||||
if (i == REL_WHEEL || i == REL_HWHEEL || i == REL_DIAL)
|
||||
continue;
|
||||
|
||||
@@ -2354,8 +2363,10 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
pInfo->type_name = XI_TOUCHSCREEN;
|
||||
} else {
|
||||
if (!libevdev_has_event_code(pEvdev->dev, EV_REL, REL_X) ||
|
||||
!libevdev_has_event_code(pEvdev->dev, EV_REL, REL_Y))
|
||||
!libevdev_has_event_code(pEvdev->dev, EV_REL, REL_Y)) {
|
||||
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
|
||||
EvdevForceXY(pInfo, Relative);
|
||||
}
|
||||
xf86IDrvMsg(pInfo, X_INFO, "Configuring as mouse\n");
|
||||
pInfo->type_name = XI_MOUSE;
|
||||
}
|
||||
@@ -2486,7 +2497,7 @@ EvdevOpenDevice(InputInfoPtr pInfo)
|
||||
}
|
||||
|
||||
if (pInfo->fd < 0) {
|
||||
xf86IDrvMsg(pInfo, X_ERROR, "Unable to open evdev device \"%s\".\n", device);
|
||||
xf86IDrvMsg(pInfo, X_ERROR, "Unable to open evdev device \"%s\" (%s).\n", device, strerror(errno));
|
||||
return BadValue;
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,7 @@ typedef struct {
|
||||
int state; /* state machine (see bt3emu.c) */
|
||||
Time expires; /* time of expiry */
|
||||
Time timeout;
|
||||
uint8_t button; /* phys button to emit */
|
||||
} emulateMB;
|
||||
/* Third mouse button emulation */
|
||||
struct emulate3B {
|
||||
|
||||
Reference in New Issue
Block a user