2 #include "e_input_private.h"
4 static void _device_modifiers_update(E_Input_Evdev *edev);
7 _device_calibration_set(E_Input_Evdev *edev)
13 output = e_comp_screen_primary_output_get(e_comp->e_comp_screen);
14 e_output_size_get(output, &w, &h);
18 edev->mouse.minx = edev->mouse.miny = 0;
22 if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
24 edev->seat->ptr.dx = (double)(w / 2);
25 edev->seat->ptr.dy = (double)(h / 2);
26 edev->seat->ptr.ix = (int)edev->seat->ptr.dx;
27 edev->seat->ptr.iy = (int)edev->seat->ptr.dy;
28 edev->mouse.dx = edev->seat->ptr.dx;
29 edev->mouse.dy = edev->seat->ptr.dy;
31 if (output->config.rotation == 90 || output->config.rotation == 270)
33 temp = edev->mouse.minx;
34 edev->mouse.minx = edev->mouse.miny;
35 edev->mouse.miny = temp;
37 temp = edev->mouse.maxw;
38 edev->mouse.maxw = edev->mouse.maxh;
39 edev->mouse.maxh = temp;
45 #ifdef _F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
51 if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
52 (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
55 sysname = libinput_device_get_sysname(edev->device);
57 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
58 if (eina_list_count(devices) < 1) return;
60 #ifdef _F_E_INPUT_USE_WL_CALIBRATION_
62 enum libinput_config_status status;
64 EINA_LIST_FREE(devices, device)
66 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
68 (sscanf(vals, "%f %f %f %f %f %f",
69 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
76 libinput_device_config_calibration_set_matrix(edev->device, cal);
78 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
79 ERR("Failed to apply calibration");
82 eina_stringshare_del(device);
85 #endif//_F_E_INPUT_USE_WL_CALIBRATION_
86 #endif//_F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
91 _device_configure(E_Input_Evdev *edev)
93 if (libinput_device_config_tap_get_finger_count(edev->device) > 0)
95 Eina_Bool tap = EINA_FALSE;
97 tap = libinput_device_config_tap_get_default_enabled(edev->device);
98 libinput_device_config_tap_set_enabled(edev->device, tap);
101 _device_calibration_set(edev);
105 _device_keyboard_setup(E_Input_Evdev *edev)
107 E_Input_Backend *input;
108 xkb_mod_index_t xkb_idx;
110 if ((!edev) || (!edev->seat)) return;
111 if (!(input = edev->seat->input)) return;
112 if (!input->dev->xkb_ctx) return;
114 /* create keymap from xkb context */
115 edev->xkb.keymap = _e_input_device_cached_keymap_get(input->dev->xkb_ctx, NULL, 0);
116 if (!edev->xkb.keymap)
118 ERR("Failed to create keymap: %m");
122 /* create xkb state */
123 if (!(edev->xkb.state = xkb_state_new(edev->xkb.keymap)))
125 ERR("Failed to create xkb state: %m");
129 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CTRL);
130 if (xkb_idx != XKB_MOD_INVALID)
131 edev->xkb.ctrl_mask = 1 << xkb_idx;
133 edev->xkb.ctrl_mask = 0;
135 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_ALT);
136 if (xkb_idx != XKB_MOD_INVALID)
137 edev->xkb.alt_mask = 1 << xkb_idx;
139 edev->xkb.alt_mask = 0;
141 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_SHIFT);
142 if (xkb_idx != XKB_MOD_INVALID)
143 edev->xkb.shift_mask = 1 << xkb_idx;
145 edev->xkb.shift_mask = 0;
147 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_LOGO);
148 if (xkb_idx != XKB_MOD_INVALID)
149 edev->xkb.win_mask = 1 << xkb_idx;
151 edev->xkb.win_mask = 0;
153 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_LED_NAME_SCROLL);
154 if (xkb_idx != XKB_MOD_INVALID)
155 edev->xkb.scroll_mask = 1 << xkb_idx;
157 edev->xkb.scroll_mask = 0;
159 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_LED_NAME_NUM);
160 if (xkb_idx != XKB_MOD_INVALID)
161 edev->xkb.num_mask = 1 << xkb_idx;
163 edev->xkb.num_mask = 0;
165 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, XKB_MOD_NAME_CAPS);
166 if (xkb_idx != XKB_MOD_INVALID)
167 edev->xkb.caps_mask = 1 << xkb_idx;
169 edev->xkb.caps_mask = 0;
171 xkb_idx = xkb_map_mod_get_index(edev->xkb.keymap, "ISO_Level3_Shift");
172 if (xkb_idx != XKB_MOD_INVALID)
173 edev->xkb.altgr_mask = 1 << xkb_idx;
175 edev->xkb.altgr_mask = 0;
179 _device_keysym_translate(xkb_keysym_t keysym, unsigned int modifiers, char *buffer, int bytes)
181 unsigned long hbytes = 0;
184 if (!keysym) return 0;
185 hbytes = (keysym >> 8);
190 (((keysym >= XKB_KEY_BackSpace) && (keysym <= XKB_KEY_Clear)) ||
191 (keysym == XKB_KEY_Return) || (keysym == XKB_KEY_Escape) ||
192 (keysym == XKB_KEY_KP_Space) || (keysym == XKB_KEY_KP_Tab) ||
193 (keysym == XKB_KEY_KP_Enter) ||
194 ((keysym >= XKB_KEY_KP_Multiply) && (keysym <= XKB_KEY_KP_9)) ||
195 (keysym == XKB_KEY_KP_Equal) || (keysym == XKB_KEY_Delete))))))
198 if (keysym == XKB_KEY_KP_Space)
199 c = (XKB_KEY_space & 0x7F);
200 else if (hbytes == 0xFF)
205 if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
207 if (((c >= '@') && (c < '\177')) || c == ' ')
211 else if ((c >= '3') && (c <= '7'))
223 _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
227 edev->xkb.depressed =
228 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_DEPRESSED);
230 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LATCHED);
232 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LOCKED);
234 xkb_state_serialize_mods(from->xkb.state, XKB_STATE_EFFECTIVE);
236 mask = (edev->xkb.depressed | edev->xkb.latched);
238 if (mask & from->xkb.ctrl_mask)
239 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_CTRL;
240 if (mask & from->xkb.alt_mask)
241 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_ALT;
242 if (mask & from->xkb.shift_mask)
243 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
244 if (mask & from->xkb.win_mask)
245 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_WIN;
246 if (mask & from->xkb.scroll_mask)
247 edev->xkb.modifiers |= ECORE_EVENT_LOCK_SCROLL;
248 if (mask & from->xkb.num_mask)
249 edev->xkb.modifiers |= ECORE_EVENT_LOCK_NUM;
250 if (mask & from->xkb.caps_mask)
251 edev->xkb.modifiers |= ECORE_EVENT_LOCK_CAPS;
252 if (mask & from->xkb.altgr_mask)
253 edev->xkb.modifiers |= ECORE_EVENT_MODIFIER_ALTGR;
257 _device_modifiers_update(E_Input_Evdev *edev)
262 edev->xkb.modifiers = 0;
264 if (edev->caps & E_INPUT_SEAT_KEYBOARD)
265 _device_modifiers_update_device(edev, edev);
268 EINA_LIST_FOREACH(edev->seat->devices, l, ed)
270 if (!(ed->caps & E_INPUT_SEAT_KEYBOARD)) continue;
271 _device_modifiers_update_device(edev, ed);
278 _device_remapped_key_get(E_Input_Evdev *edev, int code)
282 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, code);
283 if (!edev->key_remap_enabled) return code;
284 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->key_remap_hash, code);
286 ret = eina_hash_find(edev->key_remap_hash, &code);
288 if (ret) code = (int)(intptr_t)ret;
294 e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas)
296 const Eina_List *dev_list = NULL;
298 Ecore_Device *dev = NULL;
299 const char *identifier;
301 if (!path) return NULL;
303 dev_list = ecore_device_list();
304 if (!dev_list) return NULL;
305 EINA_LIST_FOREACH(dev_list, l, dev)
308 identifier = ecore_device_identifier_get(dev);
309 if (!identifier) continue;
310 if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
317 _e_input_event_mouse_move_cb_free(void *data EINA_UNUSED, void *event)
319 Ecore_Event_Mouse_Move *ev = event;
321 if (ev->dev) ecore_device_unref(ev->dev);
327 _e_input_event_mouse_wheel_cb_free(void *data EINA_UNUSED, void *event)
329 Ecore_Event_Mouse_Wheel *ev = event;
331 if (ev->dev) ecore_device_unref(ev->dev);
337 _e_input_event_mouse_button_cb_free(void *data EINA_UNUSED, void *event)
339 Ecore_Event_Mouse_Button *ev = event;
341 if (ev->dev) ecore_device_unref(ev->dev);
347 _e_input_event_key_cb_free(void *data EINA_UNUSED, void *event)
349 Ecore_Event_Key *ev = event;
351 if (ev->dev) ecore_device_unref(ev->dev);
352 if (ev->data) E_FREE(ev->data);
358 _device_handle_key(struct libinput_device *device, struct libinput_event_keyboard *event)
361 E_Input_Backend *input;
363 uint32_t code, nsyms;
364 const xkb_keysym_t *syms;
365 enum libinput_key_state state;
367 xkb_keysym_t sym = XKB_KEY_NoSymbol;
368 char key[256], keyname[256], compose_buffer[256];
370 char *tmp = NULL, *compose = NULL;
371 E_Keyrouter_Event_Data *key_data;
372 Ecore_Device *ecore_dev = NULL, *data;
374 E_Comp_Config *comp_conf = NULL;
376 if (!(edev = libinput_device_get_user_data(device)))
381 if (!(input = edev->seat->input))
386 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
387 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
389 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
391 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_KEYBOARD)
400 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
401 ecore_dev = edev->ecore_dev;
406 ERR("Failed to get source ecore device from event !\n");
410 timestamp = libinput_event_keyboard_get_time(event);
411 code = libinput_event_keyboard_get_key(event);
412 code = _device_remapped_key_get(edev, code + 8);
413 state = libinput_event_keyboard_get_key_state(event);
414 key_count = libinput_event_keyboard_get_seat_key_count(event);
416 /* ignore key events that are not seat wide state changes */
417 if (((state == LIBINPUT_KEY_STATE_PRESSED) && (key_count != 1)) ||
418 ((state == LIBINPUT_KEY_STATE_RELEASED) && (key_count != 0)))
423 xkb_state_update_key(edev->xkb.state, code,
424 (state ? XKB_KEY_DOWN : XKB_KEY_UP));
426 /* get the keysym for this code */
427 nsyms = xkb_key_get_syms(edev->xkb.state, code, &syms);
428 if (nsyms == 1) sym = syms[0];
430 /* get the keyname for this sym */
431 memset(key, 0, sizeof(key));
432 xkb_keysym_get_name(sym, key, sizeof(key));
434 memset(keyname, 0, sizeof(keyname));
435 memcpy(keyname, key, sizeof(keyname));
437 if (keyname[0] == '\0')
438 snprintf(keyname, sizeof(keyname), "Keycode-%u", code);
440 /* if shift is active, we need to transform the key to lower */
441 if (xkb_state_mod_index_is_active(edev->xkb.state,
442 xkb_map_mod_get_index(edev->xkb.keymap,
444 XKB_STATE_MODS_EFFECTIVE))
446 if (keyname[0] != '\0')
447 keyname[0] = tolower(keyname[0]);
450 memset(compose_buffer, 0, sizeof(compose_buffer));
451 if (_device_keysym_translate(sym, edev->xkb.modifiers,
452 compose_buffer, sizeof(compose_buffer)))
454 compose = eina_str_convert("ISO8859-1", "UTF-8", compose_buffer);
457 ERR("E Input cannot convert input key string '%s' to UTF-8. "
458 "Is Eina built with iconv support?", compose_buffer);
464 if (!compose) compose = compose_buffer;
466 e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
467 ((compose[0] != '\0') ? strlen(compose) : 0) + 3);
473 key_data = E_NEW(E_Keyrouter_Event_Data, 1);
481 e->keyname = (char *)(e + 1);
482 e->key = e->keyname + strlen(keyname) + 1;
483 e->compose = strlen(compose) ? e->key + strlen(key) + 1 : NULL;
484 e->string = e->compose;
486 strncpy((char *)e->keyname, keyname, strlen(keyname));
487 strncpy((char *)e->key, key, strlen(key));
488 if (strlen(compose)) strncpy((char *)e->compose, compose, strlen(compose));
490 e->window = (Ecore_Window)input->dev->window;
491 e->event_window = (Ecore_Window)input->dev->window;
492 e->root_window = (Ecore_Window)input->dev->window;
493 e->timestamp = timestamp;
498 _device_modifiers_update(edev);
500 e->modifiers = edev->xkb.modifiers;
501 e->dev = ecore_device_ref(ecore_dev);
503 comp_conf = e_comp_config_get();
504 if (comp_conf && comp_conf->input_log_enable)
505 ELOGF("Key", "%s (keyname: %s, keycode: %d, device: %s)", NULL, state?"Press":"Release", e->keyname, e->keycode, ecore_device_name_get(e->dev));
508 ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _e_input_event_key_cb_free, NULL);
510 ecore_event_add(ECORE_EVENT_KEY_UP, e, _e_input_event_key_cb_free, NULL);
516 _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event)
518 E_Input_Backend *input;
519 Ecore_Event_Mouse_Move *ev;
520 Ecore_Device *ecore_dev = NULL, *data, *detent_data = NULL;
523 if (!(input = edev->seat->input)) return;
525 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
526 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
528 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
530 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
535 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
540 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
542 ecore_dev = detent_data;
547 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
548 ecore_dev = edev->ecore_dev;
553 ERR("Failed to get source ecore device from event !\n");
556 else if ((detent_data == ecore_dev) || e_devicemgr_detent_is_detent(ecore_device_name_get(ecore_dev)))
558 /* Do not process detent device's move events. */
562 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
564 if (edev->seat->ptr.ix < edev->mouse.minx)
565 edev->seat->ptr.dx = edev->seat->ptr.ix = edev->mouse.minx;
566 else if (edev->seat->ptr.ix >= (edev->mouse.minx + edev->mouse.maxw))
567 edev->seat->ptr.dx = edev->seat->ptr.ix = (edev->mouse.minx + edev->mouse.maxw - 1);
569 if (edev->seat->ptr.iy < edev->mouse.miny)
570 edev->seat->ptr.dy = edev->seat->ptr.iy = edev->mouse.miny;
571 else if (edev->seat->ptr.iy >= (edev->mouse.miny + edev->mouse.maxh))
572 edev->seat->ptr.dy = edev->seat->ptr.iy = (edev->mouse.miny + edev->mouse.maxh - 1);
574 edev->mouse.dx = edev->seat->ptr.dx;
575 edev->mouse.dy = edev->seat->ptr.dy;
577 ev->window = (Ecore_Window)input->dev->window;
578 ev->event_window = (Ecore_Window)input->dev->window;
579 ev->root_window = (Ecore_Window)input->dev->window;
580 if (event) ev->timestamp = libinput_event_pointer_get_time(event);
583 _device_modifiers_update(edev);
584 ev->modifiers = edev->xkb.modifiers;
586 ev->x = edev->seat->ptr.ix;
587 ev->y = edev->seat->ptr.iy;
591 ev->multi.device = edev->mt_slot;
592 ev->multi.radius = 1;
593 ev->multi.radius_x = 1;
594 ev->multi.radius_y = 1;
595 ev->multi.pressure = 1.0;
596 ev->multi.angle = 0.0;
599 ev->multi.root.x = ev->x;
600 ev->multi.root.y = ev->y;
601 ev->dev = ecore_device_ref(ecore_dev);
603 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
607 _e_input_pointer_motion_post(E_Input_Evdev *edev)
609 _device_pointer_motion(edev, NULL);
613 _device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event)
618 if (!(edev = libinput_device_get_user_data(device)))
623 dx = libinput_event_pointer_get_dx(event);
624 dy = libinput_event_pointer_get_dy(event);
626 if (edev->seat->ptr.swap)
632 if (edev->seat->ptr.invert_x)
634 if (edev->seat->ptr.invert_y)
637 edev->seat->ptr.dx += dx;
638 edev->seat->ptr.dy += dy;
640 edev->mouse.dx = edev->seat->ptr.dx;
641 edev->mouse.dy = edev->seat->ptr.dy;
643 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
644 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
649 edev->seat->ptr.ix = edev->seat->ptr.dx;
650 edev->seat->ptr.iy = edev->seat->ptr.dy;
652 _device_pointer_motion(edev, event);
656 _device_handle_pointer_motion_absolute(struct libinput_device *device, struct libinput_event_pointer *event)
661 if (!(edev = libinput_device_get_user_data(device)))
666 e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
668 edev->mouse.dx = edev->seat->ptr.dx =
669 libinput_event_pointer_get_absolute_x_transformed(event, w);
670 edev->mouse.dy = edev->seat->ptr.dy =
671 libinput_event_pointer_get_absolute_y_transformed(event, h);
673 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
674 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
679 edev->seat->ptr.ix = edev->seat->ptr.dx;
680 edev->seat->ptr.iy = edev->seat->ptr.dy;
681 _device_pointer_motion(edev, event);
685 _device_handle_button(struct libinput_device *device, struct libinput_event_pointer *event)
688 E_Input_Backend *input;
689 Ecore_Event_Mouse_Button *ev;
690 enum libinput_button_state state;
691 uint32_t button, timestamp;
692 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
694 E_Comp_Config *comp_conf = NULL;
696 if (!(edev = libinput_device_get_user_data(device)))
700 if (!(input = edev->seat->input))
705 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
706 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
708 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
710 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
715 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
720 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
722 ecore_dev = detent_data;
727 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
728 ecore_dev = edev->ecore_dev;
733 ERR("Failed to get source ecore device from event !\n");
737 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button))))
742 state = libinput_event_pointer_get_button_state(event);
743 button = libinput_event_pointer_get_button(event);
744 timestamp = libinput_event_pointer_get_time(event);
746 button = ((button & 0x00F) + 1);
747 if (button == 3) button = 2;
748 else if (button == 2) button = 3;
750 ev->window = (Ecore_Window)input->dev->window;
751 ev->event_window = (Ecore_Window)input->dev->window;
752 ev->root_window = (Ecore_Window)input->dev->window;
753 ev->timestamp = timestamp;
756 _device_modifiers_update(edev);
757 ev->modifiers = edev->xkb.modifiers;
759 ev->x = edev->seat->ptr.ix;
760 ev->y = edev->seat->ptr.iy;
764 ev->multi.device = edev->mt_slot;
765 ev->multi.radius = 1;
766 ev->multi.radius_x = 1;
767 ev->multi.radius_y = 1;
768 ev->multi.pressure = 1.0;
769 ev->multi.angle = 0.0;
772 ev->multi.root.x = ev->x;
773 ev->multi.root.y = ev->y;
774 ev->dev = ecore_device_ref(ecore_dev);
778 unsigned int current;
781 edev->mouse.did_double = EINA_FALSE;
782 edev->mouse.did_triple = EINA_FALSE;
784 if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
785 (button == edev->mouse.prev_button))
787 edev->mouse.did_double = EINA_TRUE;
788 if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
789 (button == edev->mouse.last_button))
791 edev->mouse.did_triple = EINA_TRUE;
792 edev->mouse.prev = 0;
793 edev->mouse.last = 0;
798 edev->mouse.last = edev->mouse.prev;
799 edev->mouse.prev = current;
800 edev->mouse.last_button = edev->mouse.prev_button;
801 edev->mouse.prev_button = button;
804 ev->buttons = button;
806 if (edev->mouse.did_double)
807 ev->double_click = 1;
808 if (edev->mouse.did_triple)
809 ev->triple_click = 1;
811 comp_conf = e_comp_config_get();
812 if (comp_conf && comp_conf->input_log_enable)
813 ELOGF("Mouse", "Button %s (btn: %d, device: %s)", NULL, state?"Press":"Release", button, ecore_device_name_get(ev->dev));
816 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, _e_input_event_mouse_button_cb_free, NULL);
818 ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, _e_input_event_mouse_button_cb_free, NULL);
822 _device_handle_axis(struct libinput_device *device, struct libinput_event_pointer *event)
825 E_Input_Backend *input;
826 Ecore_Event_Mouse_Wheel *ev;
828 enum libinput_pointer_axis axis;
829 Ecore_Device *ecore_dev = NULL, *detent_data = NULL, *data;
831 E_Comp_Config *comp_conf = NULL;
833 if (!(edev = libinput_device_get_user_data(device)))
837 if (!(input = edev->seat->input))
842 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
843 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
845 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
847 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
852 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
857 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
859 ecore_dev = detent_data;
864 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
865 ecore_dev = edev->ecore_dev;
870 ERR("Failed to get source ecore device from event !\n");
874 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
879 timestamp = libinput_event_pointer_get_time(event);
881 ev->window = (Ecore_Window)input->dev->window;
882 ev->event_window = (Ecore_Window)input->dev->window;
883 ev->root_window = (Ecore_Window)input->dev->window;
884 ev->timestamp = timestamp;
887 _device_modifiers_update(edev);
888 ev->modifiers = edev->xkb.modifiers;
890 ev->x = edev->seat->ptr.ix;
891 ev->y = edev->seat->ptr.iy;
894 ev->dev = ecore_device_ref(ecore_dev);
896 axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
897 if (libinput_event_pointer_has_axis(event, axis))
898 ev->z = libinput_event_pointer_get_axis_value(event, axis);
900 axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
901 if (libinput_event_pointer_has_axis(event, axis))
904 ev->z = libinput_event_pointer_get_axis_value(event, axis);
907 comp_conf = e_comp_config_get();
908 if (comp_conf && comp_conf->input_log_enable)
911 ELOGF("Mouse", "Detent (direction: %d, value: %d)", NULL, ev->direction, ev->z);
913 ELOGF("Mouse", "Wheel (direction: %d, value: %d)", NULL, ev->direction, ev->z);
916 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
920 _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch *event, int state)
922 E_Input_Backend *input;
923 Ecore_Event_Mouse_Button *ev;
924 uint32_t timestamp, button = 0;
925 Ecore_Device *ecore_dev = NULL, *data;
929 if (!(input = edev->seat->input)) return;
931 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
932 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
934 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
936 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
945 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
946 ecore_dev = edev->ecore_dev;
951 ERR("Failed to get source ecore device from event !\n");
955 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
957 timestamp = libinput_event_touch_get_time(event);
959 ev->window = (Ecore_Window)input->dev->window;
960 ev->event_window = (Ecore_Window)input->dev->window;
961 ev->root_window = (Ecore_Window)input->dev->window;
962 ev->timestamp = timestamp;
965 _device_modifiers_update(edev);
966 ev->modifiers = edev->xkb.modifiers;
968 ev->x = edev->seat->ptr.ix;
969 ev->y = edev->seat->ptr.iy;
973 ev->multi.device = edev->mt_slot;
974 ev->multi.radius = 1;
975 ev->multi.radius_x = 1;
976 ev->multi.radius_y = 1;
977 ev->multi.pressure = 1.0;
978 ev->multi.angle = 0.0;
979 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
980 if (libinput_event_get_type(libinput_event_touch_get_base_event(event))
981 == LIBINPUT_EVENT_TOUCH_DOWN)
983 if (libinput_event_touch_has_minor(event))
984 ev->multi.radius_x = libinput_event_touch_get_minor(event);
985 if (libinput_event_touch_has_major(event))
986 ev->multi.radius_y = libinput_event_touch_get_major(event);
987 if (libinput_event_touch_has_pressure(event))
988 ev->multi.pressure = libinput_event_touch_get_pressure(event);
989 if (libinput_event_touch_has_orientation(event))
990 ev->multi.angle = libinput_event_touch_get_orientation(event);
995 ev->multi.root.x = ev->x;
996 ev->multi.root.y = ev->y;
997 ev->dev = ecore_device_ref(ecore_dev);
999 if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN)
1001 unsigned int current;
1003 current = timestamp;
1004 edev->mouse.did_double = EINA_FALSE;
1005 edev->mouse.did_triple = EINA_FALSE;
1007 if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
1008 (button == edev->mouse.prev_button))
1010 edev->mouse.did_double = EINA_TRUE;
1011 if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
1012 (button == edev->mouse.last_button))
1014 edev->mouse.did_triple = EINA_TRUE;
1015 edev->mouse.prev = 0;
1016 edev->mouse.last = 0;
1021 edev->mouse.last = edev->mouse.prev;
1022 edev->mouse.prev = current;
1023 edev->mouse.last_button = edev->mouse.prev_button;
1024 edev->mouse.prev_button = button;
1025 edev->touch.pressed |= (1 << ev->multi.device);
1029 edev->touch.pressed &= ~(1 << ev->multi.device);
1032 ev->buttons = ((button & 0x00F) + 1);
1034 if (edev->mouse.did_double)
1035 ev->double_click = 1;
1036 if (edev->mouse.did_triple)
1037 ev->triple_click = 1;
1039 ecore_event_add(state, ev, _e_input_event_mouse_button_cb_free, NULL);
1043 _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touch *event)
1045 E_Input_Backend *input;
1046 Ecore_Event_Mouse_Move *ev;
1047 Ecore_Device *ecore_dev = NULL, *data;
1051 if (!(input = edev->seat->input)) return;
1053 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1054 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1056 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1058 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1067 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1068 ecore_dev = edev->ecore_dev;
1073 ERR("Failed to get source ecore device from event !\n");
1077 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
1079 ev->window = (Ecore_Window)input->dev->window;
1080 ev->event_window = (Ecore_Window)input->dev->window;
1081 ev->root_window = (Ecore_Window)input->dev->window;
1082 ev->timestamp = libinput_event_touch_get_time(event);
1083 ev->same_screen = 1;
1085 _device_modifiers_update(edev);
1086 ev->modifiers = edev->xkb.modifiers;
1088 ev->x = edev->seat->ptr.ix;
1089 ev->y = edev->seat->ptr.iy;
1093 ev->multi.device = edev->mt_slot;
1094 ev->multi.radius = 1;
1095 ev->multi.radius_x = 1;
1096 ev->multi.radius_y = 1;
1097 ev->multi.pressure = 1.0;
1098 ev->multi.angle = 0.0;
1099 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
1100 if (libinput_event_touch_has_minor(event))
1101 ev->multi.radius_x = libinput_event_touch_get_minor(event);
1102 if (libinput_event_touch_has_major(event))
1103 ev->multi.radius_y = libinput_event_touch_get_major(event);
1104 if (libinput_event_touch_has_pressure(event))
1105 ev->multi.pressure = libinput_event_touch_get_pressure(event);
1106 if (libinput_event_touch_has_orientation(event))
1107 ev->multi.angle = libinput_event_touch_get_orientation(event);
1109 ev->multi.x = ev->x;
1110 ev->multi.y = ev->y;
1111 ev->multi.root.x = ev->x;
1112 ev->multi.root.y = ev->y;
1113 ev->dev = ecore_device_ref(ecore_dev);
1115 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
1119 _device_handle_touch_down(struct libinput_device *device, struct libinput_event_touch *event)
1121 E_Input_Evdev *edev;
1123 E_Comp_Config *comp_conf = NULL;
1125 if (!(edev = libinput_device_get_user_data(device)))
1130 e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
1132 edev->mouse.dx = edev->seat->ptr.ix = edev->seat->ptr.dx =
1133 libinput_event_touch_get_x_transformed(event, w);
1134 edev->mouse.dy = edev->seat->ptr.iy = edev->seat->ptr.dy =
1135 libinput_event_touch_get_y_transformed(event, h);
1137 edev->mt_slot = libinput_event_touch_get_slot(event);
1138 if (edev->mt_slot < 0)
1140 /* FIXME: The single touch device return slot id -1
1141 * But currently we have no API to distinguish multi touch or single touch
1142 * After libinput 1.11 version, libinput provides get_touch_count API,
1143 * so we can distinguish multi touch device or single touch device.
1145 if (edev->mt_slot == -1)
1149 WRN("%d slot touch down events are not supported\n", edev->mt_slot);
1154 if (edev->mt_slot < E_INPUT_MAX_SLOTS)
1156 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1157 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1160 comp_conf = e_comp_config_get();
1161 if (comp_conf && comp_conf->input_log_enable)
1162 ELOGF("Touch", "Down (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1164 _device_handle_touch_motion_send(edev, event);
1165 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN);
1169 _device_handle_touch_motion(struct libinput_device *device, struct libinput_event_touch *event)
1171 E_Input_Evdev *edev;
1174 if (!(edev = libinput_device_get_user_data(device)))
1179 e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
1181 edev->mouse.dx = edev->seat->ptr.dx =
1182 libinput_event_touch_get_x_transformed(event, w);
1183 edev->mouse.dy = edev->seat->ptr.dy =
1184 libinput_event_touch_get_y_transformed(event, h);
1186 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
1187 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
1192 edev->seat->ptr.ix = edev->seat->ptr.dx;
1193 edev->seat->ptr.iy = edev->seat->ptr.dy;
1195 edev->mt_slot = libinput_event_touch_get_slot(event);
1196 if (edev->mt_slot < 0)
1198 /* FIXME: The single touch device return slot id -1
1199 * But currently we have no API to distinguish multi touch or single touch
1200 * After libinput 1.11 version, libinput provides get_touch_count API,
1201 * so we can distinguish multi touch device or single touch device.
1203 if (edev->mt_slot == -1)
1207 WRN("%d slot touch motion events are not supported\n", edev->mt_slot);
1212 if (edev->mt_slot < E_INPUT_MAX_SLOTS)
1214 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1215 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1218 _device_handle_touch_motion_send(edev, event);
1222 _device_handle_touch_up(struct libinput_device *device, struct libinput_event_touch *event)
1224 E_Input_Evdev *edev;
1225 E_Comp_Config *comp_conf = NULL;
1227 if (!(edev = libinput_device_get_user_data(device)))
1232 edev->mt_slot = libinput_event_touch_get_slot(event);
1233 if (edev->mt_slot < 0)
1235 /* FIXME: The single touch device return slot id -1
1236 * But currently we have no API to distinguish multi touch or single touch
1237 * After libinput 1.11 version, libinput provides get_touch_count API,
1238 * so we can distinguish multi touch device or single touch device.
1240 if (edev->mt_slot == -1)
1244 WRN("%d slot touch up events are not supported\n", edev->mt_slot);
1249 if (edev->mt_slot < E_INPUT_MAX_SLOTS)
1251 edev->mouse.dx = edev->seat->ptr.dx = edev->seat->ptr.ix =
1252 edev->touch.coords[edev->mt_slot].x;
1253 edev->mouse.dy = edev->seat->ptr.dy = edev->seat->ptr.iy =
1254 edev->touch.coords[edev->mt_slot].y;
1257 comp_conf = e_comp_config_get();
1258 if (comp_conf && comp_conf->input_log_enable)
1259 ELOGF("Touch", "Up (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1261 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_UP);
1265 _device_handle_touch_frame(struct libinput_device *device EINA_UNUSED, struct libinput_event_touch *event EINA_UNUSED)
1267 /* DBG("Unhandled Touch Frame Event"); */
1271 _e_input_aux_data_event_free(void *user_data EINA_UNUSED, void *ev)
1273 Ecore_Event_Axis_Update *e = (Ecore_Event_Axis_Update *)ev;
1275 if (e->axis) free(e->axis);
1276 if (e->dev) ecore_device_unref(e->dev);
1282 _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_event_touch_aux_data *event)
1284 E_Input_Evdev *edev;
1285 E_Input_Backend *input;
1286 Ecore_Event_Axis_Update *ev;
1288 Ecore_Device *ecore_dev = NULL, *data;
1290 E_Comp_Config *comp_conf;
1292 if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
1293 libinput_event_touch_aux_data_get_value(event) > 0)
1296 if (!(edev = libinput_device_get_user_data(device))) goto end;
1297 if (!(input = edev->seat->input)) goto end;
1299 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1300 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1302 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1304 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1313 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1314 ecore_dev = edev->ecore_dev;
1319 ERR("Failed to get source ecore device from event !\n");
1323 if (!(ev = calloc(1, sizeof(Ecore_Event_Axis_Update))))goto end;
1325 ev->window = (Ecore_Window)input->dev->window;
1326 ev->event_window = (Ecore_Window)input->dev->window;
1327 ev->root_window = (Ecore_Window)input->dev->window;
1328 ev->timestamp = libinput_event_touch_aux_data_get_time(event);
1330 axis = (Ecore_Axis *)calloc(1, sizeof(Ecore_Axis));
1333 axis->label = ECORE_AXIS_LABEL_TOUCH_PALM;
1334 axis->value = libinput_event_touch_aux_data_get_value(event);
1338 ev->dev = ecore_device_ref(ecore_dev);
1340 comp_conf = e_comp_config_get();
1341 if (comp_conf && comp_conf->input_log_enable)
1342 ELOGF("Touch", "Axis (label: %d, value: %lf)", NULL, axis?axis->label:-1, axis?axis->value:0.0);
1344 ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
1351 _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
1353 E_Input_Evdev *edev;
1354 E_Input_Backend *b_input;
1356 EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
1358 /* try to allocate space for new evdev */
1359 if (!(edev = calloc(1, sizeof(E_Input_Evdev)))) return NULL;
1362 edev->device = device;
1363 edev->path = eina_stringshare_printf("%s/%s", e_input_base_dir_get(), libinput_device_get_sysname(device));
1365 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
1367 edev->caps |= E_INPUT_SEAT_KEYBOARD;
1368 _device_keyboard_setup(edev);
1371 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
1373 edev->caps |= E_INPUT_SEAT_POINTER;
1375 /* TODO: make this configurable */
1376 edev->mouse.threshold = 250;
1378 b_input = seat->input;
1379 if (b_input->left_handed == EINA_TRUE)
1381 if (libinput_device_config_left_handed_set(device, 1) !=
1382 LIBINPUT_CONFIG_STATUS_SUCCESS)
1384 WRN("Failed to set left hand mode about device: %s\n",
1385 libinput_device_get_name(device));
1390 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
1393 edev->caps |= E_INPUT_SEAT_TOUCH;
1394 palm_code = libinput_device_touch_aux_data_get_code(LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM);
1395 if (libinput_device_touch_has_aux_data(device, palm_code))
1397 libinput_device_touch_set_aux_data(device, palm_code);
1401 libinput_device_set_user_data(device, edev);
1402 libinput_device_ref(device);
1404 /* configure device */
1405 _device_configure(edev);
1411 _e_input_evdev_device_destroy(E_Input_Evdev *edev)
1415 EINA_SAFETY_ON_NULL_RETURN(edev);
1417 if (edev->caps & E_INPUT_SEAT_KEYBOARD)
1419 if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
1420 if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
1423 if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
1424 if (edev->ecore_dev_list)
1425 EINA_LIST_FREE(edev->ecore_dev_list, dev)
1427 ecore_device_del(dev);
1429 if (edev->path) eina_stringshare_del(edev->path);
1430 if (edev->device) libinput_device_unref(edev->device);
1431 if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
1437 _e_input_evdev_event_process(struct libinput_event *event)
1439 struct libinput_device *device;
1440 Eina_Bool ret = EINA_TRUE;
1442 device = libinput_event_get_device(event);
1443 switch (libinput_event_get_type(event))
1445 case LIBINPUT_EVENT_KEYBOARD_KEY:
1446 _device_handle_key(device, libinput_event_get_keyboard_event(event));
1448 case LIBINPUT_EVENT_POINTER_MOTION:
1449 _device_handle_pointer_motion(device,
1450 libinput_event_get_pointer_event(event));
1452 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
1453 _device_handle_pointer_motion_absolute(device,
1454 libinput_event_get_pointer_event(event));
1456 case LIBINPUT_EVENT_POINTER_BUTTON:
1457 _device_handle_button(device, libinput_event_get_pointer_event(event));
1459 case LIBINPUT_EVENT_POINTER_AXIS:
1460 _device_handle_axis(device, libinput_event_get_pointer_event(event));
1462 case LIBINPUT_EVENT_TOUCH_DOWN:
1463 _device_handle_touch_down(device, libinput_event_get_touch_event(event));
1465 case LIBINPUT_EVENT_TOUCH_MOTION:
1466 _device_handle_touch_motion(device,
1467 libinput_event_get_touch_event(event));
1469 case LIBINPUT_EVENT_TOUCH_UP:
1470 _device_handle_touch_up(device, libinput_event_get_touch_event(event));
1472 case LIBINPUT_EVENT_TOUCH_FRAME:
1473 _device_handle_touch_frame(device, libinput_event_get_touch_event(event));
1475 case LIBINPUT_EVENT_TOUCH_AUX_DATA:
1476 _device_handle_touch_aux_data(device, libinput_event_get_touch_aux_data(event));
1487 * @brief Set the axis size of the given device.
1489 * @param dev The device to set the axis size to.
1490 * @param w The width of the axis.
1491 * @param h The height of the axis.
1493 * This function sets set the width @p w and height @p h of the axis
1494 * of device @p dev. If @p dev is a relative input device, a width and
1495 * height must set for it. If its absolute set the ioctl correctly, if
1496 * not, unsupported device.
1499 e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h)
1501 const char *sysname;
1506 enum libinput_config_status status;
1508 EINA_SAFETY_ON_NULL_RETURN(edev);
1509 EINA_SAFETY_ON_TRUE_RETURN((w == 0) || (h == 0));
1511 if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
1512 (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
1515 sysname = libinput_device_get_sysname(edev->device);
1517 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
1518 if (eina_list_count(devices) < 1) return;
1520 EINA_LIST_FREE(devices, device)
1522 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
1524 (sscanf(vals, "%f %f %f %f %f %f",
1525 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
1532 libinput_device_config_calibration_set_matrix(edev->device, cal);
1534 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
1535 ERR("Failed to apply calibration");
1538 eina_stringshare_del(device);
1544 e_input_evdev_name_get(E_Input_Evdev *evdev)
1546 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
1547 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
1549 return libinput_device_get_name(evdev->device);
1552 EINTERN const char *
1553 e_input_evdev_sysname_get(E_Input_Evdev *evdev)
1555 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
1556 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
1558 return libinput_device_get_sysname(evdev->device);
1562 e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool enable)
1564 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1565 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1567 edev->key_remap_enabled = enable;
1569 if (enable == EINA_FALSE && edev->key_remap_hash)
1571 eina_hash_free(edev->key_remap_hash);
1572 edev->key_remap_hash = NULL;
1579 e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num)
1583 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1584 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1585 EINA_SAFETY_ON_NULL_RETURN_VAL(from_keys, EINA_FALSE);
1586 EINA_SAFETY_ON_NULL_RETURN_VAL(to_keys, EINA_FALSE);
1587 EINA_SAFETY_ON_TRUE_RETURN_VAL(num <= 0, EINA_FALSE);
1588 EINA_SAFETY_ON_TRUE_RETURN_VAL(!edev->key_remap_enabled, EINA_FALSE);
1590 if (edev->key_remap_hash == NULL)
1591 edev->key_remap_hash = eina_hash_int32_new(NULL);
1593 if (edev->key_remap_hash == NULL)
1595 ERR("Failed to set remap key information : creating a hash is failed.");
1599 for (i = 0; i < num ; i++)
1601 if (!from_keys[i] || !to_keys[i])
1603 ERR("Failed to set remap key information : given arguments are invalid.");
1608 for (i = 0; i < num ; i++)
1610 eina_hash_add(edev->key_remap_hash, &from_keys[i], (void *)(intptr_t)to_keys[i]);
1617 e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev)
1619 EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
1620 return libinput_device_config_scroll_get_wheel_click_angle(dev->device);
1624 e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6])
1626 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1627 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1629 if (!libinput_device_config_calibration_has_matrix(edev->device) ||
1630 !libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_TOUCH))
1633 if (libinput_device_config_calibration_set_matrix(edev->device, matrix) !=
1634 LIBINPUT_CONFIG_STATUS_SUCCESS)
1636 WRN("Failed to set input transformation about device: %s\n",
1637 libinput_device_get_name(edev->device));
1645 e_input_evdev_mouse_accel_speed_set(E_Input_Evdev *edev, double speed)
1647 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1648 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1650 if (!libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
1653 if (!libinput_device_config_accel_is_available(edev->device))
1656 if (libinput_device_config_accel_set_speed(edev->device, speed) !=
1657 LIBINPUT_CONFIG_STATUS_SUCCESS)
1659 WRN("Failed to set mouse accel about device: %s\n",
1660 libinput_device_get_name(edev->device));
1667 EINTERN unsigned int
1668 e_input_evdev_touch_pressed_get(E_Input_Evdev *edev)
1670 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, 0x0);
1672 return edev->touch.pressed;