mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Compare commits
9 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fa49dfcab | ||
|
|
941391ca34 | ||
|
|
2144f7d834 | ||
|
|
61b4e88e01 | ||
|
|
9ee70943ec | ||
|
|
415b6ffa95 | ||
|
|
f4ba2bd785 | ||
|
|
2e5f68754f | ||
|
|
8fdb2abb6f |
14
configure.ac
14
configure.ac
@@ -22,7 +22,7 @@
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([xf86-input-evdev],
|
||||
2.2.99.1,
|
||||
2.2.99.2,
|
||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||
xf86-input-evdev)
|
||||
|
||||
@@ -32,16 +32,16 @@ AM_INIT_AUTOMAKE([dist-bzip2])
|
||||
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
# Require xorg-macros: XORG_CWARNFLAGS, XORG_CHANGELOG
|
||||
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.2 or later before running autoconf/autogen])])
|
||||
XORG_MACROS_VERSION(1.2)
|
||||
# Require xorg-macros: XORG_DEFAULT_OPTIONS
|
||||
m4_ifndef([XORG_MACROS_VERSION], [AC_FATAL([must install xorg-macros 1.3 or later before running autoconf/autogen])])
|
||||
XORG_MACROS_VERSION(1.3)
|
||||
AM_CONFIG_HEADER([config.h])
|
||||
|
||||
# Checks for programs.
|
||||
AC_DISABLE_STATIC
|
||||
AC_PROG_LIBTOOL
|
||||
AC_PROG_CC
|
||||
XORG_CWARNFLAGS
|
||||
XORG_DEFAULT_OPTIONS
|
||||
|
||||
AH_TOP([#include "xorg-server.h"])
|
||||
|
||||
@@ -70,10 +70,6 @@ AC_HEADER_STDC
|
||||
DRIVER_NAME=evdev
|
||||
AC_SUBST([DRIVER_NAME])
|
||||
|
||||
XORG_MANPAGE_SECTIONS
|
||||
XORG_RELEASE_VERSION
|
||||
XORG_CHANGELOG
|
||||
|
||||
AC_OUTPUT([Makefile
|
||||
src/Makefile
|
||||
man/Makefile
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
#define EVDEV_PROP_WHEEL_INERTIA "Evdev Wheel Emulation Inertia"
|
||||
/* CARD16 */
|
||||
#define EVDEV_PROP_WHEEL_TIMEOUT "Evdev Wheel Emulation Timeout"
|
||||
/* CARD8, value range 0-32, 0 to disable a value */
|
||||
/* CARD8, value range 0-32, 0 to always scroll */
|
||||
#define EVDEV_PROP_WHEEL_BUTTON "Evdev Wheel Emulation Button"
|
||||
|
||||
/* Drag lock */
|
||||
|
||||
@@ -105,7 +105,10 @@ press/release events as specified for the
|
||||
.B XAxisMapping
|
||||
and
|
||||
.B YAxisMapping
|
||||
settings. Default: 4. Property: "Evdev Wheel Emulation Button".
|
||||
settings. If the button is 0 and
|
||||
.BR EmulateWheel
|
||||
is on, any motion of the device is converted into wheel events. Default: 4.
|
||||
Property: "Evdev Wheel Emulation Button".
|
||||
.TP 7
|
||||
.BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q
|
||||
Specifies how far (in pixels) the pointer must move to generate button
|
||||
@@ -132,6 +135,17 @@ Default: disabled.
|
||||
.BI "Option \*qInvertY\*q \*q" Bool \*q
|
||||
Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
|
||||
.TP 7
|
||||
.BI "Option \*qIgnoreRelativeAxes\*q \*q" Bool \*q
|
||||
.TP 7
|
||||
.BI "Option \*qIgnoreAbsoluteAxes\*q \*q" Bool \*q
|
||||
Ignore the specified type of axis. Default: off. The X server cannot deal
|
||||
with devices that have both relative and absolute axes. Evdev tries to guess
|
||||
wich axes to ignore given the device type and disables absolute axes for
|
||||
mice and relative axes for tablets, touchscreens and touchpad. These options
|
||||
allow to forcibly disable an axis type. Mouse wheel axes are exempt and will
|
||||
work even if relative axes are ignored. No property, this configuration must
|
||||
be set in the configuration.
|
||||
.TP 7
|
||||
.BI "Option \*qReopenAttempts\*q \*q" integer \*q
|
||||
Number of reopen attempts after a read error occurs on the device (e.g. after
|
||||
waking up from suspend). In between each attempt is a 100ms wait. Default: 10.
|
||||
|
||||
@@ -54,7 +54,7 @@ static Atom prop_wheel_button = 0;
|
||||
|
||||
/* Local Funciton Prototypes */
|
||||
static BOOL EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char *axis_name);
|
||||
static void EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
|
||||
static int EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
|
||||
|
||||
/* Filter mouse button events */
|
||||
BOOL
|
||||
@@ -98,38 +98,51 @@ BOOL
|
||||
EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
WheelAxisPtr pAxis = NULL;
|
||||
WheelAxisPtr pAxis = NULL, pOtherAxis = NULL;
|
||||
int value = pEv->value;
|
||||
int ms;
|
||||
|
||||
/* Has wheel emulation been configured to be enabled? */
|
||||
if (!pEvdev->emulateWheel.enabled)
|
||||
return FALSE;
|
||||
|
||||
/* Handle our motion events if the emuWheel button is pressed*/
|
||||
if (pEvdev->emulateWheel.button_state) {
|
||||
/* Handle our motion events if the emuWheel button is pressed
|
||||
* wheel button of 0 means always emulate wheel.
|
||||
*/
|
||||
if (pEvdev->emulateWheel.button_state || !pEvdev->emulateWheel.button) {
|
||||
/* Just return if the timeout hasn't expired yet */
|
||||
ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
|
||||
if (ms > 0)
|
||||
return TRUE;
|
||||
if (pEvdev->emulateWheel.button)
|
||||
{
|
||||
int ms = pEvdev->emulateWheel.expires - GetTimeInMillis();
|
||||
if (ms > 0)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* We don't want to intercept real mouse wheel events */
|
||||
switch(pEv->code) {
|
||||
case REL_X:
|
||||
pAxis = &(pEvdev->emulateWheel.X);
|
||||
pOtherAxis = &(pEvdev->emulateWheel.Y);
|
||||
break;
|
||||
|
||||
case REL_Y:
|
||||
pAxis = &(pEvdev->emulateWheel.Y);
|
||||
pOtherAxis = &(pEvdev->emulateWheel.X);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/* If we found REL_X or REL_Y, emulate a mouse wheel */
|
||||
/* If we found REL_X or REL_Y, emulate a mouse wheel.
|
||||
Reset the inertia of the other axis when a scroll event was sent
|
||||
to avoid the buildup of erroneous scroll events if the user
|
||||
doesn't move in a perfectly straight line.
|
||||
*/
|
||||
if (pAxis)
|
||||
EvdevWheelEmuInertia(pInfo, pAxis, value);
|
||||
{
|
||||
if (EvdevWheelEmuInertia(pInfo, pAxis, value))
|
||||
pOtherAxis->traveled_distance = 0;
|
||||
}
|
||||
|
||||
/* Eat motion events while emulateWheel button pressed. */
|
||||
return TRUE;
|
||||
@@ -138,17 +151,20 @@ EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Simulate inertia for our emulated mouse wheel */
|
||||
static void
|
||||
/* Simulate inertia for our emulated mouse wheel.
|
||||
Returns the number of wheel events generated.
|
||||
*/
|
||||
static int
|
||||
EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
|
||||
{
|
||||
EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
|
||||
int button;
|
||||
int inertia;
|
||||
int rc = 0;
|
||||
|
||||
/* if this axis has not been configured, just eat the motion */
|
||||
if (!axis->up_button)
|
||||
return;
|
||||
return rc;
|
||||
|
||||
axis->traveled_distance += value;
|
||||
|
||||
@@ -164,7 +180,9 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
|
||||
while(abs(axis->traveled_distance) > pEvdev->emulateWheel.inertia) {
|
||||
axis->traveled_distance -= inertia;
|
||||
EvdevQueueButtonClicks(pInfo, button, 1);
|
||||
rc++;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Handle button mapping here to avoid code duplication,
|
||||
|
||||
39
src/evdev.c
39
src/evdev.c
@@ -1774,8 +1774,9 @@ error:
|
||||
static int
|
||||
EvdevProbe(InputInfoPtr pInfo)
|
||||
{
|
||||
int i, has_rel_axes, has_abs_axes, has_xy, has_keys, num_buttons, has_scroll;
|
||||
int i, has_rel_axes, has_abs_axes, has_keys, num_buttons, has_scroll;
|
||||
int kernel24 = 0;
|
||||
int ignore_rel, ignore_abs;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
|
||||
@@ -1791,9 +1792,11 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
ioctl(pInfo->fd, EVIOCGRAB, (void *)0);
|
||||
}
|
||||
|
||||
ignore_rel = xf86SetBoolOption(pInfo->options, "IgnoreRelativeAxes", FALSE);
|
||||
ignore_abs = xf86SetBoolOption(pInfo->options, "IgnoreAbsoluteAxes", FALSE);
|
||||
|
||||
has_rel_axes = FALSE;
|
||||
has_abs_axes = FALSE;
|
||||
has_xy = FALSE;
|
||||
has_keys = FALSE;
|
||||
has_scroll = FALSE;
|
||||
num_buttons = 0;
|
||||
@@ -1804,8 +1807,7 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
int mapping = 0;
|
||||
if (TestBit(i, pEvdev->key_bitmask))
|
||||
{
|
||||
mapping =
|
||||
pEvdev->btnmap[EvdevUtilButtonEventToButtonNumber(pEvdev, i)];
|
||||
mapping = EvdevUtilButtonEventToButtonNumber(pEvdev, i);
|
||||
if (mapping > num_buttons)
|
||||
num_buttons = mapping;
|
||||
}
|
||||
@@ -1827,14 +1829,6 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
}
|
||||
|
||||
if (has_rel_axes) {
|
||||
xf86Msg(X_INFO, "%s: found relative axes\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
|
||||
if (TestBit(REL_X, pEvdev->rel_bitmask) &&
|
||||
TestBit(REL_Y, pEvdev->rel_bitmask)) {
|
||||
xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
|
||||
has_xy = TRUE;
|
||||
}
|
||||
|
||||
if (TestBit(REL_WHEEL, pEvdev->rel_bitmask) ||
|
||||
TestBit(REL_HWHEEL, pEvdev->rel_bitmask) ||
|
||||
TestBit(REL_DIAL, pEvdev->rel_bitmask)) {
|
||||
@@ -1846,6 +1840,20 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
num_buttons = (num_buttons < 3) ? 7 : num_buttons + 4;
|
||||
pEvdev->num_buttons = num_buttons;
|
||||
}
|
||||
|
||||
if (!ignore_rel)
|
||||
{
|
||||
xf86Msg(X_INFO, "%s: found relative axes\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
|
||||
|
||||
if (TestBit(REL_X, pEvdev->rel_bitmask) &&
|
||||
TestBit(REL_Y, pEvdev->rel_bitmask)) {
|
||||
xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
|
||||
}
|
||||
} else {
|
||||
xf86Msg(X_INFO, "%s: relative axes present but ignored.\n", pInfo->name);
|
||||
has_rel_axes = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ABS_MAX; i++) {
|
||||
@@ -1855,7 +1863,11 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
}
|
||||
}
|
||||
|
||||
if (has_abs_axes) {
|
||||
if (ignore_abs && has_abs_axes)
|
||||
{
|
||||
xf86Msg(X_INFO, "%s: absolute axes present but ignored.\n", pInfo->name);
|
||||
has_abs_axes = FALSE;
|
||||
} else if (has_abs_axes) {
|
||||
xf86Msg(X_INFO, "%s: found absolute axes\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
|
||||
|
||||
@@ -1878,7 +1890,6 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
pEvdev->flags |= EVDEV_BUTTON_EVENTS;
|
||||
}
|
||||
}
|
||||
has_xy = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user