lunaryorn/pyudev — Issue #42: Add a method to get the XID of a Device
Author: zedtux
Created: 2012-02-28 18:44:06+00:00
State: open

When I do a `xinput list` I got:

````bash
⎡ Virtual core pointer	id=2	[master pointer (3)]
⎜ ↳ Virtual core XTEST pointer	id=4	[slave pointer (2)]
⎜ ↳ Logitech USB Laser Mouse	id=8	[slave pointer (2)]
⎣ Virtual core keyboard	id=3	[master keyboard (2)]
↳ Virtual core XTEST keyboard	id=5	[slave keyboard (3)]
↳ Power Button	id=6	[slave keyboard (3)]
↳ Power Button	id=7	[slave keyboard (3)]
↳ CHESEN USB Keyboard	id=9	[slave keyboard (3)]
↳ CHESEN USB Keyboard	id=10	[slave keyboard (3)]
````

My mouse id is 8 (So the XID of my mouse is 8).

But when I execute this Python code:

````python
for device in pyudev.Context().list_devices(subsystem="input", ID_INPUT_MOUSE=True):
if device.sys_name.startswith("event"):
print "Device id is %s" % device.parent.device_number
````

I also tried to show all parent's attributes, but I can't find any one that match the XID.