mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Compare commits
15 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f7850a4042 | ||
|
|
bd4102af6e | ||
|
|
22e816eb32 | ||
|
|
b6b377fe9a | ||
|
|
3772676fd6 | ||
|
|
4f05afd495 | ||
|
|
c6964dd28a | ||
|
|
175af93bdb | ||
|
|
7c3c7f83d0 | ||
|
|
aa6399fdb9 | ||
|
|
1d86f5dec1 | ||
|
|
fbd86e2530 | ||
|
|
9ea1f9a695 | ||
|
|
57b54ee399 | ||
|
|
f2dc0681fe |
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
AC_PREREQ(2.57)
|
AC_PREREQ(2.57)
|
||||||
AC_INIT([xf86-input-evdev],
|
AC_INIT([xf86-input-evdev],
|
||||||
2.2.99.2,
|
2.3.2,
|
||||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||||
xf86-input-evdev)
|
xf86-input-evdev)
|
||||||
|
|
||||||
|
|||||||
@@ -138,18 +138,31 @@ Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
|
|||||||
.BI "Option \*qIgnoreRelativeAxes\*q \*q" Bool \*q
|
.BI "Option \*qIgnoreRelativeAxes\*q \*q" Bool \*q
|
||||||
.TP 7
|
.TP 7
|
||||||
.BI "Option \*qIgnoreAbsoluteAxes\*q \*q" Bool \*q
|
.BI "Option \*qIgnoreAbsoluteAxes\*q \*q" Bool \*q
|
||||||
Ignore the specified type of axis. Default: off. The X server cannot deal
|
Ignore the specified type of axis. Default: unset. The X server cannot deal
|
||||||
with devices that have both relative and absolute axes. Evdev tries to guess
|
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
|
wich axes to ignore given the device type and disables absolute axes for
|
||||||
mice and relative axes for tablets, touchscreens and touchpad. These options
|
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
|
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
|
work even if relative axes are ignored. No property, this configuration must
|
||||||
be set in the configuration.
|
be set in the configuration.
|
||||||
|
.br
|
||||||
|
If either option is set to False, the driver will not ignore the specified
|
||||||
|
axes regardless of the presence of other axes. This may trigger buggy
|
||||||
|
behavior and events from this axis are always forwarded. Users are
|
||||||
|
discouraged from setting this option.
|
||||||
.TP 7
|
.TP 7
|
||||||
.BI "Option \*qReopenAttempts\*q \*q" integer \*q
|
.BI "Option \*qReopenAttempts\*q \*q" integer \*q
|
||||||
Number of reopen attempts after a read error occurs on the device (e.g. after
|
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.
|
waking up from suspend). In between each attempt is a 100ms wait. Default: 10.
|
||||||
.TP 7
|
.TP 7
|
||||||
|
.BI "Option \*qCalibration\*q \*q" "min-x max-x min-y max-y" \*q
|
||||||
|
Calibrates the X and Y axes for devices that need to scale to a different
|
||||||
|
coordinate system than reported to the X server. This feature is required
|
||||||
|
for devices that need to scale to a different coordinate system than
|
||||||
|
originally reported by the kernel (e.g. touchscreens). The scaling to the
|
||||||
|
custom coordinate system is done in-driver and the X server is unaware of
|
||||||
|
the transformation. Property: "Evdev Axis Calibration".
|
||||||
|
.TP 7
|
||||||
.BI "Option \*qSwapAxes\*q \*q" Bool \*q
|
.BI "Option \*qSwapAxes\*q \*q" Bool \*q
|
||||||
Swap x/y axes. Default: off. Property: "Evdev Axes Swap".
|
Swap x/y axes. Default: off. Property: "Evdev Axes Swap".
|
||||||
.TP 7
|
.TP 7
|
||||||
@@ -178,9 +191,7 @@ driver.
|
|||||||
.TP 7
|
.TP 7
|
||||||
.BI "Evdev Axis Calibration"
|
.BI "Evdev Axis Calibration"
|
||||||
4 32-bit values, order min-x, max-x, min-y, max-y or 0 values to disable
|
4 32-bit values, order min-x, max-x, min-y, max-y or 0 values to disable
|
||||||
run-time axis calibration. This feature is required for devices that need to
|
in-driver axis calibration.
|
||||||
scale to a different coordinate system than originally reported to the X
|
|
||||||
server, such as touchscreens that require run-time calibration.
|
|
||||||
.TP 7
|
.TP 7
|
||||||
.BI "Evdev Axis Inversion"
|
.BI "Evdev Axis Inversion"
|
||||||
2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis.
|
2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis.
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
|||||||
pEvdev->dragLock.meta = meta;
|
pEvdev->dragLock.meta = meta;
|
||||||
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
|
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
|
||||||
}
|
}
|
||||||
} else
|
} else if ((val->size % 2) == 0)
|
||||||
{
|
{
|
||||||
CARD8* vals = (CARD8*)val->data;
|
CARD8* vals = (CARD8*)val->data;
|
||||||
|
|
||||||
@@ -269,10 +269,11 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
|||||||
pEvdev->dragLock.meta = 0;
|
pEvdev->dragLock.meta = 0;
|
||||||
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
|
memset(pEvdev->dragLock.lock_pair, 0, sizeof(pEvdev->dragLock.lock_pair));
|
||||||
|
|
||||||
for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i++)
|
for (i = 0; i < val->size && i < EVDEV_MAXBUTTONS; i += 2)
|
||||||
pEvdev->dragLock.lock_pair[i] = vals[i];
|
pEvdev->dragLock.lock_pair[vals[i] - 1] = vals[i + 1];
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
return BadMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
|||||||
290
src/evdev.c
290
src/evdev.c
@@ -89,7 +89,9 @@
|
|||||||
#define EVDEV_INITIALIZED (1 << 5) /* WheelInit etc. called already? */
|
#define EVDEV_INITIALIZED (1 << 5) /* WheelInit etc. called already? */
|
||||||
#define EVDEV_TOUCHSCREEN (1 << 6)
|
#define EVDEV_TOUCHSCREEN (1 << 6)
|
||||||
#define EVDEV_CALIBRATED (1 << 7) /* run-time calibrated? */
|
#define EVDEV_CALIBRATED (1 << 7) /* run-time calibrated? */
|
||||||
#define EVDEV_TABLET (1 << 8) /* run-time calibrated? */
|
#define EVDEV_TABLET (1 << 8) /* device looks like a tablet? */
|
||||||
|
#define EVDEV_UNIGNORE_ABSOLUTE (1 << 9) /* explicitly unignore abs axes */
|
||||||
|
#define EVDEV_UNIGNORE_RELATIVE (1 << 10) /* explicitly unignore rel axes */
|
||||||
|
|
||||||
#define MIN_KEYCODE 8
|
#define MIN_KEYCODE 8
|
||||||
#define GLYPHS_PER_KEY 2
|
#define GLYPHS_PER_KEY 2
|
||||||
@@ -438,7 +440,7 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
|
|||||||
for (i = 0; i < REL_CNT; i++)
|
for (i = 0; i < REL_CNT; i++)
|
||||||
{
|
{
|
||||||
int map = pEvdev->axis_map[i];
|
int map = pEvdev->axis_map[i];
|
||||||
if (pEvdev->delta[i] && map != -1)
|
if (map != -1)
|
||||||
{
|
{
|
||||||
v[map] = pEvdev->delta[i];
|
v[map] = pEvdev->delta[i];
|
||||||
if (map < first)
|
if (map < first)
|
||||||
@@ -462,6 +464,13 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
|
|||||||
*/
|
*/
|
||||||
else if (pEvdev->abs && pEvdev->tool) {
|
else if (pEvdev->abs && pEvdev->tool) {
|
||||||
memcpy(v, pEvdev->vals, sizeof(int) * pEvdev->num_vals);
|
memcpy(v, pEvdev->vals, sizeof(int) * pEvdev->num_vals);
|
||||||
|
|
||||||
|
if (pEvdev->swap_axes) {
|
||||||
|
int tmp = v[0];
|
||||||
|
v[0] = v[1];
|
||||||
|
v[1] = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
if (pEvdev->flags & EVDEV_CALIBRATED)
|
if (pEvdev->flags & EVDEV_CALIBRATED)
|
||||||
{
|
{
|
||||||
v[0] = xf86ScaleAxis(v[0],
|
v[0] = xf86ScaleAxis(v[0],
|
||||||
@@ -474,12 +483,6 @@ EvdevProcessValuators(InputInfoPtr pInfo, int v[MAX_VALUATORS], int *num_v,
|
|||||||
pEvdev->calibration.max_y, pEvdev->calibration.min_y);
|
pEvdev->calibration.max_y, pEvdev->calibration.min_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pEvdev->swap_axes) {
|
|
||||||
int tmp = v[0];
|
|
||||||
v[0] = v[1];
|
|
||||||
v[1] = tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pEvdev->invert_x)
|
if (pEvdev->invert_x)
|
||||||
v[0] = (pEvdev->absinfo[ABS_X].maximum - v[0] +
|
v[0] = (pEvdev->absinfo[ABS_X].maximum - v[0] +
|
||||||
pEvdev->absinfo[ABS_X].minimum);
|
pEvdev->absinfo[ABS_X].minimum);
|
||||||
@@ -614,7 +617,6 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
switch (ev->code) {
|
switch (ev->code) {
|
||||||
case BTN_TOUCH:
|
|
||||||
case BTN_TOOL_PEN:
|
case BTN_TOOL_PEN:
|
||||||
case BTN_TOOL_RUBBER:
|
case BTN_TOOL_RUBBER:
|
||||||
case BTN_TOOL_BRUSH:
|
case BTN_TOOL_BRUSH:
|
||||||
@@ -624,7 +626,11 @@ EvdevProcessKeyEvent(InputInfoPtr pInfo, struct input_event *ev)
|
|||||||
case BTN_TOOL_MOUSE:
|
case BTN_TOOL_MOUSE:
|
||||||
case BTN_TOOL_LENS:
|
case BTN_TOOL_LENS:
|
||||||
pEvdev->tool = value ? ev->code : 0;
|
pEvdev->tool = value ? ev->code : 0;
|
||||||
if (!(pEvdev->flags & EVDEV_TOUCHSCREEN))
|
break;
|
||||||
|
|
||||||
|
case BTN_TOUCH:
|
||||||
|
pEvdev->tool = value ? ev->code : 0;
|
||||||
|
if (!(pEvdev->flags & (EVDEV_TOUCHSCREEN | EVDEV_TABLET)))
|
||||||
break;
|
break;
|
||||||
/* Treat BTN_TOUCH from devices that only have BTN_TOUCH as
|
/* Treat BTN_TOUCH from devices that only have BTN_TOUCH as
|
||||||
* BTN_LEFT. */
|
* BTN_LEFT. */
|
||||||
@@ -768,6 +774,7 @@ EvdevReadInput(InputInfoPtr pInfo)
|
|||||||
{
|
{
|
||||||
if (errno == ENODEV) /* May happen after resume */
|
if (errno == ENODEV) /* May happen after resume */
|
||||||
{
|
{
|
||||||
|
EvdevMBEmuFinalize(pInfo);
|
||||||
xf86RemoveEnabledDevice(pInfo);
|
xf86RemoveEnabledDevice(pInfo);
|
||||||
close(pInfo->fd);
|
close(pInfo->fd);
|
||||||
pInfo->fd = -1;
|
pInfo->fd = -1;
|
||||||
@@ -1421,6 +1428,17 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
EvdevInitAnyClass(DeviceIntPtr device, EvdevPtr pEvdev)
|
||||||
|
{
|
||||||
|
if (pEvdev->flags & EVDEV_RELATIVE_EVENTS &&
|
||||||
|
EvdevAddRelClass(device) == Success)
|
||||||
|
xf86Msg(X_INFO, "%s: initialized for relative axes.\n", device->name);
|
||||||
|
if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS &&
|
||||||
|
EvdevAddAbsClass(device) == Success)
|
||||||
|
xf86Msg(X_INFO, "%s: initialized for absolute axes.\n", device->name);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
EvdevInitAbsClass(DeviceIntPtr device, EvdevPtr pEvdev)
|
EvdevInitAbsClass(DeviceIntPtr device, EvdevPtr pEvdev)
|
||||||
{
|
{
|
||||||
@@ -1512,7 +1530,9 @@ EvdevInit(DeviceIntPtr device)
|
|||||||
* used and relative axes are ignored.
|
* used and relative axes are ignored.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN | EVDEV_TABLET))
|
if (pEvdev->flags & (EVDEV_UNIGNORE_RELATIVE | EVDEV_UNIGNORE_ABSOLUTE))
|
||||||
|
EvdevInitAnyClass(device, pEvdev);
|
||||||
|
else if (pEvdev->flags & (EVDEV_TOUCHPAD | EVDEV_TOUCHSCREEN | EVDEV_TABLET))
|
||||||
EvdevInitTouchDevice(device, pEvdev);
|
EvdevInitTouchDevice(device, pEvdev);
|
||||||
else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
|
else if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
|
||||||
EvdevInitRelClass(device, pEvdev);
|
EvdevInitRelClass(device, pEvdev);
|
||||||
@@ -1655,6 +1675,7 @@ static int
|
|||||||
EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare)
|
EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare)
|
||||||
{
|
{
|
||||||
EvdevPtr pEvdev = pInfo->private;
|
EvdevPtr pEvdev = pInfo->private;
|
||||||
|
size_t len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
char name[1024] = {0};
|
char name[1024] = {0};
|
||||||
@@ -1663,107 +1684,122 @@ EvdevCacheCompare(InputInfoPtr pInfo, BOOL compare)
|
|||||||
unsigned long rel_bitmask[NLONGS(REL_CNT)] = {0};
|
unsigned long rel_bitmask[NLONGS(REL_CNT)] = {0};
|
||||||
unsigned long abs_bitmask[NLONGS(ABS_CNT)] = {0};
|
unsigned long abs_bitmask[NLONGS(ABS_CNT)] = {0};
|
||||||
unsigned long led_bitmask[NLONGS(LED_CNT)] = {0};
|
unsigned long led_bitmask[NLONGS(LED_CNT)] = {0};
|
||||||
struct input_absinfo absinfo[ABS_CNT];
|
|
||||||
|
|
||||||
if (ioctl(pInfo->fd,
|
if (ioctl(pInfo->fd, EVIOCGNAME(sizeof(name) - 1), name) < 0) {
|
||||||
EVIOCGNAME(sizeof(name) - 1), name) < 0) {
|
|
||||||
xf86Msg(X_ERROR, "ioctl EVIOCGNAME failed: %s\n", strerror(errno));
|
xf86Msg(X_ERROR, "ioctl EVIOCGNAME failed: %s\n", strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare && strcmp(pEvdev->name, name)) {
|
if (!compare) {
|
||||||
xf86Msg(X_ERROR, "%s: device name changed: %s != %s\n", pInfo->name, pEvdev->name, name);
|
strcpy(pEvdev->name, name);
|
||||||
|
} else if (strcmp(pEvdev->name, name)) {
|
||||||
|
xf86Msg(X_ERROR, "%s: device name changed: %s != %s\n",
|
||||||
|
pInfo->name, pEvdev->name, name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(pInfo->fd,
|
len = ioctl(pInfo->fd, EVIOCGBIT(0, sizeof(bitmask)), bitmask);
|
||||||
EVIOCGBIT(0, sizeof(bitmask)), bitmask) < 0) {
|
if (len < 0) {
|
||||||
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno));
|
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n",
|
||||||
|
pInfo->name, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare && memcmp(pEvdev->bitmask, bitmask, sizeof(bitmask))) {
|
if (!compare) {
|
||||||
|
memcpy(pEvdev->bitmask, bitmask, len);
|
||||||
|
} else if (memcmp(pEvdev->bitmask, bitmask, len)) {
|
||||||
xf86Msg(X_ERROR, "%s: device bitmask has changed\n", pInfo->name);
|
xf86Msg(X_ERROR, "%s: device bitmask has changed\n", pInfo->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
len = ioctl(pInfo->fd, EVIOCGBIT(EV_REL, sizeof(rel_bitmask)), rel_bitmask);
|
||||||
if (ioctl(pInfo->fd,
|
if (len < 0) {
|
||||||
EVIOCGBIT(EV_REL, sizeof(rel_bitmask)), rel_bitmask) < 0) {
|
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n",
|
||||||
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno));
|
pInfo->name, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare && memcmp(pEvdev->rel_bitmask, rel_bitmask, sizeof(rel_bitmask))) {
|
if (!compare) {
|
||||||
|
memcpy(pEvdev->rel_bitmask, rel_bitmask, len);
|
||||||
|
} else if (memcmp(pEvdev->rel_bitmask, rel_bitmask, len)) {
|
||||||
xf86Msg(X_ERROR, "%s: device rel_bitmask has changed\n", pInfo->name);
|
xf86Msg(X_ERROR, "%s: device rel_bitmask has changed\n", pInfo->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(pInfo->fd,
|
len = ioctl(pInfo->fd, EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask);
|
||||||
EVIOCGBIT(EV_ABS, sizeof(abs_bitmask)), abs_bitmask) < 0) {
|
if (len < 0) {
|
||||||
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno));
|
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n",
|
||||||
|
pInfo->name, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare && memcmp(pEvdev->abs_bitmask, abs_bitmask, sizeof(abs_bitmask))) {
|
if (!compare) {
|
||||||
|
memcpy(pEvdev->abs_bitmask, abs_bitmask, len);
|
||||||
|
} else if (memcmp(pEvdev->abs_bitmask, abs_bitmask, len)) {
|
||||||
xf86Msg(X_ERROR, "%s: device abs_bitmask has changed\n", pInfo->name);
|
xf86Msg(X_ERROR, "%s: device abs_bitmask has changed\n", pInfo->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(pInfo->fd,
|
len = ioctl(pInfo->fd, EVIOCGBIT(EV_LED, sizeof(led_bitmask)), led_bitmask);
|
||||||
EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask) < 0) {
|
if (len < 0) {
|
||||||
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno));
|
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n",
|
||||||
|
pInfo->name, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare && memcmp(pEvdev->key_bitmask, key_bitmask, sizeof(key_bitmask))) {
|
if (!compare) {
|
||||||
xf86Msg(X_ERROR, "%s: device key_bitmask has changed\n", pInfo->name);
|
memcpy(pEvdev->led_bitmask, led_bitmask, len);
|
||||||
goto error;
|
} else if (memcmp(pEvdev->led_bitmask, led_bitmask, len)) {
|
||||||
}
|
|
||||||
|
|
||||||
if (ioctl(pInfo->fd,
|
|
||||||
EVIOCGBIT(EV_LED, sizeof(led_bitmask)), led_bitmask) < 0) {
|
|
||||||
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n", pInfo->name, strerror(errno));
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (compare && memcmp(pEvdev->led_bitmask, led_bitmask, sizeof(led_bitmask))) {
|
|
||||||
xf86Msg(X_ERROR, "%s: device led_bitmask has changed\n", pInfo->name);
|
xf86Msg(X_ERROR, "%s: device led_bitmask has changed\n", pInfo->name);
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(absinfo, 0, sizeof(absinfo));
|
/*
|
||||||
|
* Do not try to validate absinfo data since it is not expected
|
||||||
for (i = ABS_X; i <= ABS_MAX; i++)
|
* to be static, always refresh it in evdev structure.
|
||||||
{
|
*/
|
||||||
if (TestBit(i, abs_bitmask))
|
for (i = ABS_X; i <= ABS_MAX; i++) {
|
||||||
{
|
if (TestBit(i, abs_bitmask)) {
|
||||||
if (ioctl(pInfo->fd, EVIOCGABS(i), &absinfo[i]) < 0) {
|
len = ioctl(pInfo->fd, EVIOCGABS(i), &pEvdev->absinfo[i]);
|
||||||
xf86Msg(X_ERROR, "%s: ioctl EVIOCGABS failed: %s\n", pInfo->name, strerror(errno));
|
if (len < 0) {
|
||||||
|
xf86Msg(X_ERROR, "%s: ioctl EVIOCGABSi(%d) failed: %s\n",
|
||||||
|
pInfo->name, i, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
/* ignore current position (value) in comparison (bug #19819) */
|
|
||||||
absinfo[i].value = pEvdev->absinfo[i].value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compare && memcmp(pEvdev->absinfo, absinfo, sizeof(absinfo))) {
|
len = ioctl(pInfo->fd, EVIOCGBIT(EV_KEY, sizeof(key_bitmask)), key_bitmask);
|
||||||
xf86Msg(X_ERROR, "%s: device absinfo has changed\n", pInfo->name);
|
if (len < 0) {
|
||||||
|
xf86Msg(X_ERROR, "%s: ioctl EVIOCGBIT failed: %s\n",
|
||||||
|
pInfo->name, strerror(errno));
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cache info */
|
if (compare) {
|
||||||
if (!compare)
|
/*
|
||||||
{
|
* Keys are special as user can adjust keymap at any time (on
|
||||||
strcpy(pEvdev->name, name);
|
* devices that support EVIOCSKEYCODE. However we do not expect
|
||||||
memcpy(pEvdev->bitmask, bitmask, sizeof(bitmask));
|
* buttons reserved for mice/tablets/digitizers and so on to
|
||||||
memcpy(pEvdev->key_bitmask, key_bitmask, sizeof(key_bitmask));
|
* appear/disappear so we will check only those in
|
||||||
memcpy(pEvdev->rel_bitmask, rel_bitmask, sizeof(rel_bitmask));
|
* [BTN_MISC, KEY_OK) range.
|
||||||
memcpy(pEvdev->abs_bitmask, abs_bitmask, sizeof(abs_bitmask));
|
*/
|
||||||
memcpy(pEvdev->led_bitmask, led_bitmask, sizeof(led_bitmask));
|
size_t start_word = BTN_MISC / LONG_BITS;
|
||||||
memcpy(pEvdev->absinfo, absinfo, sizeof(absinfo));
|
size_t start_byte = start_word * sizeof(unsigned long);
|
||||||
|
size_t end_word = KEY_OK / LONG_BITS;
|
||||||
|
size_t end_byte = end_word * sizeof(unsigned long);
|
||||||
|
|
||||||
|
if (len >= start_byte &&
|
||||||
|
memcmp(&pEvdev->key_bitmask[start_word], &key_bitmask[start_word],
|
||||||
|
min(len, end_byte) - start_byte + 1)) {
|
||||||
|
xf86Msg(X_ERROR, "%s: device key_bitmask has changed\n", pInfo->name);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Copy the data so we have reasonably up-to-date info */
|
||||||
|
memcpy(pEvdev->key_bitmask, key_bitmask, len);
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@@ -1776,7 +1812,7 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
{
|
{
|
||||||
int i, has_rel_axes, has_abs_axes, has_keys, num_buttons, has_scroll;
|
int i, has_rel_axes, has_abs_axes, has_keys, num_buttons, has_scroll;
|
||||||
int kernel24 = 0;
|
int kernel24 = 0;
|
||||||
int ignore_rel, ignore_abs;
|
int ignore_abs = 0, ignore_rel = 0;
|
||||||
EvdevPtr pEvdev = pInfo->private;
|
EvdevPtr pEvdev = pInfo->private;
|
||||||
|
|
||||||
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
|
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
|
||||||
@@ -1792,8 +1828,26 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
ioctl(pInfo->fd, EVIOCGRAB, (void *)0);
|
ioctl(pInfo->fd, EVIOCGRAB, (void *)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
ignore_rel = xf86SetBoolOption(pInfo->options, "IgnoreRelativeAxes", FALSE);
|
/* Trinary state for ignoring axes:
|
||||||
ignore_abs = xf86SetBoolOption(pInfo->options, "IgnoreAbsoluteAxes", FALSE);
|
- unset: do the normal thing.
|
||||||
|
- TRUE: explicitly ignore them.
|
||||||
|
- FALSE: unignore axes, use them at all cost if they're present.
|
||||||
|
*/
|
||||||
|
if (xf86FindOption(pInfo->options, "IgnoreRelativeAxes"))
|
||||||
|
{
|
||||||
|
if (xf86SetBoolOption(pInfo->options, "IgnoreRelativeAxes", FALSE))
|
||||||
|
ignore_rel = TRUE;
|
||||||
|
else
|
||||||
|
pEvdev->flags |= EVDEV_UNIGNORE_RELATIVE;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (xf86FindOption(pInfo->options, "IgnoreAbsoluteAxes"))
|
||||||
|
{
|
||||||
|
if (xf86SetBoolOption(pInfo->options, "IgnoreAbsoluteAxes", FALSE))
|
||||||
|
ignore_abs = TRUE;
|
||||||
|
else
|
||||||
|
pEvdev->flags |= EVDEV_UNIGNORE_ABSOLUTE;
|
||||||
|
}
|
||||||
|
|
||||||
has_rel_axes = FALSE;
|
has_rel_axes = FALSE;
|
||||||
has_abs_axes = FALSE;
|
has_abs_axes = FALSE;
|
||||||
@@ -1843,7 +1897,7 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
|
|
||||||
if (!ignore_rel)
|
if (!ignore_rel)
|
||||||
{
|
{
|
||||||
xf86Msg(X_INFO, "%s: found relative axes\n", pInfo->name);
|
xf86Msg(X_INFO, "%s: Found relative axes\n", pInfo->name);
|
||||||
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
|
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
|
||||||
|
|
||||||
if (TestBit(REL_X, pEvdev->rel_bitmask) &&
|
if (TestBit(REL_X, pEvdev->rel_bitmask) &&
|
||||||
@@ -1851,7 +1905,7 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
|
xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
xf86Msg(X_INFO, "%s: relative axes present but ignored.\n", pInfo->name);
|
xf86Msg(X_INFO, "%s: Relative axes present but ignored.\n", pInfo->name);
|
||||||
has_rel_axes = FALSE;
|
has_rel_axes = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1865,10 +1919,10 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
|
|
||||||
if (ignore_abs && has_abs_axes)
|
if (ignore_abs && has_abs_axes)
|
||||||
{
|
{
|
||||||
xf86Msg(X_INFO, "%s: absolute axes present but ignored.\n", pInfo->name);
|
xf86Msg(X_INFO, "%s: Absolute axes present but ignored.\n", pInfo->name);
|
||||||
has_abs_axes = FALSE;
|
has_abs_axes = FALSE;
|
||||||
} else if (has_abs_axes) {
|
} else if (has_abs_axes) {
|
||||||
xf86Msg(X_INFO, "%s: found absolute axes\n", pInfo->name);
|
xf86Msg(X_INFO, "%s: Found absolute axes\n", pInfo->name);
|
||||||
pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
|
pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
|
||||||
|
|
||||||
if ((TestBit(ABS_X, pEvdev->abs_bitmask) &&
|
if ((TestBit(ABS_X, pEvdev->abs_bitmask) &&
|
||||||
@@ -1878,6 +1932,11 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
{
|
{
|
||||||
xf86Msg(X_INFO, "%s: Found absolute tablet.\n", pInfo->name);
|
xf86Msg(X_INFO, "%s: Found absolute tablet.\n", pInfo->name);
|
||||||
pEvdev->flags |= EVDEV_TABLET;
|
pEvdev->flags |= EVDEV_TABLET;
|
||||||
|
if (!pEvdev->num_buttons)
|
||||||
|
{
|
||||||
|
pEvdev->num_buttons = 7; /* LMR + scroll wheels */
|
||||||
|
pEvdev->flags |= EVDEV_BUTTON_EVENTS;
|
||||||
|
}
|
||||||
} else if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask) ||
|
} else if (TestBit(ABS_PRESSURE, pEvdev->abs_bitmask) ||
|
||||||
TestBit(BTN_TOUCH, pEvdev->key_bitmask)) {
|
TestBit(BTN_TOUCH, pEvdev->key_bitmask)) {
|
||||||
if (num_buttons || TestBit(BTN_TOOL_FINGER, pEvdev->key_bitmask)) {
|
if (num_buttons || TestBit(BTN_TOOL_FINGER, pEvdev->key_bitmask)) {
|
||||||
@@ -1949,12 +2008,32 @@ EvdevProbe(InputInfoPtr pInfo)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4])
|
||||||
|
{
|
||||||
|
EvdevPtr pEvdev = pInfo->private;
|
||||||
|
|
||||||
|
if (num_calibration == 0) {
|
||||||
|
pEvdev->flags &= ~EVDEV_CALIBRATED;
|
||||||
|
pEvdev->calibration.min_x = 0;
|
||||||
|
pEvdev->calibration.max_x = 0;
|
||||||
|
pEvdev->calibration.min_y = 0;
|
||||||
|
pEvdev->calibration.max_y = 0;
|
||||||
|
} else if (num_calibration == 4) {
|
||||||
|
pEvdev->flags |= EVDEV_CALIBRATED;
|
||||||
|
pEvdev->calibration.min_x = calibration[0];
|
||||||
|
pEvdev->calibration.max_x = calibration[1];
|
||||||
|
pEvdev->calibration.min_y = calibration[2];
|
||||||
|
pEvdev->calibration.max_y = calibration[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static InputInfoPtr
|
static InputInfoPtr
|
||||||
EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
||||||
{
|
{
|
||||||
InputInfoPtr pInfo;
|
InputInfoPtr pInfo;
|
||||||
const char *device;
|
const char *device, *str;
|
||||||
|
int num_calibration = 0, calibration[4] = { 0, 0, 0, 0 };
|
||||||
EvdevPtr pEvdev;
|
EvdevPtr pEvdev;
|
||||||
|
|
||||||
if (!(pInfo = xf86AllocateInput(drv, 0)))
|
if (!(pInfo = xf86AllocateInput(drv, 0)))
|
||||||
@@ -2027,6 +2106,19 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
|||||||
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
|
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
|
||||||
pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
|
pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
|
||||||
|
|
||||||
|
str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
|
||||||
|
if (str) {
|
||||||
|
num_calibration = sscanf(str, "%d %d %d %d",
|
||||||
|
&calibration[0], &calibration[1],
|
||||||
|
&calibration[2], &calibration[3]);
|
||||||
|
if (num_calibration == 4)
|
||||||
|
EvdevSetCalibration(pInfo, num_calibration, calibration);
|
||||||
|
else
|
||||||
|
xf86Msg(X_ERROR,
|
||||||
|
"%s: Insufficient calibration factors (%d). Ignoring calibration\n",
|
||||||
|
pInfo->name, num_calibration);
|
||||||
|
}
|
||||||
|
|
||||||
/* Grabbing the event device stops in-kernel event forwarding. In other
|
/* Grabbing the event device stops in-kernel event forwarding. In other
|
||||||
words, it disables rfkill and the "Macintosh mouse button emulation".
|
words, it disables rfkill and the "Macintosh mouse button emulation".
|
||||||
Note that this needs a server that sets the console to RAW mode. */
|
Note that this needs a server that sets the console to RAW mode. */
|
||||||
@@ -2318,16 +2410,16 @@ static void EvdevInitAxesLabels(EvdevPtr pEvdev, int natoms, Atom *atoms)
|
|||||||
int labels_len = 0;
|
int labels_len = 0;
|
||||||
char *misc_label;
|
char *misc_label;
|
||||||
|
|
||||||
if (pEvdev->flags & EVDEV_RELATIVE_EVENTS)
|
if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
|
||||||
{
|
|
||||||
labels = rel_labels;
|
|
||||||
labels_len = ArrayLength(rel_labels);
|
|
||||||
misc_label = AXIS_LABEL_PROP_REL_MISC;
|
|
||||||
} else if ((pEvdev->flags & EVDEV_ABSOLUTE_EVENTS))
|
|
||||||
{
|
{
|
||||||
labels = abs_labels;
|
labels = abs_labels;
|
||||||
labels_len = ArrayLength(abs_labels);
|
labels_len = ArrayLength(abs_labels);
|
||||||
misc_label = AXIS_LABEL_PROP_ABS_MISC;
|
misc_label = AXIS_LABEL_PROP_ABS_MISC;
|
||||||
|
} else if ((pEvdev->flags & EVDEV_RELATIVE_EVENTS))
|
||||||
|
{
|
||||||
|
labels = rel_labels;
|
||||||
|
labels_len = ArrayLength(rel_labels);
|
||||||
|
misc_label = AXIS_LABEL_PROP_REL_MISC;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(atoms, 0, natoms * sizeof(Atom));
|
memset(atoms, 0, natoms * sizeof(Atom));
|
||||||
@@ -2427,8 +2519,22 @@ EvdevInitProperty(DeviceIntPtr dev)
|
|||||||
|
|
||||||
prop_calibration = MakeAtom(EVDEV_PROP_CALIBRATION,
|
prop_calibration = MakeAtom(EVDEV_PROP_CALIBRATION,
|
||||||
strlen(EVDEV_PROP_CALIBRATION), TRUE);
|
strlen(EVDEV_PROP_CALIBRATION), TRUE);
|
||||||
rc = XIChangeDeviceProperty(dev, prop_calibration, XA_INTEGER, 32,
|
if (pEvdev->flags & EVDEV_CALIBRATED) {
|
||||||
PropModeReplace, 0, NULL, FALSE);
|
int calibration[4];
|
||||||
|
|
||||||
|
calibration[0] = pEvdev->calibration.min_x;
|
||||||
|
calibration[1] = pEvdev->calibration.max_x;
|
||||||
|
calibration[2] = pEvdev->calibration.min_y;
|
||||||
|
calibration[3] = pEvdev->calibration.max_y;
|
||||||
|
|
||||||
|
rc = XIChangeDeviceProperty(dev, prop_calibration, XA_INTEGER,
|
||||||
|
32, PropModeReplace, 4, calibration,
|
||||||
|
FALSE);
|
||||||
|
} else if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS) {
|
||||||
|
rc = XIChangeDeviceProperty(dev, prop_calibration, XA_INTEGER,
|
||||||
|
32, PropModeReplace, 0, NULL,
|
||||||
|
FALSE);
|
||||||
|
}
|
||||||
if (rc != Success)
|
if (rc != Success)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -2502,25 +2608,7 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
|||||||
return BadMatch;
|
return BadMatch;
|
||||||
|
|
||||||
if (!checkonly)
|
if (!checkonly)
|
||||||
{
|
EvdevSetCalibration(pInfo, val->size, val->data);
|
||||||
if (val->size == 0)
|
|
||||||
{
|
|
||||||
pEvdev->flags &= ~EVDEV_CALIBRATED;
|
|
||||||
pEvdev->calibration.min_x = 0;
|
|
||||||
pEvdev->calibration.max_x = 0;
|
|
||||||
pEvdev->calibration.min_y = 0;
|
|
||||||
pEvdev->calibration.max_y = 0;
|
|
||||||
} else if (val->size == 4)
|
|
||||||
{
|
|
||||||
CARD32 *vals = (CARD32*)val->data;
|
|
||||||
|
|
||||||
pEvdev->flags |= EVDEV_CALIBRATED;
|
|
||||||
pEvdev->calibration.min_x = vals[0];
|
|
||||||
pEvdev->calibration.max_x = vals[1];
|
|
||||||
pEvdev->calibration.min_y = vals[2];
|
|
||||||
pEvdev->calibration.max_y = vals[3];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (atom == prop_swap)
|
} else if (atom == prop_swap)
|
||||||
{
|
{
|
||||||
if (val->format != 8 || val->type != XA_INTEGER || val->size != 1)
|
if (val->format != 8 || val->type != XA_INTEGER || val->size != 1)
|
||||||
|
|||||||
Reference in New Issue
Block a user