summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Expósito <jose.exposito89@gmail.com>2024-02-28 16:18:54 +0100
committerMarge Bot <emma+marge@anholt.net>2024-02-28 22:49:29 +0000
commita43f1edbfe9813ef32877292b086096ec27142fb (patch)
treeda5fedfdecce319ffe1992d96f388c93b1801cf3
parent7ac26ed9c241d00e8688139b06e804badb25fa46 (diff)
Add libinput_device_get_id_bustype()
Allow to get the device bus type ID in addition to its vid and pid. Closes: https://gitlab.freedesktop.org/libinput/libinput/-/issues/975 Signed-off-by: José Expósito <jose.exposito89@gmail.com> Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/977>
-rw-r--r--src/evdev.c6
-rw-r--r--src/evdev.h3
-rw-r--r--src/libinput.c6
-rw-r--r--src/libinput.h13
-rw-r--r--src/libinput.sym1
-rw-r--r--test/test-device.c5
6 files changed, 33 insertions, 1 deletions
diff --git a/src/evdev.c b/src/evdev.c
index f3b4f9f1..da538df7 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2518,6 +2518,12 @@ evdev_device_get_name(struct evdev_device *device)
}
unsigned int
+evdev_device_get_id_bustype(struct evdev_device *device)
+{
+ return libevdev_get_id_bustype(device->evdev);
+}
+
+unsigned int
evdev_device_get_id_product(struct evdev_device *device)
{
return libevdev_get_id_product(device->evdev);
diff --git a/src/evdev.h b/src/evdev.h
index 7e2567be..f954938c 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -474,6 +474,9 @@ const char *
evdev_device_get_name(struct evdev_device *device);
unsigned int
+evdev_device_get_id_bustype(struct evdev_device *device);
+
+unsigned int
evdev_device_get_id_product(struct evdev_device *device);
unsigned int
diff --git a/src/libinput.c b/src/libinput.c
index 0b42db2e..5bebe56b 100644
--- a/src/libinput.c
+++ b/src/libinput.c
@@ -3305,6 +3305,12 @@ libinput_device_get_name(struct libinput_device *device)
}
LIBINPUT_EXPORT unsigned int
+libinput_device_get_id_bustype(struct libinput_device *device)
+{
+ return evdev_device_get_id_bustype((struct evdev_device *) device);
+}
+
+LIBINPUT_EXPORT unsigned int
libinput_device_get_id_product(struct libinput_device *device)
{
return evdev_device_get_id_product((struct evdev_device *) device);
diff --git a/src/libinput.h b/src/libinput.h
index 0c14098a..85403be5 100644
--- a/src/libinput.h
+++ b/src/libinput.h
@@ -4200,6 +4200,19 @@ libinput_device_get_name(struct libinput_device *device);
/**
* @ingroup device
*
+ * Get the bus type ID for this device.
+ *
+ * @param device A previously obtained device
+ * @return The bus type ID of this device (see BUS_* in linux/input.h)
+ *
+ * @since 1.26
+ */
+unsigned int
+libinput_device_get_id_bustype(struct libinput_device *device);
+
+/**
+ * @ingroup device
+ *
* Get the product ID for this device.
*
* @param device A previously obtained device
diff --git a/src/libinput.sym b/src/libinput.sym
index f48e39e2..3624401c 100644
--- a/src/libinput.sym
+++ b/src/libinput.sym
@@ -335,6 +335,7 @@ LIBINPUT_1.23 {
} LIBINPUT_1.21;
LIBINPUT_1.26 {
+ libinput_device_get_id_bustype;
libinput_device_tablet_pad_get_num_dials;
libinput_event_tablet_pad_get_dial_delta_v120;
libinput_event_tablet_pad_get_dial_number;
diff --git a/test/test-device.c b/test/test-device.c
index a117ac65..55dd12b1 100644
--- a/test/test-device.c
+++ b/test/test-device.c
@@ -748,14 +748,17 @@ START_TEST(device_ids)
{
struct litest_device *dev = litest_current_device();
const char *name;
- unsigned int pid, vid;
+ unsigned int bus, pid, vid;
name = libevdev_get_name(dev->evdev);
+ bus = libevdev_get_id_bustype(dev->evdev);
pid = libevdev_get_id_product(dev->evdev);
vid = libevdev_get_id_vendor(dev->evdev);
ck_assert_str_eq(name,
libinput_device_get_name(dev->libinput_device));
+ ck_assert_int_eq(bus,
+ libinput_device_get_id_bustype(dev->libinput_device));
ck_assert_int_eq(pid,
libinput_device_get_id_product(dev->libinput_device));
ck_assert_int_eq(vid,