Export device node as property.

There is currently no mapping between XI devices and physical devices other
than what can be extracted by parsing the Xorg logfile. Add new property
"Device Node" to the driver to export the open device file.

Server 1.11 and later standardises on this property name.

The client is responsible for detecting if the device is on the same host
and converting the data into a more useful format (e.g. sysfs path).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
master
Peter Hutterer 15 years ago
parent 74151b3c52
commit eaf202531f
  1. 3
      man/evdev.man
  2. 20
      src/evdev.c
  3. 4
      src/evdev.h

@ -66,7 +66,8 @@ is used. Buttons not specified in the user's mapping use the default mapping.
.BI "Option \*qDevice\*q \*q" string \*q .BI "Option \*qDevice\*q \*q" string \*q
Specifies the device through which the device can be accessed. This will Specifies the device through which the device can be accessed. This will
generally be of the form \*q/dev/input/eventX\*q, where X is some integer. generally be of the form \*q/dev/input/eventX\*q, where X is some integer.
The mapping from device node to hardware is system-dependent. The mapping from device node to hardware is system-dependent. Property:
"Device Node" (read-only).
.TP 7 .TP 7
.BI "Option \*qDragLockButtons\*q \*q" "L1 B2 L3 B4" \*q .BI "Option \*qDragLockButtons\*q \*q" "L1 B2 L3 B4" \*q
Sets \*qdrag lock buttons\*q that simulate holding a button down, so Sets \*qdrag lock buttons\*q that simulate holding a button down, so

@ -118,6 +118,7 @@ static Atom prop_calibration;
static Atom prop_swap; static Atom prop_swap;
static Atom prop_axis_label; static Atom prop_axis_label;
static Atom prop_btn_label; static Atom prop_btn_label;
static Atom prop_device;
/* All devices the evdev driver has allocated and knows about. /* All devices the evdev driver has allocated and knows about.
* MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK) * MAXDEVICES is safe as null-terminated array, as two devices (VCP and VCK)
@ -2263,6 +2264,8 @@ EvdevInitProperty(DeviceIntPtr dev)
InputInfoPtr pInfo = dev->public.devicePrivate; InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private; EvdevPtr pEvdev = pInfo->private;
int rc; int rc;
char *device_node;
CARD32 product[2]; CARD32 product[2];
prop_product_id = MakeAtom(XI_PROP_PRODUCT_ID, strlen(XI_PROP_PRODUCT_ID), TRUE); prop_product_id = MakeAtom(XI_PROP_PRODUCT_ID, strlen(XI_PROP_PRODUCT_ID), TRUE);
@ -2275,6 +2278,21 @@ EvdevInitProperty(DeviceIntPtr dev)
XISetDevicePropertyDeletable(dev, prop_invert, FALSE); XISetDevicePropertyDeletable(dev, prop_invert, FALSE);
/* Device node property */
device_node = strdup(pEvdev->device);
prop_device = MakeAtom(XI_PROP_DEVICE_NODE,
strlen(XI_PROP_DEVICE_NODE), TRUE);
rc = XIChangeDeviceProperty(dev, prop_device, XA_STRING, 8,
PropModeReplace,
strlen(device_node), device_node,
FALSE);
free(device_node);
if (rc != Success)
return;
XISetDevicePropertyDeletable(dev, prop_device, FALSE);
if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS)) if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS))
{ {
BOOL invert[2]; BOOL invert[2];
@ -2382,7 +2400,7 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
if (!checkonly) if (!checkonly)
pEvdev->swap_axes = *((BOOL*)val->data); pEvdev->swap_axes = *((BOOL*)val->data);
} else if (atom == prop_axis_label || atom == prop_btn_label || } else if (atom == prop_axis_label || atom == prop_btn_label ||
atom == prop_product_id) atom == prop_product_id || atom == prop_device)
return BadAccess; /* Read-only properties */ return BadAccess; /* Read-only properties */
return Success; return Success;

@ -80,6 +80,10 @@
#define MAX_VALUATORS 36 #define MAX_VALUATORS 36
#endif #endif
#ifndef XI_PROP_DEVICE_NODE
#define XI_PROP_DEVICE_NODE "Device Node"
#endif
#define LONG_BITS (sizeof(long) * 8) #define LONG_BITS (sizeof(long) * 8)
/* Number of longs needed to hold the given number of bits */ /* Number of longs needed to hold the given number of bits */

Loading…
Cancel
Save