summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/elput/Elput.h13
-rw-r--r--src/lib/elput/elput_evdev.c17
-rw-r--r--src/lib/elput/elput_input.c49
-rw-r--r--src/lib/elput/elput_private.h3
4 files changed, 80 insertions, 2 deletions
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h
index f52815038e..c434a12859 100644
--- a/src/lib/elput/Elput.h
+++ b/src/lib/elput/Elput.h
@@ -354,6 +354,19 @@ EAPI Eina_Bool elput_input_pointer_left_handed_set(Elput_Manager *manager, const
354EAPI void elput_input_pointer_max_set(Elput_Manager *manager, int maxw, int maxh); 354EAPI void elput_input_pointer_max_set(Elput_Manager *manager, int maxw, int maxh);
355 355
356/** 356/**
357 * Set pointer value rotation
358 *
359 * @param manager
360 * @param rotation
361 *
362 * @return EINA_TRUE on success, EINA_FALSE otherwise
363 *
364 * @ingroup Elput_Input_Group
365 * @since 1.20
366 */
367EAPI Eina_Bool elput_input_pointer_rotation_set(Elput_Manager *manager, int rotation);
368
369/**
357 * Calibrate input devices for given screen size 370 * Calibrate input devices for given screen size
358 * 371 *
359 * @param manager 372 * @param manager
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);
diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c
index aa7351dd69..09551ef727 100644
--- a/src/lib/elput/elput_input.c
+++ b/src/lib/elput/elput_input.c
@@ -559,6 +559,55 @@ elput_input_pointer_max_set(Elput_Manager *manager, int maxw, int maxh)
559 manager->input.pointer_h = maxh; 559 manager->input.pointer_h = maxh;
560} 560}
561 561
562EAPI Eina_Bool
563elput_input_pointer_rotation_set(Elput_Manager *manager, int rotation)
564{
565 Elput_Seat *eseat;
566 Elput_Device *edev;
567 Eina_List *l, *ll;
568
569 EINA_SAFETY_ON_NULL_RETURN_VAL(manager, EINA_FALSE);
570
571 if ((rotation % 90 != 0) || (rotation / 90 > 3) || (rotation < 0))
572 return EINA_FALSE;
573
574 EINA_LIST_FOREACH(manager->input.seats, l, eseat)
575 {
576 EINA_LIST_FOREACH(eseat->devices, ll, edev)
577 {
578 if (!(edev->caps & ELPUT_DEVICE_CAPS_POINTER)) continue;
579
580 switch (rotation)
581 {
582 case 0:
583 edev->swap = EINA_FALSE;
584 edev->invert_x = EINA_FALSE;
585 edev->invert_y = EINA_FALSE;
586 break;
587 case 90:
588 edev->swap = EINA_TRUE;
589 edev->invert_x = EINA_FALSE;
590 edev->invert_y = EINA_TRUE;
591 break;
592 case 180:
593 edev->swap = EINA_FALSE;
594 edev->invert_x = EINA_TRUE;
595 edev->invert_y = EINA_TRUE;
596 break;
597 case 270:
598 edev->swap = EINA_TRUE;
599 edev->invert_x = EINA_TRUE;
600 edev->invert_y = EINA_FALSE;
601 break;
602 default:
603 break;
604 }
605 }
606 }
607
608 return EINA_TRUE;
609}
610
562EAPI void 611EAPI void
563elput_input_devices_calibrate(Elput_Manager *manager, int w, int h) 612elput_input_devices_calibrate(Elput_Manager *manager, int w, int h)
564{ 613{
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 7d4909a5d9..6b253d2fae 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -229,6 +229,9 @@ struct _Elput_Device
229 229
230 Eina_Bool left_handed : 1; 230 Eina_Bool left_handed : 1;
231 Eina_Bool key_remap : 1; 231 Eina_Bool key_remap : 1;
232 Eina_Bool swap : 1;
233 Eina_Bool invert_x : 1;
234 Eina_Bool invert_y : 1;
232}; 235};
233 236
234struct _Elput_Manager 237struct _Elput_Manager