devilhorns pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=eb9b894167ea2bf0628f5b93a47e47e5c6d19cfd

commit eb9b894167ea2bf0628f5b93a47e47e5c6d19cfd
Author: JengHyun Kang <jhyuni.k...@samsung.com>
Date:   Tue Dec 29 09:03:43 2015 -0500

    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
---
 src/lib/ecore_drm/Ecore_Drm.h        | 17 +++++++++++++++++
 src/lib/ecore_drm/ecore_drm_device.c | 34 ++++++++++++++++++++++++++++++++++
 src/lib/ecore_drm/ecore_drm_evdev.c  | 11 +++++++++++
 3 files changed, 62 insertions(+)

diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h
index b7dccce..1f110ef 100644
--- a/src/lib/ecore_drm/Ecore_Drm.h
+++ b/src/lib/ecore_drm/Ecore_Drm.h
@@ -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
@@ -365,6 +366,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
  *
  * This function will loop all the existing outputs in Ecore_Drm_Device and 
diff --git a/src/lib/ecore_drm/ecore_drm_device.c 
b/src/lib/ecore_drm/ecore_drm_device.c
index 9d0442c..f0c0cfe 100644
--- a/src/lib/ecore_drm/ecore_drm_device.c
+++ b/src/lib/ecore_drm/ecore_drm_device.c
@@ -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;
+}
diff --git a/src/lib/ecore_drm/ecore_drm_evdev.c 
b/src/lib/ecore_drm/ecore_drm_evdev.c
index 1052f98..b40aa43 100644
--- a/src/lib/ecore_drm/ecore_drm_evdev.c
+++ b/src/lib/ecore_drm/ecore_drm_evdev.c
@@ -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))

-- 


Reply via email to