summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-04-07 09:10:48 -0400
committerChris Michael <cpmichael@osg.samsung.com>2016-04-13 14:16:17 -0400
commit43360ca98a60e20d268251aca00a3650f56d7a84 (patch)
treea4ddd3edcd2dd0ba834d93f9766ef6d7bf84f403
parent404b3049f3339e4ea95c116312386b3d19d1c99c (diff)
elput: Add API function to set output size on an input device
This function is used to adjust device calibration based on size of output 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.c67
-rw-r--r--src/lib/elput/elput_private.h1
3 files changed, 79 insertions, 1 deletions
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h
index 06a027d68c..a1ac7213b6 100644
--- a/src/lib/elput/Elput.h
+++ b/src/lib/elput/Elput.h
@@ -245,6 +245,18 @@ EAPI void elput_input_shutdown(Elput_Manager *manager);
245 */ 245 */
246EAPI void elput_device_window_set(Elput_Device *device, unsigned int window); 246EAPI void elput_device_window_set(Elput_Device *device, unsigned int window);
247 247
248/**
249 * Set size of output for input device calibration
250 *
251 * @param device
252 * @param w
253 * @param h
254 *
255 * @ingroup Elput_Device_Group
256 * @since 1.18
257 */
258EAPI void elput_device_output_size_set(Elput_Device *device, int w, int h);
259
248# endif 260# endif
249 261
250# undef EAPI 262# undef EAPI
diff --git a/src/lib/elput/elput_evdev.c b/src/lib/elput/elput_evdev.c
index 4b6955d103..45ccefbcd6 100644
--- a/src/lib/elput/elput_evdev.c
+++ b/src/lib/elput/elput_evdev.c
@@ -1131,6 +1131,49 @@ _touch_motion(struct libinput_device *idevice, struct libinput_event_touch *even
1131 _touch_motion_send(dev, event); 1131 _touch_motion_send(dev, event);
1132} 1132}
1133 1133
1134static void
1135_evdev_device_calibrate(Elput_Device *dev)
1136{
1137 float cal[6];
1138 const char *vals;
1139 const char *sysname;
1140 const char *device;
1141 Eina_List *devices;
1142 int w = 0, h = 0;
1143 enum libinput_config_status status;
1144
1145 w = dev->ow;
1146 h = dev->oh;
1147 if ((w == 0) || (h == 0)) return;
1148
1149 if ((!libinput_device_config_calibration_has_matrix(dev->device)) ||
1150 (libinput_device_config_calibration_get_default_matrix(dev->device, cal)))
1151 return;
1152
1153 sysname = libinput_device_get_sysname(dev->device);
1154
1155 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
1156 EINA_LIST_FREE(devices, device)
1157 {
1158 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
1159 if ((!vals) ||
1160 (sscanf(vals, "%f %f %f %f %f %f",
1161 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
1162 goto cont;
1163
1164 cal[2] /= w;
1165 cal[5] /= h;
1166
1167 status =
1168 libinput_device_config_calibration_set_matrix(dev->device, cal);
1169 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
1170 WRN("Failed to apply device calibration");
1171
1172cont:
1173 eina_stringshare_del(device);
1174 }
1175}
1176
1134int 1177int
1135_evdev_event_process(struct libinput_event *event) 1178_evdev_event_process(struct libinput_event *event)
1136{ 1179{
@@ -1314,3 +1357,27 @@ elput_device_window_set(Elput_Device *device, unsigned int window)
1314 1357
1315 device->window = window; 1358 device->window = window;
1316} 1359}
1360
1361EAPI void
1362elput_device_output_size_set(Elput_Device *device, int w, int h)
1363{
1364 EINA_SAFETY_ON_NULL_RETURN(device);
1365
1366 device->ow = w;
1367 device->oh = h;
1368
1369 if (libinput_device_has_capability(device->device,
1370 LIBINPUT_DEVICE_CAP_POINTER))
1371 {
1372 Elput_Pointer *ptr;
1373
1374 ptr = _evdev_pointer_get(device->seat);
1375 if (ptr)
1376 {
1377 ptr->x = device->ow / 2;
1378 ptr->y = device->oh / 2;
1379 }
1380 }
1381
1382 _evdev_device_calibrate(device);
1383}
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 8dc2752185..3564161375 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -203,7 +203,6 @@ struct _Elput_Device
203{ 203{
204 Elput_Seat *seat; 204 Elput_Seat *seat;
205 205
206 /* TODO: we will need an API to set this */
207 uint32_t window; 206 uint32_t window;
208 uint32_t ow, oh; 207 uint32_t ow, oh;
209 208