aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2011-05-18 12:20:00 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2011-05-27 15:26:53 +1000
commitbb15bac149411a2066eca6ddd50e2ca2cc38f7c8 (patch)
treee5af86be70f0e6e4b1a8c014902c9bedbb6b6cbd
parentMove invert variable to the block it is used in. (diff)
downloadxf86-input-evdev-bb15bac149411a2066eca6ddd50e2ca2cc38f7c8.tar.gz
xf86-input-evdev-bb15bac149411a2066eca6ddd50e2ca2cc38f7c8.tar.bz2
xf86-input-evdev-bb15bac149411a2066eca6ddd50e2ca2cc38f7c8.zip
Export product/vendor ID through a property.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--src/evdev.c35
-rw-r--r--src/evdev.h3
2 files changed, 36 insertions, 2 deletions
diff --git a/src/evdev.c b/src/evdev.c
index 389ccc8..f997490 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -52,6 +52,10 @@
#include <evdev-properties.h>
#include <xserver-properties.h>
+#ifndef XI_PROP_PRODUCT_ID
+#define XI_PROP_PRODUCT_ID "Device Product ID"
+#endif
+
/* removed from server, purge when dropping support for server 1.10 */
#define XI86_SEND_DRAG_EVENTS 0x08
@@ -108,6 +112,7 @@ static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
static void EvdevInitProperty(DeviceIntPtr dev);
static int EvdevSetProperty(DeviceIntPtr dev, Atom atom,
XIPropertyValuePtr val, BOOL checkonly);
+static Atom prop_product_id;
static Atom prop_invert;
static Atom prop_calibration;
static Atom prop_swap;
@@ -1450,6 +1455,7 @@ EvdevCache(InputInfoPtr pInfo)
{
EvdevPtr pEvdev = pInfo->private;
int i, len;
+ struct input_id id;
char name[1024] = {0};
unsigned long bitmask[NLONGS(EV_CNT)] = {0};
@@ -1458,6 +1464,16 @@ EvdevCache(InputInfoPtr pInfo)
unsigned long abs_bitmask[NLONGS(ABS_CNT)] = {0};
unsigned long led_bitmask[NLONGS(LED_CNT)] = {0};
+
+ if (ioctl(pInfo->fd, EVIOCGID, &id) < 0)
+ {
+ xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGID failed: %s\n", strerror(errno));
+ goto error;
+ }
+
+ pEvdev->id_vendor = id.vendor;
+ pEvdev->id_product = id.product;
+
if (ioctl(pInfo->fd, EVIOCGNAME(sizeof(name) - 1), name) < 0) {
xf86IDrvMsg(pInfo, X_ERROR, "ioctl EVIOCGNAME failed: %s\n", strerror(errno));
goto error;
@@ -1567,6 +1583,9 @@ EvdevProbe(InputInfoPtr pInfo)
EvdevPtr pEvdev = pInfo->private;
int rc = 1;
+ xf86IDrvMsg(pInfo, X_PROBED, "Vendor %#hx Product %#hx\n",
+ pEvdev->id_vendor, pEvdev->id_product);
+
/* Trinary state for ignoring axes:
- unset: do the normal thing.
- TRUE: explicitly ignore them.
@@ -2237,6 +2256,17 @@ EvdevInitProperty(DeviceIntPtr dev)
InputInfoPtr pInfo = dev->public.devicePrivate;
EvdevPtr pEvdev = pInfo->private;
int rc;
+ CARD32 product[2];
+
+ prop_product_id = MakeAtom(XI_PROP_PRODUCT_ID, strlen(XI_PROP_PRODUCT_ID), TRUE);
+ product[0] = pEvdev->id_vendor;
+ product[1] = pEvdev->id_product;
+ rc = XIChangeDeviceProperty(dev, prop_product_id, XA_INTEGER, 32,
+ PropModeReplace, 2, product, FALSE);
+ if (rc != Success)
+ return;
+
+ XISetDevicePropertyDeletable(dev, prop_invert, FALSE);
if (pEvdev->flags & (EVDEV_RELATIVE_EVENTS | EVDEV_ABSOLUTE_EVENTS))
{
@@ -2344,8 +2374,9 @@ EvdevSetProperty(DeviceIntPtr dev, Atom atom, XIPropertyValuePtr val,
if (!checkonly)
pEvdev->swap_axes = *((BOOL*)val->data);
- } else if (atom == prop_axis_label || atom == prop_btn_label)
- return BadAccess; /* Axis/Button labels can't be changed */
+ } else if (atom == prop_axis_label || atom == prop_btn_label ||
+ atom == prop_product_id)
+ return BadAccess; /* Read-only properties */
return Success;
}
diff --git a/src/evdev.h b/src/evdev.h
index c16ccb2..1741e59 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -104,6 +104,9 @@ typedef struct {
} EventQueueRec, *EventQueuePtr;
typedef struct {
+ unsigned short id_vendor;
+ unsigned short id_product;
+
char *device;
int grabDevice; /* grab the event device? */