2 #include "e_input_private.h"
4 #include "e_keyrouter_private.h"
5 #include "e_input_event.h"
9 static void _device_modifiers_update(E_Input_Evdev *edev);
10 static void _device_configured_size_get(E_Input_Evdev *edev, int *x, int *y, int *w, int *h);
11 static void _device_output_assign(E_Input_Evdev *edev, E_Input_Seat_Capabilities cap);
14 _device_calibration_set(E_Input_Evdev *edev)
19 E_Comp_Config *comp_conf;
21 if (e_comp->e_comp_screen->num_outputs > 1) //multiple outputs
23 comp_conf = e_comp_config_get();
24 if (comp_conf && (comp_conf->input_output_assign_policy == 1)) //use output-assignment policy
26 _device_output_assign(edev, E_INPUT_SEAT_POINTER);
27 _device_output_assign(edev, E_INPUT_SEAT_TOUCH);
31 output = e_comp_screen_primary_output_get(e_comp->e_comp_screen);
32 e_output_size_get(output, &w, &h);
36 edev->mouse.minx = edev->mouse.miny = 0;
40 if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
42 edev->seat->ptr.dx = (double)(w / 2);
43 edev->seat->ptr.dy = (double)(h / 2);
44 edev->seat->ptr.ix = (int)edev->seat->ptr.dx;
45 edev->seat->ptr.iy = (int)edev->seat->ptr.dy;
46 edev->mouse.dx = edev->seat->ptr.dx;
47 edev->mouse.dy = edev->seat->ptr.dy;
49 if (output->config.rotation == 90 || output->config.rotation == 270)
51 temp = edev->mouse.minx;
52 edev->mouse.minx = edev->mouse.miny;
53 edev->mouse.miny = temp;
55 temp = edev->mouse.maxw;
56 edev->mouse.maxw = edev->mouse.maxh;
57 edev->mouse.maxh = temp;
63 #ifdef _F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
69 if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
70 (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
73 sysname = libinput_device_get_sysname(edev->device);
75 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
76 if (eina_list_count(devices) < 1) return;
78 #ifdef _F_E_INPUT_USE_WL_CALIBRATION_
80 enum libinput_config_status status;
82 EINA_LIST_FREE(devices, device)
84 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
86 (sscanf(vals, "%f %f %f %f %f %f",
87 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
94 libinput_device_config_calibration_set_matrix(edev->device, cal);
96 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
97 ERR("Failed to apply calibration");
100 eina_stringshare_del(device);
103 #endif//_F_E_INPUT_USE_WL_CALIBRATION_
104 #endif//_F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
109 _device_output_assign(E_Input_Evdev *edev, E_Input_Seat_Capabilities cap)
114 Eina_Bool need_assign_output = EINA_FALSE;
115 const char *output_name;
118 if (!(edev->caps & cap)) return;
119 if (edev->output_name) return; //already assigned
120 if (e_comp->e_comp_screen->num_outputs <= 1) return;
122 last_output_idx = e_comp->e_comp_screen->num_outputs - 1;
123 EINA_LIST_FOREACH(edev->seat->devices, l, ed)
125 if (!(ed->caps & cap)) continue;
126 if (ed == edev) continue;
129 need_assign_output = EINA_FALSE;
132 need_assign_output = EINA_TRUE;
134 if (need_assign_output)
136 output = e_output_find_by_index(last_output_idx);
137 if (!output || !output->info.connected) return;
138 output_name = e_output_output_id_get(output);
139 if (output_name) edev->output_name = eina_stringshare_add(output_name);
140 ELOGF("E_INPUT_EVDEV", "Device is assigned to output:%s", NULL, output_name);
145 _device_touch_count_update(E_Input_Evdev *edev)
147 unsigned int device_touch_count = 0;
148 static unsigned int _max_device_touch_count = 0;
150 E_Input *ei = e_input_get();
151 EINA_SAFETY_ON_NULL_RETURN(ei);
153 device_touch_count = libinput_device_touch_get_touch_count(edev->device);
155 if (_max_device_touch_count < device_touch_count)
156 _max_device_touch_count = device_touch_count;
158 if (e_config->configured_max_touch.use)
160 if (_max_device_touch_count > 0 && e_config->configured_max_touch.count > _max_device_touch_count)
162 ELOGF("E_INPUT_EVDEV_TOUCH", "Touch max count(%d) must be less or equal to device's touch count(%d) !\nTouch max count has been shrinken to %d.\n",
163 NULL, e_config->configured_max_touch.count, _max_device_touch_count, _max_device_touch_count);
164 ei->touch_max_count = _max_device_touch_count;
168 if (ei->touch_max_count != e_config->configured_max_touch.count)
170 ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n",
171 NULL, ei->touch_max_count, e_config->configured_max_touch.count);
172 ei->touch_max_count = e_config->configured_max_touch.count;
178 if (ei->touch_max_count < _max_device_touch_count)
180 ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n", NULL,
181 ei->touch_max_count, _max_device_touch_count);
182 ei->touch_max_count = _max_device_touch_count;
186 ei->touch_device_count++;
187 ELOGF("E_INPUT_EVDEV_TOUCH", "Touch device count is %d.\n", NULL, ei->touch_device_count);
191 _device_configure(E_Input_Evdev *edev)
193 if (libinput_device_config_tap_get_finger_count(edev->device) > 0)
195 Eina_Bool tap = EINA_FALSE;
197 tap = libinput_device_config_tap_get_default_enabled(edev->device);
198 libinput_device_config_tap_set_enabled(edev->device, tap);
201 _device_calibration_set(edev);
205 _device_keyboard_setup(E_Input_Evdev *edev)
207 E_Input_Backend *input;
208 xkb_mod_index_t xkb_idx;
210 if ((!edev) || (!edev->seat)) return;
211 if (!(input = edev->seat->input)) return;
212 if (!input->dev->xkb_ctx) return;
214 /* create keymap from xkb context */
215 edev->xkb.keymap = _e_input_device_cached_keymap_get(input->dev->xkb_ctx, NULL, 0);
216 if (!edev->xkb.keymap)
218 ERR("Failed to create keymap: %m");
222 /* create xkb state */
223 if (!(edev->xkb.state = xkb_state_new(edev->xkb.keymap)))
225 ERR("Failed to create xkb state: %m");
229 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CTRL);
230 if (xkb_idx != XKB_MOD_INVALID)
231 edev->xkb.ctrl_mask = 1 << xkb_idx;
233 edev->xkb.ctrl_mask = 0;
235 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_ALT);
236 if (xkb_idx != XKB_MOD_INVALID)
237 edev->xkb.alt_mask = 1 << xkb_idx;
239 edev->xkb.alt_mask = 0;
241 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_SHIFT);
242 if (xkb_idx != XKB_MOD_INVALID)
243 edev->xkb.shift_mask = 1 << xkb_idx;
245 edev->xkb.shift_mask = 0;
247 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_LOGO);
248 if (xkb_idx != XKB_MOD_INVALID)
249 edev->xkb.win_mask = 1 << xkb_idx;
251 edev->xkb.win_mask = 0;
253 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_LED_NAME_SCROLL);
254 if (xkb_idx != XKB_MOD_INVALID)
255 edev->xkb.scroll_mask = 1 << xkb_idx;
257 edev->xkb.scroll_mask = 0;
259 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_LED_NAME_NUM);
260 if (xkb_idx != XKB_MOD_INVALID)
261 edev->xkb.num_mask = 1 << xkb_idx;
263 edev->xkb.num_mask = 0;
265 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CAPS);
266 if (xkb_idx != XKB_MOD_INVALID)
267 edev->xkb.caps_mask = 1 << xkb_idx;
269 edev->xkb.caps_mask = 0;
271 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, "ISO_Level3_Shift");
272 if (xkb_idx != XKB_MOD_INVALID)
273 edev->xkb.altgr_mask = 1 << xkb_idx;
275 edev->xkb.altgr_mask = 0;
279 _device_keysym_translate(xkb_keysym_t keysym, unsigned int modifiers, char *buffer, int bytes)
281 unsigned long hbytes = 0;
284 if (!keysym) return 0;
285 hbytes = (keysym >> 8);
290 (((keysym >= XKB_KEY_BackSpace) && (keysym <= XKB_KEY_Clear)) ||
291 (keysym == XKB_KEY_Return) || (keysym == XKB_KEY_Escape) ||
292 (keysym == XKB_KEY_KP_Space) || (keysym == XKB_KEY_KP_Tab) ||
293 (keysym == XKB_KEY_KP_Enter) ||
294 ((keysym >= XKB_KEY_KP_Multiply) && (keysym <= XKB_KEY_KP_9)) ||
295 (keysym == XKB_KEY_KP_Equal) || (keysym == XKB_KEY_Delete))))))
298 if (keysym == XKB_KEY_KP_Space)
299 c = (XKB_KEY_space & 0x7F);
300 else if (hbytes == 0xFF)
305 if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
307 if (((c >= '@') && (c < '\177')) || c == ' ')
311 else if ((c >= '3') && (c <= '7'))
323 _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
327 edev->xkb.depressed =
328 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_DEPRESSED);
330 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LATCHED);
332 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LOCKED);
334 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_EFFECTIVE);
336 mask = (edev->xkb.depressed | edev->xkb.latched);
338 if (mask & from->xkb.ctrl_mask)
339 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_CTRL;
340 if (mask & from->xkb.alt_mask)
341 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_ALT;
342 if (mask & from->xkb.shift_mask)
343 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
344 if (mask & from->xkb.win_mask)
345 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_WIN;
346 if (mask & from->xkb.scroll_mask)
347 edev->xkb.modifiers |= ECORE_EVENT_LOCK_SCROLL;
348 if (mask & from->xkb.num_mask)
349 edev->xkb.modifiers |= ECORE_EVENT_LOCK_NUM;
350 if (mask & from->xkb.caps_mask)
351 edev->xkb.modifiers |= ECORE_EVENT_LOCK_CAPS;
352 if (mask & from->xkb.altgr_mask)
353 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
357 _device_modifiers_update(E_Input_Evdev *edev)
362 edev->xkb.modifiers = 0;
364 if (edev->caps & E_INPUT_SEAT_KEYBOARD)
365 _device_modifiers_update_device(edev, edev);
368 EINA_LIST_FOREACH(edev->seat->devices, l, ed)
370 if (!(ed->caps & E_INPUT_SEAT_KEYBOARD)) continue;
371 _device_modifiers_update_device(edev, ed);
378 _device_remapped_key_get(E_Input_Evdev *edev, int code)
382 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, code);
383 if (!edev->key_remap_enabled) return code;
384 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->key_remap_hash, code);
386 ret = eina_hash_find(edev->key_remap_hash, &code);
388 if (ret) code = (int)(intptr_t)ret;
394 e_input_evdev_get_e_device(const char *path, Ecore_Device_Class clas)
396 const GList *dev_list = NULL;
398 E_Device *dev = NULL;
399 const char *identifier;
401 if (!path) return NULL;
403 dev_list = e_device_list_get();
404 if (!dev_list) return NULL;
405 for (l = dev_list, dev = dev_list->data;
407 l = g_list_next(l), dev = l->data)
410 identifier = e_device_identifier_get(dev);
411 if (!identifier) continue;
412 if ((e_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
419 EINTERN Ecore_Device *
420 e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas)
422 const Eina_List *dev_list = NULL;
424 Ecore_Device *dev = NULL;
425 const char *identifier;
427 if (!path) return NULL;
429 dev_list = ecore_device_list();
430 if (!dev_list) return NULL;
431 EINA_LIST_FOREACH(dev_list, l, dev)
434 identifier = ecore_device_identifier_get(dev);
435 if (!identifier) continue;
436 if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
443 _e_input_event_mouse_move_cb_free(void *data EINA_UNUSED, void *event)
445 Ecore_Event_Mouse_Move *ev = event;
447 if (ev->dev) ecore_device_unref(ev->dev);
453 _e_input_event_mouse_wheel_cb_free(void *data EINA_UNUSED, void *event)
455 Ecore_Event_Mouse_Wheel *ev = event;
457 if (ev->dev) ecore_device_unref(ev->dev);
463 _e_input_event_mouse_button_cb_free(void *data EINA_UNUSED, void *event)
465 Ecore_Event_Mouse_Button *ev = event;
467 if (ev->dev) ecore_device_unref(ev->dev);
473 _e_input_event_key_cb_free(void *data EINA_UNUSED, void *event)
475 Ecore_Event_Key *ev = event;
477 //if (ev->dev) ecore_device_unref(ev->dev);
478 if (ev->data) E_FREE(ev->data);
484 _device_handle_key(struct libinput_device *device, struct libinput_event_keyboard *event)
487 E_Input_Backend *input;
489 uint32_t code, nsyms;
490 const xkb_keysym_t *syms;
491 enum libinput_key_state state;
493 xkb_keysym_t sym = XKB_KEY_NoSymbol;
494 char key[256] = {0, }, keyname[256] = {0, }, compose_buffer[256] = {0, };
496 char *tmp = NULL, *compose = NULL;
497 E_Keyrouter_Event_Data *key_data;
498 Ecore_Device *ecore_dev = NULL, *data;
499 E_Device *e_dev = NULL, *e_dev_data;
500 Eina_List *l = NULL, *l_next = NULL;
502 E_Comp_Config *comp_conf = NULL;
503 int *pressed_keycode = NULL, *idata = NULL;
504 Eina_Bool dup_found = EINA_FALSE;
506 if (!(edev = libinput_device_get_user_data(device)))
511 if (!(input = edev->seat->input))
516 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
517 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
519 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
521 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_KEYBOARD)
530 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
531 ecore_dev = edev->ecore_dev;
536 ERR("Failed to get source ecore device from event !\n");
540 if (edev->e_dev) e_dev = edev->e_dev;
541 else if (edev->e_dev_list && g_list_length(edev->e_dev_list) > 0)
543 for (glist = edev->e_dev_list, e_dev_data = edev->e_dev_list->data;
545 glist = g_list_next(l), e_dev_data = l->data)
547 if (e_device_class_get(e_dev_data) == ECORE_DEVICE_CLASS_KEYBOARD)
556 edev->e_dev = e_input_evdev_get_e_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
562 ERR("Failed to get source e device from event !\n");
566 timestamp = libinput_event_keyboard_get_time(event);
567 code = libinput_event_keyboard_get_key(event);
568 code = _device_remapped_key_get(edev, code + 8);
569 state = libinput_event_keyboard_get_key_state(event);
570 key_count = libinput_event_keyboard_get_seat_key_count(event);
572 if (state == LIBINPUT_KEY_STATE_PRESSED)
574 if ((edev->seat->dev->blocked & E_INPUT_SEAT_KEYBOARD) ||
575 (edev->seat->dev->server_blocked & E_INPUT_SEAT_KEYBOARD))
577 ELOGF("Key", "Press (keycode: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
578 code, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
579 edev->seat->dev->server_blocked);
583 /* FIXME: Currently to maintain press/release event pair during input block,
584 * used Eina_List and this is method used in devicemgr module.
585 * But we need to consider which way is better to maintain key press/release pair.
588 EINA_LIST_FOREACH(edev->xkb.pressed_keys, l, idata)
592 dup_found = EINA_TRUE;
598 pressed_keycode = E_NEW(int, 1);
599 EINA_SAFETY_ON_NULL_RETURN(pressed_keycode);
600 *pressed_keycode = code;
602 edev->xkb.pressed_keys = eina_list_append(edev->xkb.pressed_keys, pressed_keycode);
607 dup_found = EINA_FALSE;
608 EINA_LIST_FOREACH_SAFE(edev->xkb.pressed_keys, l, l_next, idata)
612 edev->xkb.pressed_keys = eina_list_remove_list(edev->xkb.pressed_keys, l);
614 dup_found = EINA_TRUE;
620 ELOGF("Key", "Release (keycode: %d, device: %s) is blocked by %p", NULL,
621 code, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client);
626 /* ignore key events that are not seat wide state changes */
627 if (((state == LIBINPUT_KEY_STATE_PRESSED) && (key_count != 1)) ||
628 ((state == LIBINPUT_KEY_STATE_RELEASED) && (key_count != 0)))
633 xkb_state_update_key(edev->xkb.state, code,
634 (state ? XKB_KEY_DOWN : XKB_KEY_UP));
636 /* get the keysym for this code */
637 nsyms = xkb_key_get_syms(edev->xkb.state, code, &syms);
638 if (nsyms == 1) sym = syms[0];
640 /* If no keysym was found, name it "Keycode-NNN" */
641 if (sym == XKB_KEY_NoSymbol)
642 snprintf(key, sizeof(key), "Keycode-%u", code);
645 /* get the keyname for this sym */
646 xkb_keysym_get_name(sym, key, sizeof(key));
651 /* If no keyname was found, name it "Keycode-NNN" */
652 snprintf(keyname, sizeof(keyname), "Keycode-%u", code);
656 memcpy(keyname, key, sizeof(keyname));
659 /* if shift is active, we need to transform the key to lower */
660 if (xkb_state_mod_index_is_active(edev->xkb.state,
661 xkb_map_mod_get_index(edev->xkb.keymap,
663 XKB_STATE_MODS_EFFECTIVE))
665 if (keyname[0] != '\0')
666 keyname[0] = tolower(keyname[0]);
669 if (_device_keysym_translate(sym, edev->xkb.modifiers,
670 compose_buffer, sizeof(compose_buffer)))
672 compose = eina_str_convert("ISO8859-1", "UTF-8", compose_buffer);
675 ERR("E Input cannot convert input key string '%s' to UTF-8. "
676 "Is Eina built with iconv support?", compose_buffer);
682 if (!compose) compose = compose_buffer;
684 e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
685 ((compose[0] != '\0') ? strlen(compose) : 0) + 3);
691 key_data = E_NEW(E_Keyrouter_Event_Data, 1);
699 e->keyname = (char *)(e + 1);
700 e->key = e->keyname + strlen(keyname) + 1;
701 e->compose = strlen(compose) ? e->key + strlen(key) + 1 : NULL;
702 e->string = e->compose;
704 strncpy((char *)e->keyname, keyname, strlen(keyname));
705 strncpy((char *)e->key, key, strlen(key));
706 if (strlen(compose)) strncpy((char *)e->compose, compose, strlen(compose));
708 e->window = (Ecore_Window)input->dev->window;
709 e->event_window = (Ecore_Window)input->dev->window;
710 e->root_window = (Ecore_Window)input->dev->window;
711 e->timestamp = timestamp;
715 e->dev = (Eo *)e_dev;
717 _device_modifiers_update(edev);
719 e->modifiers = edev->xkb.modifiers;
721 comp_conf = e_comp_config_get();
722 if (comp_conf && comp_conf->input_log_enable)
723 ELOGF("Key", "%s (keyname: %s, keycode: %d, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e_device_name_get(e_dev));
725 e_input_event_add(input->event_source, state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
731 _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event)
733 E_Input_Backend *input;
734 Ecore_Event_Mouse_Move *ev;
735 Ecore_Device *ecore_dev = NULL, *data, *detent_data = NULL;
737 int x = 0, y = 0, w = 0, h = 0;
739 if (!(input = edev->seat->input)) return;
741 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
742 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
744 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
746 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
751 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
756 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
758 ecore_dev = detent_data;
763 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
764 ecore_dev = edev->ecore_dev;
769 ERR("Failed to get source ecore device from event !\n");
772 else if ((detent_data == ecore_dev) || e_devicemgr_detent_is_detent(ecore_device_name_get(ecore_dev)))
774 /* Do not process detent device's move events. */
778 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
780 _device_configured_size_get(edev, &x, &y, &w, &h);
782 if (edev->seat->ptr.ix < x)
783 edev->seat->ptr.dx = edev->seat->ptr.ix = x;
784 else if (edev->seat->ptr.ix >= (x + w))
785 edev->seat->ptr.dx = edev->seat->ptr.ix = (x + w - 1);
787 if (edev->seat->ptr.iy < y)
788 edev->seat->ptr.dy = edev->seat->ptr.iy = y;
789 else if (edev->seat->ptr.iy >= (y + h))
790 edev->seat->ptr.dy = edev->seat->ptr.iy = (y + h - 1);
792 edev->mouse.dx = edev->seat->ptr.dx;
793 edev->mouse.dy = edev->seat->ptr.dy;
795 ev->window = (Ecore_Window)input->dev->window;
796 ev->event_window = (Ecore_Window)input->dev->window;
797 ev->root_window = (Ecore_Window)input->dev->window;
798 if (event) ev->timestamp = libinput_event_pointer_get_time(event);
801 _device_modifiers_update(edev);
802 ev->modifiers = edev->xkb.modifiers;
804 ev->x = edev->seat->ptr.ix;
805 ev->y = edev->seat->ptr.iy;
809 ev->multi.device = edev->mt_slot;
810 ev->multi.radius = 1;
811 ev->multi.radius_x = 1;
812 ev->multi.radius_y = 1;
813 ev->multi.pressure = 1.0;
814 ev->multi.angle = 0.0;
817 ev->multi.root.x = ev->x;
818 ev->multi.root.y = ev->y;
820 ecore_thread_main_loop_begin();
822 ev->dev = ecore_device_ref(ecore_dev);
824 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
826 ecore_thread_main_loop_end();
830 _e_input_pointer_motion_post(E_Input_Evdev *edev)
832 _device_pointer_motion(edev, NULL);
836 _device_pointer_relative_motion_send(double dx[2], double dy[2], uint64_t time_us)
838 e_input_relative_motion_cb func = e_input_relative_motion_handler_get();
839 if (func) func(dx, dy, time_us);
843 _device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event)
846 double delta_x[2]; /* delta_x[0] for accelerated, delta_x[1] for unaccelerated */
847 double delta_y[2]; /* delta_y[0] for accelerated, delta_y[1] for unaccelerated */
850 if (!(edev = libinput_device_get_user_data(device)))
855 delta_x[0] = libinput_event_pointer_get_dx(event);
856 delta_x[1] = libinput_event_pointer_get_dx_unaccelerated(event);
857 delta_y[0] = libinput_event_pointer_get_dy(event);
858 delta_y[1] = libinput_event_pointer_get_dy_unaccelerated(event);
860 if (edev->disable_acceleration)
871 if (edev->seat->ptr.swap)
877 if (edev->seat->ptr.invert_x)
879 if (edev->seat->ptr.invert_y)
882 edev->seat->ptr.dx += dx;
883 edev->seat->ptr.dy += dy;
885 edev->mouse.dx = edev->seat->ptr.dx;
886 edev->mouse.dy = edev->seat->ptr.dy;
888 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
889 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
894 edev->seat->ptr.ix = edev->seat->ptr.dx;
895 edev->seat->ptr.iy = edev->seat->ptr.dy;
897 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
898 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
903 _device_pointer_relative_motion_send(&delta_x[0], &delta_y[0],
904 libinput_event_pointer_get_time_usec(event));
905 _device_pointer_motion(edev, event);
909 _device_handle_pointer_motion_absolute(struct libinput_device *device, struct libinput_event_pointer *event)
914 if (!(edev = libinput_device_get_user_data(device)))
919 e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
921 edev->mouse.dx = edev->seat->ptr.dx =
922 libinput_event_pointer_get_absolute_x_transformed(event, w);
923 edev->mouse.dy = edev->seat->ptr.dy =
924 libinput_event_pointer_get_absolute_y_transformed(event, h);
926 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
927 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
932 edev->seat->ptr.ix = edev->seat->ptr.dx;
933 edev->seat->ptr.iy = edev->seat->ptr.dy;
935 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
936 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
941 _device_pointer_motion(edev, event);
945 _device_handle_button(struct libinput_device *device, struct libinput_event_pointer *event)
948 E_Input_Backend *input;
949 Ecore_Event_Mouse_Button *ev;
950 enum libinput_button_state state;
951 uint32_t button, timestamp;
952 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
954 E_Comp_Config *comp_conf = NULL;
956 if (!(edev = libinput_device_get_user_data(device)))
960 if (!(input = edev->seat->input))
965 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
966 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
968 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
970 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
975 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
980 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
982 ecore_dev = detent_data;
987 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
988 ecore_dev = edev->ecore_dev;
993 ERR("Failed to get source ecore device from event !\n");
997 state = libinput_event_pointer_get_button_state(event);
998 button = libinput_event_pointer_get_button(event);
999 timestamp = libinput_event_pointer_get_time(event);
1001 button = ((button & 0x00F) + 1);
1002 if (button == 3) button = 2;
1003 else if (button == 2) button = 3;
1007 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
1008 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
1010 ELOGF("Mouse", "Button Press (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
1011 button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
1012 edev->seat->dev->server_blocked);
1017 edev->mouse.pressed_button |= (1 << button);
1022 if (!(edev->mouse.pressed_button & (1 << button)))
1024 ELOGF("Mouse", "Button Release (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
1025 button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
1026 edev->seat->dev->server_blocked);
1029 edev->mouse.pressed_button &= ~(1 << button);
1032 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button))))
1037 ev->window = (Ecore_Window)input->dev->window;
1038 ev->event_window = (Ecore_Window)input->dev->window;
1039 ev->root_window = (Ecore_Window)input->dev->window;
1040 ev->timestamp = timestamp;
1041 ev->same_screen = 1;
1043 _device_modifiers_update(edev);
1044 ev->modifiers = edev->xkb.modifiers;
1046 ev->x = edev->seat->ptr.ix;
1047 ev->y = edev->seat->ptr.iy;
1051 ev->multi.device = edev->mt_slot;
1052 ev->multi.radius = 1;
1053 ev->multi.radius_x = 1;
1054 ev->multi.radius_y = 1;
1055 ev->multi.pressure = 1.0;
1056 ev->multi.angle = 0.0;
1057 ev->multi.x = ev->x;
1058 ev->multi.y = ev->y;
1059 ev->multi.root.x = ev->x;
1060 ev->multi.root.y = ev->y;
1062 ecore_thread_main_loop_begin();
1064 ev->dev = ecore_device_ref(ecore_dev);
1068 unsigned int current;
1070 current = timestamp;
1071 edev->mouse.did_double = EINA_FALSE;
1072 edev->mouse.did_triple = EINA_FALSE;
1074 if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
1075 (button == edev->mouse.prev_button))
1077 edev->mouse.did_double = EINA_TRUE;
1078 if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
1079 (button == edev->mouse.last_button))
1081 edev->mouse.did_triple = EINA_TRUE;
1082 edev->mouse.prev = 0;
1083 edev->mouse.last = 0;
1088 edev->mouse.last = edev->mouse.prev;
1089 edev->mouse.prev = current;
1090 edev->mouse.last_button = edev->mouse.prev_button;
1091 edev->mouse.prev_button = button;
1094 ev->buttons = button;
1096 if (edev->mouse.did_double)
1097 ev->double_click = 1;
1098 if (edev->mouse.did_triple)
1099 ev->triple_click = 1;
1101 comp_conf = e_comp_config_get();
1102 if (comp_conf && comp_conf->input_log_enable)
1103 ELOGF("Mouse", "Button %s (btn: %d, device: %s)", NULL, state?"Press":"Release", button, ecore_device_name_get(ev->dev));
1106 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, _e_input_event_mouse_button_cb_free, NULL);
1108 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, _e_input_event_mouse_button_cb_free, NULL);
1110 ecore_thread_main_loop_end();
1113 #if !LIBINPUT_HAVE_SCROLL_VALUE_V120
1115 _axis_value_get(struct libinput_event_pointer *pointer_event, enum libinput_pointer_axis axis)
1117 enum libinput_pointer_axis_source source;
1118 double value = 0.0, value_discrete = 0.0;
1120 E_Comp_Config *comp_conf = NULL;
1122 comp_conf = e_comp_config_get();
1123 source = libinput_event_pointer_get_axis_source(pointer_event);
1126 case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL:
1127 value_discrete = libinput_event_pointer_get_axis_value_discrete(pointer_event, axis);
1128 value = libinput_event_pointer_get_axis_value(pointer_event, axis);
1129 if (comp_conf && comp_conf->input_log_enable)
1131 ELOGF("Axis", "SOURCE_WHEEL discrete: %lf (cf. value: %lf)", NULL, value_discrete, value);
1133 ret = (int)value_discrete;
1135 case LIBINPUT_POINTER_AXIS_SOURCE_FINGER:
1136 case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
1137 value = libinput_event_pointer_get_axis_value(pointer_event, axis);
1138 if (comp_conf && comp_conf->input_log_enable)
1140 ELOGF("Axis", "SOURCE_FINGER/CONTINUOUS value: %lf", NULL, value);
1142 if (value >= E_INPUT_FINGER_SCROLL_THRESHOLD)
1144 else if (value <= E_INPUT_FINGER_SCROLL_THRESHOLD * (-1))
1157 _device_handle_axis(struct libinput_device *device, struct libinput_event_pointer *event)
1159 E_Input_Evdev *edev;
1160 E_Input_Backend *input;
1161 Ecore_Event_Mouse_Wheel *ev;
1163 enum libinput_pointer_axis axis;
1164 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
1166 E_Comp_Config *comp_conf = NULL;
1167 int direction = 0, z = 0;
1169 if (!(edev = libinput_device_get_user_data(device)))
1173 if (!(input = edev->seat->input))
1178 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1179 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1181 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1183 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
1188 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
1193 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
1195 ecore_dev = detent_data;
1200 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
1201 ecore_dev = edev->ecore_dev;
1206 ERR("Failed to get source ecore device from event !\n");
1210 axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
1211 if (libinput_event_pointer_has_axis(event, axis))
1212 z = _axis_value_get(event, axis);
1214 axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
1215 if (libinput_event_pointer_has_axis(event, axis))
1218 z = _axis_value_get(event, axis);
1223 ELOGF("Mouse", "Axis event is ignored since it has zero value", NULL);
1227 comp_conf = e_comp_config_get();
1228 if (comp_conf && comp_conf->e_wheel_click_angle)
1230 z = (int)(z * comp_conf->e_wheel_click_angle);
1233 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
1234 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
1237 ELOGF("Mouse", "Detent (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1238 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1240 ELOGF("Mouse", "Wheel (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1241 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1245 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
1250 timestamp = libinput_event_pointer_get_time(event);
1252 ev->window = (Ecore_Window)input->dev->window;
1253 ev->event_window = (Ecore_Window)input->dev->window;
1254 ev->root_window = (Ecore_Window)input->dev->window;
1255 ev->timestamp = timestamp;
1256 ev->same_screen = 1;
1258 _device_modifiers_update(edev);
1259 ev->modifiers = edev->xkb.modifiers;
1261 ev->x = edev->seat->ptr.ix;
1262 ev->y = edev->seat->ptr.iy;
1266 ev->direction = direction;
1268 if (comp_conf && comp_conf->input_log_enable)
1271 ELOGF("Mouse", "Detent (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1273 ELOGF("Mouse", "Wheel (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1276 ecore_thread_main_loop_begin();
1277 ev->dev = ecore_device_ref(ecore_dev);
1278 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
1279 ecore_thread_main_loop_end();
1283 #if LIBINPUT_HAVE_SCROLL_VALUE_V120
1285 _scroll_value_get(struct libinput_event_pointer *pointer_event, enum libinput_pointer_axis axis, E_Input_Axis_Source source)
1288 double value_v120 = 0.0;
1290 E_Comp_Config *comp_conf = NULL;
1292 comp_conf = e_comp_config_get();
1295 case E_INPUT_AXIS_SOURCE_WHEEL:
1296 value_v120 = libinput_event_pointer_get_scroll_value_v120(pointer_event, axis);
1297 value = libinput_event_pointer_get_scroll_value(pointer_event, axis);
1298 if (comp_conf && comp_conf->input_log_enable)
1300 ELOGF("Scroll", "SOURCE_WHEELL value_v120: %lf (cf. value: %lf)", NULL, value_v120, value);
1302 if (((int)value_v120 % E_INPUT_POINTER_AXIS_DISCRETE_STEP) != 0)
1304 ERR("Wheel movements should be multiples (or fractions) of 120!\n");
1309 ret = value_v120 / E_INPUT_POINTER_AXIS_DISCRETE_STEP;
1312 case E_INPUT_AXIS_SOURCE_FINGER:
1313 case E_INPUT_AXIS_SOURCE_CONTINUOUS:
1314 value = libinput_event_pointer_get_scroll_value(pointer_event, axis);
1315 if (comp_conf && comp_conf->input_log_enable)
1317 ELOGF("Scroll", "SOURCE_FINGER/CONTINUOUS value: %lf", NULL, value);
1319 if (value >= E_INPUT_FINGER_SCROLL_THRESHOLD)
1321 else if (value <= E_INPUT_FINGER_SCROLL_THRESHOLD * (-1))
1334 _device_handle_axis_v120(struct libinput_device *device, struct libinput_event_pointer *event, E_Input_Axis_Source source)
1336 E_Input_Evdev *edev;
1337 E_Input_Backend *input;
1338 Ecore_Event_Mouse_Wheel *ev;
1340 enum libinput_pointer_axis axis;
1341 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
1343 E_Comp_Config *comp_conf = NULL;
1344 int direction = 0, z = 0;
1346 if (!(edev = libinput_device_get_user_data(device)))
1350 if (!(input = edev->seat->input))
1355 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1356 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1358 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1360 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
1365 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
1370 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
1372 ecore_dev = detent_data;
1377 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
1378 ecore_dev = edev->ecore_dev;
1383 ERR("Failed to get source ecore device from event !\n");
1387 axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
1388 if (libinput_event_pointer_has_axis(event, axis))
1389 z = _scroll_value_get(event, axis, source);
1391 axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
1392 if (libinput_event_pointer_has_axis(event, axis))
1395 z = _scroll_value_get(event, axis, source);
1400 ELOGF("Mouse", "Scroll event is ignored since it has zero value", NULL);
1404 comp_conf = e_comp_config_get();
1405 if (comp_conf && comp_conf->e_wheel_click_angle)
1407 z = (int)(z * comp_conf->e_wheel_click_angle);
1410 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
1411 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
1414 ELOGF("Mouse", "Detent (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1415 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1417 ELOGF("Mouse", "Wheel (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1418 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1422 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
1427 timestamp = libinput_event_pointer_get_time(event);
1429 ev->window = (Ecore_Window)input->dev->window;
1430 ev->event_window = (Ecore_Window)input->dev->window;
1431 ev->root_window = (Ecore_Window)input->dev->window;
1432 ev->timestamp = timestamp;
1433 ev->same_screen = 1;
1435 _device_modifiers_update(edev);
1436 ev->modifiers = edev->xkb.modifiers;
1438 ev->x = edev->seat->ptr.ix;
1439 ev->y = edev->seat->ptr.iy;
1443 ev->direction = direction;
1445 if (comp_conf && comp_conf->input_log_enable)
1448 ELOGF("Mouse", "Detent (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1450 ELOGF("Mouse", "Wheel (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1453 ecore_thread_main_loop_begin();
1454 ev->dev = ecore_device_ref(ecore_dev);
1455 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
1456 ecore_thread_main_loop_end();
1461 _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch *event, int state)
1463 E_Input_Backend *input;
1464 Ecore_Event_Mouse_Button *ev;
1465 uint32_t timestamp, button = 0;
1466 Ecore_Device *ecore_dev = NULL, *data;
1470 if (!(input = edev->seat->input)) return;
1472 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1473 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1475 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1477 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1486 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1487 ecore_dev = edev->ecore_dev;
1492 ERR("Failed to get source ecore device from event !\n");
1496 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
1498 timestamp = libinput_event_touch_get_time(event);
1500 ev->window = (Ecore_Window)input->dev->window;
1501 ev->event_window = (Ecore_Window)input->dev->window;
1502 ev->root_window = (Ecore_Window)input->dev->window;
1503 ev->timestamp = timestamp;
1504 ev->same_screen = 1;
1506 _device_modifiers_update(edev);
1507 ev->modifiers = edev->xkb.modifiers;
1509 ev->x = edev->seat->ptr.ix;
1510 ev->y = edev->seat->ptr.iy;
1514 ev->multi.device = edev->mt_slot;
1515 ev->multi.radius = 1;
1516 ev->multi.radius_x = 1;
1517 ev->multi.radius_y = 1;
1518 ev->multi.pressure = 1.0;
1519 ev->multi.angle = 0.0;
1520 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
1521 if (libinput_event_get_type(libinput_event_touch_get_base_event(event))
1522 == LIBINPUT_EVENT_TOUCH_DOWN)
1524 if (libinput_event_touch_has_minor(event))
1525 ev->multi.radius_x = libinput_event_touch_get_minor(event);
1526 if (libinput_event_touch_has_major(event))
1527 ev->multi.radius_y = libinput_event_touch_get_major(event);
1528 if (libinput_event_touch_has_pressure(event))
1529 ev->multi.pressure = libinput_event_touch_get_pressure(event);
1530 if (libinput_event_touch_has_orientation(event))
1531 ev->multi.angle = libinput_event_touch_get_orientation(event);
1534 ev->multi.x = ev->x;
1535 ev->multi.y = ev->y;
1536 ev->multi.root.x = ev->x;
1537 ev->multi.root.y = ev->y;
1539 ecore_thread_main_loop_begin();
1541 ev->dev = ecore_device_ref(ecore_dev);
1543 if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN)
1545 unsigned int current;
1547 current = timestamp;
1548 edev->mouse.did_double = EINA_FALSE;
1549 edev->mouse.did_triple = EINA_FALSE;
1551 if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
1552 (button == edev->mouse.prev_button))
1554 edev->mouse.did_double = EINA_TRUE;
1555 if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
1556 (button == edev->mouse.last_button))
1558 edev->mouse.did_triple = EINA_TRUE;
1559 edev->mouse.prev = 0;
1560 edev->mouse.last = 0;
1565 edev->mouse.last = edev->mouse.prev;
1566 edev->mouse.prev = current;
1567 edev->mouse.last_button = edev->mouse.prev_button;
1568 edev->mouse.prev_button = button;
1569 edev->touch.pressed |= (1 << ev->multi.device);
1573 edev->touch.pressed &= ~(1 << ev->multi.device);
1576 ev->buttons = ((button & 0x00F) + 1);
1578 if (edev->mouse.did_double)
1579 ev->double_click = 1;
1580 if (edev->mouse.did_triple)
1581 ev->triple_click = 1;
1583 ecore_event_add(state, ev, _e_input_event_mouse_button_cb_free, NULL);
1585 ecore_thread_main_loop_end();
1589 _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touch *event)
1591 E_Input_Backend *input;
1592 Ecore_Event_Mouse_Move *ev;
1593 Ecore_Device *ecore_dev = NULL, *data;
1597 if (!(input = edev->seat->input)) return;
1599 ecore_thread_main_loop_begin();
1601 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1602 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1604 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1606 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1615 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1616 ecore_dev = edev->ecore_dev;
1621 ERR("Failed to get source ecore device from event !\n");
1625 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
1627 ev->window = (Ecore_Window)input->dev->window;
1628 ev->event_window = (Ecore_Window)input->dev->window;
1629 ev->root_window = (Ecore_Window)input->dev->window;
1630 ev->timestamp = libinput_event_touch_get_time(event);
1631 ev->same_screen = 1;
1633 _device_modifiers_update(edev);
1634 ev->modifiers = edev->xkb.modifiers;
1636 ev->x = edev->seat->ptr.ix;
1637 ev->y = edev->seat->ptr.iy;
1641 ev->multi.device = edev->mt_slot;
1642 ev->multi.radius = 1;
1643 ev->multi.radius_x = 1;
1644 ev->multi.radius_y = 1;
1645 ev->multi.pressure = 1.0;
1646 ev->multi.angle = 0.0;
1647 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
1648 if (libinput_event_touch_has_minor(event))
1649 ev->multi.radius_x = libinput_event_touch_get_minor(event);
1650 if (libinput_event_touch_has_major(event))
1651 ev->multi.radius_y = libinput_event_touch_get_major(event);
1652 if (libinput_event_touch_has_pressure(event))
1653 ev->multi.pressure = libinput_event_touch_get_pressure(event);
1654 if (libinput_event_touch_has_orientation(event))
1655 ev->multi.angle = libinput_event_touch_get_orientation(event);
1657 ev->multi.x = ev->x;
1658 ev->multi.y = ev->y;
1659 ev->multi.root.x = ev->x;
1660 ev->multi.root.y = ev->y;
1661 ev->dev = ecore_device_ref(ecore_dev);
1663 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
1665 ecore_thread_main_loop_end();
1669 _device_handle_touch_cancel_send(E_Input_Evdev *edev, struct libinput_event_touch *event)
1671 E_Input_Backend *input;
1672 Ecore_Event_Mouse_Button *ev;
1673 uint32_t timestamp, button = 0;
1674 Ecore_Device *ecore_dev = NULL, *data;
1678 if (!(input = edev->seat->input)) return;
1680 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1681 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1683 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1685 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1694 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1695 ecore_dev = edev->ecore_dev;
1700 ERR("Failed to get source ecore device from event !\n");
1704 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
1706 timestamp = libinput_event_touch_get_time(event);
1708 ev->window = (Ecore_Window)input->dev->window;
1709 ev->event_window = (Ecore_Window)input->dev->window;
1710 ev->root_window = (Ecore_Window)input->dev->window;
1711 ev->timestamp = timestamp;
1712 ev->same_screen = 1;
1714 ev->x = edev->seat->ptr.ix;
1715 ev->y = edev->seat->ptr.iy;
1719 ev->multi.device = edev->mt_slot;
1720 ev->multi.radius = 1;
1721 ev->multi.radius_x = 1;
1722 ev->multi.radius_y = 1;
1723 ev->multi.pressure = 1.0;
1724 ev->multi.angle = 0.0;
1725 ev->multi.x = ev->x;
1726 ev->multi.y = ev->y;
1727 ev->multi.root.x = ev->x;
1728 ev->multi.root.y = ev->y;
1730 edev->touch.pressed &= ~(1 << ev->multi.device);
1732 ev->buttons = ((button & 0x00F) + 1);
1734 ecore_thread_main_loop_begin();
1736 ev->dev = ecore_device_ref(ecore_dev);
1738 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, ev, _e_input_event_mouse_button_cb_free, NULL);
1739 ecore_thread_main_loop_end();
1743 _device_configured_size_get(E_Input_Evdev *edev, int *x, int *y, int *w, int *h)
1745 E_Output *output = NULL;
1747 EINA_SAFETY_ON_NULL_RETURN(edev);
1749 if (!edev->output_configured)
1751 if (edev->output_name)
1753 output = e_output_find(edev->output_name);
1756 edev->mouse.minx = output->config.geom.x;
1757 edev->mouse.miny = output->config.geom.y;
1758 edev->mouse.maxw = output->config.geom.w;
1759 edev->mouse.maxh = output->config.geom.h;
1760 if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
1762 edev->seat->ptr.dx = (double)(edev->mouse.maxw / 2);
1763 edev->seat->ptr.dy = (double)(edev->mouse.maxh / 2);
1764 edev->seat->ptr.ix = (int)edev->seat->ptr.dx;
1765 edev->seat->ptr.iy = (int)edev->seat->ptr.dy;
1766 edev->mouse.dx = edev->seat->ptr.dx;
1767 edev->mouse.dy = edev->seat->ptr.dy;
1772 edev->output_configured = EINA_TRUE;
1773 ELOGF("E_INPUT_EVDEV", "Device is configured by output x:%d,y:%d (w:%d, h:%d)",
1774 NULL, edev->mouse.minx, edev->mouse.miny, edev->mouse.maxw, edev->mouse.maxh);
1776 if (x) *x = edev->mouse.minx;
1777 if (y) *y = edev->mouse.miny;
1778 if (w) *w = edev->mouse.maxw;
1779 if (h) *h = edev->mouse.maxh;
1783 _device_handle_touch_down(struct libinput_device *device, struct libinput_event_touch *event)
1785 E_Input_Evdev *edev;
1786 int x = 0, y = 0, w = 0, h = 0;
1787 E_Comp_Config *comp_conf = NULL;
1789 if (!(edev = libinput_device_get_user_data(device)))
1794 _device_configured_size_get(edev, &x, &y, &w, &h);
1796 edev->mouse.dx = edev->seat->ptr.ix = edev->seat->ptr.dx =
1797 x + libinput_event_touch_get_x_transformed(event, w);
1798 edev->mouse.dy = edev->seat->ptr.iy = edev->seat->ptr.dy =
1799 y + libinput_event_touch_get_y_transformed(event, h);
1801 edev->mt_slot = libinput_event_touch_get_slot(event);
1802 if (edev->mt_slot < 0)
1804 /* FIXME: The single touch device return slot id -1
1805 * But currently we have no API to distinguish multi touch or single touch
1806 * After libinput 1.11 version, libinput provides get_touch_count API,
1807 * so we can distinguish multi touch device or single touch device.
1809 if (edev->mt_slot == -1)
1813 WRN("%d slot touch down events are not supported\n", edev->mt_slot);
1818 if (edev->mt_slot < e_input_touch_max_count_get())
1820 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1821 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1824 comp_conf = e_comp_config_get();
1825 if (comp_conf && comp_conf->input_log_enable)
1826 ELOGF("Touch", "Down (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1828 edev->touch.raw_pressed |= (1 << edev->mt_slot);
1830 if (edev->touch.blocked)
1832 ELOGF("Touch", "Down (id: %d, x: %d, y: %d) is blocked by %p, server: 0x%x", NULL,
1833 edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client,
1834 edev->seat->dev->server_blocked);
1838 _device_handle_touch_motion_send(edev, event);
1839 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN);
1843 _device_handle_touch_motion(struct libinput_device *device, struct libinput_event_touch *event)
1845 E_Input_Evdev *edev;
1846 int x = 0, y = 0, w = 0, h = 0;
1848 if (!(edev = libinput_device_get_user_data(device)))
1853 _device_configured_size_get(edev, &x, &y, &w, &h);
1855 edev->mouse.dx = edev->seat->ptr.dx =
1856 x + libinput_event_touch_get_x_transformed(event, w);
1857 edev->mouse.dy = edev->seat->ptr.dy =
1858 y + libinput_event_touch_get_y_transformed(event, h);
1860 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
1861 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
1866 edev->seat->ptr.ix = edev->seat->ptr.dx;
1867 edev->seat->ptr.iy = edev->seat->ptr.dy;
1869 edev->mt_slot = libinput_event_touch_get_slot(event);
1870 if (edev->mt_slot < 0)
1872 /* FIXME: The single touch device return slot id -1
1873 * But currently we have no API to distinguish multi touch or single touch
1874 * After libinput 1.11 version, libinput provides get_touch_count API,
1875 * so we can distinguish multi touch device or single touch device.
1877 if (edev->mt_slot == -1)
1881 WRN("%d slot touch motion events are not supported\n", edev->mt_slot);
1886 if (edev->mt_slot < e_input_touch_max_count_get())
1888 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1889 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1892 if (!(edev->touch.pressed & (1 << edev->mt_slot)))
1894 if (edev->touch.blocked)
1900 _device_handle_touch_motion_send(edev, event);
1904 _device_handle_touch_up(struct libinput_device *device, struct libinput_event_touch *event)
1906 E_Input_Evdev *edev;
1907 E_Comp_Config *comp_conf = NULL;
1909 if (!(edev = libinput_device_get_user_data(device)))
1914 edev->mt_slot = libinput_event_touch_get_slot(event);
1915 if (edev->mt_slot < 0)
1917 /* FIXME: The single touch device return slot id -1
1918 * But currently we have no API to distinguish multi touch or single touch
1919 * After libinput 1.11 version, libinput provides get_touch_count API,
1920 * so we can distinguish multi touch device or single touch device.
1922 if (edev->mt_slot == -1)
1926 WRN("%d slot touch up events are not supported\n", edev->mt_slot);
1931 if (edev->mt_slot < e_input_touch_max_count_get())
1933 edev->mouse.dx = edev->seat->ptr.dx = edev->seat->ptr.ix =
1934 edev->touch.coords[edev->mt_slot].x;
1935 edev->mouse.dy = edev->seat->ptr.dy = edev->seat->ptr.iy =
1936 edev->touch.coords[edev->mt_slot].y;
1939 comp_conf = e_comp_config_get();
1940 if (comp_conf && comp_conf->input_log_enable)
1941 ELOGF("Touch", "Up (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1943 edev->touch.raw_pressed &= ~(1 << edev->mt_slot);
1945 if (edev->touch.blocked)
1947 if (!(edev->touch.pressed & (1 << edev->mt_slot)))
1949 ELOGF("Touch", "Up (id: %d, x: %d, y: %d) is blocked by %p, server(0x%x)", NULL,
1950 edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client,
1951 edev->seat->dev->server_blocked);
1952 if (edev->touch.raw_pressed == 0x0)
1954 edev->touch.blocked = EINA_FALSE;
1960 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_UP);
1964 _device_handle_touch_cancel(struct libinput_device *device, struct libinput_event_touch *event)
1966 E_Input_Evdev *edev;
1967 E_Comp_Config *comp_conf = NULL;
1969 if (!(edev = libinput_device_get_user_data(device)))
1974 edev->mt_slot = libinput_event_touch_get_slot(event);
1975 if (edev->mt_slot < 0)
1977 /* FIXME: The single touch device return slot id -1
1978 * But currently we have no API to distinguish multi touch or single touch
1979 * After libinput 1.11 version, libinput provides get_touch_count API,
1980 * so we can distinguish multi touch device or single touch device.
1982 if (edev->mt_slot == -1)
1986 WRN("%d slot touch up events are not supported\n", edev->mt_slot);
1991 comp_conf = e_comp_config_get();
1992 if (comp_conf && comp_conf->input_log_enable)
1993 ELOGF("Touch", "cancel (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1995 _device_handle_touch_cancel_send(edev, event);
2000 _device_handle_touch_frame(struct libinput_device *device EINA_UNUSED, struct libinput_event_touch *event EINA_UNUSED)
2002 /* DBG("Unhandled Touch Frame Event"); */
2006 _e_input_aux_data_event_free(void *user_data EINA_UNUSED, void *ev)
2008 Ecore_Event_Axis_Update *e = (Ecore_Event_Axis_Update *)ev;
2010 if (e->axis) free(e->axis);
2011 if (e->dev) ecore_device_unref(e->dev);
2017 _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_event_touch_aux_data *event)
2019 E_Input_Evdev *edev;
2020 E_Input_Backend *input;
2021 Ecore_Event_Axis_Update *ev;
2023 Ecore_Device *ecore_dev = NULL, *data;
2025 E_Comp_Config *comp_conf;
2027 if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
2028 libinput_event_touch_aux_data_get_value(event) > 0)
2031 if (!(edev = libinput_device_get_user_data(device))) goto end;
2032 if (!(input = edev->seat->input)) goto end;
2034 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
2035 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
2037 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
2039 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
2048 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
2049 ecore_dev = edev->ecore_dev;
2054 ERR("Failed to get source ecore device from event !\n");
2058 if (!(ev = calloc(1, sizeof(Ecore_Event_Axis_Update))))goto end;
2060 ev->window = (Ecore_Window)input->dev->window;
2061 ev->event_window = (Ecore_Window)input->dev->window;
2062 ev->root_window = (Ecore_Window)input->dev->window;
2063 ev->timestamp = libinput_event_touch_aux_data_get_time(event);
2065 axis = (Ecore_Axis *)calloc(1, sizeof(Ecore_Axis));
2068 axis->label = ECORE_AXIS_LABEL_TOUCH_PALM;
2069 axis->value = libinput_event_touch_aux_data_get_value(event);
2074 comp_conf = e_comp_config_get();
2075 if (comp_conf && comp_conf->input_log_enable)
2076 ELOGF("Touch", "Axis (label: %d, value: %lf)", NULL, axis?axis->label:-1, axis?axis->value:0.0);
2078 ecore_thread_main_loop_begin();
2080 ev->dev = ecore_device_ref(ecore_dev);
2082 ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
2083 ecore_thread_main_loop_end();
2090 _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
2092 E_Input_Evdev *edev;
2093 E_Input_Backend *b_input;
2094 const char *output_name;
2096 EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
2098 /* try to allocate space for new evdev */
2099 if (!(edev = calloc(1, sizeof(E_Input_Evdev)))) return NULL;
2102 edev->device = device;
2103 edev->path = eina_stringshare_printf("%s/%s", e_input_base_dir_get(), libinput_device_get_sysname(device));
2105 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
2107 edev->caps |= E_INPUT_SEAT_KEYBOARD;
2108 _device_keyboard_setup(edev);
2111 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
2113 edev->caps |= E_INPUT_SEAT_POINTER;
2115 /* TODO: make this configurable */
2116 edev->mouse.threshold = 250;
2118 b_input = seat->input;
2119 if (b_input->left_handed == EINA_TRUE)
2121 if (libinput_device_config_left_handed_set(device, 1) !=
2122 LIBINPUT_CONFIG_STATUS_SUCCESS)
2124 WRN("Failed to set left hand mode about device: %s\n",
2125 libinput_device_get_name(device));
2130 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
2133 edev->caps |= E_INPUT_SEAT_TOUCH;
2134 palm_code = libinput_device_touch_aux_data_get_code(LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM);
2135 if (libinput_device_touch_has_aux_data(device, palm_code))
2137 libinput_device_touch_set_aux_data(device, palm_code);
2140 _device_touch_count_update(edev);
2142 edev->touch.coords = calloc(1, sizeof(E_Input_Coord)*e_input_touch_max_count_get());
2144 if (!edev->touch.coords)
2145 ERR("Failed to allocate memory for touch coords !\n");
2148 output_name = libinput_device_get_output_name(device);
2151 eina_stringshare_replace(&edev->output_name, output_name);
2152 ELOGF("E_INPUT_EVDEV", "Device has output_name:%s", NULL, output_name);
2155 libinput_device_set_user_data(device, edev);
2156 libinput_device_ref(device);
2158 /* configure device */
2159 _device_configure(edev);
2165 _e_input_evdev_device_destroy(E_Input_Evdev *edev)
2169 EINA_SAFETY_ON_NULL_RETURN(edev);
2171 ecore_thread_main_loop_begin();
2173 if (edev->caps & E_INPUT_SEAT_KEYBOARD)
2175 if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
2176 if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
2179 if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
2180 if (edev->ecore_dev_list)
2181 EINA_LIST_FREE(edev->ecore_dev_list, dev)
2183 ecore_device_del(dev);
2185 if (edev->path) eina_stringshare_del(edev->path);
2186 if (edev->device) libinput_device_unref(edev->device);
2187 if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
2188 if (edev->touch.coords)
2190 free(edev->touch.coords);
2191 edev->touch.coords = NULL;
2193 eina_stringshare_del(edev->output_name);
2195 ecore_thread_main_loop_end();
2201 _e_input_evdev_event_process(struct libinput_event *event)
2203 struct libinput_device *device;
2204 Eina_Bool ret = EINA_TRUE;
2206 device = libinput_event_get_device(event);
2207 switch (libinput_event_get_type(event))
2209 case LIBINPUT_EVENT_KEYBOARD_KEY:
2210 _device_handle_key(device, libinput_event_get_keyboard_event(event));
2212 case LIBINPUT_EVENT_POINTER_MOTION:
2213 _device_handle_pointer_motion(device,
2214 libinput_event_get_pointer_event(event));
2216 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
2217 _device_handle_pointer_motion_absolute(device,
2218 libinput_event_get_pointer_event(event));
2220 case LIBINPUT_EVENT_POINTER_BUTTON:
2221 _device_handle_button(device, libinput_event_get_pointer_event(event));
2223 case LIBINPUT_EVENT_POINTER_AXIS:
2224 #if !LIBINPUT_HAVE_SCROLL_VALUE_V120
2225 _device_handle_axis(device, libinput_event_get_pointer_event(event));
2228 #if LIBINPUT_HAVE_SCROLL_VALUE_V120
2229 case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
2230 _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_WHEEL);
2232 case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
2233 _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_FINGER);
2235 case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
2236 _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_CONTINUOUS);
2239 case LIBINPUT_EVENT_TOUCH_DOWN:
2240 _device_handle_touch_down(device, libinput_event_get_touch_event(event));
2242 case LIBINPUT_EVENT_TOUCH_MOTION:
2243 _device_handle_touch_motion(device,
2244 libinput_event_get_touch_event(event));
2246 case LIBINPUT_EVENT_TOUCH_UP:
2247 _device_handle_touch_up(device, libinput_event_get_touch_event(event));
2249 case LIBINPUT_EVENT_TOUCH_CANCEL:
2250 _device_handle_touch_cancel(device, libinput_event_get_touch_event(event));
2252 case LIBINPUT_EVENT_TOUCH_FRAME:
2253 _device_handle_touch_frame(device, libinput_event_get_touch_event(event));
2255 case LIBINPUT_EVENT_TOUCH_AUX_DATA:
2256 _device_handle_touch_aux_data(device, libinput_event_get_touch_aux_data(event));
2267 * @brief Set the axis size of the given device.
2269 * @param dev The device to set the axis size to.
2270 * @param w The width of the axis.
2271 * @param h The height of the axis.
2273 * This function sets set the width @p w and height @p h of the axis
2274 * of device @p dev. If @p dev is a relative input device, a width and
2275 * height must set for it. If its absolute set the ioctl correctly, if
2276 * not, unsupported device.
2279 e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h)
2281 const char *sysname;
2286 enum libinput_config_status status;
2288 EINA_SAFETY_ON_NULL_RETURN(edev);
2289 EINA_SAFETY_ON_TRUE_RETURN((w == 0) || (h == 0));
2291 if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
2292 (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
2295 sysname = libinput_device_get_sysname(edev->device);
2297 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
2298 if (eina_list_count(devices) < 1) return;
2300 EINA_LIST_FREE(devices, device)
2302 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
2304 (sscanf(vals, "%f %f %f %f %f %f",
2305 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
2312 libinput_device_config_calibration_set_matrix(edev->device, cal);
2314 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
2315 ERR("Failed to apply calibration");
2318 eina_stringshare_del(device);
2323 EINTERN const char *
2324 e_input_evdev_name_get(E_Input_Evdev *evdev)
2326 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
2327 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
2329 return libinput_device_get_name(evdev->device);
2332 EINTERN const char *
2333 e_input_evdev_sysname_get(E_Input_Evdev *evdev)
2335 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
2336 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
2338 return libinput_device_get_sysname(evdev->device);
2342 e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool enable)
2344 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2345 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2347 edev->key_remap_enabled = enable;
2349 if (enable == EINA_FALSE && edev->key_remap_hash)
2351 eina_hash_free(edev->key_remap_hash);
2352 edev->key_remap_hash = NULL;
2359 e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num)
2363 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2364 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2365 EINA_SAFETY_ON_NULL_RETURN_VAL(from_keys, EINA_FALSE);
2366 EINA_SAFETY_ON_NULL_RETURN_VAL(to_keys, EINA_FALSE);
2367 EINA_SAFETY_ON_TRUE_RETURN_VAL(num <= 0, EINA_FALSE);
2368 EINA_SAFETY_ON_TRUE_RETURN_VAL(!edev->key_remap_enabled, EINA_FALSE);
2370 if (edev->key_remap_hash == NULL)
2371 edev->key_remap_hash = eina_hash_int32_new(NULL);
2373 if (edev->key_remap_hash == NULL)
2375 ERR("Failed to set remap key information : creating a hash is failed.");
2379 for (i = 0; i < num ; i++)
2381 if (!from_keys[i] || !to_keys[i])
2383 ERR("Failed to set remap key information : given arguments are invalid.");
2388 for (i = 0; i < num ; i++)
2390 eina_hash_add(edev->key_remap_hash, &from_keys[i], (void *)(intptr_t)to_keys[i]);
2397 e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev)
2399 EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
2400 return libinput_device_config_scroll_get_wheel_click_angle(dev->device);
2404 e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6])
2406 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2407 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2409 if (!libinput_device_config_calibration_has_matrix(edev->device) ||
2410 !libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_TOUCH))
2413 if (libinput_device_config_calibration_set_matrix(edev->device, matrix) !=
2414 LIBINPUT_CONFIG_STATUS_SUCCESS)
2416 WRN("Failed to set input transformation about device: %s\n",
2417 libinput_device_get_name(edev->device));
2425 e_input_evdev_mouse_accel_speed_set(E_Input_Evdev *edev, double speed)
2427 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2428 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2430 if (!libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
2433 if (!libinput_device_config_accel_is_available(edev->device))
2436 if (libinput_device_config_accel_set_speed(edev->device, speed) !=
2437 LIBINPUT_CONFIG_STATUS_SUCCESS)
2439 WRN("Failed to set mouse accel about device: %s\n",
2440 libinput_device_get_name(edev->device));
2447 EINTERN unsigned int
2448 e_input_evdev_touch_pressed_get(E_Input_Evdev *edev)
2450 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, 0x0);
2452 return edev->touch.pressed;
2456 e_input_evdev_seatname_get(E_Input_Evdev *evdev)
2458 struct libinput_seat *libinput_seat;
2459 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
2460 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
2462 libinput_seat = libinput_device_get_seat(evdev->device);
2464 return libinput_seat_get_logical_name(libinput_seat);
2468 e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname)
2470 Eina_Bool res = EINA_FALSE;
2471 E_Input_Backend *input;
2473 EINA_SAFETY_ON_NULL_RETURN_VAL(seatname, EINA_FALSE);
2474 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, EINA_FALSE);
2475 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, EINA_FALSE);
2477 if (libinput_device_set_seat_logical_name(evdev->device, seatname) == 0)
2479 input = evdev->seat->input;
2480 if (!input) return EINA_FALSE;
2481 if (libinput_dispatch(input->libinput) != 0)
2483 ERR("Failed to dispatch libinput events: %m");
2487 /* process pending events */
2488 _input_events_process(input);
2496 e_input_evdev_mouse_accel_enable(E_Input_Evdev *edev, Eina_Bool enable)
2498 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2499 edev->disable_acceleration = !enable;