mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-06 02:18:06 +02:00
tools: libinput-record: record the hid report descriptor where available
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
29e83bcf94
commit
b8a04553de
3 changed files with 60 additions and 0 deletions
|
|
@ -140,6 +140,15 @@ class TestYaml(unittest.TestCase):
|
||||||
properties = evdev['properties']
|
properties = evdev['properties']
|
||||||
self.assertTrue(isinstance(properties, list))
|
self.assertTrue(isinstance(properties, list))
|
||||||
|
|
||||||
|
def test_hid(self):
|
||||||
|
devices = self.yaml['devices']
|
||||||
|
for d in devices:
|
||||||
|
hid = d['hid']
|
||||||
|
self.assertTrue(isinstance(hid, list))
|
||||||
|
for byte in hid:
|
||||||
|
self.assertGreaterEqual(byte, 0)
|
||||||
|
self.assertLessEqual(byte, 255)
|
||||||
|
|
||||||
def test_udev_sections_exist(self):
|
def test_udev_sections_exist(self):
|
||||||
sections = ['properties']
|
sections = ['properties']
|
||||||
devices = self.yaml['devices']
|
devices = self.yaml['devices']
|
||||||
|
|
|
||||||
|
|
@ -1614,6 +1614,52 @@ print_evdev_description(struct record_context *ctx, struct record_device *dev)
|
||||||
indent_pop(ctx);
|
indent_pop(ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
print_hid_report_descriptor(struct record_context *ctx,
|
||||||
|
struct record_device *dev)
|
||||||
|
{
|
||||||
|
const char *prefix = "/dev/input/event";
|
||||||
|
const char *node;
|
||||||
|
char syspath[PATH_MAX];
|
||||||
|
unsigned char buf[1024];
|
||||||
|
int len;
|
||||||
|
int fd;
|
||||||
|
bool first = true;
|
||||||
|
|
||||||
|
/* we take the shortcut rather than the proper udev approach, the
|
||||||
|
report_descriptor is available in sysfs and two devices up from
|
||||||
|
our device. 2 digits for the event number should be enough.
|
||||||
|
This approach won't work for /dev/input/by-id devices. */
|
||||||
|
if (!strneq(dev->devnode, prefix, strlen(prefix)) ||
|
||||||
|
strlen(dev->devnode) > strlen(prefix) + 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
node = &dev->devnode[strlen(prefix)];
|
||||||
|
len = snprintf(syspath,
|
||||||
|
sizeof(syspath),
|
||||||
|
"/sys/class/input/event%s/device/device/report_descriptor",
|
||||||
|
node);
|
||||||
|
if (len < 55 || len > 56)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fd = open(syspath, O_RDONLY);
|
||||||
|
if (fd == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
iprintf(ctx, "hid: [");
|
||||||
|
|
||||||
|
while ((len = read(fd, buf, sizeof(buf))) > 0) {
|
||||||
|
for (int i = 0; i < len; i++) {
|
||||||
|
/* YAML requires decimal */
|
||||||
|
noiprintf(ctx, "%s%u",first ? "" : ", ", buf[i]);
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
noiprintf(ctx, " ]\n");
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
print_udev_properties(struct record_context *ctx, struct record_device *dev)
|
print_udev_properties(struct record_context *ctx, struct record_device *dev)
|
||||||
{
|
{
|
||||||
|
|
@ -1778,6 +1824,7 @@ print_device_description(struct record_context *ctx, struct record_device *dev)
|
||||||
iprintf(ctx, "- node: %s\n", dev->devnode);
|
iprintf(ctx, "- node: %s\n", dev->devnode);
|
||||||
|
|
||||||
print_evdev_description(ctx, dev);
|
print_evdev_description(ctx, dev);
|
||||||
|
print_hid_report_descriptor(ctx, dev);
|
||||||
print_udev_properties(ctx, dev);
|
print_udev_properties(ctx, dev);
|
||||||
print_device_quirks(ctx, dev);
|
print_device_quirks(ctx, dev);
|
||||||
print_libinput_description(ctx, dev);
|
print_libinput_description(ctx, dev);
|
||||||
|
|
|
||||||
|
|
@ -145,6 +145,7 @@ devices:
|
||||||
57: [0, 65535, 0, 0, 0]
|
57: [0, 65535, 0, 0, 0]
|
||||||
58: [0, 255, 0, 0, 0]
|
58: [0, 255, 0, 0, 0]
|
||||||
properties: [0, 2, 4]
|
properties: [0, 2, 4]
|
||||||
|
hid: [12, 23, 34, 45, ...]
|
||||||
udev:
|
udev:
|
||||||
properties:
|
properties:
|
||||||
- ID_INPUT_MOUSE=1
|
- ID_INPUT_MOUSE=1
|
||||||
|
|
@ -225,6 +226,9 @@ the device node recorded
|
||||||
.B evdev
|
.B evdev
|
||||||
A dictionary with the evdev device information.
|
A dictionary with the evdev device information.
|
||||||
.TP 8
|
.TP 8
|
||||||
|
.B hid
|
||||||
|
A list of integers representing the HID report descriptor bytes.
|
||||||
|
.TP 8
|
||||||
.B udev
|
.B udev
|
||||||
A dictionary with the udev device information.
|
A dictionary with the udev device information.
|
||||||
.TP 8
|
.TP 8
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue