mirror of
https://github.com/X11Libre/xf86-input-evdev.git
synced 2026-04-14 11:44:16 +00:00
Compare commits
8 Commits
xf86-input
...
xf86-input
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a64a78791f | ||
|
|
09b2a5e87b | ||
|
|
fa18a4a38d | ||
|
|
172523d745 | ||
|
|
8fb820ffaf | ||
|
|
c7893b212d | ||
|
|
e9dd721e2d | ||
|
|
cab104fd9e |
@@ -22,7 +22,7 @@
|
||||
|
||||
AC_PREREQ(2.57)
|
||||
AC_INIT([xf86-input-evdev],
|
||||
2.0.99.1,
|
||||
2.0.99.2,
|
||||
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
|
||||
xf86-input-evdev)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
/* Middle mouse button emulation */
|
||||
/* BOOL */
|
||||
#define EVDEV_PROP_MIDBUTTON "Evdev Middle Button Emulation"
|
||||
/* CARD16 */
|
||||
/* CARD32 */
|
||||
#define EVDEV_PROP_MIDBUTTON_TIMEOUT "Evdev Middle Button Timeout"
|
||||
|
||||
/* Wheel emulation */
|
||||
|
||||
@@ -11,6 +11,7 @@ evdev \- Generic Linux input driver
|
||||
.BI " Option \*qDevice\*q \*q" devpath \*q
|
||||
.BI " Option \*qEmulate3Buttons\*q \*q" True \*q
|
||||
.BI " Option \*qEmulate3Timeout\*q \*q" 50 \*q
|
||||
.BI " Option \*qGrabDevice\*q \*q" False \*q
|
||||
\ \ ...
|
||||
.B EndSection
|
||||
.fi
|
||||
@@ -145,6 +146,13 @@ waking up from suspend). In between each attempt is a 100ms wait. Default: 10.
|
||||
.TP 7
|
||||
.BI "Option \*qInvertY\*q \*q" Bool \*q
|
||||
Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
|
||||
.TP 7
|
||||
.BI "Option \*qGrabDevice\*q \*q" boolean \*q
|
||||
Force a grab on the event device. Doing so will ensure that no other driver
|
||||
can initialise the same device and it will also stop the device from sending
|
||||
events to /dev/kbd or /dev/input/mice. Events from this device will not be
|
||||
sent to virtual devices (e.g. rfkill or the Macintosh mouse button emulation).
|
||||
Default disabled.
|
||||
|
||||
.SH SUPPORTED PROPERTIES
|
||||
The following properties are provided by the
|
||||
|
||||
@@ -358,11 +358,11 @@ EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
|
||||
pEvdev->emulateMB.enabled = *((BOOL*)val->data);
|
||||
} else if (atom == prop_mbtimeout)
|
||||
{
|
||||
if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
|
||||
if (val->format != 32 || val->size != 1 || val->type != XA_INTEGER)
|
||||
return BadMatch;
|
||||
|
||||
if (!checkonly)
|
||||
pEvdev->emulateMB.timeout = *((INT16*)val->data);
|
||||
pEvdev->emulateMB.timeout = *((CARD32*)val->data);
|
||||
}
|
||||
|
||||
return Success;
|
||||
@@ -393,7 +393,7 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
|
||||
prop_mbtimeout = MakeAtom(EVDEV_PROP_MIDBUTTON_TIMEOUT,
|
||||
strlen(EVDEV_PROP_MIDBUTTON_TIMEOUT),
|
||||
TRUE);
|
||||
rc = XIChangeDeviceProperty(dev, prop_mbtimeout, XA_INTEGER, 16, PropModeReplace, 1,
|
||||
rc = XIChangeDeviceProperty(dev, prop_mbtimeout, XA_INTEGER, 32, PropModeReplace, 1,
|
||||
&pEvdev->emulateMB.timeout, FALSE);
|
||||
|
||||
if (rc != Success)
|
||||
|
||||
88
src/evdev.c
88
src/evdev.c
@@ -75,6 +75,7 @@
|
||||
#define EVDEV_ABSOLUTE_EVENTS (1 << 3)
|
||||
#define EVDEV_TOUCHPAD (1 << 4)
|
||||
#define EVDEV_INITIALIZED (1 << 5) /* WheelInit etc. called already? */
|
||||
#define EVDEV_TOUCHSCREEN (1 << 6)
|
||||
|
||||
#define MIN_KEYCODE 8
|
||||
#define GLYPHS_PER_KEY 2
|
||||
@@ -164,6 +165,10 @@ PostKbdEvent(InputInfoPtr pInfo, struct input_event *ev, int value)
|
||||
warned[ev->code] = 1;
|
||||
}
|
||||
|
||||
/* The X server can't handle keycodes > 255 anyway, just drop them. */
|
||||
if (code > 255)
|
||||
return;
|
||||
|
||||
xf86PostKeyboardEvent(pInfo->dev, code, value);
|
||||
}
|
||||
|
||||
@@ -313,7 +318,12 @@ EvdevReadInput(InputInfoPtr pInfo)
|
||||
case BTN_TOOL_MOUSE:
|
||||
case BTN_TOOL_LENS:
|
||||
pEvdev->tool = value ? ev.code : 0;
|
||||
break;
|
||||
if (!(pEvdev->flags & EVDEV_TOUCHSCREEN))
|
||||
break;
|
||||
/* Treat BTN_TOUCH from devices that only have BTN_TOUCH as
|
||||
* BTN_LEFT. */
|
||||
ev.code = BTN_LEFT;
|
||||
/* Intentional fallthrough! */
|
||||
|
||||
default:
|
||||
button = EvdevUtilButtonEventToButtonNumber(ev.code);
|
||||
@@ -386,7 +396,7 @@ EvdevReadInput(InputInfoPtr pInfo)
|
||||
}
|
||||
}
|
||||
|
||||
#define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1 << ((bit) % LONG_BITS))
|
||||
#define TestBit(bit, array) (array[(bit) / LONG_BITS]) & (1L << ((bit) % LONG_BITS))
|
||||
|
||||
static void
|
||||
EvdevPtrCtrlProc(DeviceIntPtr device, PtrCtrl *ctrl)
|
||||
@@ -665,6 +675,8 @@ EvdevKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
|
||||
struct input_event ev[ArrayLength(bits)];
|
||||
int i;
|
||||
|
||||
memset(ev, 0, sizeof(ev));
|
||||
|
||||
pInfo = device->public.devicePrivate;
|
||||
for (i = 0; i < ArrayLength(bits); i++) {
|
||||
ev[i].type = EV_LED;
|
||||
@@ -975,7 +987,7 @@ EvdevOn(DeviceIntPtr device)
|
||||
pInfo = device->public.devicePrivate;
|
||||
pEvdev = pInfo->private;
|
||||
|
||||
if (pInfo->fd != -1 && !pEvdev->kernel24 &&
|
||||
if (pInfo->fd != -1 && pEvdev->grabDevice &&
|
||||
(rc = ioctl(pInfo->fd, EVIOCGRAB, (void *)1)))
|
||||
{
|
||||
xf86Msg(X_WARNING, "%s: Grab failed (%s)\n", pInfo->name,
|
||||
@@ -1024,7 +1036,7 @@ EvdevProc(DeviceIntPtr device, int what)
|
||||
case DEVICE_OFF:
|
||||
if (pInfo->fd != -1)
|
||||
{
|
||||
if (!pEvdev->kernel24 && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
|
||||
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)0))
|
||||
xf86Msg(X_WARNING, "%s: Release failed (%s)\n", pInfo->name,
|
||||
strerror(errno));
|
||||
xf86RemoveEnabledDevice(pInfo);
|
||||
@@ -1169,21 +1181,23 @@ error:
|
||||
static int
|
||||
EvdevProbe(InputInfoPtr pInfo)
|
||||
{
|
||||
long key_bitmask[NBITS(KEY_MAX)];
|
||||
long rel_bitmask[NBITS(REL_MAX)];
|
||||
long abs_bitmask[NBITS(ABS_MAX)];
|
||||
long key_bitmask[NBITS(KEY_MAX)] = {0};
|
||||
long rel_bitmask[NBITS(REL_MAX)] = {0};
|
||||
long abs_bitmask[NBITS(ABS_MAX)] = {0};
|
||||
int i, has_axes, has_keys, num_buttons;
|
||||
int kernel24 = 0;
|
||||
EvdevPtr pEvdev = pInfo->private;
|
||||
|
||||
if (ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
|
||||
if (pEvdev->grabDevice && ioctl(pInfo->fd, EVIOCGRAB, (void *)1)) {
|
||||
if (errno == EINVAL) {
|
||||
/* keyboards are unsafe in 2.4 */
|
||||
pEvdev->kernel24 = 1;
|
||||
kernel24 = 1;
|
||||
pEvdev->grabDevice = 0;
|
||||
} else {
|
||||
xf86Msg(X_ERROR, "Grab failed. Device already configured?\n");
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
} else if (pEvdev->grabDevice) {
|
||||
ioctl(pInfo->fd, EVIOCGRAB, (void *)0);
|
||||
}
|
||||
|
||||
@@ -1209,23 +1223,6 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
has_keys = FALSE;
|
||||
num_buttons = 0;
|
||||
|
||||
if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) {
|
||||
xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
|
||||
has_axes = TRUE;
|
||||
}
|
||||
|
||||
if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) {
|
||||
xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
|
||||
if (TestBit(BTN_TOUCH, key_bitmask)) {
|
||||
xf86Msg(X_INFO, "%s: Found absolute touchpad\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_TOUCHPAD;
|
||||
pEvdev->old_x = pEvdev->old_y = -1;
|
||||
}
|
||||
has_axes = TRUE;
|
||||
}
|
||||
|
||||
/* count all buttons */
|
||||
for (i = BTN_MISC; i < BTN_JOYSTICK; i++)
|
||||
{
|
||||
@@ -1241,6 +1238,29 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
num_buttons);
|
||||
}
|
||||
|
||||
if (TestBit(REL_X, rel_bitmask) && TestBit(REL_Y, rel_bitmask)) {
|
||||
xf86Msg(X_INFO, "%s: Found x and y relative axes\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_RELATIVE_EVENTS;
|
||||
has_axes = TRUE;
|
||||
}
|
||||
|
||||
if (TestBit(ABS_X, abs_bitmask) && TestBit(ABS_Y, abs_bitmask)) {
|
||||
xf86Msg(X_INFO, "%s: Found x and y absolute axes\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_ABSOLUTE_EVENTS;
|
||||
if (TestBit(BTN_TOUCH, key_bitmask)) {
|
||||
if (num_buttons) {
|
||||
xf86Msg(X_INFO, "%s: Found absolute touchpad\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_TOUCHPAD;
|
||||
pEvdev->old_x = pEvdev->old_y = -1;
|
||||
} else {
|
||||
xf86Msg(X_INFO, "%s: Found absolute touchscreen\n", pInfo->name);
|
||||
pEvdev->flags |= EVDEV_TOUCHSCREEN;
|
||||
pEvdev->flags |= EVDEV_BUTTON_EVENTS;
|
||||
}
|
||||
}
|
||||
has_axes = TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < BTN_MISC; i++)
|
||||
if (TestBit(i, key_bitmask))
|
||||
break;
|
||||
@@ -1258,8 +1278,15 @@ EvdevProbe(InputInfoPtr pInfo)
|
||||
pInfo->type_name = XI_MOUSE;
|
||||
}
|
||||
|
||||
if (pEvdev->flags & EVDEV_TOUCHSCREEN) {
|
||||
xf86Msg(X_INFO, "%s: Configuring as touchscreen\n", pInfo->name);
|
||||
pInfo->type_name = XI_TOUCHSCREEN;
|
||||
pInfo->flags |= XI86_POINTER_CAPABLE | XI86_SEND_DRAG_EVENTS |
|
||||
XI86_CONFIGURED;
|
||||
}
|
||||
|
||||
if (has_keys) {
|
||||
if (pEvdev->kernel24) {
|
||||
if (kernel24) {
|
||||
xf86Msg(X_INFO, "%s: Kernel < 2.6 is too old, ignoring keyboard\n",
|
||||
pInfo->name);
|
||||
} else {
|
||||
@@ -1344,6 +1371,11 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
|
||||
pEvdev->invert_x = xf86SetBoolOption(pInfo->options, "InvertX", FALSE);
|
||||
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
|
||||
|
||||
/* Grabbing the event device stops in-kernel event forwarding. In other
|
||||
words, it disables rfkill and the "Macintosh mouse button emulation".
|
||||
Note that this needs a server that sets the console to RAW mode. */
|
||||
pEvdev->grabDevice = xf86CheckBoolOption(dev->commonOptions, "GrabDevice", 0);
|
||||
|
||||
pEvdev->noXkb = noXkbExtension; /* parse the XKB options during kbd setup */
|
||||
|
||||
EvdevInitButtonMapping(pInfo);
|
||||
|
||||
@@ -57,7 +57,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
const char *device;
|
||||
int kernel24;
|
||||
int grabDevice; /* grab the event device? */
|
||||
int screen;
|
||||
int min_x, min_y, max_x, max_y;
|
||||
int abs_x, abs_y, old_x, old_y;
|
||||
|
||||
Reference in New Issue
Block a user