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;
832 if (!(edev = libinput_device_get_user_data(device)))
836 if (!(input = edev->seat->input))
841 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
842 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
844 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
846 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_MOUSE)
851 else if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_NONE)
856 if (!ecore_dev && e_devicemgr_detent_is_detent(libinput_device_get_name(edev->device)))
858 ecore_dev = detent_data;
863 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
864 ecore_dev = edev->ecore_dev;
869 ERR("Failed to get source ecore device from event !\n");
873 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
878 timestamp = libinput_event_pointer_get_time(event);
880 ev->window = (Ecore_Window)input->dev->window;
881 ev->event_window = (Ecore_Window)input->dev->window;
882 ev->root_window = (Ecore_Window)input->dev->window;
883 ev->timestamp = timestamp;
886 _device_modifiers_update(edev);
887 ev->modifiers = edev->xkb.modifiers;
889 ev->x = edev->seat->ptr.ix;
890 ev->y = edev->seat->ptr.iy;
893 ev->dev = ecore_device_ref(ecore_dev);
895 axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
896 if (libinput_event_pointer_has_axis(event, axis))
897 ev->z = libinput_event_pointer_get_axis_value(event, axis);
899 axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
900 if (libinput_event_pointer_has_axis(event, axis))
903 ev->z = libinput_event_pointer_get_axis_value(event, axis);
906 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, _e_input_event_mouse_wheel_cb_free, NULL);
910 _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch *event, int state)
912 E_Input_Backend *input;
913 Ecore_Event_Mouse_Button *ev;
914 uint32_t timestamp, button = 0;
915 Ecore_Device *ecore_dev = NULL, *data;
919 if (!(input = edev->seat->input)) return;
921 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
922 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
924 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
926 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
935 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
936 ecore_dev = edev->ecore_dev;
941 ERR("Failed to get source ecore device from event !\n");
945 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
947 timestamp = libinput_event_touch_get_time(event);
949 ev->window = (Ecore_Window)input->dev->window;
950 ev->event_window = (Ecore_Window)input->dev->window;
951 ev->root_window = (Ecore_Window)input->dev->window;
952 ev->timestamp = timestamp;
955 _device_modifiers_update(edev);
956 ev->modifiers = edev->xkb.modifiers;
958 ev->x = edev->seat->ptr.ix;
959 ev->y = edev->seat->ptr.iy;
963 ev->multi.device = edev->mt_slot;
964 ev->multi.radius = 1;
965 ev->multi.radius_x = 1;
966 ev->multi.radius_y = 1;
967 ev->multi.pressure = 1.0;
968 ev->multi.angle = 0.0;
969 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
970 if (libinput_event_get_type(libinput_event_touch_get_base_event(event))
971 == LIBINPUT_EVENT_TOUCH_DOWN)
973 if (libinput_event_touch_has_minor(event))
974 ev->multi.radius_x = libinput_event_touch_get_minor(event);
975 if (libinput_event_touch_has_major(event))
976 ev->multi.radius_y = libinput_event_touch_get_major(event);
977 if (libinput_event_touch_has_pressure(event))
978 ev->multi.pressure = libinput_event_touch_get_pressure(event);
979 if (libinput_event_touch_has_orientation(event))
980 ev->multi.angle = libinput_event_touch_get_orientation(event);
985 ev->multi.root.x = ev->x;
986 ev->multi.root.y = ev->y;
987 ev->dev = ecore_device_ref(ecore_dev);
989 if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN)
991 unsigned int current;
994 edev->mouse.did_double = EINA_FALSE;
995 edev->mouse.did_triple = EINA_FALSE;
997 if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
998 (button == edev->mouse.prev_button))
1000 edev->mouse.did_double = EINA_TRUE;
1001 if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
1002 (button == edev->mouse.last_button))
1004 edev->mouse.did_triple = EINA_TRUE;
1005 edev->mouse.prev = 0;
1006 edev->mouse.last = 0;
1011 edev->mouse.last = edev->mouse.prev;
1012 edev->mouse.prev = current;
1013 edev->mouse.last_button = edev->mouse.prev_button;
1014 edev->mouse.prev_button = button;
1015 edev->touch.pressed |= (1 << ev->multi.device);
1019 edev->touch.pressed &= ~(1 << ev->multi.device);
1022 ev->buttons = ((button & 0x00F) + 1);
1024 if (edev->mouse.did_double)
1025 ev->double_click = 1;
1026 if (edev->mouse.did_triple)
1027 ev->triple_click = 1;
1029 ecore_event_add(state, ev, _e_input_event_mouse_button_cb_free, NULL);
1033 _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touch *event)
1035 E_Input_Backend *input;
1036 Ecore_Event_Mouse_Move *ev;
1037 Ecore_Device *ecore_dev = NULL, *data;
1041 if (!(input = edev->seat->input)) return;
1043 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1044 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1046 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1048 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1057 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1058 ecore_dev = edev->ecore_dev;
1063 ERR("Failed to get source ecore device from event !\n");
1067 if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
1069 ev->window = (Ecore_Window)input->dev->window;
1070 ev->event_window = (Ecore_Window)input->dev->window;
1071 ev->root_window = (Ecore_Window)input->dev->window;
1072 ev->timestamp = libinput_event_touch_get_time(event);
1073 ev->same_screen = 1;
1075 _device_modifiers_update(edev);
1076 ev->modifiers = edev->xkb.modifiers;
1078 ev->x = edev->seat->ptr.ix;
1079 ev->y = edev->seat->ptr.iy;
1083 ev->multi.device = edev->mt_slot;
1084 ev->multi.radius = 1;
1085 ev->multi.radius_x = 1;
1086 ev->multi.radius_y = 1;
1087 ev->multi.pressure = 1.0;
1088 ev->multi.angle = 0.0;
1089 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
1090 if (libinput_event_touch_has_minor(event))
1091 ev->multi.radius_x = libinput_event_touch_get_minor(event);
1092 if (libinput_event_touch_has_major(event))
1093 ev->multi.radius_y = libinput_event_touch_get_major(event);
1094 if (libinput_event_touch_has_pressure(event))
1095 ev->multi.pressure = libinput_event_touch_get_pressure(event);
1096 if (libinput_event_touch_has_orientation(event))
1097 ev->multi.angle = libinput_event_touch_get_orientation(event);
1099 ev->multi.x = ev->x;
1100 ev->multi.y = ev->y;
1101 ev->multi.root.x = ev->x;
1102 ev->multi.root.y = ev->y;
1103 ev->dev = ecore_device_ref(ecore_dev);
1105 ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, _e_input_event_mouse_move_cb_free, NULL);
1109 _device_handle_touch_down(struct libinput_device *device, struct libinput_event_touch *event)
1111 E_Input_Evdev *edev;
1113 E_Comp_Config *comp_conf = NULL;
1115 if (!(edev = libinput_device_get_user_data(device)))
1120 e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
1122 edev->mouse.dx = edev->seat->ptr.ix = edev->seat->ptr.dx =
1123 libinput_event_touch_get_x_transformed(event, w);
1124 edev->mouse.dy = edev->seat->ptr.iy = edev->seat->ptr.dy =
1125 libinput_event_touch_get_y_transformed(event, h);
1127 edev->mt_slot = libinput_event_touch_get_slot(event);
1128 if (edev->mt_slot < 0)
1130 /* FIXME: The single touch device return slot id -1
1131 * But currently we have no API to distinguish multi touch or single touch
1132 * After libinput 1.11 version, libinput provides get_touch_count API,
1133 * so we can distinguish multi touch device or single touch device.
1135 if (edev->mt_slot == -1)
1139 WRN("%d slot touch down events are not supported\n", edev->mt_slot);
1144 if (edev->mt_slot < E_INPUT_MAX_SLOTS)
1146 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1147 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1150 comp_conf = e_comp_config_get();
1151 if (comp_conf && comp_conf->input_log_enable)
1152 ELOGF("Touch", "Down (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1154 _device_handle_touch_motion_send(edev, event);
1155 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN);
1159 _device_handle_touch_motion(struct libinput_device *device, struct libinput_event_touch *event)
1161 E_Input_Evdev *edev;
1164 if (!(edev = libinput_device_get_user_data(device)))
1169 e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
1171 edev->mouse.dx = edev->seat->ptr.dx =
1172 libinput_event_touch_get_x_transformed(event, w);
1173 edev->mouse.dy = edev->seat->ptr.dy =
1174 libinput_event_touch_get_y_transformed(event, h);
1176 if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
1177 floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
1182 edev->seat->ptr.ix = edev->seat->ptr.dx;
1183 edev->seat->ptr.iy = edev->seat->ptr.dy;
1185 edev->mt_slot = libinput_event_touch_get_slot(event);
1186 if (edev->mt_slot < 0)
1188 /* FIXME: The single touch device return slot id -1
1189 * But currently we have no API to distinguish multi touch or single touch
1190 * After libinput 1.11 version, libinput provides get_touch_count API,
1191 * so we can distinguish multi touch device or single touch device.
1193 if (edev->mt_slot == -1)
1197 WRN("%d slot touch motion events are not supported\n", edev->mt_slot);
1202 if (edev->mt_slot < E_INPUT_MAX_SLOTS)
1204 edev->touch.coords[edev->mt_slot].x = edev->seat->ptr.ix;
1205 edev->touch.coords[edev->mt_slot].y = edev->seat->ptr.iy;
1208 _device_handle_touch_motion_send(edev, event);
1212 _device_handle_touch_up(struct libinput_device *device, struct libinput_event_touch *event)
1214 E_Input_Evdev *edev;
1215 E_Comp_Config *comp_conf = NULL;
1217 if (!(edev = libinput_device_get_user_data(device)))
1222 edev->mt_slot = libinput_event_touch_get_slot(event);
1223 if (edev->mt_slot < 0)
1225 /* FIXME: The single touch device return slot id -1
1226 * But currently we have no API to distinguish multi touch or single touch
1227 * After libinput 1.11 version, libinput provides get_touch_count API,
1228 * so we can distinguish multi touch device or single touch device.
1230 if (edev->mt_slot == -1)
1234 WRN("%d slot touch up events are not supported\n", edev->mt_slot);
1239 if (edev->mt_slot < E_INPUT_MAX_SLOTS)
1241 edev->mouse.dx = edev->seat->ptr.dx = edev->seat->ptr.ix =
1242 edev->touch.coords[edev->mt_slot].x;
1243 edev->mouse.dy = edev->seat->ptr.dy = edev->seat->ptr.iy =
1244 edev->touch.coords[edev->mt_slot].y;
1247 comp_conf = e_comp_config_get();
1248 if (comp_conf && comp_conf->input_log_enable)
1249 ELOGF("Touch", "Up (id: %d, x: %d, y: %d)", NULL, edev->mt_slot, edev->seat->ptr.ix, edev->seat->ptr.iy);
1251 _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_UP);
1255 _device_handle_touch_frame(struct libinput_device *device EINA_UNUSED, struct libinput_event_touch *event EINA_UNUSED)
1257 /* DBG("Unhandled Touch Frame Event"); */
1261 _e_input_aux_data_event_free(void *user_data EINA_UNUSED, void *ev)
1263 Ecore_Event_Axis_Update *e = (Ecore_Event_Axis_Update *)ev;
1265 if (e->axis) free(e->axis);
1266 if (e->dev) ecore_device_unref(e->dev);
1272 _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_event_touch_aux_data *event)
1274 E_Input_Evdev *edev;
1275 E_Input_Backend *input;
1276 Ecore_Event_Axis_Update *ev;
1278 Ecore_Device *ecore_dev = NULL, *data;
1281 if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
1282 libinput_event_touch_aux_data_get_value(event) > 0)
1285 if (!(edev = libinput_device_get_user_data(device))) goto end;
1286 if (!(input = edev->seat->input)) goto end;
1288 if (edev->ecore_dev) ecore_dev = edev->ecore_dev;
1289 else if (edev->ecore_dev_list && eina_list_count(edev->ecore_dev_list) > 0)
1291 EINA_LIST_FOREACH(edev->ecore_dev_list, l, data)
1293 if (ecore_device_class_get(data) == ECORE_DEVICE_CLASS_TOUCH)
1302 edev->ecore_dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
1303 ecore_dev = edev->ecore_dev;
1308 ERR("Failed to get source ecore device from event !\n");
1312 if (!(ev = calloc(1, sizeof(Ecore_Event_Axis_Update))))goto end;
1314 ev->window = (Ecore_Window)input->dev->window;
1315 ev->event_window = (Ecore_Window)input->dev->window;
1316 ev->root_window = (Ecore_Window)input->dev->window;
1317 ev->timestamp = libinput_event_touch_aux_data_get_time(event);
1319 axis = (Ecore_Axis *)calloc(1, sizeof(Ecore_Axis));
1322 axis->label = ECORE_AXIS_LABEL_TOUCH_PALM;
1323 axis->value = libinput_event_touch_aux_data_get_value(event);
1327 ev->dev = ecore_device_ref(ecore_dev);
1329 ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
1336 _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
1338 E_Input_Evdev *edev;
1339 E_Input_Backend *b_input;
1341 EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
1343 /* try to allocate space for new evdev */
1344 if (!(edev = calloc(1, sizeof(E_Input_Evdev)))) return NULL;
1347 edev->device = device;
1348 edev->path = eina_stringshare_printf("%s/%s", e_input_base_dir_get(), libinput_device_get_sysname(device));
1350 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
1352 edev->caps |= E_INPUT_SEAT_KEYBOARD;
1353 _device_keyboard_setup(edev);
1356 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
1358 edev->caps |= E_INPUT_SEAT_POINTER;
1360 /* TODO: make this configurable */
1361 edev->mouse.threshold = 250;
1363 b_input = seat->input;
1364 if (b_input->left_handed == EINA_TRUE)
1366 if (libinput_device_config_left_handed_set(device, 1) !=
1367 LIBINPUT_CONFIG_STATUS_SUCCESS)
1369 WRN("Failed to set left hand mode about device: %s\n",
1370 libinput_device_get_name(device));
1375 if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
1378 edev->caps |= E_INPUT_SEAT_TOUCH;
1379 palm_code = libinput_device_touch_aux_data_get_code(LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM);
1380 if (libinput_device_touch_has_aux_data(device, palm_code))
1382 libinput_device_touch_set_aux_data(device, palm_code);
1386 libinput_device_set_user_data(device, edev);
1387 libinput_device_ref(device);
1389 /* configure device */
1390 _device_configure(edev);
1396 _e_input_evdev_device_destroy(E_Input_Evdev *edev)
1400 EINA_SAFETY_ON_NULL_RETURN(edev);
1402 if (edev->caps & E_INPUT_SEAT_KEYBOARD)
1404 if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
1405 if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
1408 if (edev->ecore_dev) ecore_device_del(edev->ecore_dev);
1409 if (edev->ecore_dev_list)
1410 EINA_LIST_FREE(edev->ecore_dev_list, dev)
1412 ecore_device_del(dev);
1414 if (edev->path) eina_stringshare_del(edev->path);
1415 if (edev->device) libinput_device_unref(edev->device);
1416 if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
1422 _e_input_evdev_event_process(struct libinput_event *event)
1424 struct libinput_device *device;
1425 Eina_Bool ret = EINA_TRUE;
1427 device = libinput_event_get_device(event);
1428 switch (libinput_event_get_type(event))
1430 case LIBINPUT_EVENT_KEYBOARD_KEY:
1431 _device_handle_key(device, libinput_event_get_keyboard_event(event));
1433 case LIBINPUT_EVENT_POINTER_MOTION:
1434 _device_handle_pointer_motion(device,
1435 libinput_event_get_pointer_event(event));
1437 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
1438 _device_handle_pointer_motion_absolute(device,
1439 libinput_event_get_pointer_event(event));
1441 case LIBINPUT_EVENT_POINTER_BUTTON:
1442 _device_handle_button(device, libinput_event_get_pointer_event(event));
1444 case LIBINPUT_EVENT_POINTER_AXIS:
1445 _device_handle_axis(device, libinput_event_get_pointer_event(event));
1447 case LIBINPUT_EVENT_TOUCH_DOWN:
1448 _device_handle_touch_down(device, libinput_event_get_touch_event(event));
1450 case LIBINPUT_EVENT_TOUCH_MOTION:
1451 _device_handle_touch_motion(device,
1452 libinput_event_get_touch_event(event));
1454 case LIBINPUT_EVENT_TOUCH_UP:
1455 _device_handle_touch_up(device, libinput_event_get_touch_event(event));
1457 case LIBINPUT_EVENT_TOUCH_FRAME:
1458 _device_handle_touch_frame(device, libinput_event_get_touch_event(event));
1460 case LIBINPUT_EVENT_TOUCH_AUX_DATA:
1461 _device_handle_touch_aux_data(device, libinput_event_get_touch_aux_data(event));
1472 * @brief Set the axis size of the given device.
1474 * @param dev The device to set the axis size to.
1475 * @param w The width of the axis.
1476 * @param h The height of the axis.
1478 * This function sets set the width @p w and height @p h of the axis
1479 * of device @p dev. If @p dev is a relative input device, a width and
1480 * height must set for it. If its absolute set the ioctl correctly, if
1481 * not, unsupported device.
1484 e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h)
1486 const char *sysname;
1491 enum libinput_config_status status;
1493 EINA_SAFETY_ON_NULL_RETURN(edev);
1494 EINA_SAFETY_ON_TRUE_RETURN((w == 0) || (h == 0));
1496 if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
1497 (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
1500 sysname = libinput_device_get_sysname(edev->device);
1502 devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
1503 if (eina_list_count(devices) < 1) return;
1505 EINA_LIST_FREE(devices, device)
1507 vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
1509 (sscanf(vals, "%f %f %f %f %f %f",
1510 &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
1517 libinput_device_config_calibration_set_matrix(edev->device, cal);
1519 if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
1520 ERR("Failed to apply calibration");
1523 eina_stringshare_del(device);
1529 e_input_evdev_name_get(E_Input_Evdev *evdev)
1531 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
1532 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
1534 return libinput_device_get_name(evdev->device);
1537 EINTERN const char *
1538 e_input_evdev_sysname_get(E_Input_Evdev *evdev)
1540 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
1541 EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
1543 return libinput_device_get_sysname(evdev->device);
1547 e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool enable)
1549 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1550 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1552 edev->key_remap_enabled = enable;
1554 if (enable == EINA_FALSE && edev->key_remap_hash)
1556 eina_hash_free(edev->key_remap_hash);
1557 edev->key_remap_hash = NULL;
1564 e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num)
1568 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1569 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1570 EINA_SAFETY_ON_NULL_RETURN_VAL(from_keys, EINA_FALSE);
1571 EINA_SAFETY_ON_NULL_RETURN_VAL(to_keys, EINA_FALSE);
1572 EINA_SAFETY_ON_TRUE_RETURN_VAL(num <= 0, EINA_FALSE);
1573 EINA_SAFETY_ON_TRUE_RETURN_VAL(!edev->key_remap_enabled, EINA_FALSE);
1575 if (edev->key_remap_hash == NULL)
1576 edev->key_remap_hash = eina_hash_int32_new(NULL);
1578 if (edev->key_remap_hash == NULL)
1580 ERR("Failed to set remap key information : creating a hash is failed.");
1584 for (i = 0; i < num ; i++)
1586 if (!from_keys[i] || !to_keys[i])
1588 ERR("Failed to set remap key information : given arguments are invalid.");
1593 for (i = 0; i < num ; i++)
1595 eina_hash_add(edev->key_remap_hash, &from_keys[i], (void *)(intptr_t)to_keys[i]);
1602 e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev)
1604 EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
1605 return libinput_device_config_scroll_get_wheel_click_angle(dev->device);
1609 e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6])
1611 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1612 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1614 if (!libinput_device_config_calibration_has_matrix(edev->device) ||
1615 !libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_TOUCH))
1618 if (libinput_device_config_calibration_set_matrix(edev->device, matrix) !=
1619 LIBINPUT_CONFIG_STATUS_SUCCESS)
1621 WRN("Failed to set input transformation about device: %s\n",
1622 libinput_device_get_name(edev->device));
1630 e_input_evdev_mouse_accel_speed_set(E_Input_Evdev *edev, double speed)
1632 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1633 EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1635 if (!libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
1638 if (!libinput_device_config_accel_is_available(edev->device))
1641 if (libinput_device_config_accel_set_speed(edev->device, speed) !=
1642 LIBINPUT_CONFIG_STATUS_SUCCESS)
1644 WRN("Failed to set mouse accel about device: %s\n",
1645 libinput_device_get_name(edev->device));
1652 EINTERN unsigned int
1653 e_input_evdev_touch_pressed_get(E_Input_Evdev *edev)
1655 EINA_SAFETY_ON_NULL_RETURN_VAL(edev, 0x0);
1657 return edev->touch.pressed;