Compare commits

...

13 Commits

Author SHA1 Message Date
Peter Hutterer
708eb34599 evdev 2.1 RC 1. 2008-10-14 17:19:58 +10:30
Peter Hutterer
36a687796f Fix "Device reopened after N attempts" message.
(cherry picked from commit 0089d931ac)
2008-10-14 17:18:08 +10:30
Peter Hutterer
26229df106 Don't init draglock, etc. if we don't have the required capabilities.
(cherry picked from commit 0f5a5ac09e)
2008-10-14 17:18:07 +10:30
Peter Hutterer
f4616d87fc 8-bit properties should use 8-bit storage types...
(cherry picked from commit 36d68b006d)
2008-10-14 17:18:07 +10:30
Peter Hutterer
2aa5ca8cdd Don't include the client-side header anymore. xkbstr.h is server SDK.
(cherry picked from commit bb1f421687)
2008-10-14 17:18:07 +10:30
Peter Hutterer
39263dc65d Tidy up evdev.h
This includes shuffling some functions around so we don't need the prototypes
in evdev.h.
(cherry picked from commit 0405f7b17f)
2008-10-14 17:18:07 +10:30
Peter Hutterer
57521e4e60 Rename DragLockInit to DragLockPreInit, remove superfluous "return".
(cherry picked from commit 088e0a175a)
2008-10-14 17:18:07 +10:30
Peter Hutterer
7da1522309 Register property handler from within the modules, not the main evdev file.
(cherry picked from commit cefedeb205)
2008-10-14 17:18:07 +10:30
Peter Hutterer
b4fcb825fc Clean up program flow - don't call PreInit for "modules" on DEVICE_INIT.
Call the PreInit functions for MB Emulation, wheel emu, and draglock during
PreInit, not on DEVICE_INIT. This way, we only parse the options once and
don't overwrite with defaults when coming back from a VT switch.
(cherry picked from commit b0737bdbd1)
2008-10-14 17:18:07 +10:30
Peter Hutterer
7c955ad050 Janitor: clean up xf86Msg use, might as well use X_CONFIG directly.
(cherry picked from commit 5f2c8a2dcd)
2008-10-14 17:18:07 +10:30
Peter Hutterer
4f80c0f2cb Add property support for ReopenAttempts option.
(cherry picked from commit ff783fce65)
2008-10-14 17:18:07 +10:30
Peter Hutterer
5070d64aa8 Document properties in man page.
(cherry picked from commit c638aa4a88)
2008-10-14 17:18:07 +10:30
Peter Hutterer
caacacf057 Document InvertX/Y options.
(cherry picked from commit b46677e346)
2008-10-14 17:18:07 +10:30
8 changed files with 240 additions and 206 deletions

View File

