summaryrefslogtreecommitdiff
path: root/src/lib/elput/elput_evdev.c
diff options
context:
space:
mode:
authorChris Michael <cp.michael@samsung.com>2017-06-08 09:21:16 -0400
committerChris Michael <cp.michael@samsung.com>2017-06-08 10:03:36 -0400
commit26af19b543e313cdf1756cc1d158dca9d8cef02e (patch)
tree46030c6f87ad6bfd1b613b9940e0ae43274bcc73 /src/lib/elput/elput_evdev.c
parent75b5310781bc4c89f8accc94eecae83e3259e422 (diff)
elput: Add API function to swap dx & dy axis from pointer motion event
Small patch which adds an API function that can be called to swap x and y axis and invert them according to rotation angle. @feature Signed-off-by: Chris Michael <cp.michael@samsung.com>
Diffstat (limited to 'src/lib/elput/elput_evdev.c')
-rw-r--r--src/lib/elput/elput_evdev.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index f2fd46b36c..a8b4903e02 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -882,6 +882,7 @@ _pointer_motion(struct libinput_device *idev, struct libinput_event_pointer *eve
882{ 882{
883 Elput_Device *edev; 883 Elput_Device *edev;
884 Elput_Pointer *ptr; 884 Elput_Pointer *ptr;
885 double dx, dy, tmp;
885 886
886 edev = libinput_device_get_user_data(idev); 887 edev = libinput_device_get_user_data(idev);
887 if (!edev) return EINA_FALSE; 888 if (!edev) return EINA_FALSE;
@@ -889,8 +890,20 @@ _pointer_motion(struct libinput_device *idev, struct libinput_event_pointer *eve
889 ptr = _evdev_pointer_get(edev->seat); 890 ptr = _evdev_pointer_get(edev->seat);
890 if (!ptr) return EINA_FALSE; 891 if (!ptr) return EINA_FALSE;
891 892
892 ptr->seat->pointer.x += libinput_event_pointer_get_dx(event); 893 dx = libinput_event_pointer_get_dx(event);
893 ptr->seat->pointer.y += libinput_event_pointer_get_dy(event); 894 dy = libinput_event_pointer_get_dy(event);
895
896 if (edev->swap)
897 {
898 tmp = dx;
899 dx = dy;
900 dy = tmp;
901 }
902 if (edev->invert_x) dx *= -1;
903 if (edev->invert_y) dy *= -1;
904
905 ptr->seat->pointer.x += dx;
906 ptr->seat->pointer.y += dy;
894 ptr->timestamp = libinput_event_pointer_get_time(event); 907 ptr->timestamp = libinput_event_pointer_get_time(event);
895 908
896 _pointer_motion_send(edev); 909 _pointer_motion_send(edev);