summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-05-26 10:45:47 -0400
committerChris Michael <cpmichael@osg.samsung.com>2016-05-26 11:43:22 -0400
commit054a9c8182a7823b52a0a4381db155b8b4842cc6 (patch)
tree980d07309f1af9cc56f696cdfb4c97b0c4e51921
parentad58478b76d4e158e6f0c26b97577e8dc1dfbce5 (diff)
downloadefl-054a9c8182a7823b52a0a4381db155b8b4842cc6.tar.gz
elput: Add API function to calibrate input devices
This adds an API function that can be called to calibrate input devices based on a given output size @feature Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
-rw-r--r--src/lib/elput/Elput.h12
-rw-r--r--src/lib/elput/elput_evdev.c2
-rw-r--r--src/lib/elput/elput_input.c35
-rw-r--r--src/lib/elput/elput_private.h4
4 files changed, 52 insertions, 1 deletions
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h
index ce3ad98217..8d3d6f6669 100644
--- a/src/lib/elput/Elput.h
+++ b/src/lib/elput/Elput.h
@@ -339,6 +339,18 @@ EAPI const Eina_List *elput_input_devices_get(Elput_Seat *seat);
*/
EAPI void elput_input_pointer_max_set(Elput_Manager *manager, int maxw, int maxh);
+/**
+ * Calibrate input devices for given screen size
+ *
+ * @param manager
+ * @param w
+ * @param h
+ *
+ * @ingroup Elput_Input_Group
+ * @since 1.18
+ */
+EAPI void elput_input_devices_calibrate(Elput_Manager *manager, int w, int h);
+
# endif
# undef EAPI
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 416c02f45d..82768d6b35 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -1120,7 +1120,7 @@ _touch_motion(struct libinput_device *idevice, struct libinput_event_touch *even
_touch_motion_send(dev, event);
}
-static void
+void
_evdev_device_calibrate(Elput_Device *dev)
{
float cal[6];
diff --git a/src/lib/elput/elput_input.c b/src/lib/elput/elput_input.c
index 64431bb354..b427c38ed1 100644
--- a/src/lib/elput/elput_input.c
+++ b/src/lib/elput/elput_input.c
@@ -288,6 +288,14 @@ _elput_input_init_end(void *data, Ecore_Thread *eth EINA_UNUSED)
libinput_unref(manager->input.lib);
manager->input.lib = NULL;
}
+
+ if ((manager->pending_ptr_x) || (manager->pending_ptr_y))
+ {
+ elput_input_pointer_xy_set(manager, NULL, manager->pending_ptr_x,
+ manager->pending_ptr_y);
+ manager->pending_ptr_x = 0;
+ manager->pending_ptr_y = 0;
+ }
}
static void
@@ -398,6 +406,13 @@ elput_input_pointer_xy_set(Elput_Manager *manager, const char *seat, int x, int
/* if no seat name is passed in, just use default seat name */
if (!seat) seat = "seat0";
+ if (eina_list_count(manager->input.seats) < 1)
+ {
+ manager->pending_ptr_x = x;
+ manager->pending_ptr_y = y;
+ return;
+ }
+
EINA_LIST_FOREACH(manager->input.seats, l, eseat)
{
if (!eseat->ptr) continue;
@@ -475,3 +490,23 @@ elput_input_pointer_max_set(Elput_Manager *manager, int maxw, int maxh)
manager->input.pointer_w = maxw;
manager->input.pointer_h = maxh;
}
+
+EAPI void
+elput_input_devices_calibrate(Elput_Manager *manager, int w, int h)
+{
+ Elput_Seat *eseat;
+ Elput_Device *edev;
+ Eina_List *l, *ll;
+
+ EINA_SAFETY_ON_NULL_RETURN(manager);
+
+ EINA_LIST_FOREACH(manager->input.seats, l, eseat)
+ {
+ EINA_LIST_FOREACH(eseat->devices, ll, edev)
+ {
+ edev->ow = w;
+ edev->oh = h;
+ _evdev_device_calibrate(edev);
+ }
+ }
+}
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 0e0edd1774..dc34f24099 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -232,6 +232,9 @@ struct _Elput_Manager
Ecore_Event_Handler *vt_hdlr;
uint32_t window;
+ int pending_ptr_x;
+ int pending_ptr_y;
+
struct
{
char *path;
@@ -261,6 +264,7 @@ void _evdev_keyboard_destroy(Elput_Keyboard *kbd);
void _evdev_pointer_destroy(Elput_Pointer *ptr);
void _evdev_touch_destroy(Elput_Touch *touch);
void _evdev_pointer_motion_send(Elput_Device *edev);
+void _evdev_device_calibrate(Elput_Device *dev);
Elput_Pointer *_evdev_pointer_get(Elput_Seat *seat);
Elput_Keyboard *_evdev_keyboard_get(Elput_Seat *seat);