@@ -22,7 +22,7 @@
AC_PREREQ(2.57) AC_PREREQ(2.57)
AC_INIT([xf86-input-evdev], AC_INIT([xf86-input-evdev],
2.0.99, 2.0.99.1,
[https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
xf86-input-evdev) xf86-input-evdev)

View File

@@ -54,4 +54,8 @@
/* BOOL, 2 values [x, y], 1 inverts axis */ /* BOOL, 2 values [x, y], 1 inverts axis */
#define EVDEV_PROP_INVERT_AXES "Evdev Axis Inversion" #define EVDEV_PROP_INVERT_AXES "Evdev Axis Inversion"
/* Reopen attempts. */
/* CARD8 */
#define EVDEV_PROP_REOPEN "Evdev Reopen Attempts"
#endif #endif

View File

@@ -52,12 +52,12 @@ The mapping from device node to hardware is system-dependent.
Enable/disable the emulation of the third (middle) mouse button for mice Enable/disable the emulation of the third (middle) mouse button for mice
which only have two physical buttons. The third button is emulated by which only have two physical buttons. The third button is emulated by
pressing both buttons simultaneously. Default: on, until a middle mouse pressing both buttons simultaneously. Default: on, until a middle mouse
button event is registered. button event is registered. Property: "Evdev Middle Button Emulation".
.TP 7 .TP 7
.BI "Option \*qEmulate3Timeout\*q \*q" integer \*q .BI "Option \*qEmulate3Timeout\*q \*q" integer \*q
Sets the timeout (in milliseconds) that the driver waits before deciding Sets the timeout (in milliseconds) that the driver waits before deciding
if two buttons where pressed "simultaneously" when 3 button emulation is if two buttons where pressed "simultaneously" when 3 button emulation is
enabled. Default: 50. enabled. Default: 50. Property: "Evdev Middle Button Timeout".
.TP 7 .TP 7
.BI "Option \*qButtonMapping\*q \*q" string \*q .BI "Option \*qButtonMapping\*q \*q" string \*q
Sets the button mapping for this device. The mapping is a space-separated list Sets the button mapping for this device. The mapping is a space-separated list
@@ -74,12 +74,13 @@ Sets \*qdrag lock buttons\*q that simulate holding a button down, so
that low dexterity people do not have to hold a button down at the that low dexterity people do not have to hold a button down at the
same time they move a mouse cursor. Button numbers occur in pairs, same time they move a mouse cursor. Button numbers occur in pairs,
with the lock button number occurring first, followed by the button with the lock button number occurring first, followed by the button
number that is the target of the lock button. number that is the target of the lock button. Property: "Evdev
Drag Lock Buttons".
.TP 7 .TP 7
.BI "Option \*qDragLockButtons\*q \*q" "M1" \*q .BI "Option \*qDragLockButtons\*q \*q" "M1" \*q
Sets a \*qmaster drag lock button\*q that acts as a \*qMeta Key\*q Sets a \*qmaster drag lock button\*q that acts as a \*qMeta Key\*q
indicating that the next button pressed is to be indicating that the next button pressed is to be
\*qdrag locked\*q. \*qdrag locked\*q. Property: "Evdev Drag Lock Buttons".
.TP 7 .TP 7
.BI "Option \*qEmulateWheel\*q \*q" boolean \*q .BI "Option \*qEmulateWheel\*q \*q" boolean \*q
Enable/disable "wheel" emulation. Wheel emulation means emulating button Enable/disable "wheel" emulation. Wheel emulation means emulating button
@@ -94,7 +95,7 @@ more buttons but no wheel. See the description of the
.BR XAxisMapping , .BR XAxisMapping ,
and and
.B YAxisMapping .B YAxisMapping
options below. Default: off. options below. Default: off. Property "Evdev Wheel Emulation".
.TP 7 .TP 7
.BI "Option \*qEmulateWheelButton\*q \*q" integer \*q .BI "Option \*qEmulateWheelButton\*q \*q" integer \*q
Specifies which button must be held down to enable wheel emulation mode. Specifies which button must be held down to enable wheel emulation mode.
@@ -103,11 +104,12 @@ press/release events as specified for the
.B XAxisMapping .B XAxisMapping
and and
.B YAxisMapping .B YAxisMapping
settings. Default: 4. settings. Default: 4. Property: "Evdev Wheel Emulation Button".
.TP 7 .TP 7
.BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q .BI "Option \*qEmulateWheelInertia\*q \*q" integer \*q
Specifies how far (in pixels) the pointer must move to generate button Specifies how far (in pixels) the pointer must move to generate button
press/release events in wheel emulation mode. Default: 10. press/release events in wheel emulation mode. Default: 10. Property: "Evdev
Wheel Emulation Inertia".
.TP 7 .TP 7
.BI "Option \*qEmulateWheelTimeout\*q \*q" integer \*q .BI "Option \*qEmulateWheelTimeout\*q \*q" integer \*q
Specifies the time in milliseconds the Specifies the time in milliseconds the
@@ -115,7 +117,7 @@ Specifies the time in milliseconds the
must be pressed before wheel emulation is started. If the must be pressed before wheel emulation is started. If the
.BR EmulateWheelButton .BR EmulateWheelButton
is released before this timeout, the original button press/release event is released before this timeout, the original button press/release event
is sent. Default: 200. is sent. Default: 200. Property: "Evdev Wheel Emulation Timeout".
.TP 7 .TP 7
.BI "Option \*qXAxisMapping\*q \*q" "N1 N2" \*q .BI "Option \*qXAxisMapping\*q \*q" "N1 N2" \*q
Specifies which buttons are mapped to motion in the X direction in wheel Specifies which buttons are mapped to motion in the X direction in wheel
@@ -123,7 +125,8 @@ emulation mode. Button number
.I N1 .I N1
is mapped to the negative X axis motion and button number is mapped to the negative X axis motion and button number
.I N2 .I N2
is mapped to the positive X axis motion. Default: no mapping. is mapped to the positive X axis motion. Default: no mapping. Property:
"Evdev Wheel Emulation Axes".
.TP 7 .TP 7
.BI "Option \*qYAxisMapping\*q \*q" "N1 N2" \*q .BI "Option \*qYAxisMapping\*q \*q" "N1 N2" \*q
Specifies which buttons are mapped to motion in the Y direction in wheel Specifies which buttons are mapped to motion in the Y direction in wheel
@@ -131,11 +134,50 @@ emulation mode. Button number
.I N1 .I N1
is mapped to the negative Y axis motion and button number is mapped to the negative Y axis motion and button number
.I N2 .I N2
is mapped to the positive Y axis motion. Default: "4 5" is mapped to the positive Y axis motion. Default: "4 5". Property:
"Evdev Wheel Emulation Axes".
.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
.BI "Option \*qInvertX\*q \*q" Bool \*q
.TP 7
.BI "Option \*qInvertY\*q \*q" Bool \*q
Invert the given axis. Default: off. Property: "Evdev Axis Inversion".
.SH SUPPORTED PROPERTIES
The following properties are provided by the
.B evdev
driver.
.TP 7
.BI "Evdev Middle Button Emulation"
1 boolean value (8 bit, 0 or 1).
.TP 7
.BI "Evdev Middle Button Timeout"
1 16-bit positive value.
.TP 7
.BI "Evdev Wheel Emulation"
1 boolean value (8 bit, 0 or 1).
.TP 7
.BI "Evdev Wheel Emulation Axes"
4 8-bit values, order X up, X down, Y up, Y down. 0 disables a value.
.TP 7
.BI "Evdev Wheel Emulation Inertia"
1 16-bit positive value.
.TP 7
.BI "Evdev Wheel Emulation Timeout"
1 16-bit positive value.
.TP 7
.BI "Evdev Wheel Emulation Button"
1 8-bit value, allowed range 0-32, 0 disables the button.
.TP 7
.BI "Evdev Drag Lock Buttons"
8-bit. Either 1 value or pairs of values. Value range 0-32, 0 disables a
value.
.TP 7
.BI "Evdev Axis Inversion"
2 boolean values (8 bit, 0 or 1), order X, Y. 1 inverts the axis.
.SH AUTHORS .SH AUTHORS
Kristian Høgsberg. Kristian Høgsberg.

View File

@@ -53,7 +53,7 @@ void EvdevDragLockLockButton(InputInfoPtr pInfo, unsigned int button);
/* Setup and configuration code */ /* Setup and configuration code */
void void
EvdevDragLockInit(InputInfoPtr pInfo) EvdevDragLockPreInit(InputInfoPtr pInfo)
{ {
EvdevPtr pEvdev = (EvdevPtr)pInfo->private; EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
char *option_string = NULL; char *option_string = NULL;
@@ -210,45 +210,6 @@ EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value)
} }
#ifdef HAVE_PROPERTIES #ifdef HAVE_PROPERTIES
/**
* Initialise property for drag lock buttons setting.
*/
void
EvdevDragLockInitProperty(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
if (!dev->button) /* don't init prop for keyboards */
return;
prop_dlock = MakeAtom(EVDEV_PROP_DRAGLOCK, strlen(EVDEV_PROP_DRAGLOCK), TRUE);
if (pEvdev->dragLock.meta)
{
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8,
PropModeReplace, 1, &pEvdev->dragLock.meta,
FALSE);
} else {
int highest = 0;
int i;
CARD8 pair[EVDEV_MAXBUTTONS] = {0};
for (i = 0; i < EVDEV_MAXBUTTONS; i++)
{
if (pEvdev->dragLock.lock_pair[i])
highest = i;
pair[i] = pEvdev->dragLock.lock_pair[i];
}
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, PropModeReplace,
highest + 1, pair, FALSE);
}
XISetDevicePropertyDeletable(dev, prop_dlock, FALSE);
return;
}
/** /**
* Set the drag lock property. * Set the drag lock property.
* If only one value is supplied, then this is used as the meta button. * If only one value is supplied, then this is used as the meta button.
@@ -314,4 +275,44 @@ EvdevDragLockSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
return Success; return Success;
} }
/**
* Initialise property for drag lock buttons setting.
*/
void
EvdevDragLockInitProperty(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
if (!dev->button) /* don't init prop for keyboards */
return;
prop_dlock = MakeAtom(EVDEV_PROP_DRAGLOCK, strlen(EVDEV_PROP_DRAGLOCK), TRUE);
if (pEvdev->dragLock.meta)
{
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8,
PropModeReplace, 1, &pEvdev->dragLock.meta,
FALSE);
} else {
int highest = 0;
int i;
CARD8 pair[EVDEV_MAXBUTTONS] = {0};
for (i = 0; i < EVDEV_MAXBUTTONS; i++)
{
if (pEvdev->dragLock.lock_pair[i])
highest = i;
pair[i] = pEvdev->dragLock.lock_pair[i];
}
XIChangeDeviceProperty(dev, prop_dlock, XA_INTEGER, 8, PropModeReplace,
highest + 1, pair, FALSE);
}
XISetDevicePropertyDeletable(dev, prop_dlock, FALSE);
XIRegisterPropertyHandler(dev, EvdevDragLockSetProperty, NULL, NULL);
}
#endif #endif

