mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2026-05-06 02:18:06 +02:00
Add functions to get the device name, PID and VID
Those three are the ones that matter for logging or device identification in callers, so let's provide them. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
parent
8fa5d0bf51
commit
6b6f24ee1c
5 changed files with 106 additions and 0 deletions
18
src/evdev.c
18
src/evdev.c
|
|
@ -857,6 +857,24 @@ evdev_device_get_sysname(struct evdev_device *device)
|
||||||
return device->sysname;
|
return device->sysname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
evdev_device_get_name(struct evdev_device *device)
|
||||||
|
{
|
||||||
|
return device->devname;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
evdev_device_get_id_product(struct evdev_device *device)
|
||||||
|
{
|
||||||
|
return libevdev_get_id_product(device->evdev);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
evdev_device_get_id_vendor(struct evdev_device *device)
|
||||||
|
{
|
||||||
|
return libevdev_get_id_vendor(device->evdev);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_device_calibrate(struct evdev_device *device, float calibration[6])
|
evdev_device_calibrate(struct evdev_device *device, float calibration[6])
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -141,6 +141,15 @@ evdev_device_get_output(struct evdev_device *device);
|
||||||
const char *
|
const char *
|
||||||
evdev_device_get_sysname(struct evdev_device *device);
|
evdev_device_get_sysname(struct evdev_device *device);
|
||||||
|
|
||||||
|
const char *
|
||||||
|
evdev_device_get_name(struct evdev_device *device);
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
evdev_device_get_id_product(struct evdev_device *device);
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
evdev_device_get_id_vendor(struct evdev_device *device);
|
||||||
|
|
||||||
void
|
void
|
||||||
evdev_device_calibrate(struct evdev_device *device, float calibration[6]);
|
evdev_device_calibrate(struct evdev_device *device, float calibration[6]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1161,6 +1161,24 @@ libinput_device_get_sysname(struct libinput_device *device)
|
||||||
return evdev_device_get_sysname((struct evdev_device *) device);
|
return evdev_device_get_sysname((struct evdev_device *) device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIBINPUT_EXPORT const char *
|
||||||
|
libinput_device_get_name(struct libinput_device *device)
|
||||||
|
{
|
||||||
|
return evdev_device_get_name((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);
|
||||||
|
}
|
||||||
|
|
||||||
|
LIBINPUT_EXPORT unsigned int
|
||||||
|
libinput_device_get_id_vendor(struct libinput_device *device)
|
||||||
|
{
|
||||||
|
return evdev_device_get_id_vendor((struct evdev_device *) device);
|
||||||
|
}
|
||||||
|
|
||||||
LIBINPUT_EXPORT const char *
|
LIBINPUT_EXPORT const char *
|
||||||
libinput_device_get_output_name(struct libinput_device *device)
|
libinput_device_get_output_name(struct libinput_device *device)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1248,12 +1248,53 @@ libinput_device_get_user_data(struct libinput_device *device);
|
||||||
*
|
*
|
||||||
* Get the system name of the device.
|
* Get the system name of the device.
|
||||||
*
|
*
|
||||||
|
* To get the descriptive device name, use libinput_device_get_name().
|
||||||
|
*
|
||||||
* @param device A previously obtained device
|
* @param device A previously obtained device
|
||||||
* @return System name of the device
|
* @return System name of the device
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
const char *
|
const char *
|
||||||
libinput_device_get_sysname(struct libinput_device *device);
|
libinput_device_get_sysname(struct libinput_device *device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup device
|
||||||
|
*
|
||||||
|
* The descriptive device name as advertised by the kernel and/or the
|
||||||
|
* hardware itself. To get the sysname for this device, use
|
||||||
|
* libinput_device_get_sysname().
|
||||||
|
*
|
||||||
|
* The lifetime of the returned string is tied to the struct
|
||||||
|
* libinput_device. The string may be the empty string but is never NULL.
|
||||||
|
*
|
||||||
|
* @param device A previously obtained device
|
||||||
|
* @return The device name
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
libinput_device_get_name(struct libinput_device *device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup device
|
||||||
|
*
|
||||||
|
* Get the product ID for this device.
|
||||||
|
*
|
||||||
|
* @param device A previously obtained device
|
||||||
|
* @return The product ID of this device
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
libinput_device_get_id_product(struct libinput_device *device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup device
|
||||||
|
*
|
||||||
|
* Get the vendor ID for this device.
|
||||||
|
*
|
||||||
|
* @param device A previously obtained device
|
||||||
|
* @return The vendor ID of this device
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
libinput_device_get_id_vendor(struct libinput_device *device);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ingroup device
|
* @ingroup device
|
||||||
*
|
*
|
||||||
|
|
|
||||||
20
test/misc.c
20
test/misc.c
|
|
@ -390,6 +390,25 @@ START_TEST(context_ref_counting)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
|
START_TEST(device_ids)
|
||||||
|
{
|
||||||
|
struct litest_device *dev = litest_current_device();
|
||||||
|
const char *name;
|
||||||
|
int pid, vid;
|
||||||
|
|
||||||
|
name = libevdev_get_name(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(pid,
|
||||||
|
libinput_device_get_id_product(dev->libinput_device));
|
||||||
|
ck_assert_int_eq(vid,
|
||||||
|
libinput_device_get_id_vendor(dev->libinput_device));
|
||||||
|
}
|
||||||
|
END_TEST
|
||||||
|
|
||||||
int main (int argc, char **argv) {
|
int main (int argc, char **argv) {
|
||||||
litest_add_no_device("events:conversion", event_conversion_device_notify);
|
litest_add_no_device("events:conversion", event_conversion_device_notify);
|
||||||
litest_add_no_device("events:conversion", event_conversion_pointer);
|
litest_add_no_device("events:conversion", event_conversion_pointer);
|
||||||
|
|
@ -397,6 +416,7 @@ int main (int argc, char **argv) {
|
||||||
litest_add_no_device("events:conversion", event_conversion_key);
|
litest_add_no_device("events:conversion", event_conversion_key);
|
||||||
litest_add_no_device("events:conversion", event_conversion_touch);
|
litest_add_no_device("events:conversion", event_conversion_touch);
|
||||||
litest_add_no_device("context:refcount", context_ref_counting);
|
litest_add_no_device("context:refcount", context_ref_counting);
|
||||||
|
litest_add("device:id", device_ids, LITEST_ANY, LITEST_ANY);
|
||||||
|
|
||||||
return litest_run(argc, argv);
|
return litest_run(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue