devilhorns pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=eec50ed7bdf629ab30d0e5720ef7e0171eb44bae
commit eec50ed7bdf629ab30d0e5720ef7e0171eb44bae Author: Chris Michael <[email protected]> Date: Tue May 24 09:19:04 2016 -0400 elput: Add API function to set left-handed device This commit adds an API function which Enlightenment can call in order to set an input device to be "left-handed". Mainly used for a mouse pointer, but not specific to pointers. @feature Signed-off-by: Chris Michael <[email protected]> --- src/lib/elput/Elput.h | 14 ++++++++++++++ src/lib/elput/elput_input.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/lib/elput/elput_private.h | 2 ++ 3 files changed, 57 insertions(+) diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h index dfddf78..6a4545d 100644 --- a/src/lib/elput/Elput.h +++ b/src/lib/elput/Elput.h @@ -286,6 +286,20 @@ EAPI void elput_input_pointer_xy_get(Elput_Manager *manager, const char *seat, i EAPI void elput_input_pointer_xy_set(Elput_Manager *manager, const char *seat, int x, int y); /** + * Set the pointer left-handed mode + * + * @param manager + * @param seat + * @param left + * + * @return EINA_TRUE on success, EINA_FALSE otherwise + * + * @ingroup Elput_Input_Group + * @since 1.18 + */ +EAPI Eina_Bool elput_input_pointer_left_handed_set(Elput_Manager *manager, const char *seat, Eina_Bool left); + +/** * Get the list of devices on a given seat * * @param seat diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c index 2dd5607..d49a2d0 100644 --- a/src/lib/elput/elput_input.c +++ b/src/lib/elput/elput_input.c @@ -332,6 +332,47 @@ elput_input_pointer_xy_set(Elput_Manager *manager, const char *seat, int x, int } } +EAPI Eina_Bool +elput_input_pointer_left_handed_set(Elput_Manager *manager, const char *seat, Eina_Bool left) +{ + Elput_Seat *eseat; + Elput_Device *edev; + Eina_List *l, *ll; + + EINA_SAFETY_ON_NULL_RETURN_VAL(manager, EINA_FALSE); + + /* if no seat name is passed in, just use default seat name */ + if (!seat) seat = "seat0"; + + EINA_LIST_FOREACH(manager->input.seats, l, eseat) + { + if ((eseat->name) && (strcmp(eseat->name, seat))) + continue; + + EINA_LIST_FOREACH(eseat->devices, ll, edev) + { + if (!libinput_device_has_capability(edev->device, + LIBINPUT_DEVICE_CAP_POINTER)) + continue; + + if (edev->left_handed == left) continue; + + if (libinput_device_config_left_handed_set(edev->device, + (int)left) != + LIBINPUT_CONFIG_STATUS_SUCCESS) + { + WRN("Failed to set left handed mode for device: %s", + libinput_device_get_name(edev->device)); + continue; + } + else + edev->left_handed = !!left; + } + } + + return EINA_TRUE; +} + EAPI const Eina_List * elput_input_devices_get(Elput_Seat *seat) { diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h index d3297fa..1f6d608 100644 --- a/src/lib/elput/elput_private.h +++ b/src/lib/elput/elput_private.h @@ -212,6 +212,8 @@ struct _Elput_Device struct libinput_device *device; Elput_Device_Capability caps; + + Eina_Bool left_handed : 1; }; struct _Elput_Manager --
