From d47197e65b59406e0f25c5a4db56e68da61bec30 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 18 May 2017 11:36:55 -0400 Subject: [PATCH] evas: add evas_device_get_by_seat_id() sometimes it may be more useful to find a device by its hw id @feature --- src/lib/evas/Evas_Common.h | 14 ++++++++++++++ src/lib/evas/canvas/evas_device.c | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/lib/evas/Evas_Common.h b/src/lib/evas/Evas_Common.h index c7928aac4f..2cccabf107 100644 --- a/src/lib/evas/Evas_Common.h +++ b/src/lib/evas/Evas_Common.h @@ -1021,6 +1021,20 @@ EAPI const Eina_List *evas_device_list(Evas *e, const Evas_Device *dev); */ EAPI Evas_Device *evas_device_get(Evas *e, const char *name); +/** + * Get a device by its seat id + * + * @param e The canvas to find the device on + * @param id The seat id of the device. + * + * Gets the device with id @p id on Evas @p e list of devices. + * + * @return the device or NULL if no device with a matching id was found. + * + * @since 1.20 + */ +EAPI Evas_Device *evas_device_get_by_seat_id(Evas *eo_e, unsigned int id); + /** * Set the name of a device as a string * diff --git a/src/lib/evas/canvas/evas_device.c b/src/lib/evas/canvas/evas_device.c index 3d63a4c7c1..2e7763aa1c 100644 --- a/src/lib/evas/canvas/evas_device.c +++ b/src/lib/evas/canvas/evas_device.c @@ -121,6 +121,29 @@ evas_device_get(Evas *eo_e, const char *name) return NULL; } +EAPI Evas_Device * +evas_device_get_by_seat_id(Evas *eo_e, unsigned int id) +{ + unsigned int seat_id; + Evas_Public_Data *e; + Evas_Device *dev; + Eina_List *l; + + SAFETY_CHECK(eo_e, EVAS_CANVAS_CLASS, NULL); + + e = efl_data_scope_get(eo_e, EVAS_CANVAS_CLASS); + + EINA_LIST_FOREACH(e->devices, l, dev) + { + seat_id = efl_input_device_seat_id_get(dev); + + if (seat_id == id) + return dev; + } + + return NULL; +} + EAPI Evas_Device * evas_device_add(Evas *eo_e) {