View File

@@ -320,15 +320,6 @@ EvdevMBEmuPreInit(InputInfoPtr pInfo)
RegisterBlockAndWakeupHandlers (EvdevMBEmuBlockHandler, RegisterBlockAndWakeupHandlers (EvdevMBEmuBlockHandler,
EvdevMBEmuWakeupHandler, EvdevMBEmuWakeupHandler,
(pointer)pInfo); (pointer)pInfo);
#ifdef HAVE_PROPERTIES
XIChangeDeviceProperty(pInfo->dev, prop_mbemu, XA_INTEGER, 8,
PropModeReplace, 1, &pEvdev->emulateMB.enabled,
TRUE);
XIChangeDeviceProperty(pInfo->dev, prop_mbtimeout, XA_INTEGER, 16,
PropModeReplace, 1, &pEvdev->emulateMB.timeout,
TRUE);
#endif
} }
void void
@@ -351,6 +342,32 @@ EvdevMBEmuEnable(InputInfoPtr pInfo, BOOL enable)
#ifdef HAVE_PROPERTIES #ifdef HAVE_PROPERTIES
int
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
if (atom == prop_mbemu)
{
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
pEvdev->emulateMB.enabled = *((BOOL*)val->data);
} else if (atom == prop_mbtimeout)
{
if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
pEvdev->emulateMB.timeout = *((INT16*)val->data);
}
return Success;
}
/** /**
* Initialise property for MB emulation on/off. * Initialise property for MB emulation on/off.
*/ */
@@ -382,31 +399,7 @@ EvdevMBEmuInitProperty(DeviceIntPtr dev)
if (rc != Success) if (rc != Success)
return; return;
XISetDevicePropertyDeletable(dev, prop_mbtimeout, FALSE); XISetDevicePropertyDeletable(dev, prop_mbtimeout, FALSE);
}
int XIRegisterPropertyHandler(dev, EvdevMBEmuSetProperty, NULL, NULL);
EvdevMBEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
if (atom == prop_mbemu)
{
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
pEvdev->emulateMB.enabled = *((BOOL*)val->data);
} else if (atom == prop_mbtimeout)
{
if (val->format != 16 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
pEvdev->emulateMB.timeout = *((INT16*)val->data);
}
return Success;
} }
#endif #endif

View File

@@ -308,91 +308,9 @@ EvdevWheelEmuPreInit(InputInfoPtr pInfo)
"EmulateWheelInertia: %d, " "EmulateWheelInertia: %d, "
"EmulateWheelTimeout: %d\n", "EmulateWheelTimeout: %d\n",
pInfo->name, pEvdev->emulateWheel.button, inertia, timeout); pInfo->name, pEvdev->emulateWheel.button, inertia, timeout);
#ifdef HAVE_PROPERTIES
XIChangeDeviceProperty(pInfo->dev, prop_wheel_emu, XA_INTEGER, 8,
PropModeReplace, 1, &pEvdev->emulateWheel.enabled, TRUE);
XIChangeDeviceProperty(pInfo->dev, prop_wheel_button, XA_INTEGER, 8,
PropModeReplace, 1, &pEvdev->emulateWheel.button, TRUE);
XIChangeDeviceProperty(pInfo->dev, prop_wheel_inertia, XA_INTEGER, 8,
PropModeReplace, 1, &pEvdev->emulateWheel.inertia, TRUE);
XIChangeDeviceProperty(pInfo->dev, prop_wheel_timeout, XA_INTEGER, 16,
PropModeReplace, 1, &pEvdev->emulateWheel.timeout, TRUE);
val[0] = pEvdev->emulateWheel.X.up_button;
val[1] = pEvdev->emulateWheel.X.down_button;
val[2] = pEvdev->emulateWheel.Y.up_button;
val[3] = pEvdev->emulateWheel.Y.down_button;
XIChangeDeviceProperty(pInfo->dev, prop_wheel_axismap, XA_INTEGER, 8,
PropModeReplace, 4, val, TRUE);
#endif
} }
#ifdef HAVE_PROPERTIES #ifdef HAVE_PROPERTIES
void
EvdevWheelEmuInitProperty(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
int rc = TRUE;
INT32 vals[4] = { TRUE, FALSE};
if (!dev->button) /* don't init prop for keyboards */
return;
prop_wheel_emu = MakeAtom(EVDEV_PROP_WHEEL, strlen(EVDEV_PROP_WHEEL), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_emu, XA_INTEGER, 8,
PropModeReplace, 1,
&pEvdev->emulateWheel.enabled, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_emu, FALSE);
vals[0] = pEvdev->emulateWheel.X.up_button;
vals[1] = pEvdev->emulateWheel.X.down_button;
vals[2] = pEvdev->emulateWheel.Y.up_button;
vals[3] = pEvdev->emulateWheel.Y.down_button;
prop_wheel_axismap = MakeAtom(EVDEV_PROP_WHEEL_AXES, strlen(EVDEV_PROP_WHEEL_AXES), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_axismap, XA_INTEGER, 8,
PropModeReplace, 4, vals, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_axismap, FALSE);
prop_wheel_inertia = MakeAtom(EVDEV_PROP_WHEEL_INERTIA, strlen(EVDEV_PROP_WHEEL_INERTIA), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16,
PropModeReplace, 1,
&pEvdev->emulateWheel.inertia, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_inertia, FALSE);
prop_wheel_timeout = MakeAtom(EVDEV_PROP_WHEEL_TIMEOUT, strlen(EVDEV_PROP_WHEEL_TIMEOUT), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
PropModeReplace, 1,
&pEvdev->emulateWheel.timeout, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_timeout, FALSE);
prop_wheel_button = MakeAtom(EVDEV_PROP_WHEEL_BUTTON, strlen(EVDEV_PROP_WHEEL_BUTTON), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_button, XA_INTEGER, 8,
PropModeReplace, 1,
&pEvdev->emulateWheel.button, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_button, FALSE);
}
int int
EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val, EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
BOOL checkonly) BOOL checkonly)
@@ -482,4 +400,67 @@ EvdevWheelEmuSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
return Success; return Success;
} }
void
EvdevWheelEmuInitProperty(DeviceIntPtr dev)
{
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
int rc = TRUE;
char vals[4];
if (!dev->button) /* don't init prop for keyboards */
return;
prop_wheel_emu = MakeAtom(EVDEV_PROP_WHEEL, strlen(EVDEV_PROP_WHEEL), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_emu, XA_INTEGER, 8,
PropModeReplace, 1,
&pEvdev->emulateWheel.enabled, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_emu, FALSE);
vals[0] = pEvdev->emulateWheel.X.up_button;
vals[1] = pEvdev->emulateWheel.X.down_button;
vals[2] = pEvdev->emulateWheel.Y.up_button;
vals[3] = pEvdev->emulateWheel.Y.down_button;
prop_wheel_axismap = MakeAtom(EVDEV_PROP_WHEEL_AXES, strlen(EVDEV_PROP_WHEEL_AXES), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_axismap, XA_INTEGER, 8,
PropModeReplace, 4, vals, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_axismap, FALSE);
prop_wheel_inertia = MakeAtom(EVDEV_PROP_WHEEL_INERTIA, strlen(EVDEV_PROP_WHEEL_INERTIA), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_inertia, XA_INTEGER, 16,
PropModeReplace, 1,
&pEvdev->emulateWheel.inertia, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_inertia, FALSE);
prop_wheel_timeout = MakeAtom(EVDEV_PROP_WHEEL_TIMEOUT, strlen(EVDEV_PROP_WHEEL_TIMEOUT), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_timeout, XA_INTEGER, 16,
PropModeReplace, 1,
&pEvdev->emulateWheel.timeout, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_timeout, FALSE);
prop_wheel_button = MakeAtom(EVDEV_PROP_WHEEL_BUTTON, strlen(EVDEV_PROP_WHEEL_BUTTON), TRUE);
rc = XIChangeDeviceProperty(dev, prop_wheel_button, XA_INTEGER, 8,
PropModeReplace, 1,
&pEvdev->emulateWheel.button, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_wheel_button, FALSE);
XIRegisterPropertyHandler(dev, EvdevWheelEmuSetProperty, NULL, NULL);
}
#endif #endif

View File

@@ -105,6 +105,7 @@ static void EvdevInitProperty(DeviceIntPtr dev);
static int EvdevSetProperty(DeviceIntPtr dev, Atom atom, static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
XIPropertyValuePtr val, BOOL checkonly); XIPropertyValuePtr val, BOOL checkonly);
static Atom prop_invert = 0; static Atom prop_invert = 0;
static Atom prop_reopen = 0;
#endif #endif
@@ -184,12 +185,10 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
if (pInfo->fd != -1) if (pInfo->fd != -1)
{ {
pEvdev->reopen_left = 0;
if (EvdevCacheCompare(pInfo, TRUE) == Success) if (EvdevCacheCompare(pInfo, TRUE) == Success)
{ {
xf86Msg(X_INFO, "%s: Device reopened after %d attempts.\n", pInfo->name, xf86Msg(X_INFO, "%s: Device reopened after %d attempts.\n", pInfo->name,
pEvdev->reopen_attempts - pEvdev->reopen_left); pEvdev->reopen_attempts - pEvdev->reopen_left + 1);
EvdevOn(pInfo->dev); EvdevOn(pInfo->dev);
} else } else
{ {
@@ -199,6 +198,7 @@ EvdevReopenTimer(OsTimerPtr timer, CARD32 time, pointer arg)
close(pInfo->fd); close(pInfo->fd);
pInfo->fd = -1; pInfo->fd = -1;
} }
pEvdev->reopen_left = 0;
return 0; return 0;
} }
@@ -949,9 +949,6 @@ EvdevInit(DeviceIntPtr device)
/* We drop the return value, the only time we ever want the handlers to /* We drop the return value, the only time we ever want the handlers to
* unregister is when the device dies. In which case we don't have to * unregister is when the device dies. In which case we don't have to
* unregister anyway */ * unregister anyway */
XIRegisterPropertyHandler(device, EvdevMBEmuSetProperty, NULL, NULL);
XIRegisterPropertyHandler(device, EvdevWheelEmuSetProperty, NULL, NULL);
XIRegisterPropertyHandler(device, EvdevDragLockSetProperty, NULL, NULL);
XIRegisterPropertyHandler(device, EvdevSetProperty, NULL, NULL); XIRegisterPropertyHandler(device, EvdevSetProperty, NULL, NULL);
EvdevInitProperty(device); EvdevInitProperty(device);
EvdevMBEmuInitProperty(device); EvdevMBEmuInitProperty(device);
@@ -999,13 +996,6 @@ EvdevOn(DeviceIntPtr device)
} else } else
{ {
xf86AddEnabledDevice(pInfo); xf86AddEnabledDevice(pInfo);
if ((pEvdev->flags & EVDEV_BUTTON_EVENTS) &&
!(pEvdev->flags & EVDEV_INITIALIZED))
{
EvdevMBEmuPreInit(pInfo);
EvdevWheelEmuPreInit(pInfo);
EvdevDragLockInit(pInfo);
}
pEvdev->flags |= EVDEV_INITIALIZED; pEvdev->flags |= EVDEV_INITIALIZED;
device->public.on = TRUE; device->public.on = TRUE;
} }
@@ -1293,7 +1283,6 @@ static InputInfoPtr
EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags) EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
{ {
InputInfoPtr pInfo; InputInfoPtr pInfo;
MessageType deviceFrom = X_CONFIG;
const char *device; const char *device;
EvdevPtr pEvdev; EvdevPtr pEvdev;
@@ -1340,7 +1329,7 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pEvdev->device = device; pEvdev->device = device;
xf86Msg(deviceFrom, "%s: Device: \"%s\"\n", pInfo->name, device); xf86Msg(X_CONFIG, "%s: Device: \"%s\"\n", pInfo->name, device);
do { do {
pInfo->fd = open(device, O_RDWR, 0); pInfo->fd = open(device, O_RDWR, 0);
} while (pInfo->fd < 0 && errno == EINTR); } while (pInfo->fd < 0 && errno == EINTR);
@@ -1367,6 +1356,13 @@ EvdevPreInit(InputDriverPtr drv, IDevPtr dev, int flags)
EvdevCacheCompare(pInfo, FALSE); /* cache device data */ EvdevCacheCompare(pInfo, FALSE); /* cache device data */
if (pEvdev->flags & EVDEV_BUTTON_EVENTS)
{
EvdevMBEmuPreInit(pInfo);
EvdevWheelEmuPreInit(pInfo);
EvdevDragLockPreInit(pInfo);
}
return pInfo; return pInfo;
} }
@@ -1467,19 +1463,35 @@ EvdevInitProperty(DeviceIntPtr dev)
EvdevPtr pEvdev = pInfo->private; EvdevPtr pEvdev = pInfo->private;
int rc; int rc;
BOOL invert[2]; BOOL invert[2];
char reopen;
invert[0] = pEvdev->invert_x;
invert[1] = pEvdev->invert_y;
prop_invert = MakeAtom(EVDEV_PROP_INVERT_AXES, strlen(EVDEV_PROP_INVERT_AXES), TRUE); if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS))
{
invert[0] = pEvdev->invert_x;
invert[1] = pEvdev->invert_y;
rc = XIChangeDeviceProperty(dev, prop_invert, XA_INTEGER, 8, prop_invert = MakeAtom(EVDEV_PROP_INVERT_AXES, strlen(EVDEV_PROP_INVERT_AXES), TRUE);
PropModeReplace, 2,
invert, FALSE); rc = XIChangeDeviceProperty(dev, prop_invert, XA_INTEGER, 8,
PropModeReplace, 2,
invert, FALSE);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_invert, FALSE);
}
prop_reopen = MakeAtom(EVDEV_PROP_REOPEN, strlen(EVDEV_PROP_REOPEN),
TRUE);
reopen = pEvdev->reopen_attempts;
rc = XIChangeDeviceProperty(dev, prop_reopen, XA_INTEGER, 8,
PropModeReplace, 1, &reopen, FALSE);
if (rc != Success) if (rc != Success)
return; return;
XISetDevicePropertyDeletable(dev, prop_invert, FALSE); XISetDevicePropertyDeletable(dev, prop_reopen, FALSE);
} }
static int static int
@@ -1501,6 +1513,13 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
pEvdev->invert_x = data[0]; pEvdev->invert_x = data[0];
pEvdev->invert_y = data[1]; pEvdev->invert_y = data[1];
} }
} else if (atom == prop_reopen)
{
if (val->format != 8 || val->size != 1 || val->type != XA_INTEGER)
return BadMatch;
if (!checkonly)
pEvdev->reopen_attempts = *((CARD8*)val->data);
} }
return Success; return Success;

