2 #include "e_input_private.h"
4 #include "e_keyrouter_private.h"
5 #include "e_input_event.h"
6 #include "e_devicemgr.h"
10 #define G_LIST_GET_DATA(list) ((list) ? (((GList *)(list))->data) : NULL)
12 static void _device_modifiers_update(E_Input_Evdev *edev);
13 static void _device_configured_size_get(E_Input_Evdev *edev, int *x, int *y, int *w, int *h);
14 static void _device_output_assign(E_Input_Evdev *edev, E_Input_Seat_Capabilities cap);
17 _device_calibration_set(E_Input_Evdev *edev)
22 E_Comp_Config *comp_conf;
24 if (e_comp->e_comp_screen->num_outputs > 1) //multiple outputs
26 comp_conf = e_comp_config_get();
27 if (comp_conf && (comp_conf->input_output_assign_policy == 1)) //use output-assignment policy
29 _device_output_assign(edev, E_INPUT_SEAT_POINTER);
30 _device_output_assign(edev, E_INPUT_SEAT_TOUCH);
34 output = e_comp_screen_primary_output_get(e_comp->e_comp_screen);
35 e_output_size_get(output, &w, &h);
39 edev->mouse.minx = edev->mouse.miny = 0;
43 if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
45 edev->seat->ptr.dx = (double)(w / 2);
46 edev->seat->ptr.dy = (double)(h / 2);
47 edev->seat->ptr.ix = (int)edev->seat->ptr.dx;
48 edev->seat->ptr.iy = (int)edev->seat->ptr.dy;
49 edev->mouse.dx = edev->seat->ptr.dx;
50 edev->mouse.dy = edev->seat->ptr.dy;
52 if (output->config.rotation == 90 || output->config.rotation == 270)
54 temp = edev->mouse.minx;
55 edev->mouse.minx = edev->mouse.miny;
56 edev->mouse.miny = temp;
58 temp = edev->mouse.maxw;
59 edev->mouse.maxw = edev->mouse.maxh;
60 edev->mouse.maxh = temp;
66 #ifdef _F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
72 if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
73 (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
76 sysname = libinput_device_get_sysname(edev->device);
78 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
79 if (eina_list_count(devices) < 1) return;
81 #ifdef _F_E_INPUT_USE_WL_CALIBRATION_
83 enum libinput_config_status status;
85 EINA_LIST_FREE(devices, device)
87 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
89 (sscanf(vals, "%f %f %f %f %f %f",
90 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
97 libinput_device_config_calibration_set_matrix(edev->device, cal);
99 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
100 ERR("Failed to apply calibration");
103 eina_stringshare_del(device);
106 #endif//_F_E_INPUT_USE_WL_CALIBRATION_
107 #endif//_F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
112 _device_output_assign(E_Input_Evdev *edev, E_Input_Seat_Capabilities cap)
117 Eina_Bool need_assign_output = EINA_FALSE;
118 const char *output_name;
121 if (!(edev->caps & cap)) return;
122 if (edev->output_name) return; //already assigned
123 if (e_comp->e_comp_screen->num_outputs <= 1) return;
125 last_output_idx = e_comp->e_comp_screen->num_outputs - 1;
126 EINA_LIST_FOREACH(edev->seat->devices, l, ed)
128 if (!(ed->caps & cap)) continue;
129 if (ed == edev) continue;
132 need_assign_output = EINA_FALSE;
135 need_assign_output = EINA_TRUE;
137 if (need_assign_output)
139 output = e_output_find_by_index(last_output_idx);
140 if (!output || !output->info.connected) return;
141 output_name = e_output_output_id_get(output);
142 if (output_name) edev->output_name = eina_stringshare_add(output_name);
143 ELOGF("E_INPUT_EVDEV", "Device is assigned to output:%s", NULL, output_name);
148 _device_touch_count_update(E_Input_Evdev *edev)
150 unsigned int device_touch_count = 0;
151 static unsigned int _max_device_touch_count = 0;
153 E_Input *ei = e_input_get();
154 EINA_SAFETY_ON_NULL_RETURN(ei);
156 device_touch_count = libinput_device_touch_get_touch_count(edev->device);
158 if (_max_device_touch_count < device_touch_count)
159 _max_device_touch_count = device_touch_count;
161 if (e_config->configured_max_touch.use)
163 if (_max_device_touch_count > 0 && e_config->configured_max_touch.count > _max_device_touch_count)
165 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",
166 NULL, e_config->configured_max_touch.count, _max_device_touch_count, _max_device_touch_count);
167 ei->touch_max_count = _max_device_touch_count;
171 if (ei->touch_max_count != e_config->configured_max_touch.count)
173 ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n",
174 NULL, ei->touch_max_count, e_config->configured_max_touch.count);
175 ei->touch_max_count = e_config->configured_max_touch.count;
181 if (ei->touch_max_count < _max_device_touch_count)
183 ELOGF("E_INPUT_EVDEV_TOUCH", "Touch_max_count has been updated to %d -> %d.\n", NULL,
184 ei->touch_max_count, _max_device_touch_count);
185 ei->touch_max_count = _max_device_touch_count;
189 ei->touch_device_count++;
190 ELOGF("E_INPUT_EVDEV_TOUCH", "Touch device count is %d.\n", NULL, ei->touch_device_count);
194 _device_configure(E_Input_Evdev *edev)
196 if (libinput_device_config_tap_get_finger_count(edev->device) > 0)
198 Eina_Bool tap = EINA_FALSE;
200 tap = libinput_device_config_tap_get_default_enabled(edev->device);
201 libinput_device_config_tap_set_enabled(edev->device, tap);
204 _device_calibration_set(edev);
208 _device_keyboard_setup(E_Input_Evdev *edev)
210 E_Input_Backend *input;
211 xkb_mod_index_t xkb_idx;
213 if ((!edev) || (!edev->seat)) return;
214 if (!(input = edev->seat->input)) return;
215 if (!input->dev->xkb_ctx) return;
217 g_mutex_init(&edev->xkb.keymap_mutex);
219 /* create keymap from xkb context */
220 g_mutex_lock(&edev->xkb.keymap_mutex);
221 edev->xkb.keymap = _e_input_device_cached_keymap_get(input->dev->xkb_ctx, NULL, 0);
222 if (!edev->xkb.keymap)
224 g_mutex_unlock(&edev->xkb.keymap_mutex);
225 ERR("Failed to create keymap: %m");
229 g_mutex_lock(&edev->xkb.state_mutex);
231 /* create xkb state */
232 if (!(edev->xkb.state = xkb_state_new(edev->xkb.keymap)))
234 g_mutex_unlock(&edev->xkb.state_mutex);
235 g_mutex_unlock(&edev->xkb.keymap_mutex);
236 ERR("Failed to create xkb state: %m");
240 g_mutex_unlock(&edev->xkb.state_mutex);
242 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CTRL);
243 if (xkb_idx != XKB_MOD_INVALID)
244 edev->xkb.ctrl_mask = 1 << xkb_idx;
246 edev->xkb.ctrl_mask = 0;
248 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_ALT);
249 if (xkb_idx != XKB_MOD_INVALID)
250 edev->xkb.alt_mask = 1 << xkb_idx;
252 edev->xkb.alt_mask = 0;
254 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_SHIFT);
255 if (xkb_idx != XKB_MOD_INVALID)
256 edev->xkb.shift_mask = 1 << xkb_idx;
258 edev->xkb.shift_mask = 0;
260 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_LOGO);
261 if (xkb_idx != XKB_MOD_INVALID)
262 edev->xkb.win_mask = 1 << xkb_idx;
264 edev->xkb.win_mask = 0;
266 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_LED_NAME_SCROLL);
267 if (xkb_idx != XKB_MOD_INVALID)
268 edev->xkb.scroll_mask = 1 << xkb_idx;
270 edev->xkb.scroll_mask = 0;
272 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_LED_NAME_NUM);
273 if (xkb_idx != XKB_MOD_INVALID)
274 edev->xkb.num_mask = 1 << xkb_idx;
276 edev->xkb.num_mask = 0;
278 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CAPS);
279 if (xkb_idx != XKB_MOD_INVALID)
280 edev->xkb.caps_mask = 1 << xkb_idx;
282 edev->xkb.caps_mask = 0;
284 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, "ISO_Level3_Shift");
285 if (xkb_idx != XKB_MOD_INVALID)
286 edev->xkb.altgr_mask = 1 << xkb_idx;
288 edev->xkb.altgr_mask = 0;
290 g_mutex_unlock(&edev->xkb.keymap_mutex);
294 _device_keysym_translate(xkb_keysym_t keysym, unsigned int modifiers, char *buffer, int bytes)
296 unsigned long hbytes = 0;
299 if (!keysym) return 0;
300 hbytes = (keysym >> 8);
305 (((keysym >= XKB_KEY_BackSpace) && (keysym <= XKB_KEY_Clear)) ||
306 (keysym == XKB_KEY_Return) || (keysym == XKB_KEY_Escape) ||
307 (keysym == XKB_KEY_KP_Space) || (keysym == XKB_KEY_KP_Tab) ||
308 (keysym == XKB_KEY_KP_Enter) ||
309 ((keysym >= XKB_KEY_KP_Multiply) && (keysym <= XKB_KEY_KP_9)) ||
310 (keysym == XKB_KEY_KP_Equal) || (keysym == XKB_KEY_Delete))))))
313 if (keysym == XKB_KEY_KP_Space)
314 c = (XKB_KEY_space & 0x7F);
315 else if (hbytes == 0xFF)
320 if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
322 if (((c >= '@') && (c < '\177')) || c == ' ')
326 else if ((c >= '3') && (c <= '7'))
338 _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
342 g_mutex_lock(&from->xkb.state_mutex);
344 edev->xkb.depressed =
345 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_DEPRESSED);
347 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LATCHED);
349 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LOCKED);
351 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_EFFECTIVE);
353 g_mutex_unlock(&from->xkb.state_mutex);
355 mask = (edev->xkb.depressed | edev->xkb.latched);
357 if (mask & from->xkb.ctrl_mask)
358 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_CTRL;
359 if (mask & from->xkb.alt_mask)
360 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_ALT;
361 if (mask & from->xkb.shift_mask)
362 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
363 if (mask & from->xkb.win_mask)
364 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_WIN;
365 if (mask & from->xkb.scroll_mask)
366 edev->xkb.modifiers |= ECORE_EVENT_LOCK_SCROLL;
367 if (mask & from->xkb.num_mask)
368 edev->xkb.modifiers |= ECORE_EVENT_LOCK_NUM;
369 if (mask & from->xkb.caps_mask)
370 edev->xkb.modifiers |= ECORE_EVENT_LOCK_CAPS;
371 if (mask & from->xkb.altgr_mask)
372 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
376 _device_modifiers_update(E_Input_Evdev *edev)
381 edev->xkb.modifiers = 0;
383 if (edev->caps & E_INPUT_SEAT_KEYBOARD)
384 _device_modifiers_update_device(edev, edev);
387 EINA_LIST_FOREACH(edev->seat->devices, l, ed)
389 if (!(ed->caps & E_INPUT_SEAT_KEYBOARD)) continue;
390 _device_modifiers_update_device(edev, ed);
397 _device_remapped_key_get(E_Input_Evdev *edev, int code)
401 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, code);
402 if (!edev->key_remap_enabled) return code;
403 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->key_remap_hash, code);
405 ret = eina_hash_find(edev->key_remap_hash, &code);
407 if (ret) code = (int)(intptr_t)ret;
413 e_input_evdev_get_e_device(const char *path, Ecore_Device_Class clas)
415 const GList *dev_list = NULL;
417 E_Device *dev = NULL;
418 const char *identifier;
420 if (!path) return NULL;
422 dev_list = e_device_list_get();
423 if (!dev_list) return NULL;
430 identifier = e_device_identifier_get(dev);
431 if (!identifier) continue;
432 if ((e_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
441 EINTERN Ecore_Device *
442 e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas)
444 const Eina_List *dev_list = NULL;
446 Ecore_Device *dev = NULL;
447 const char *identifier;
449 if (!path) return NULL;
451 dev_list = ecore_device_list();
452 if (!dev_list) return NULL;
453 EINA_LIST_FOREACH(dev_list, l, dev)
456 identifier = ecore_device_identifier_get(dev);
457 if (!identifier) continue;
458 if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
465 _e_input_event_mouse_move_cb_free(void *data EINA_UNUSED, void *event)
467 Ecore_Event_Mouse_Move *ev = event;
469 if (ev->dev) ecore_device_unref(ev->dev);
475 _e_input_event_mouse_wheel_cb_free(void *data EINA_UNUSED, void *event)
477 Ecore_Event_Mouse_Wheel *ev = event;
479 if (ev->dev) ecore_device_unref(ev->dev);
485 _e_input_event_mouse_button_cb_free(void *data EINA_UNUSED, void *event)
487 Ecore_Event_Mouse_Button *ev = event;
489 if (ev->dev) ecore_device_unref(ev->dev);
495 _e_input_event_key_cb_free(void *data EINA_UNUSED, void *event)
497 Ecore_Event_Key *ev = event;
499 if (e_input_thread_mode_get())
501 if (ev->dev) g_object_unref(ev->dev);
505 if (ev->dev) ecore_device_unref(ev->dev);
508 if (ev->data) E_FREE(ev->data);
514 _device_handle_key(struct libinput_device *device, struct libinput_event_keyboard *event)
517 E_Input_Backend *input;
519 uint32_t code, nsyms;
520 const xkb_keysym_t *syms;
521 enum libinput_key_state state;
523 xkb_keysym_t sym = XKB_KEY_NoSymbol;
524 char key[256] = {0, }, keyname[256] = {0, }, compose_buffer[256] = {0, };
526 char *tmp = NULL, *compose = NULL;
527 E_Keyrouter_Event_Data *key_data;
528 Ecore_Device *ecore_dev = NULL, *data;
529 E_Device *e_dev = NULL, *e_dev_data;
530 Eina_List *l = NULL, *l_next = NULL;
532 E_Comp_Config *comp_conf = NULL;
533 int *pressed_keycode = NULL, *idata = NULL;
534 Eina_Bool dup_found = EINA_FALSE;
535 const char* device_name = NULL;
536 Ecore_Device_Subclass device_subclas = ECORE_DEVICE_SUBCLASS_NONE;
538 if (!(edev = libinput_device_get_user_data(device)))
543 if (!(input = edev->seat->input))
548 if (!e_input_thread_mode_get())
550 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
551 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
553 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
555 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_KEYBOARD)
564 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
565 ecore_dev = edev->ecore_dev;
570 ERR("Failed to get source ecore device from event !\n");
574 device_name = ecore_device_name_get(ecore_dev);
575 device_subclas = ecore_device_subclass_get(ecore_dev);
579 if (edev->e_dev) e_dev = edev->e_dev;
580 else if (edev->e_dev_list && g_list_length(edev->e_dev_list) > 0)
582 glist = edev->e_dev_list;
585 e_dev_data = glist->data;
586 if (e_device_class_get(e_dev_data) == ECORE_DEVICE_CLASS_KEYBOARD)
592 glist = g_list_next(glist);
597 edev->e_dev = e_input_evdev_get_e_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
603 ERR("Failed to get source e device from event !\n");
607 device_name = e_device_name_get(e_dev);
608 device_subclas = e_device_subclass_get(e_dev);
611 timestamp = libinput_event_keyboard_get_time(event);
612 code = libinput_event_keyboard_get_key(event);
613 code = _device_remapped_key_get(edev, code + 8);
614 state = libinput_event_keyboard_get_key_state(event);
615 key_count = libinput_event_keyboard_get_seat_key_count(event);
617 if (state == LIBINPUT_KEY_STATE_PRESSED)
619 if ((edev->seat->dev->blocked & E_INPUT_SEAT_KEYBOARD) ||
620 (edev->seat->dev->server_blocked & E_INPUT_SEAT_KEYBOARD))
622 ELOGF("Key", "Press (keycode: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
623 code, device_name, edev->seat->dev->blocked_client,
624 edev->seat->dev->server_blocked);
628 /* FIXME: Currently to maintain press/release event pair during input block,
629 * used Eina_List and this is method used in devicemgr module.
630 * But we need to consider which way is better to maintain key press/release pair.
633 EINA_LIST_FOREACH(edev->xkb.pressed_keys, l, idata)
637 dup_found = EINA_TRUE;
643 pressed_keycode = E_NEW(int, 1);
644 EINA_SAFETY_ON_NULL_RETURN(pressed_keycode);
645 *pressed_keycode = code;
647 edev->xkb.pressed_keys = eina_list_append(edev->xkb.pressed_keys, pressed_keycode);
652 dup_found = EINA_FALSE;
653 EINA_LIST_FOREACH_SAFE(edev->xkb.pressed_keys, l, l_next, idata)
657 edev->xkb.pressed_keys = eina_list_remove_list(edev->xkb.pressed_keys, l);
659 dup_found = EINA_TRUE;
665 ELOGF("Key", "Release (keycode: %d, device: %s) is blocked by %p", NULL,
666 code, device_name, edev->seat->dev->blocked_client);
671 /* ignore key events that are not seat wide state changes */
672 if (((state == LIBINPUT_KEY_STATE_PRESSED) && (key_count != 1)) ||
673 ((state == LIBINPUT_KEY_STATE_RELEASED) && (key_count != 0)))
678 e_input_keyboard_grab_key_cb func = e_input_keyboard_grab_key_handler_get();
681 if (e_devicemgr_keyboard_grab_subtype_is_grabbed(device_subclas))
683 func(code, state, timestamp);
688 g_mutex_lock(&edev->xkb.state_mutex);
689 xkb_state_update_key(edev->xkb.state, code,
690 (state ? XKB_KEY_DOWN : XKB_KEY_UP));
692 /* get the keysym for this code */
693 nsyms = xkb_key_get_syms(edev->xkb.state, code, &syms);
694 g_mutex_unlock(&edev->xkb.state_mutex);
696 if (nsyms == 1) sym = syms[0];
698 /* If no keysym was found, name it "Keycode-NNN" */
699 if (sym == XKB_KEY_NoSymbol)
700 snprintf(key, sizeof(key), "Keycode-%u", code);
703 /* get the keyname for this sym */
704 xkb_keysym_get_name(sym, key, sizeof(key));
709 /* If no keyname was found, name it "Keycode-NNN" */
710 snprintf(keyname, sizeof(keyname), "Keycode-%u", code);
714 memcpy(keyname, key, sizeof(keyname));
717 /* if shift is active, we need to transform the key to lower */
718 g_mutex_lock(&edev->xkb.keymap_mutex);
719 g_mutex_lock(&edev->xkb.state_mutex);
720 if (xkb_state_mod_index_is_active(edev->xkb.state,
721 xkb_map_mod_get_index(edev->xkb.keymap,
723 XKB_STATE_MODS_EFFECTIVE))
725 if (keyname[0] != '\0')
726 keyname[0] = tolower(keyname[0]);
728 g_mutex_unlock(&edev->xkb.keymap_mutex);
729 g_mutex_unlock(&edev->xkb.state_mutex);
731 if (_device_keysym_translate(sym, edev->xkb.modifiers,
732 compose_buffer, sizeof(compose_buffer)))
734 compose = eina_str_convert("ISO8859-1", "UTF-8", compose_buffer);
737 ERR("E Input cannot convert input key string '%s' to UTF-8. "
738 "Is Eina built with iconv support?", compose_buffer);
744 if (!compose) compose = compose_buffer;
746 e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
747 ((compose[0] != '\0') ? strlen(compose) : 0) + 3);
753 key_data = E_NEW(E_Keyrouter_Event_Data, 1);
761 e->keyname = (char *)(e + 1);
762 e->key = e->keyname + strlen(keyname) + 1;
763 e->compose = strlen(compose) ? e->key + strlen(key) + 1 : NULL;
764 e->string = e->compose;
766 strncpy((char *)e->keyname, keyname, strlen(keyname));
767 strncpy((char *)e->key, key, strlen(key));
768 if (strlen(compose)) strncpy((char *)e->compose, compose, strlen(compose));
770 e->window = (Ecore_Window)input->dev->window;
771 e->event_window = (Ecore_Window)input->dev->window;
772 e->root_window = (Ecore_Window)input->dev->window;
773 e->timestamp = timestamp;
778 _device_modifiers_update(edev);
780 e->modifiers = edev->xkb.modifiers;
782 comp_conf = e_comp_config_get();
784 if (comp_conf && comp_conf->input_log_enable)
785 ELOGF("Key", "%s (keyname: %s, keycode: %d, timestamp: %u, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, e->timestamp, device_name);
787 if (e_input_thread_mode_get())
789 e->dev = (Eo *)g_object_ref(e_dev);
790 e_input_event_add(input->event_source, state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
794 e->dev = ecore_device_ref(ecore_dev);
795 ecore_event_add(state ? ECORE_EVENT_KEY_DOWN : ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
802 _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event)
804 E_Input_Backend *input;
805 Ecore_Event_Mouse_Move *ev;
806 Ecore_Device *ecore_dev = NULL, *data, *detent_data = NULL;
808 int x = 0, y = 0, w = 0, h = 0;
810 if (!(input = edev->seat->input)) return;
812 ecore_thread_main_loop_begin();
814 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
815 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
817 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
819 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
824 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
829 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
831 ecore_dev = detent_data;
836 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
837 ecore_dev = edev->ecore_dev;
842 ERR("Failed to get source ecore device from event !\n");
845 else if ((detent_data == ecore_dev) || e_devicemgr_detent_is_detent(ecore_device_name_get(ecore_dev)))
847 /* Do not process detent device's move events. */
851 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
853 _device_configured_size_get(edev, &x, &y, &w, &h);
855 if (edev->seat->ptr.ix < x)
856 edev->seat->ptr.dx = edev->seat->ptr.ix = x;
857 else if (edev->seat->ptr.ix >= (x + w))
858 edev->seat->ptr.dx = edev->seat->ptr.ix = (x + w - 1);
860 if (edev->seat->ptr.iy < y)
861 edev->seat->ptr.dy = edev->seat->ptr.iy = y;
862 else if (edev->seat->ptr.iy >= (y + h))
863 edev->seat->ptr.dy = edev->seat->ptr.iy = (y + h - 1);
865 edev->mouse.dx = edev->seat->ptr.dx;
866 edev->mouse.dy = edev->seat->ptr.dy;
868 ev->window = (Ecore_Window)input->dev->window;
869 ev->event_window = (Ecore_Window)input->dev->window;
870 ev->root_window = (Ecore_Window)input->dev->window;
871 if (event) ev->timestamp = libinput_event_pointer_get_time(event);
874 _device_modifiers_update(edev);
875 ev->modifiers = edev->xkb.modifiers;
877 ev->x = edev->seat->ptr.ix;
878 ev->y = edev->seat->ptr.iy;
882 ev->multi.device = edev->mt_slot;
883 ev->multi.radius = 1;
884 ev->multi.radius_x = 1;
885 ev->multi.radius_y = 1;
886 ev->multi.pressure = 1.0;
887 ev->multi.angle = 0.0;
890 ev->multi.root.x = ev->x;
891 ev->multi.root.y = ev->y;
893 ev->dev = ecore_device_ref(ecore_dev);
895 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
898 ecore_thread_main_loop_end();
902 _e_input_pointer_motion_post(E_Input_Evdev *edev)
904 _device_pointer_motion(edev, NULL);
908 _device_pointer_motion_send(E_Input_Evdev *edev, struct libinput_event_pointer *event, double dx[2], double dy[2])
911 e_input_relative_motion_cb func = e_input_relative_motion_handler_get();
914 time_us = libinput_event_pointer_get_time_usec(event);
915 func(dx, dy, time_us);
919 _device_pointer_motion(edev, event);
924 _device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event)
927 double delta_x[2]; /* delta_x[0] for accelerated, delta_x[1] for unaccelerated */
928 double delta_y[2]; /* delta_y[0] for accelerated, delta_y[1] for unaccelerated */
931 if (!(edev = libinput_device_get_user_data(device)))
936 delta_x[0] = libinput_event_pointer_get_dx(event);
937 delta_x[1] = libinput_event_pointer_get_dx_unaccelerated(event);
938 delta_y[0] = libinput_event_pointer_get_dy(event);
939 delta_y[1] = libinput_event_pointer_get_dy_unaccelerated(event);
941 if (edev->disable_acceleration)
952 if (edev->seat->ptr.swap)
958 if (edev->seat->ptr.invert_x)
960 if (edev->seat->ptr.invert_y)
963 edev->seat->ptr.dx += dx;
964 edev->seat->ptr.dy += dy;
966 edev->mouse.dx = edev->seat->ptr.dx;
967 edev->mouse.dy = edev->seat->ptr.dy;
969 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
970 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
975 edev->seat->ptr.ix = edev->seat->ptr.dx;
976 edev->seat->ptr.iy = edev->seat->ptr.dy;
978 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
979 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
984 _device_pointer_motion_send(edev, event, &delta_x[0], &delta_y[0]);
988 _device_handle_pointer_motion_absolute(struct libinput_device *device, struct libinput_event_pointer *event)
993 if (!(edev = libinput_device_get_user_data(device)))
998 e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
1000 edev->mouse.dx = edev->seat->ptr.dx =
1001 libinput_event_pointer_get_absolute_x_transformed(event, w);
1002 edev->mouse.dy = edev->seat->ptr.dy =
1003 libinput_event_pointer_get_absolute_y_transformed(event, h);
1005 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
1006 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
1011 edev->seat->ptr.ix = edev->seat->ptr.dx;
1012 edev->seat->ptr.iy = edev->seat->ptr.dy;
1014 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
1015 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
1020 _device_pointer_motion(edev, event);
1024 _device_handle_button(struct libinput_device *device, struct libinput_event_pointer *event)
1026 E_Input_Evdev *edev;
1027 E_Input_Backend *input;
1028 Ecore_Event_Mouse_Button *ev;
1029 enum libinput_button_state state;
1030 uint32_t button, timestamp;
1031 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
1033 E_Comp_Config *comp_conf = NULL;
1035 if (!(edev = libinput_device_get_user_data(device)))
1039 if (!(input = edev->seat->input))
1044 ecore_thread_main_loop_begin();
1046 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1047 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1049 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1051 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
1056 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
1061 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
1063 ecore_dev = detent_data;
1068 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
1069 ecore_dev = edev->ecore_dev;
1074 ERR("Failed to get source ecore device from event !\n");
1078 state = libinput_event_pointer_get_button_state(event);
1079 button = libinput_event_pointer_get_button(event);
1080 timestamp = libinput_event_pointer_get_time(event);
1082 button = ((button & 0x00F) + 1);
1083 if (button == 3) button = 2;
1084 else if (button == 2) button = 3;
1088 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
1089 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
1091 ELOGF("Mouse", "Button Press (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
1092 button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
1093 edev->seat->dev->server_blocked);
1098 edev->mouse.pressed_button |= (1 << button);
1103 if (!(edev->mouse.pressed_button & (1 << button)))
1105 ELOGF("Mouse", "Button Release (btn: %d, device: %s) is blocked by %p, server: 0x%x", NULL,
1106 button, ecore_device_name_get(ecore_dev), edev->seat->dev->blocked_client,
1107 edev->seat->dev->server_blocked);
1110 edev->mouse.pressed_button &= ~(1 << button);
1113 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button))))
1118 ev->window = (Ecore_Window)input->dev->window;
1119 ev->event_window = (Ecore_Window)input->dev->window;
1120 ev->root_window = (Ecore_Window)input->dev->window;
1121 ev->timestamp = timestamp;
1122 ev->same_screen = 1;
1124 _device_modifiers_update(edev);
1125 ev->modifiers = edev->xkb.modifiers;
1127 ev->x = edev->seat->ptr.ix;
1128 ev->y = edev->seat->ptr.iy;
1132 ev->multi.device = edev->mt_slot;
1133 ev->multi.radius = 1;
1134 ev->multi.radius_x = 1;
1135 ev->multi.radius_y = 1;
1136 ev->multi.pressure = 1.0;
1137 ev->multi.angle = 0.0;
1138 ev->multi.x = ev->x;
1139 ev->multi.y = ev->y;
1140 ev->multi.root.x = ev->x;
1141 ev->multi.root.y = ev->y;
1142 ev->dev = ecore_device_ref(ecore_dev);
1146 unsigned int current;
1148 current = timestamp;
1149 edev->mouse.did_double = EINA_FALSE;
1150 edev->mouse.did_triple = EINA_FALSE;
1152 if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
1153 (button == edev->mouse.prev_button))
1155 edev->mouse.did_double = EINA_TRUE;
1156 if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
1157 (button == edev->mouse.last_button))
1159 edev->mouse.did_triple = EINA_TRUE;
1160 edev->mouse.prev = 0;
1161 edev->mouse.last = 0;
1166 edev->mouse.last = edev->mouse.prev;
1167 edev->mouse.prev = current;
1168 edev->mouse.last_button = edev->mouse.prev_button;
1169 edev->mouse.prev_button = button;
1172 ev->buttons = button;
1174 if (edev->mouse.did_double)
1175 ev->double_click = 1;
1176 if (edev->mouse.did_triple)
1177 ev->triple_click = 1;
1179 comp_conf = e_comp_config_get();
1180 if (comp_conf && comp_conf->input_log_enable)
1181 ELOGF("Mouse", "Button %s (btn: %d, device: %s)", NULL, state?"Press":"Release", button, ecore_device_name_get(ev->dev));
1184 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, _e_input_event_mouse_button_cb_free, NULL);
1186 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, _e_input_event_mouse_button_cb_free, NULL);
1189 ecore_thread_main_loop_end();
1192 #if !LIBINPUT_HAVE_SCROLL_VALUE_V120
1194 _axis_value_get(struct libinput_event_pointer *pointer_event, enum libinput_pointer_axis axis)
1196 enum libinput_pointer_axis_source source;
1197 double value = 0.0, value_discrete = 0.0;
1199 E_Comp_Config *comp_conf = NULL;
1201 comp_conf = e_comp_config_get();
1202 source = libinput_event_pointer_get_axis_source(pointer_event);
1205 case LIBINPUT_POINTER_AXIS_SOURCE_WHEEL:
1206 value_discrete = libinput_event_pointer_get_axis_value_discrete(pointer_event, axis);
1207 value = libinput_event_pointer_get_axis_value(pointer_event, axis);
1208 if (comp_conf && comp_conf->input_log_enable)
1210 ELOGF("Axis", "SOURCE_WHEEL discrete: %lf (cf. value: %lf)", NULL, value_discrete, value);
1212 ret = (int)value_discrete;
1214 case LIBINPUT_POINTER_AXIS_SOURCE_FINGER:
1215 case LIBINPUT_POINTER_AXIS_SOURCE_CONTINUOUS:
1216 value = libinput_event_pointer_get_axis_value(pointer_event, axis);
1217 if (comp_conf && comp_conf->input_log_enable)
1219 ELOGF("Axis", "SOURCE_FINGER/CONTINUOUS value: %lf", NULL, value);
1221 if (value >= E_INPUT_FINGER_SCROLL_THRESHOLD)
1223 else if (value <= E_INPUT_FINGER_SCROLL_THRESHOLD * (-1))
1236 _device_handle_axis(struct libinput_device *device, struct libinput_event_pointer *event)
1238 E_Input_Evdev *edev;
1239 E_Input_Backend *input;
1240 Ecore_Event_Mouse_Wheel *ev;
1242 enum libinput_pointer_axis axis;
1243 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
1245 E_Comp_Config *comp_conf = NULL;
1246 int direction = 0, z = 0;
1248 if (!(edev = libinput_device_get_user_data(device)))
1252 if (!(input = edev->seat->input))
1257 ecore_thread_main_loop_begin();
1259 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1260 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1262 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1264 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
1269 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
1274 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
1276 ecore_dev = detent_data;
1281 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
1282 ecore_dev = edev->ecore_dev;
1287 ERR("Failed to get source ecore device from event !\n");
1291 axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
1292 if (libinput_event_pointer_has_axis(event, axis))
1293 z = _axis_value_get(event, axis);
1295 axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
1296 if (libinput_event_pointer_has_axis(event, axis))
1299 z = _axis_value_get(event, axis);
1304 ELOGF("Mouse", "Axis event is ignored since it has zero value", NULL);
1308 comp_conf = e_comp_config_get();
1309 if (comp_conf && comp_conf->e_wheel_click_angle)
1311 z = (int)(z * comp_conf->e_wheel_click_angle);
1314 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
1315 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
1318 ELOGF("Mouse", "Detent (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1319 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1321 ELOGF("Mouse", "Wheel (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1322 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1326 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
1331 timestamp = libinput_event_pointer_get_time(event);
1333 ev->window = (Ecore_Window)input->dev->window;
1334 ev->event_window = (Ecore_Window)input->dev->window;
1335 ev->root_window = (Ecore_Window)input->dev->window;
1336 ev->timestamp = timestamp;
1337 ev->same_screen = 1;
1339 _device_modifiers_update(edev);
1340 ev->modifiers = edev->xkb.modifiers;
1342 ev->x = edev->seat->ptr.ix;
1343 ev->y = edev->seat->ptr.iy;
1347 ev->direction = direction;
1349 if (comp_conf && comp_conf->input_log_enable)
1352 ELOGF("Mouse", "Detent (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1354 ELOGF("Mouse", "Wheel (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1358 ev->dev = ecore_device_ref(ecore_dev);
1359 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
1362 ecore_thread_main_loop_end();
1366 #if LIBINPUT_HAVE_SCROLL_VALUE_V120
1368 _scroll_value_get(struct libinput_event_pointer *pointer_event, enum libinput_pointer_axis axis, E_Input_Axis_Source source)
1371 double value_v120 = 0.0;
1373 E_Comp_Config *comp_conf = NULL;
1375 comp_conf = e_comp_config_get();
1378 case E_INPUT_AXIS_SOURCE_WHEEL:
1379 value_v120 = libinput_event_pointer_get_scroll_value_v120(pointer_event, axis);
1380 value = libinput_event_pointer_get_scroll_value(pointer_event, axis);
1381 if (comp_conf && comp_conf->input_log_enable)
1383 ELOGF("Scroll", "SOURCE_WHEELL value_v120: %lf (cf. value: %lf)", NULL, value_v120, value);
1385 if (((int)value_v120 % E_INPUT_POINTER_AXIS_DISCRETE_STEP) != 0)
1387 ERR("Wheel movements should be multiples (or fractions) of 120!\n");
1392 ret = value_v120 / E_INPUT_POINTER_AXIS_DISCRETE_STEP;
1395 case E_INPUT_AXIS_SOURCE_FINGER:
1396 case E_INPUT_AXIS_SOURCE_CONTINUOUS:
1397 value = libinput_event_pointer_get_scroll_value(pointer_event, axis);
1398 if (comp_conf && comp_conf->input_log_enable)
1400 ELOGF("Scroll", "SOURCE_FINGER/CONTINUOUS value: %lf", NULL, value);
1402 if (value >= E_INPUT_FINGER_SCROLL_THRESHOLD)
1404 else if (value <= E_INPUT_FINGER_SCROLL_THRESHOLD * (-1))
1417 _device_handle_axis_v120(struct libinput_device *device, struct libinput_event_pointer *event, E_Input_Axis_Source source)
1419 E_Input_Evdev *edev;
1420 E_Input_Backend *input;
1421 Ecore_Event_Mouse_Wheel *ev;
1423 enum libinput_pointer_axis axis;
1424 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
1426 E_Comp_Config *comp_conf = NULL;
1427 int direction = 0, z = 0;
1429 if (!(edev = libinput_device_get_user_data(device)))
1433 if (!(input = edev->seat->input))
1438 ecore_thread_main_loop_begin();
1440 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1441 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1443 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1445 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
1450 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
1455 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
1457 ecore_dev = detent_data;
1462 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
1463 ecore_dev = edev->ecore_dev;
1468 ERR("Failed to get source ecore device from event !\n");
1472 axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
1473 if (libinput_event_pointer_has_axis(event, axis))
1474 z = _scroll_value_get(event, axis, source);
1476 axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
1477 if (libinput_event_pointer_has_axis(event, axis))
1480 z = _scroll_value_get(event, axis, source);
1485 ELOGF("Mouse", "Scroll event is ignored since it has zero value", NULL);
1489 comp_conf = e_comp_config_get();
1490 if (comp_conf && comp_conf->e_wheel_click_angle)
1492 z = (int)(z * comp_conf->e_wheel_click_angle);
1495 if ((edev->seat->dev->blocked & E_INPUT_SEAT_POINTER) ||
1496 (edev->seat->dev->server_blocked & E_INPUT_SEAT_POINTER))
1499 ELOGF("Mouse", "Detent (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1500 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1502 ELOGF("Mouse", "Wheel (direction: %d, value: %d) is blocked by %p, server: 0x%x", NULL,
1503 direction, z, edev->seat->dev->blocked_client, edev->seat->dev->server_blocked);
1507 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
1512 timestamp = libinput_event_pointer_get_time(event);
1514 ev->window = (Ecore_Window)input->dev->window;
1515 ev->event_window = (Ecore_Window)input->dev->window;
1516 ev->root_window = (Ecore_Window)input->dev->window;
1517 ev->timestamp = timestamp;
1518 ev->same_screen = 1;
1520 _device_modifiers_update(edev);
1521 ev->modifiers = edev->xkb.modifiers;
1523 ev->x = edev->seat->ptr.ix;
1524 ev->y = edev->seat->ptr.iy;
1528 ev->direction = direction;
1530 if (comp_conf && comp_conf->input_log_enable)
1533 ELOGF("Mouse", "Detent (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1535 ELOGF("Mouse", "Wheel (direction: %d, value: %d)", NULL, ev->direction, ev->z);
1538 ev->dev = ecore_device_ref(ecore_dev);
1539 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
1542 ecore_thread_main_loop_end();
1547 _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch *event, int state)
1549 E_Input_Backend *input;
1550 Ecore_Event_Mouse_Button *ev;
1551 uint32_t timestamp, button = 0;
1552 Ecore_Device *ecore_dev = NULL, *data;
1556 if (!(input = edev->seat->input)) return;
1558 ecore_thread_main_loop_begin();
1560 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1561 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1563 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1565 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1574 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1575 ecore_dev = edev->ecore_dev;
1580 ERR("Failed to get source ecore device from event !\n");
1584 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) goto end;
1586 timestamp = libinput_event_touch_get_time(event);
1588 ev->window = (Ecore_Window)input->dev->window;
1589 ev->event_window = (Ecore_Window)input->dev->window;
1590 ev->root_window = (Ecore_Window)input->dev->window;
1591 ev->timestamp = timestamp;
1592 ev->same_screen = 1;
1594 _device_modifiers_update(edev);
1595 ev->modifiers = edev->xkb.modifiers;
1597 ev->x = edev->seat->ptr.ix;
1598 ev->y = edev->seat->ptr.iy;
1602 ev->multi.device = edev->mt_slot;
1603 ev->multi.radius = 1;
1604 ev->multi.radius_x = 1;
1605 ev->multi.radius_y = 1;
1606 ev->multi.pressure = 1.0;
1607 ev->multi.angle = 0.0;
1608 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
1609 if (libinput_event_get_type(libinput_event_touch_get_base_event(event))
1610 == LIBINPUT_EVENT_TOUCH_DOWN)
1612 if (libinput_event_touch_has_minor(event))
1613 ev->multi.radius_x = libinput_event_touch_get_minor(event);
1614 if (libinput_event_touch_has_major(event))
1615 ev->multi.radius_y = libinput_event_touch_get_major(event);
1616 if (libinput_event_touch_has_pressure(event))
1617 ev->multi.pressure = libinput_event_touch_get_pressure(event);
1618 if (libinput_event_touch_has_orientation(event))
1619 ev->multi.angle = libinput_event_touch_get_orientation(event);
1622 ev->multi.x = ev->x;
1623 ev->multi.y = ev->y;
1624 ev->multi.root.x = ev->x;
1625 ev->multi.root.y = ev->y;
1626 ev->dev = ecore_device_ref(ecore_dev);
1628 if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN)
1630 unsigned int current;
1632 current = timestamp;
1633 edev->mouse.did_double = EINA_FALSE;
1634 edev->mouse.did_triple = EINA_FALSE;
1636 if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
1637 (button == edev->mouse.prev_button))
1639 edev->mouse.did_double = EINA_TRUE;
1640 if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
1641 (button == edev->mouse.last_button))
1643 edev->mouse.did_triple = EINA_TRUE;
1644 edev->mouse.prev = 0;
1645 edev->mouse.last = 0;
1650 edev->mouse.last = edev->mouse.prev;
1651 edev->mouse.prev = current;
1652 edev->mouse.last_button = edev->mouse.prev_button;
1653 edev->mouse.prev_button = button;
1654 edev->touch.pressed |= (1 << ev->multi.device);
1658 edev->touch.pressed &= ~(1 << ev->multi.device);
1661 ev->buttons = ((button & 0x00F) + 1);
1663 if (edev->mouse.did_double)
1664 ev->double_click = 1;
1665 if (edev->mouse.did_triple)
1666 ev->triple_click = 1;
1668 ecore_event_add(state, ev, _e_input_event_mouse_button_cb_free, NULL);
1671 ecore_thread_main_loop_end();
1675 _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touch *event)
1677 E_Input_Backend *input;
1678 Ecore_Event_Mouse_Move *ev;
1679 Ecore_Device *ecore_dev = NULL, *data;
1683 if (!(input = edev->seat->input)) return;
1685 ecore_thread_main_loop_begin();
1687 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1688 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1690 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1692 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1701 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1702 ecore_dev = edev->ecore_dev;
1707 ERR("Failed to get source ecore device from event !\n");
1711 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) goto end;
1713 ev->window = (Ecore_Window)input->dev->window;
1714 ev->event_window = (Ecore_Window)input->dev->window;
1715 ev->root_window = (Ecore_Window)input->dev->window;
1716 ev->timestamp = libinput_event_touch_get_time(event);
1717 ev->same_screen = 1;
1719 _device_modifiers_update(edev);
1720 ev->modifiers = edev->xkb.modifiers;
1722 ev->x = edev->seat->ptr.ix;
1723 ev->y = edev->seat->ptr.iy;
1727 ev->multi.device = edev->mt_slot;
1728 ev->multi.radius = 1;
1729 ev->multi.radius_x = 1;
1730 ev->multi.radius_y = 1;
1731 ev->multi.pressure = 1.0;
1732 ev->multi.angle = 0.0;
1733 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
1734 if (libinput_event_touch_has_minor(event))
1735 ev->multi.radius_x = libinput_event_touch_get_minor(event);
1736 if (libinput_event_touch_has_major(event))
1737 ev->multi.radius_y = libinput_event_touch_get_major(event);
1738 if (libinput_event_touch_has_pressure(event))
1739 ev->multi.pressure = libinput_event_touch_get_pressure(event);
1740 if (libinput_event_touch_has_orientation(event))
1741 ev->multi.angle = libinput_event_touch_get_orientation(event);
1743 ev->multi.x = ev->x;
1744 ev->multi.y = ev->y;
1745 ev->multi.root.x = ev->x;
1746 ev->multi.root.y = ev->y;
1747 ev->dev = ecore_device_ref(ecore_dev);
1749 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
1752 ecore_thread_main_loop_end();
1756 _device_handle_touch_cancel_send(E_Input_Evdev *edev, struct libinput_event_touch *event)
1758 E_Input_Backend *input;
1759 Ecore_Event_Mouse_Button *ev;
1760 uint32_t timestamp, button = 0;
1761 Ecore_Device *ecore_dev = NULL, *data;
1765 if (!(input = edev->seat->input)) return;
1767 ecore_thread_main_loop_begin();
1769 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1770 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1772 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1774 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1783 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1784 ecore_dev = edev->ecore_dev;
1789 ERR("Failed to get source ecore device from event !\n");
1793 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) goto end;
1795 timestamp = libinput_event_touch_get_time(event);
1797 ev->window = (Ecore_Window)input->dev->window;
1798 ev->event_window = (Ecore_Window)input->dev->window;
1799 ev->root_window = (Ecore_Window)input->dev->window;
1800 ev->timestamp = timestamp;
1801 ev->same_screen = 1;
1803 ev->x = edev->seat->ptr.ix;
1804 ev->y = edev->seat->ptr.iy;
1808 ev->multi.device = edev->mt_slot;
1809 ev->multi.radius = 1;
1810 ev->multi.radius_x = 1;
1811 ev->multi.radius_y = 1;
1812 ev->multi.pressure = 1.0;
1813 ev->multi.angle = 0.0;
1814 ev->multi.x = ev->x;
1815 ev->multi.y = ev->y;
1816 ev->multi.root.x = ev->x;
1817 ev->multi.root.y = ev->y;
1819 edev->touch.pressed &= ~(1 << ev->multi.device);
1821 ev->buttons = ((button & 0x00F) + 1);
1822 ev->dev = ecore_device_ref(ecore_dev);
1824 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_CANCEL, ev, _e_input_event_mouse_button_cb_free, NULL);
1827 ecore_thread_main_loop_end();
1831 _device_configured_size_get(E_Input_Evdev *edev, int *x, int *y, int *w, int *h)
1833 E_Output *output = NULL;
1835 EINA_SAFETY_ON_NULL_RETURN(edev);
1837 if (!edev->output_configured)
1839 if (edev->output_name)
1841 output = e_output_find(edev->output_name);
1844 edev->mouse.minx = output->config.geom.x;
1845 edev->mouse.miny = output->config.geom.y;
1846 edev->mouse.maxw = output->config.geom.w;
1847 edev->mouse.maxh = output->config.geom.h;
1848 if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
1850 edev->seat->ptr.dx = (double)(edev->mouse.maxw / 2);
1851 edev->seat->ptr.dy = (double)(edev->mouse.maxh / 2);
1852 edev->seat->ptr.ix = (int)edev->seat->ptr.dx;
1853 edev->seat->ptr.iy = (int)edev->seat->ptr.dy;
1854 edev->mouse.dx = edev->seat->ptr.dx;
1855 edev->mouse.dy = edev->seat->ptr.dy;
1860 edev->output_configured = EINA_TRUE;
1861 ELOGF("E_INPUT_EVDEV", "Device is configured by output x:%d,y:%d (w:%d, h:%d)",
1862 NULL, edev->mouse.minx, edev->mouse.miny, edev->mouse.maxw, edev->mouse.maxh);
1864 if (x) *x = edev->mouse.minx;
1865 if (y) *y = edev->mouse.miny;
1866 if (w) *w = edev->mouse.maxw;
1867 if (h) *h = edev->mouse.maxh;
1871 _device_handle_touch_down(struct libinput_device *device, struct libinput_event_touch *event)
1873 E_Input_Evdev *edev;
1874 int x = 0, y = 0, w = 0, h = 0;
1875 E_Comp_Config *comp_conf = NULL;
1877 if (!(edev = libinput_device_get_user_data(device)))
1882 _device_configured_size_get(edev, &x, &y, &w, &h);
1884 edev->mouse.dx = edev->seat->ptr.ix = edev->seat->ptr.dx =
1885 x + libinput_event_touch_get_x_transformed(event, w);
1886 edev->mouse.dy = edev->seat->ptr.iy = edev->seat->ptr.dy =
1887 y + libinput_event_touch_get_y_transformed(event, h);
1889 edev->mt_slot = libinput_event_touch_get_slot(event);
1890 if (edev->mt_slot < 0)
1892 /* FIXME: The single touch device return slot id -1
1893 * But currently we have no API to distinguish multi touch or single touch
1894 * After libinput 1.11 version, libinput provides get_touch_count API,
1895 * so we can distinguish multi touch device or single touch device.
1897 if (edev->mt_slot == -1)
1901 WRN("%d slot touch down events are not supported\n", edev->mt_slot);
1906 if (edev->mt_slot < e_input_touch_max_count_get())
1908 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1909 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1912 comp_conf = e_comp_config_get();
1913 if (comp_conf && comp_conf->input_log_enable)
1914 ELOGF("Touch", "Down (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1916 edev->touch.raw_pressed |= (1 << edev->mt_slot);
1918 if (edev->touch.blocked)
1920 ELOGF("Touch", "Down (id: %d, x: %d, y: %d) is blocked by %p, server: 0x%x", NULL,
1921 edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client,
1922 edev->seat->dev->server_blocked);
1926 _device_handle_touch_motion_send(edev, event);
1927 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN);
1931 _device_handle_touch_motion(struct libinput_device *device, struct libinput_event_touch *event)
1933 E_Input_Evdev *edev;
1934 int x = 0, y = 0, w = 0, h = 0;
1936 if (!(edev = libinput_device_get_user_data(device)))
1941 _device_configured_size_get(edev, &x, &y, &w, &h);
1943 edev->mouse.dx = edev->seat->ptr.dx =
1944 x + libinput_event_touch_get_x_transformed(event, w);
1945 edev->mouse.dy = edev->seat->ptr.dy =
1946 y + libinput_event_touch_get_y_transformed(event, h);
1948 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
1949 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
1954 edev->seat->ptr.ix = edev->seat->ptr.dx;
1955 edev->seat->ptr.iy = edev->seat->ptr.dy;
1957 edev->mt_slot = libinput_event_touch_get_slot(event);
1958 if (edev->mt_slot < 0)
1960 /* FIXME: The single touch device return slot id -1
1961 * But currently we have no API to distinguish multi touch or single touch
1962 * After libinput 1.11 version, libinput provides get_touch_count API,
1963 * so we can distinguish multi touch device or single touch device.
1965 if (edev->mt_slot == -1)
1969 WRN("%d slot touch motion events are not supported\n", edev->mt_slot);
1974 if (edev->mt_slot < e_input_touch_max_count_get())
1976 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1977 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1980 if (!(edev->touch.pressed & (1 << edev->mt_slot)))
1982 if (edev->touch.blocked)
1988 _device_handle_touch_motion_send(edev, event);
1992 _device_handle_touch_up(struct libinput_device *device, struct libinput_event_touch *event)
1994 E_Input_Evdev *edev;
1995 E_Comp_Config *comp_conf = NULL;
1997 if (!(edev = libinput_device_get_user_data(device)))
2002 edev->mt_slot = libinput_event_touch_get_slot(event);
2003 if (edev->mt_slot < 0)
2005 /* FIXME: The single touch device return slot id -1
2006 * But currently we have no API to distinguish multi touch or single touch
2007 * After libinput 1.11 version, libinput provides get_touch_count API,
2008 * so we can distinguish multi touch device or single touch device.
2010 if (edev->mt_slot == -1)
2014 WRN("%d slot touch up events are not supported\n", edev->mt_slot);
2019 if (edev->mt_slot < e_input_touch_max_count_get())
2021 edev->mouse.dx = edev->seat->ptr.dx = edev->seat->ptr.ix =
2022 edev->touch.coords[edev->mt_slot].x;
2023 edev->mouse.dy = edev->seat->ptr.dy = edev->seat->ptr.iy =
2024 edev->touch.coords[edev->mt_slot].y;
2027 comp_conf = e_comp_config_get();
2028 if (comp_conf && comp_conf->input_log_enable)
2029 ELOGF("Touch", "Up (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
2031 edev->touch.raw_pressed &= ~(1 << edev->mt_slot);
2033 if (edev->touch.blocked)
2035 if (!(edev->touch.pressed & (1 << edev->mt_slot)))
2037 ELOGF("Touch", "Up (id: %d, x: %d, y: %d) is blocked by %p, server(0x%x)", NULL,
2038 edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy, edev->seat->dev->blocked_client,
2039 edev->seat->dev->server_blocked);
2040 if (edev->touch.raw_pressed == 0x0)
2042 edev->touch.blocked = EINA_FALSE;
2048 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_UP);
2052 _device_handle_touch_cancel(struct libinput_device *device, struct libinput_event_touch *event)
2054 E_Input_Evdev *edev;
2055 E_Comp_Config *comp_conf = NULL;
2057 if (!(edev = libinput_device_get_user_data(device)))
2062 edev->mt_slot = libinput_event_touch_get_slot(event);
2063 if (edev->mt_slot < 0)
2065 /* FIXME: The single touch device return slot id -1
2066 * But currently we have no API to distinguish multi touch or single touch
2067 * After libinput 1.11 version, libinput provides get_touch_count API,
2068 * so we can distinguish multi touch device or single touch device.
2070 if (edev->mt_slot == -1)
2074 WRN("%d slot touch up events are not supported\n", edev->mt_slot);
2079 comp_conf = e_comp_config_get();
2080 if (comp_conf && comp_conf->input_log_enable)
2081 ELOGF("Touch", "cancel (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
2083 _device_handle_touch_cancel_send(edev, event);
2088 _device_handle_touch_frame(struct libinput_device *device EINA_UNUSED, struct libinput_event_touch *event EINA_UNUSED)
2090 /* DBG("Unhandled Touch Frame Event"); */
2094 _e_input_aux_data_event_free(void *user_data EINA_UNUSED, void *ev)
2096 Ecore_Event_Axis_Update *e = (Ecore_Event_Axis_Update *)ev;
2098 if (e->axis) free(e->axis);
2099 if (e->dev) ecore_device_unref(e->dev);
2105 _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_event_touch_aux_data *event)
2107 E_Input_Evdev *edev;
2108 E_Input_Backend *input;
2109 Ecore_Event_Axis_Update *ev;
2111 Ecore_Device *ecore_dev = NULL, *data;
2113 E_Comp_Config *comp_conf;
2115 ecore_thread_main_loop_begin();
2117 if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
2118 libinput_event_touch_aux_data_get_value(event) > 0)
2121 if (!(edev = libinput_device_get_user_data(device))) goto end;
2122 if (!(input = edev->seat->input)) goto end;
2124 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
2125 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
2127 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
2129 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
2138 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
2139 ecore_dev = edev->ecore_dev;
2144 ERR("Failed to get source ecore device from event !\n");
2148 if (!(ev = calloc(1, sizeof(Ecore_Event_Axis_Update)))) goto end;
2150 ev->window = (Ecore_Window)input->dev->window;
2151 ev->event_window = (Ecore_Window)input->dev->window;
2152 ev->root_window = (Ecore_Window)input->dev->window;
2153 ev->timestamp = libinput_event_touch_aux_data_get_time(event);
2155 axis = (Ecore_Axis *)calloc(1, sizeof(Ecore_Axis));
2158 axis->label = ECORE_AXIS_LABEL_TOUCH_PALM;
2159 axis->value = libinput_event_touch_aux_data_get_value(event);
2164 comp_conf = e_comp_config_get();
2165 if (comp_conf && comp_conf->input_log_enable)
2166 ELOGF("Touch", "Axis (label: %d, value: %lf)", NULL, axis?axis->label:-1, axis?axis->value:0.0);
2168 ev->dev = ecore_device_ref(ecore_dev);
2170 ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
2173 ecore_thread_main_loop_end();
2177 _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
2179 E_Input_Evdev *edev;
2180 E_Input_Backend *b_input;
2181 const char *output_name;
2183 EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
2185 /* try to allocate space for new evdev */
2186 if (!(edev = calloc(1, sizeof(E_Input_Evdev)))) return NULL;
2189 edev->device = device;
2190 edev->path = eina_stringshare_printf("%s/%s", e_input_base_dir_get(), libinput_device_get_sysname(device));
2192 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
2194 edev->caps |= E_INPUT_SEAT_KEYBOARD;
2195 _device_keyboard_setup(edev);
2198 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
2200 edev->caps |= E_INPUT_SEAT_POINTER;
2202 /* TODO: make this configurable */
2203 edev->mouse.threshold = 250;
2205 b_input = seat->input;
2206 if (b_input->left_handed == EINA_TRUE)
2208 if (libinput_device_config_left_handed_set(device, 1) !=
2209 LIBINPUT_CONFIG_STATUS_SUCCESS)
2211 WRN("Failed to set left hand mode about device: %s\n",
2212 libinput_device_get_name(device));
2217 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
2220 edev->caps |= E_INPUT_SEAT_TOUCH;
2221 palm_code = libinput_device_touch_aux_data_get_code(LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM);
2222 if (libinput_device_touch_has_aux_data(device, palm_code))
2224 libinput_device_touch_set_aux_data(device, palm_code);
2227 _device_touch_count_update(edev);
2229 edev->touch.coords = calloc(1, sizeof(E_Input_Coord)*e_input_touch_max_count_get());
2231 if (!edev->touch.coords)
2232 ERR("Failed to allocate memory for touch coords !\n");
2235 output_name = libinput_device_get_output_name(device);
2238 eina_stringshare_replace(&edev->output_name, output_name);
2239 ELOGF("E_INPUT_EVDEV", "Device has output_name:%s", NULL, output_name);
2242 libinput_device_set_user_data(device, edev);
2243 libinput_device_ref(device);
2245 /* configure device */
2246 _device_configure(edev);
2252 _e_input_evdev_device_destroy(E_Input_Evdev *edev)
2256 EINA_SAFETY_ON_NULL_RETURN(edev);
2258 ecore_thread_main_loop_begin();
2260 if (edev->caps & E_INPUT_SEAT_KEYBOARD)
2262 g_mutex_lock(&edev->xkb.state_mutex);
2263 if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
2264 g_mutex_unlock(&edev->xkb.state_mutex);
2266 g_mutex_lock(&edev->xkb.keymap_mutex);
2267 if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
2268 g_mutex_unlock(&edev->xkb.keymap_mutex);
2271 if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
2272 if (edev->ecore_dev_list)
2273 EINA_LIST_FREE(edev->ecore_dev_list, dev)
2275 ecore_device_del(dev);
2278 if (edev->e_dev) g_object_unref(edev->e_dev);
2279 if (edev->e_dev_list)
2281 GList *glist = edev->e_dev_list;
2285 e_dev = glist->data;
2286 g_object_unref(e_dev);
2288 glist = g_list_next(glist);
2291 if (edev->path) eina_stringshare_del(edev->path);
2292 if (edev->device) libinput_device_unref(edev->device);
2293 if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
2294 if (edev->touch.coords)
2296 free(edev->touch.coords);
2297 edev->touch.coords = NULL;
2299 eina_stringshare_del(edev->output_name);
2301 ecore_thread_main_loop_end();
2307 _e_input_evdev_event_process(struct libinput_event *event)
2309 struct libinput_device *device;
2310 Eina_Bool ret = EINA_TRUE;
2312 device = libinput_event_get_device(event);
2313 switch (libinput_event_get_type(event))
2315 case LIBINPUT_EVENT_KEYBOARD_KEY:
2316 _device_handle_key(device, libinput_event_get_keyboard_event(event));
2318 case LIBINPUT_EVENT_POINTER_MOTION:
2319 _device_handle_pointer_motion(device,
2320 libinput_event_get_pointer_event(event));
2322 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
2323 _device_handle_pointer_motion_absolute(device,
2324 libinput_event_get_pointer_event(event));
2326 case LIBINPUT_EVENT_POINTER_BUTTON:
2327 _device_handle_button(device, libinput_event_get_pointer_event(event));
2329 case LIBINPUT_EVENT_POINTER_AXIS:
2330 #if !LIBINPUT_HAVE_SCROLL_VALUE_V120
2331 _device_handle_axis(device, libinput_event_get_pointer_event(event));
2334 #if LIBINPUT_HAVE_SCROLL_VALUE_V120
2335 case LIBINPUT_EVENT_POINTER_SCROLL_WHEEL:
2336 _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_WHEEL);
2338 case LIBINPUT_EVENT_POINTER_SCROLL_FINGER:
2339 _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_FINGER);
2341 case LIBINPUT_EVENT_POINTER_SCROLL_CONTINUOUS:
2342 _device_handle_axis_v120(device, libinput_event_get_pointer_event(event), E_INPUT_AXIS_SOURCE_CONTINUOUS);
2345 case LIBINPUT_EVENT_TOUCH_DOWN:
2346 _device_handle_touch_down(device, libinput_event_get_touch_event(event));
2348 case LIBINPUT_EVENT_TOUCH_MOTION:
2349 _device_handle_touch_motion(device,
2350 libinput_event_get_touch_event(event));
2352 case LIBINPUT_EVENT_TOUCH_UP:
2353 _device_handle_touch_up(device, libinput_event_get_touch_event(event));
2355 case LIBINPUT_EVENT_TOUCH_CANCEL:
2356 _device_handle_touch_cancel(device, libinput_event_get_touch_event(event));
2358 case LIBINPUT_EVENT_TOUCH_FRAME:
2359 _device_handle_touch_frame(device, libinput_event_get_touch_event(event));
2361 case LIBINPUT_EVENT_TOUCH_AUX_DATA:
2362 _device_handle_touch_aux_data(device, libinput_event_get_touch_aux_data(event));
2373 * @brief Set the axis size of the given device.
2375 * @param dev The device to set the axis size to.
2376 * @param w The width of the axis.
2377 * @param h The height of the axis.
2379 * This function sets set the width @p w and height @p h of the axis
2380 * of device @p dev. If @p dev is a relative input device, a width and
2381 * height must set for it. If its absolute set the ioctl correctly, if
2382 * not, unsupported device.
2385 e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h)
2387 const char *sysname;
2392 enum libinput_config_status status;
2394 EINA_SAFETY_ON_NULL_RETURN(edev);
2395 EINA_SAFETY_ON_TRUE_RETURN((w == 0) || (h == 0));
2397 if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
2398 (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
2401 sysname = libinput_device_get_sysname(edev->device);
2403 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
2404 if (eina_list_count(devices) < 1) return;
2406 EINA_LIST_FREE(devices, device)
2408 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
2410 (sscanf(vals, "%f %f %f %f %f %f",
2411 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
2418 libinput_device_config_calibration_set_matrix(edev->device, cal);
2420 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
2421 ERR("Failed to apply calibration");
2424 eina_stringshare_del(device);
2429 EINTERN const char *
2430 e_input_evdev_name_get(E_Input_Evdev *evdev)
2432 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
2433 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
2435 return libinput_device_get_name(evdev->device);
2438 EINTERN const char *
2439 e_input_evdev_sysname_get(E_Input_Evdev *evdev)
2441 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
2442 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
2444 return libinput_device_get_sysname(evdev->device);
2448 e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool enable)
2450 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2451 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2453 edev->key_remap_enabled = enable;
2455 if (enable == EINA_FALSE && edev->key_remap_hash)
2457 eina_hash_free(edev->key_remap_hash);
2458 edev->key_remap_hash = NULL;
2465 e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num)
2469 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2470 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2471 EINA_SAFETY_ON_NULL_RETURN_VAL(from_keys, EINA_FALSE);
2472 EINA_SAFETY_ON_NULL_RETURN_VAL(to_keys, EINA_FALSE);
2473 EINA_SAFETY_ON_TRUE_RETURN_VAL(num <= 0, EINA_FALSE);
2474 EINA_SAFETY_ON_TRUE_RETURN_VAL(!edev->key_remap_enabled, EINA_FALSE);
2476 if (edev->key_remap_hash == NULL)
2477 edev->key_remap_hash = eina_hash_int32_new(NULL);
2479 if (edev->key_remap_hash == NULL)
2481 ERR("Failed to set remap key information : creating a hash is failed.");
2485 for (i = 0; i < num ; i++)
2487 if (!from_keys[i] || !to_keys[i])
2489 ERR("Failed to set remap key information : given arguments are invalid.");
2494 for (i = 0; i < num ; i++)
2496 eina_hash_add(edev->key_remap_hash, &from_keys[i], (void *)(intptr_t)to_keys[i]);
2503 e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev)
2505 EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
2506 return libinput_device_config_scroll_get_wheel_click_angle(dev->device);
2510 e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6])
2512 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2513 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2515 if (!libinput_device_config_calibration_has_matrix(edev->device) ||
2516 !libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_TOUCH))
2519 if (libinput_device_config_calibration_set_matrix(edev->device, matrix) !=
2520 LIBINPUT_CONFIG_STATUS_SUCCESS)
2522 WRN("Failed to set input transformation about device: %s\n",
2523 libinput_device_get_name(edev->device));
2531 e_input_evdev_mouse_accel_speed_set(E_Input_Evdev *edev, double speed)
2533 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
2534 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
2536 if (!libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
2539 if (!libinput_device_config_accel_is_available(edev->device))
2542 if (libinput_device_config_accel_set_speed(edev->device, speed) !=
2543 LIBINPUT_CONFIG_STATUS_SUCCESS)
2545 WRN("Failed to set mouse accel about device: %s\n",
2546 libinput_device_get_name(edev->device));
2553 EINTERN unsigned int
2554 e_input_evdev_touch_pressed_get(E_Input_Evdev *edev)
2556 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, 0x0);
2558 return edev->touch.pressed;
2562 e_input_evdev_seatname_get(E_Input_Evdev *evdev)
2564 struct libinput_seat *libinput_seat;
2565 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
2566 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
2568 libinput_seat = libinput_device_get_seat(evdev->device);
2570 return libinput_seat_get_logical_name(libinput_seat);
2574 e_input_evdev_seatname_set(E_Input_Evdev *evdev, const char *seatname)
2576 Eina_Bool res = EINA_FALSE;
2577 E_Input_Backend *input;
2579 EINA_SAFETY_ON_NULL_RETURN_VAL(seatname, EINA_FALSE);
2580 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, EINA_FALSE);
2581 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, EINA_FALSE);
2583 if (libinput_device_set_seat_logical_name(evdev->device, seatname) == 0)
2585 input = evdev->seat->input;
2586 if (!input) return EINA_FALSE;
2587 if (libinput_dispatch(input->libinput) != 0)
2589 ERR("Failed to dispatch libinput events: %m");
2593 /* process pending events */
2594 _input_events_process(input);