forked from enlightenment/efl
Add a new Ecore_Drm API for setting left-handed mouse
Summary: Add a new Ecore_Drm API named ecore_drm_device_left_handed_set(). Libinput support various input options. Left handed mode is one of options. Right-handed people and left-handed people use a mouse using different button mapping. So if a left handed option is enabled, libinput change right mouse button and left mouse button. So support this option, I added this api using libinput's left handed option. @feature Test Plan: After set left handed mode, left mouse button generate button numbered 3, and right mouse button generate button numbered 1. Reviewers: raster, ManMower, devilhorns Subscribers: ohduna, cedric, jpeg, input.hacker Differential Revision: https://phab.enlightenment.org/D3431
This commit is contained in:
parent
d05a14671e
commit
eb9b894167
|
@ -129,6 +129,7 @@ struct _Ecore_Drm_Device
|
|||
drmEventContext drm_ctx;
|
||||
|
||||
Eina_Bool active : 1;
|
||||
Eina_Bool left_handed : 1;
|
||||
};
|
||||
|
||||
struct _Ecore_Drm_Event_Activate
|
||||
|
@ -364,6 +365,22 @@ EAPI const char *ecore_drm_device_name_get(Ecore_Drm_Device *dev);
|
|||
*/
|
||||
EAPI Eina_Bool ecore_drm_device_software_setup(Ecore_Drm_Device *dev);
|
||||
|
||||
/**
|
||||
* Set a left handed mode at the given Ecore_Drm_Device
|
||||
*
|
||||
* This function will loop all the registered inputs in Ecore_Drm_Device and
|
||||
* set/unset left handed mode.
|
||||
*
|
||||
* @param dev The Ecore_Drm_Device to set left handed mode
|
||||
* @param left_handed The flag of enable/disable left handed mode
|
||||
*
|
||||
* @return EINA_TRUE on success, EINA_FALSE on failure
|
||||
*
|
||||
* @ingroup Ecore_Drm_Device_Group
|
||||
* @since 1.17
|
||||
*/
|
||||
EAPI Eina_Bool ecore_drm_device_pointer_left_handed_set(Ecore_Drm_Device *dev, Eina_Bool left_handed);
|
||||
|
||||
/**
|
||||
* Find an Ecore_Drm_Output at the given coordinates
|
||||
*
|
||||
|
|
|
@ -556,3 +556,37 @@ ecore_drm_device_output_name_find(Ecore_Drm_Device *dev, const char *name)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
EAPI Eina_Bool
|
||||
ecore_drm_device_pointer_left_handed_set(Ecore_Drm_Device *dev, Eina_Bool left_handed)
|
||||
{
|
||||
Ecore_Drm_Seat *seat = NULL;
|
||||
Ecore_Drm_Evdev *edev = NULL;
|
||||
Eina_List *l = NULL, *l2 = NULL;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(dev, EINA_FALSE);
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(dev->seats, EINA_FALSE);
|
||||
|
||||
if (dev->left_handed == left_handed)
|
||||
return EINA_TRUE;
|
||||
dev->left_handed = !!left_handed;
|
||||
|
||||
EINA_LIST_FOREACH(dev->seats, l, seat)
|
||||
{
|
||||
EINA_LIST_FOREACH(seat->devices, l2, edev)
|
||||
{
|
||||
if (libinput_device_has_capability(edev->device,
|
||||
LIBINPUT_DEVICE_CAP_POINTER))
|
||||
{
|
||||
if (libinput_device_config_left_handed_set(edev->device, (int)left_handed) !=
|
||||
LIBINPUT_CONFIG_STATUS_SUCCESS)
|
||||
{
|
||||
WRN("Failed to set left hand mode about device: %s\n",
|
||||
libinput_device_get_name(edev->device));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
|
|
@ -651,6 +651,17 @@ _ecore_drm_evdev_device_create(Ecore_Drm_Seat *seat, struct libinput_device *dev
|
|||
|
||||
/* TODO: make this configurable */
|
||||
edev->mouse.threshold = 250;
|
||||
|
||||
dev = seat->input->dev;
|
||||
if (dev->left_handed == EINA_TRUE)
|
||||
{
|
||||
if (libinput_device_config_left_handed_set(device, 1) !=
|
||||
LIBINPUT_CONFIG_STATUS_SUCCESS)
|
||||
{
|
||||
WRN("Failed to set left hand mode about device: %s\n",
|
||||
libinput_device_get_name(device));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
|
||||
|
|
Loading…
Reference in New Issue