diff options
| author | Peter Hutterer <peter.hutterer@who-t.net> | 2014-06-19 14:10:13 +1000 |
|---|---|---|
| committer | Peter Hutterer <peter.hutterer@who-t.net> | 2014-06-20 10:58:46 +1000 |
| commit | 2ff45c73a1ce5577a4a06cf255a394d3c93d0915 (patch) | |
| tree | fb3d06b828760bad20add83ac8ef5db9a2997973 /libevdev/libevdev-uinput.c | |
| parent | f415f2a6943f24ff19f2fe1bdd955ac6863c478a (diff) | |
| download | libevdev-2ff45c73a1ce5577a4a06cf255a394d3c93d0915.tar.gz | |
uinput: use the UI_GET_SYSNAME ioctl if available
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Diffstat (limited to 'libevdev/libevdev-uinput.c')
| -rw-r--r-- | libevdev/libevdev-uinput.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/libevdev/libevdev-uinput.c b/libevdev/libevdev-uinput.c index e0ae31e..f8607d1 100644 --- a/libevdev/libevdev-uinput.c +++ b/libevdev/libevdev-uinput.c @@ -198,8 +198,17 @@ fetch_syspath_and_devnode(struct libevdev_uinput *uinput_dev) { struct dirent **namelist; int ndev, i; - - /* FIXME: use new ioctl() here once kernel supports it */ + int rc; + char buf[sizeof(SYS_INPUT_DIR) + 64] = SYS_INPUT_DIR; + + rc = ioctl(uinput_dev->fd, + UI_GET_SYSNAME(sizeof(buf) - strlen(SYS_INPUT_DIR)), + &buf[strlen(SYS_INPUT_DIR)]); + if (rc != -1) { + uinput_dev->syspath = strdup(buf); + uinput_dev->devnode = fetch_device_node(buf); + return 0; + } ndev = scandir(SYS_INPUT_DIR, &namelist, is_input_device, alphasort); if (ndev <= 0) @@ -207,7 +216,6 @@ fetch_syspath_and_devnode(struct libevdev_uinput *uinput_dev) for (i = 0; i < ndev; i++) { int fd, len; - char buf[sizeof(SYS_INPUT_DIR) + 64]; struct stat st; strcpy(buf, SYS_INPUT_DIR); |
