e_input_evdev: check a invalid shifting value
[platform/upstream/enlightenment.git] / src / bin / e_input_evdev.c
1 #include "e.h"
2 #include "e_input_private.h"
3
4 static void  _device_modifiers_update(E_Input_Evdev *edev);
5
6 static void
7 _device_calibration_set(E_Input_Evdev *edev)
8 {
9    E_Output *output;
10    int w = 0, h = 0;
11    int temp;
12
13    output = e_comp_screen_primary_output_get(e_comp->e_comp_screen);
14    e_output_size_get(output, &w, &h);
15
16    if (output)
17      {
18         edev->mouse.minx = edev->mouse.miny = 0;
19         edev->mouse.maxw = w;
20         edev->mouse.maxh = h;
21
22         if (libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_POINTER))
23           {
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;
30
31              if (output->config.rotation == 90 || output->config.rotation == 270)
32                {
33                   temp = edev->mouse.minx;
34                   edev->mouse.minx = edev->mouse.miny;
35                   edev->mouse.miny = temp;
36
37                   temp = edev->mouse.maxw;
38                   edev->mouse.maxw = edev->mouse.maxh;
39                   edev->mouse.maxh = temp;
40                }
41           }
42      }
43
44 //LCOV_EXCL_START
45 #ifdef _F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
46    const char *sysname;
47    float cal[6];
48    const char *device;
49    Eina_List *devices;
50
51    if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
52        (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
53      return;
54
55    sysname = libinput_device_get_sysname(edev->device);
56
57    devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
58    if (eina_list_count(devices) < 1) return;
59
60 #ifdef _F_E_INPUT_USE_WL_CALIBRATION_
61    const char *vals;
62    enum libinput_config_status status;
63
64    EINA_LIST_FREE(devices, device)
65      {
66         vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
67         if ((!vals) ||
68             (sscanf(vals, "%f %f %f %f %f %f",
69                     &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
70           goto cont;
71
72         cal[2] /= w;
73         cal[5] /= h;
74
75         status =
76           libinput_device_config_calibration_set_matrix(edev->device, cal);
77
78         if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
79           ERR("Failed to apply calibration");
80
81 cont:
82         eina_stringshare_del(device);
83         continue;
84      }
85 #endif//_F_E_INPUT_USE_WL_CALIBRATION_
86 #endif//_F_E_INPUT_ENABLE_DEVICE_CALIBRATION_
87 //LCOV_EXCL_STOP
88 }
89
90 static void
91 _device_configure(E_Input_Evdev *edev)
92 {
93    if (libinput_device_config_tap_get_finger_count(edev->device) > 0)
94      {
95         Eina_Bool tap = EINA_FALSE;
96
97         tap = libinput_device_config_tap_get_default_enabled(edev->device);
98         libinput_device_config_tap_set_enabled(edev->device, tap);
99      }
100
101    _device_calibration_set(edev);
102 }
103
104 static void
105 _device_keyboard_setup(E_Input_Evdev *edev)
106 {
107    E_Input_Backend *input;
108    xkb_mod_index_t xkb_idx;
109
110    if ((!edev) || (!edev->seat)) return;
111    if (!(input = edev->seat->input)) return;
112    if (!input->dev->xkb_ctx) return;
113
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)
117      {
118         ERR("Failed to create keymap: %m");
119         return;
120      }
121
122    /* create xkb state */
123    if (!(edev->xkb.state = xkb_state_new(edev->xkb.keymap)))
124      {
125         ERR("Failed to create xkb state: %m");
126         return;
127      }
128
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;
132    else
133      edev->xkb.ctrl_mask = 0;
134
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;
138    else
139      edev->xkb.alt_mask = 0;
140
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;
144    else
145      edev->xkb.shift_mask = 0;
146
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;
150    else
151      edev->xkb.win_mask = 0;
152
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;
156    else
157      edev->xkb.scroll_mask = 0;
158
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;
162    else
163      edev->xkb.num_mask = 0;
164
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;
168    else
169      edev->xkb.caps_mask = 0;
170
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;
174    else
175      edev->xkb.altgr_mask = 0;
176 }
177
178 static int
179 _device_keysym_translate(xkb_keysym_t keysym, unsigned int modifiers, char *buffer, int bytes)
180 {
181    unsigned long hbytes = 0;
182    unsigned char c;
183
184    if (!keysym) return 0;
185    hbytes = (keysym >> 8);
186
187    if (!(bytes &&
188          ((hbytes == 0) ||
189           ((hbytes == 0xFF) &&
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))))))
196      return 0;
197
198    if (keysym == XKB_KEY_KP_Space)
199      c = (XKB_KEY_space & 0x7F);
200    else if (hbytes == 0xFF)
201      c = (keysym & 0x7F);
202    else
203      c = (keysym & 0xFF);
204
205    if (modifiers & ECORE_EVENT_MODIFIER_CTRL)
206      {
207         if (((c >= '@') && (c < '\177')) || c == ' ')
208           c &= 0x1F;
209         else if (c == '2')
210           c = '\000';
211         else if ((c >= '3') && (c <= '7'))
212           c -= ('3' - '\033');
213         else if (c == '8')
214           c = '\177';
215         else if (c == '/')
216           c = '_' & 0x1F;
217      }
218    buffer[0] = c;
219    return 1;
220 }
221
222 static void
223 _device_modifiers_update_device(E_Input_Evdev *edev, E_Input_Evdev *from)
224 {
225    xkb_mod_mask_t mask;
226
227    edev->xkb.depressed =
228      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_DEPRESSED);
229    edev->xkb.latched =
230      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LATCHED);
231    edev->xkb.locked =
232      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_LOCKED);
233    edev->xkb.group =
234      xkb_state_serialize_mods(from->xkb.state, XKB_STATE_EFFECTIVE);
235
236    mask = (edev->xkb.depressed | edev->xkb.latched);
237
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;
254 }
255
256 static void
257 _device_modifiers_update(E_Input_Evdev *edev)
258 {
259    Eina_List *l;
260    E_Input_Evdev *ed;
261
262    edev->xkb.modifiers = 0;
263
264    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
265      _device_modifiers_update_device(edev, edev);
266    else
267      {
268         EINA_LIST_FOREACH(edev->seat->devices, l, ed)
269           {
270              if (!(ed->caps & E_INPUT_SEAT_KEYBOARD)) continue;
271              _device_modifiers_update_device(edev, ed);
272           }
273      }
274
275 }
276
277 static int
278 _device_remapped_key_get(E_Input_Evdev *edev, int code)
279 {
280    void *ret = NULL;
281
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);
285
286    ret = eina_hash_find(edev->key_remap_hash, &code);
287
288    if (ret) code = (int)(intptr_t)ret;
289
290    return code;
291 }
292
293 E_API Ecore_Device *
294 e_input_evdev_get_ecore_device(const char *path, Ecore_Device_Class clas)
295 {
296    const Eina_List *dev_list = NULL;
297    const Eina_List *l;
298    Ecore_Device *dev = NULL;
299    const char *identifier;
300
301    if (!path) return NULL;
302
303    dev_list = ecore_device_list();
304    if (!dev_list) return NULL;
305    EINA_LIST_FOREACH(dev_list, l, dev)
306      {
307         if (!dev) continue;
308         identifier = ecore_device_identifier_get(dev);
309         if (!identifier) continue;
310         if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
311           return dev;
312      }
313    return NULL;
314 }
315
316 static void
317 _device_handle_key(struct libinput_device *device, struct libinput_event_keyboard *event)
318 {
319    E_Input_Evdev *edev;
320    E_Input_Backend *input;
321    uint32_t timestamp;
322    uint32_t code, nsyms;
323    const xkb_keysym_t *syms;
324    enum libinput_key_state state;
325    int key_count;
326    xkb_keysym_t sym = XKB_KEY_NoSymbol;
327    char key[256], keyname[256], compose_buffer[256];
328    Ecore_Event_Key *e;
329    char *tmp = NULL, *compose = NULL;
330
331    if (!(edev = libinput_device_get_user_data(device)))
332      {
333         return;
334      }
335
336    if (!(input = edev->seat->input))
337      {
338         return;
339      }
340
341    timestamp = libinput_event_keyboard_get_time(event);
342    code = libinput_event_keyboard_get_key(event);
343    code = _device_remapped_key_get(edev, code) + 8;
344    state = libinput_event_keyboard_get_key_state(event);
345    key_count = libinput_event_keyboard_get_seat_key_count(event);
346
347    /* ignore key events that are not seat wide state changes */
348    if (((state == LIBINPUT_KEY_STATE_PRESSED) && (key_count != 1)) ||
349        ((state == LIBINPUT_KEY_STATE_RELEASED) && (key_count != 0)))
350      {
351         return;
352      }
353
354    xkb_state_update_key(edev->xkb.state, code,
355                         (state ? XKB_KEY_DOWN : XKB_KEY_UP));
356
357    /* get the keysym for this code */
358    nsyms = xkb_key_get_syms(edev->xkb.state, code, &syms);
359    if (nsyms == 1) sym = syms[0];
360
361    /* get the keyname for this sym */
362    memset(key, 0, sizeof(key));
363    xkb_keysym_get_name(sym, key, sizeof(key));
364
365    memset(keyname, 0, sizeof(keyname));
366    memcpy(keyname, key, sizeof(keyname));
367
368    if (keyname[0] == '\0')
369      snprintf(keyname, sizeof(keyname), "Keycode-%u", code);
370
371    /* if shift is active, we need to transform the key to lower */
372    if (xkb_state_mod_index_is_active(edev->xkb.state,
373                                      xkb_map_mod_get_index(edev->xkb.keymap,
374                                      XKB_MOD_NAME_SHIFT),
375                                      XKB_STATE_MODS_EFFECTIVE))
376      {
377         if (keyname[0] != '\0')
378           keyname[0] = tolower(keyname[0]);
379      }
380
381    memset(compose_buffer, 0, sizeof(compose_buffer));
382    if (_device_keysym_translate(sym, edev->xkb.modifiers,
383                                 compose_buffer, sizeof(compose_buffer)))
384      {
385         compose = eina_str_convert("ISO8859-1", "UTF-8", compose_buffer);
386         if (!compose)
387           {
388              ERR("E Input cannot convert input key string '%s' to UTF-8. "
389                  "Is Eina built with iconv support?", compose_buffer);
390           }
391         else
392           tmp = compose;
393      }
394
395    if (!compose) compose = compose_buffer;
396
397    e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
398               ((compose[0] != '\0') ? strlen(compose) : 0) + 3);
399    if (!e)
400      {
401         E_FREE(tmp);
402         return;
403      }
404
405    e->keyname = (char *)(e + 1);
406    e->key = e->keyname + strlen(keyname) + 1;
407    e->compose = strlen(compose) ? e->key + strlen(key) + 1 : NULL;
408    e->string = e->compose;
409
410    strncpy((char *)e->keyname, keyname, strlen(keyname));
411    strncpy((char *)e->key, key, strlen(key));
412    if (strlen(compose)) strncpy((char *)e->compose, compose, strlen(compose));
413
414    e->window = (Ecore_Window)input->dev->window;
415    e->event_window = (Ecore_Window)input->dev->window;
416    e->root_window = (Ecore_Window)input->dev->window;
417    e->timestamp = timestamp;
418    e->same_screen = 1;
419    e->keycode = code;
420    e->data = NULL;
421
422    _device_modifiers_update(edev);
423
424    e->modifiers = edev->xkb.modifiers;
425    e->dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_KEYBOARD);
426
427    if (state)
428      ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL);
429    else
430      ecore_event_add(ECORE_EVENT_KEY_UP, e, NULL, NULL);
431
432    if (tmp) free(tmp);
433 }
434
435 static void
436 _device_pointer_motion(E_Input_Evdev *edev, struct libinput_event_pointer *event)
437 {
438    E_Input_Backend *input;
439    Ecore_Event_Mouse_Move *ev;
440
441    if (!(input = edev->seat->input)) return;
442
443    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
444
445    if (edev->seat->ptr.ix < edev->mouse.minx)
446      edev->seat->ptr.dx = edev->seat->ptr.ix = edev->mouse.minx;
447    else if (edev->seat->ptr.ix >= (edev->mouse.minx + edev->mouse.maxw))
448      edev->seat->ptr.dx = edev->seat->ptr.ix = (edev->mouse.minx + edev->mouse.maxw - 1);
449
450    if (edev->seat->ptr.iy < edev->mouse.miny)
451      edev->seat->ptr.dy = edev->seat->ptr.iy = edev->mouse.miny;
452    else if (edev->seat->ptr.iy >= (edev->mouse.miny + edev->mouse.maxh))
453      edev->seat->ptr.dy = edev->seat->ptr.iy = (edev->mouse.miny + edev->mouse.maxh - 1);
454
455    edev->mouse.dx = edev->seat->ptr.dx;
456    edev->mouse.dy = edev->seat->ptr.dy;
457
458    ev->window = (Ecore_Window)input->dev->window;
459    ev->event_window = (Ecore_Window)input->dev->window;
460    ev->root_window = (Ecore_Window)input->dev->window;
461    if (event) ev->timestamp = libinput_event_pointer_get_time(event);
462    ev->same_screen = 1;
463
464    _device_modifiers_update(edev);
465    ev->modifiers = edev->xkb.modifiers;
466
467    ev->x = edev->seat->ptr.ix;
468    ev->y = edev->seat->ptr.iy;
469    ev->root.x = ev->x;
470    ev->root.y = ev->y;
471
472    ev->multi.device = edev->mt_slot;
473    ev->multi.radius = 1;
474    ev->multi.radius_x = 1;
475    ev->multi.radius_y = 1;
476    ev->multi.pressure = 1.0;
477    ev->multi.angle = 0.0;
478    ev->multi.x = ev->x;
479    ev->multi.y = ev->y;
480    ev->multi.root.x = ev->x;
481    ev->multi.root.y = ev->y;
482    ev->dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
483
484    ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
485 }
486
487 void
488 _e_input_pointer_motion_post(E_Input_Evdev *edev)
489 {
490    _device_pointer_motion(edev, NULL);
491 }
492
493 static void
494 _device_handle_pointer_motion(struct libinput_device *device, struct libinput_event_pointer *event)
495 {
496    E_Input_Evdev *edev;
497    double dx, dy, temp;
498
499    if (!(edev = libinput_device_get_user_data(device)))
500      {
501         return;
502      }
503
504    dx = libinput_event_pointer_get_dx(event);
505    dy = libinput_event_pointer_get_dy(event);
506
507    if (edev->seat->ptr.swap)
508      {
509          temp = dx;
510          dx = dy;
511          dy = temp;
512      }
513    if (edev->seat->ptr.invert_x)
514      dx *= -1;
515    if (edev->seat->ptr.invert_y)
516      dy *= -1;
517
518    edev->seat->ptr.dx += dx;
519    edev->seat->ptr.dy += dy;
520
521    edev->mouse.dx = edev->seat->ptr.dx;
522    edev->mouse.dy = edev->seat->ptr.dy;
523
524    if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
525        floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
526      {
527         return;
528      }
529
530    edev->seat->ptr.ix = edev->seat->ptr.dx;
531    edev->seat->ptr.iy = edev->seat->ptr.dy;
532
533   _device_pointer_motion(edev, event);
534 }
535
536 static void
537 _device_handle_pointer_motion_absolute(struct libinput_device *device, struct libinput_event_pointer *event)
538 {
539    E_Input_Evdev *edev;
540    int w = 0, h = 0;
541
542    if (!(edev = libinput_device_get_user_data(device)))
543      {
544         return;
545      }
546
547    e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
548
549    edev->mouse.dx = edev->seat->ptr.dx =
550      libinput_event_pointer_get_absolute_x_transformed(event, w);
551    edev->mouse.dy = edev->seat->ptr.dy =
552      libinput_event_pointer_get_absolute_y_transformed(event, h);
553
554    if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
555        floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
556      {
557         return;
558      }
559
560    edev->seat->ptr.ix = edev->seat->ptr.dx;
561    edev->seat->ptr.iy = edev->seat->ptr.dy;
562    _device_pointer_motion(edev, event);
563 }
564
565 static void
566 _device_handle_button(struct libinput_device *device, struct libinput_event_pointer *event)
567 {
568    E_Input_Evdev *edev;
569    E_Input_Backend *input;
570    Ecore_Event_Mouse_Button *ev;
571    enum libinput_button_state state;
572    uint32_t button, timestamp;
573
574    if (!(edev = libinput_device_get_user_data(device)))
575      {
576         return;
577      }
578    if (!(input = edev->seat->input))
579      {
580         return;
581      }
582
583    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button))))
584      {
585         return;
586      }
587
588    state = libinput_event_pointer_get_button_state(event);
589    button = libinput_event_pointer_get_button(event);
590    timestamp = libinput_event_pointer_get_time(event);
591
592    button = ((button & 0x00F) + 1);
593    if (button == 3) button = 2;
594    else if (button == 2) button = 3;
595
596    ev->window = (Ecore_Window)input->dev->window;
597    ev->event_window = (Ecore_Window)input->dev->window;
598    ev->root_window = (Ecore_Window)input->dev->window;
599    ev->timestamp = timestamp;
600    ev->same_screen = 1;
601
602    _device_modifiers_update(edev);
603    ev->modifiers = edev->xkb.modifiers;
604
605    ev->x = edev->seat->ptr.ix;
606    ev->y = edev->seat->ptr.iy;
607    ev->root.x = ev->x;
608    ev->root.y = ev->y;
609
610    ev->multi.device = edev->mt_slot;
611    ev->multi.radius = 1;
612    ev->multi.radius_x = 1;
613    ev->multi.radius_y = 1;
614    ev->multi.pressure = 1.0;
615    ev->multi.angle = 0.0;
616    ev->multi.x = ev->x;
617    ev->multi.y = ev->y;
618    ev->multi.root.x = ev->x;
619    ev->multi.root.y = ev->y;
620    ev->dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
621
622    if (state)
623      {
624         unsigned int current;
625
626         current = timestamp;
627         edev->mouse.did_double = EINA_FALSE;
628         edev->mouse.did_triple = EINA_FALSE;
629
630         if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
631             (button == edev->mouse.prev_button))
632           {
633              edev->mouse.did_double = EINA_TRUE;
634              if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
635                  (button == edev->mouse.last_button))
636                {
637                   edev->mouse.did_triple = EINA_TRUE;
638                   edev->mouse.prev = 0;
639                   edev->mouse.last = 0;
640                   current = 0;
641                }
642           }
643
644         edev->mouse.last = edev->mouse.prev;
645         edev->mouse.prev = current;
646         edev->mouse.last_button = edev->mouse.prev_button;
647         edev->mouse.prev_button = button;
648      }
649
650    ev->buttons = button;
651
652    if (edev->mouse.did_double)
653      ev->double_click = 1;
654    if (edev->mouse.did_triple)
655      ev->triple_click = 1;
656
657    if (state)
658      ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
659    else
660      ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
661 }
662
663 static void
664 _device_handle_axis(struct libinput_device *device, struct libinput_event_pointer *event)
665 {
666    E_Input_Evdev *edev;
667    E_Input_Backend *input;
668    Ecore_Event_Mouse_Wheel *ev;
669    uint32_t timestamp;
670    enum libinput_pointer_axis axis;
671
672    if (!(edev = libinput_device_get_user_data(device)))
673      {
674         return;
675      }
676    if (!(input = edev->seat->input))
677      {
678         return;
679      }
680
681    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Wheel))))
682      {
683         return;
684      }
685
686    timestamp = libinput_event_pointer_get_time(event);
687
688    ev->window = (Ecore_Window)input->dev->window;
689    ev->event_window = (Ecore_Window)input->dev->window;
690    ev->root_window = (Ecore_Window)input->dev->window;
691    ev->timestamp = timestamp;
692    ev->same_screen = 1;
693
694    _device_modifiers_update(edev);
695    ev->modifiers = edev->xkb.modifiers;
696
697    ev->x = edev->seat->ptr.ix;
698    ev->y = edev->seat->ptr.iy;
699    ev->root.x = ev->x;
700    ev->root.y = ev->y;
701    ev->dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_MOUSE);
702
703    axis = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL;
704    if (libinput_event_pointer_has_axis(event, axis))
705      ev->z = libinput_event_pointer_get_axis_value(event, axis);
706
707    axis = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL;
708    if (libinput_event_pointer_has_axis(event, axis))
709      {
710         ev->direction = 1;
711         ev->z = libinput_event_pointer_get_axis_value(event, axis);
712      }
713
714    ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, ev, NULL, NULL);
715 }
716
717 static void
718 _device_handle_touch_event_send(E_Input_Evdev *edev, struct libinput_event_touch *event, int state)
719 {
720    E_Input_Backend *input;
721    Ecore_Event_Mouse_Button *ev;
722    uint32_t timestamp, button = 0;
723
724    if (!edev) return;
725    if (!(input = edev->seat->input)) return;
726
727    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)))) return;
728
729    timestamp = libinput_event_touch_get_time(event);
730
731    ev->window = (Ecore_Window)input->dev->window;
732    ev->event_window = (Ecore_Window)input->dev->window;
733    ev->root_window = (Ecore_Window)input->dev->window;
734    ev->timestamp = timestamp;
735    ev->same_screen = 1;
736
737    _device_modifiers_update(edev);
738    ev->modifiers = edev->xkb.modifiers;
739
740    ev->x = edev->seat->ptr.ix;
741    ev->y = edev->seat->ptr.iy;
742    ev->root.x = ev->x;
743    ev->root.y = ev->y;
744
745    ev->multi.device = edev->mt_slot;
746    ev->multi.radius = 1;
747    ev->multi.radius_x = 1;
748    ev->multi.radius_y = 1;
749    ev->multi.pressure = 1.0;
750    ev->multi.angle = 0.0;
751 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
752    if (libinput_event_get_type(libinput_event_touch_get_base_event(event))
753        == LIBINPUT_EVENT_TOUCH_DOWN)
754      {
755         if (libinput_event_touch_has_minor(event))
756           ev->multi.radius_x = libinput_event_touch_get_minor(event);
757         if (libinput_event_touch_has_major(event))
758           ev->multi.radius_y = libinput_event_touch_get_major(event);
759         if (libinput_event_touch_has_pressure(event))
760           ev->multi.pressure = libinput_event_touch_get_pressure(event);
761         if (libinput_event_touch_has_orientation(event))
762           ev->multi.angle = libinput_event_touch_get_orientation(event);
763      }
764 #endif
765    ev->multi.x = ev->x;
766    ev->multi.y = ev->y;
767    ev->multi.root.x = ev->x;
768    ev->multi.root.y = ev->y;
769    ev->dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
770
771    if (state == ECORE_EVENT_MOUSE_BUTTON_DOWN)
772      {
773         unsigned int current;
774
775         current = timestamp;
776         edev->mouse.did_double = EINA_FALSE;
777         edev->mouse.did_triple = EINA_FALSE;
778
779         if (((current - edev->mouse.prev) <= edev->mouse.threshold) &&
780             (button == edev->mouse.prev_button))
781           {
782              edev->mouse.did_double = EINA_TRUE;
783              if (((current - edev->mouse.last) <= (2 * edev->mouse.threshold)) &&
784                  (button == edev->mouse.last_button))
785                {
786                   edev->mouse.did_triple = EINA_TRUE;
787                   edev->mouse.prev = 0;
788                   edev->mouse.last = 0;
789                   current = 0;
790                }
791           }
792
793         edev->mouse.last = edev->mouse.prev;
794         edev->mouse.prev = current;
795         edev->mouse.last_button = edev->mouse.prev_button;
796         edev->mouse.prev_button = button;
797      }
798
799    ev->buttons = ((button & 0x00F) + 1);
800
801    if (edev->mouse.did_double)
802      ev->double_click = 1;
803    if (edev->mouse.did_triple)
804      ev->triple_click = 1;
805
806    ecore_event_add(state, ev, NULL, NULL);
807 }
808
809 static void
810 _device_handle_touch_motion_send(E_Input_Evdev *edev, struct libinput_event_touch *event)
811 {
812    E_Input_Backend *input;
813    Ecore_Event_Mouse_Move *ev;
814
815    if (!edev) return;
816    if (!(input = edev->seat->input)) return;
817
818    if (!(ev = calloc(1, sizeof(Ecore_Event_Mouse_Move)))) return;
819
820    ev->window = (Ecore_Window)input->dev->window;
821    ev->event_window = (Ecore_Window)input->dev->window;
822    ev->root_window = (Ecore_Window)input->dev->window;
823    ev->timestamp = libinput_event_touch_get_time(event);
824    ev->same_screen = 1;
825
826    _device_modifiers_update(edev);
827    ev->modifiers = edev->xkb.modifiers;
828
829    ev->x = edev->seat->ptr.ix;
830    ev->y = edev->seat->ptr.iy;
831    ev->root.x = ev->x;
832    ev->root.y = ev->y;
833
834    ev->multi.device = edev->mt_slot;
835    ev->multi.radius = 1;
836    ev->multi.radius_x = 1;
837    ev->multi.radius_y = 1;
838    ev->multi.pressure = 1.0;
839    ev->multi.angle = 0.0;
840 #if LIBINPUT_SUPPORT_EXTRA_TOUCH_EVENT
841    if (libinput_event_touch_has_minor(event))
842      ev->multi.radius_x = libinput_event_touch_get_minor(event);
843    if (libinput_event_touch_has_major(event))
844      ev->multi.radius_y = libinput_event_touch_get_major(event);
845    if (libinput_event_touch_has_pressure(event))
846      ev->multi.pressure = libinput_event_touch_get_pressure(event);
847    if (libinput_event_touch_has_orientation(event))
848      ev->multi.angle = libinput_event_touch_get_orientation(event);
849 #endif
850    ev->multi.x = ev->x;
851    ev->multi.y = ev->y;
852    ev->multi.root.x = ev->x;
853    ev->multi.root.y = ev->y;
854    ev->dev = e_input_evdev_get_ecore_device(edev->path, ECORE_DEVICE_CLASS_TOUCH);
855
856    ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL);
857 }
858
859 static void
860 _device_handle_touch_down(struct libinput_device *device, struct libinput_event_touch *event)
861 {
862    E_Input_Evdev *edev;
863    int w = 0, h = 0;
864
865    if (!(edev = libinput_device_get_user_data(device)))
866      {
867         return;
868      }
869
870    e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
871
872    edev->mouse.dx = edev->seat->ptr.ix = edev->seat->ptr.dx =
873      libinput_event_touch_get_x_transformed(event, w);
874    edev->mouse.dy = edev->seat->ptr.iy = edev->seat->ptr.dy =
875      libinput_event_touch_get_y_transformed(event, h);
876
877    edev->mt_slot = libinput_event_touch_get_slot(event);
878
879    _device_handle_touch_motion_send(edev, event);
880    _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_DOWN);
881 }
882
883 static void
884 _device_handle_touch_motion(struct libinput_device *device, struct libinput_event_touch *event)
885 {
886    E_Input_Evdev *edev;
887    int w = 0, h = 0;
888
889    if (!(edev = libinput_device_get_user_data(device)))
890      {
891         return;
892      }
893
894    e_output_size_get(e_comp_screen_primary_output_get(e_comp->e_comp_screen), &w, &h);
895
896    edev->mouse.dx = edev->seat->ptr.dx =
897      libinput_event_touch_get_x_transformed(event, w);
898    edev->mouse.dy = edev->seat->ptr.dy =
899      libinput_event_touch_get_y_transformed(event, h);
900
901    if (floor(edev->seat->ptr.dx) == edev->seat->ptr.ix &&
902        floor(edev->seat->ptr.dy) == edev->seat->ptr.iy)
903      {
904         return;
905      }
906
907    edev->seat->ptr.ix = edev->seat->ptr.dx;
908    edev->seat->ptr.iy = edev->seat->ptr.dy;
909
910    edev->mt_slot = libinput_event_touch_get_slot(event);
911
912    _device_handle_touch_motion_send(edev, event);
913 }
914
915 static void
916 _device_handle_touch_up(struct libinput_device *device, struct libinput_event_touch *event)
917 {
918    E_Input_Evdev *edev;
919
920    if (!(edev = libinput_device_get_user_data(device)))
921      {
922         return;
923      }
924
925    edev->mt_slot = libinput_event_touch_get_slot(event);
926    _device_handle_touch_event_send(edev, event, ECORE_EVENT_MOUSE_BUTTON_UP);
927 }
928
929 static void
930 _device_handle_touch_frame(struct libinput_device *device EINA_UNUSED, struct libinput_event_touch *event EINA_UNUSED)
931 {
932    /* DBG("Unhandled Touch Frame Event"); */
933 }
934
935 static void
936 _e_input_aux_data_event_free(void *user_data EINA_UNUSED, void *ev)
937 {
938    Ecore_Event_Axis_Update *e = (Ecore_Event_Axis_Update *)ev;
939    if (e->axis)
940      free(e->axis);
941    free(e);
942 }
943
944 static void
945 _device_handle_touch_aux_data(struct libinput_device *device, struct libinput_event_touch_aux_data *event)
946 {
947    E_Input_Evdev *edev;
948    E_Input_Backend *input;
949    Ecore_Event_Axis_Update *ev;
950    Ecore_Axis *axis;
951
952    if (libinput_event_touch_aux_data_get_type(event) != LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM &&
953        libinput_event_touch_aux_data_get_value(event) > 0)
954       goto end;
955
956    if (!(edev = libinput_device_get_user_data(device))) goto end;
957    if (!(input = edev->seat->input)) goto end;
958    if (!(ev = calloc(1, sizeof(Ecore_Event_Axis_Update))))goto end;
959
960    ev->window = (Ecore_Window)input->dev->window;
961    ev->event_window = (Ecore_Window)input->dev->window;
962    ev->root_window = (Ecore_Window)input->dev->window;
963    ev->timestamp = libinput_event_touch_aux_data_get_time(event);
964
965    axis = (Ecore_Axis *)calloc(1, sizeof(Ecore_Axis));
966    if (axis)
967      {
968         axis->label = ECORE_AXIS_LABEL_TOUCH_PALM;
969         axis->value = libinput_event_touch_aux_data_get_value(event);
970         ev->naxis = 1;
971      }
972    ev->axis = axis;
973
974    ecore_event_add(ECORE_EVENT_AXIS_UPDATE, ev, _e_input_aux_data_event_free, NULL);
975
976 end:
977    ;
978 }
979
980 E_Input_Evdev *
981 _e_input_evdev_device_create(E_Input_Seat *seat, struct libinput_device *device)
982 {
983    E_Input_Evdev *edev;
984    E_Input_Backend *b_input;
985
986    EINA_SAFETY_ON_NULL_RETURN_VAL(seat, NULL);
987
988    /* try to allocate space for new evdev */
989    if (!(edev = calloc(1, sizeof(E_Input_Evdev)))) return NULL;
990
991    edev->seat = seat;
992    edev->device = device;
993    edev->path = eina_stringshare_printf("%s/%s", e_input_base_dir_get(), libinput_device_get_sysname(device));
994    edev->fd = -1;
995
996    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_KEYBOARD))
997      {
998         edev->caps |= E_INPUT_SEAT_KEYBOARD;
999         _device_keyboard_setup(edev);
1000      }
1001
1002    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_POINTER))
1003      {
1004         edev->caps |= E_INPUT_SEAT_POINTER;
1005
1006         /* TODO: make this configurable */
1007         edev->mouse.threshold = 250;
1008
1009         b_input = seat->input;
1010         if (b_input->left_handed == EINA_TRUE)
1011           {
1012              if (libinput_device_config_left_handed_set(device, 1) !=
1013                  LIBINPUT_CONFIG_STATUS_SUCCESS)
1014                {
1015                   WRN("Failed to set left hand mode about device: %s\n",
1016                       libinput_device_get_name(device));
1017                }
1018           }
1019      }
1020
1021    if (libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_TOUCH))
1022      {
1023         int palm_code;
1024         edev->caps |= E_INPUT_SEAT_TOUCH;
1025         palm_code = libinput_device_touch_aux_data_get_code(LIBINPUT_TOUCH_AUX_DATA_TYPE_PALM);
1026         if (libinput_device_touch_has_aux_data(device, palm_code))
1027           {
1028              libinput_device_touch_set_aux_data(device, palm_code);
1029           }
1030      }
1031
1032    libinput_device_set_user_data(device, edev);
1033    libinput_device_ref(device);
1034
1035    /* configure device */
1036    _device_configure(edev);
1037
1038    return edev;
1039 }
1040
1041 void
1042 _e_input_evdev_device_destroy(E_Input_Evdev *edev)
1043 {
1044    EINA_SAFETY_ON_NULL_RETURN(edev);
1045
1046    if (edev->caps & E_INPUT_SEAT_KEYBOARD)
1047      {
1048         if (edev->xkb.state) xkb_state_unref(edev->xkb.state);
1049         if (edev->xkb.keymap) xkb_map_unref(edev->xkb.keymap);
1050      }
1051
1052    if (edev->path) eina_stringshare_del(edev->path);
1053    if (edev->device) libinput_device_unref(edev->device);
1054    if (edev->key_remap_hash) eina_hash_free(edev->key_remap_hash);
1055
1056    free(edev);
1057 }
1058
1059 Eina_Bool
1060 _e_input_evdev_event_process(struct libinput_event *event)
1061 {
1062    struct libinput_device *device;
1063    Eina_Bool ret = EINA_TRUE;
1064
1065    device = libinput_event_get_device(event);
1066    switch (libinput_event_get_type(event))
1067      {
1068       case LIBINPUT_EVENT_KEYBOARD_KEY:
1069         _device_handle_key(device, libinput_event_get_keyboard_event(event));
1070         break;
1071       case LIBINPUT_EVENT_POINTER_MOTION:
1072         _device_handle_pointer_motion(device,
1073                                       libinput_event_get_pointer_event(event));
1074         break;
1075       case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
1076         _device_handle_pointer_motion_absolute(device,
1077                                                libinput_event_get_pointer_event(event));
1078         break;
1079       case LIBINPUT_EVENT_POINTER_BUTTON:
1080         _device_handle_button(device, libinput_event_get_pointer_event(event));
1081         break;
1082       case LIBINPUT_EVENT_POINTER_AXIS:
1083         _device_handle_axis(device, libinput_event_get_pointer_event(event));
1084         break;
1085       case LIBINPUT_EVENT_TOUCH_DOWN:
1086         _device_handle_touch_down(device, libinput_event_get_touch_event(event));
1087         break;
1088       case LIBINPUT_EVENT_TOUCH_MOTION:
1089         _device_handle_touch_motion(device,
1090                                     libinput_event_get_touch_event(event));
1091         break;
1092       case LIBINPUT_EVENT_TOUCH_UP:
1093         _device_handle_touch_up(device, libinput_event_get_touch_event(event));
1094         break;
1095       case LIBINPUT_EVENT_TOUCH_FRAME:
1096         _device_handle_touch_frame(device, libinput_event_get_touch_event(event));
1097         break;
1098       case LIBINPUT_EVENT_TOUCH_AUX_DATA:
1099         _device_handle_touch_aux_data(device, libinput_event_get_touch_aux_data(event));
1100         break;
1101       default:
1102         ret = EINA_FALSE;
1103         break;
1104      }
1105
1106    return ret;
1107 }
1108
1109 /**
1110  * @brief Set the axis size of the given device.
1111  *
1112  * @param dev The device to set the axis size to.
1113  * @param w The width of the axis.
1114  * @param h The height of the axis.
1115  *
1116  * This function sets set the width @p w and height @p h of the axis
1117  * of device @p dev. If @p dev is a relative input device, a width and
1118  * height must set for it. If its absolute set the ioctl correctly, if
1119  * not, unsupported device.
1120  */
1121 EINTERN void
1122 e_input_evdev_axis_size_set(E_Input_Evdev *edev, int w, int h)
1123 {
1124    const char *sysname;
1125    float cal[6];
1126    const char *device;
1127    Eina_List *devices;
1128    const char *vals;
1129    enum libinput_config_status status;
1130
1131    EINA_SAFETY_ON_NULL_RETURN(edev);
1132    EINA_SAFETY_ON_TRUE_RETURN((w == 0) || (h == 0));
1133
1134    if ((!libinput_device_config_calibration_has_matrix(edev->device)) ||
1135        (libinput_device_config_calibration_get_default_matrix(edev->device, cal) != 0))
1136      return;
1137
1138    sysname = libinput_device_get_sysname(edev->device);
1139
1140    devices = eeze_udev_find_by_subsystem_sysname("input", sysname);
1141    if (eina_list_count(devices) < 1) return;
1142
1143    EINA_LIST_FREE(devices, device)
1144      {
1145         vals = eeze_udev_syspath_get_property(device, "WL_CALIBRATION");
1146         if ((!vals) ||
1147             (sscanf(vals, "%f %f %f %f %f %f",
1148                     &cal[0], &cal[1], &cal[2], &cal[3], &cal[4], &cal[5]) != 6))
1149           goto cont;
1150
1151         cal[2] /= w;
1152         cal[5] /= h;
1153
1154         status =
1155           libinput_device_config_calibration_set_matrix(edev->device, cal);
1156
1157         if (status != LIBINPUT_CONFIG_STATUS_SUCCESS)
1158           ERR("Failed to apply calibration");
1159
1160 cont:
1161         eina_stringshare_del(device);
1162         continue;
1163      }
1164 }
1165
1166 E_API const char *
1167 e_input_evdev_name_get(E_Input_Evdev *evdev)
1168 {
1169    EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
1170    EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
1171
1172    return libinput_device_get_name(evdev->device);
1173 }
1174
1175 EINTERN const char *
1176 e_input_evdev_sysname_get(E_Input_Evdev *evdev)
1177 {
1178    EINA_SAFETY_ON_NULL_RETURN_VAL(evdev, NULL);
1179    EINA_SAFETY_ON_NULL_RETURN_VAL(evdev->device, NULL);
1180
1181    return libinput_device_get_sysname(evdev->device);
1182 }
1183
1184 EINTERN Eina_Bool
1185 e_input_evdev_key_remap_enable(E_Input_Evdev *edev, Eina_Bool enable)
1186 {
1187    EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1188    EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1189
1190    edev->key_remap_enabled = enable;
1191
1192    if (enable == EINA_FALSE && edev->key_remap_hash)
1193      {
1194         eina_hash_free(edev->key_remap_hash);
1195         edev->key_remap_hash = NULL;
1196      }
1197
1198    return EINA_TRUE;
1199 }
1200
1201 EINTERN Eina_Bool
1202 e_input_evdev_key_remap_set(E_Input_Evdev *edev, int *from_keys, int *to_keys, int num)
1203 {
1204    int i;
1205
1206    EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1207    EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1208    EINA_SAFETY_ON_NULL_RETURN_VAL(from_keys, EINA_FALSE);
1209    EINA_SAFETY_ON_NULL_RETURN_VAL(to_keys, EINA_FALSE);
1210    EINA_SAFETY_ON_TRUE_RETURN_VAL(num <= 0, EINA_FALSE);
1211    EINA_SAFETY_ON_TRUE_RETURN_VAL(!edev->key_remap_enabled, EINA_FALSE);
1212
1213    if (edev->key_remap_hash == NULL)
1214      edev->key_remap_hash = eina_hash_int32_new(NULL);
1215
1216    if (edev->key_remap_hash == NULL)
1217      {
1218         ERR("Failed to set remap key information : creating a hash is failed.");
1219         return EINA_FALSE;
1220      }
1221
1222    for (i = 0; i < num ; i++)
1223      {
1224         if (!from_keys[i] || !to_keys[i])
1225           {
1226              ERR("Failed to set remap key information : given arguments are invalid.");
1227              return EINA_FALSE;
1228           }
1229      }
1230
1231    for (i = 0; i < num ; i++)
1232      {
1233         eina_hash_add(edev->key_remap_hash, &from_keys[i], (void *)(intptr_t)to_keys[i]);
1234      }
1235
1236    return EINA_TRUE;
1237 }
1238
1239 E_API int
1240 e_input_evdev_wheel_click_angle_get(E_Input_Evdev *dev)
1241 {
1242    EINA_SAFETY_ON_NULL_RETURN_VAL(dev, -1);
1243    return libinput_device_config_scroll_get_wheel_click_angle(dev->device);
1244 }
1245
1246 EINTERN Eina_Bool
1247 e_input_evdev_touch_calibration_set(E_Input_Evdev *edev, float matrix[6])
1248 {
1249    EINA_SAFETY_ON_NULL_RETURN_VAL(edev, EINA_FALSE);
1250    EINA_SAFETY_ON_NULL_RETURN_VAL(edev->device, EINA_FALSE);
1251
1252    if (!libinput_device_config_calibration_has_matrix(edev->device) ||
1253        !libinput_device_has_capability(edev->device, LIBINPUT_DEVICE_CAP_TOUCH))
1254      return EINA_FALSE;
1255
1256    if (libinput_device_config_calibration_set_matrix(edev->device, matrix) !=
1257        LIBINPUT_CONFIG_STATUS_SUCCESS)
1258      {
1259         WRN("Failed to set input transformation about device: %s\n",
1260             libinput_device_get_name(edev->device));
1261         return EINA_FALSE;
1262      }
1263
1264    return EINA_TRUE;
1265 }
1266