View File

@@ -35,9 +35,8 @@
#include <xf86Xinput.h> #include <xf86Xinput.h>
#include <xf86_OSproc.h> #include <xf86_OSproc.h>
#if defined(XKB) #ifdef XKB
/* XXX VERY WRONG. this is a client side header. */ #include <xkbstr.h>
#include <X11/extensions/XKBstr.h>
#endif #endif
#define EVDEV_MAXBUTTONS 32 #define EVDEV_MAXBUTTONS 32
@@ -120,6 +119,8 @@ typedef struct {
struct input_absinfo absinfo[ABS_MAX]; struct input_absinfo absinfo[ABS_MAX];
} EvdevRec, *EvdevPtr; } EvdevRec, *EvdevPtr;
unsigned int EvdevUtilButtonEventToButtonNumber(int code);
/* Middle Button emulation */ /* Middle Button emulation */
int EvdevMBEmuTimer(InputInfoPtr); int EvdevMBEmuTimer(InputInfoPtr);
BOOL EvdevMBEmuFilterEvent(InputInfoPtr, int, BOOL); BOOL EvdevMBEmuFilterEvent(InputInfoPtr, int, BOOL);
@@ -129,25 +130,18 @@ void EvdevMBEmuPreInit(InputInfoPtr);
void EvdevMBEmuFinalize(InputInfoPtr); void EvdevMBEmuFinalize(InputInfoPtr);
void EvdevMBEmuEnable(InputInfoPtr, BOOL); void EvdevMBEmuEnable(InputInfoPtr, BOOL);
unsigned int EvdevUtilButtonEventToButtonNumber(int code);
#ifdef HAVE_PROPERTIES
void EvdevMBEmuInitProperty(DeviceIntPtr);
int EvdevMBEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
void EvdevWheelEmuInitProperty(DeviceIntPtr);
int EvdevWheelEmuSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
void EvdevDragLockInitProperty(DeviceIntPtr);
int EvdevDragLockSetProperty(DeviceIntPtr, Atom, XIPropertyValuePtr, BOOL);
#endif
/* Mouse Wheel emulation */ /* Mouse Wheel emulation */
void EvdevWheelEmuPreInit(InputInfoPtr pInfo); void EvdevWheelEmuPreInit(InputInfoPtr pInfo);
BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value); BOOL EvdevWheelEmuFilterButton(InputInfoPtr pInfo, unsigned int button, int value);
BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv); BOOL EvdevWheelEmuFilterMotion(InputInfoPtr pInfo, struct input_event *pEv);
/* Draglock code */ /* Draglock code */
void EvdevDragLockInit(InputInfoPtr pInfo); void EvdevDragLockPreInit(InputInfoPtr pInfo);
BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value); BOOL EvdevDragLockFilterEvent(InputInfoPtr pInfo, unsigned int button, int value);
#ifdef HAVE_PROPERTIES
void EvdevMBEmuInitProperty(DeviceIntPtr);
void EvdevWheelEmuInitProperty(DeviceIntPtr);
void EvdevDragLockInitProperty(DeviceIntPtr);
#endif
#endif #endif