2 #include "e_mod_main.h"
4 #include <linux/uinput.h>
7 _e_gesture_device_keydev_create(void)
10 struct uinput_user_dev uinp;
13 uinp_fd = open("/dev/uinput", O_WRONLY | O_NDELAY);
16 GTWRN("Failed to open /dev/uinput: (%d)\n", uinp_fd);
20 memset(&uinp, 0, sizeof(struct uinput_user_dev));
21 strncpy(uinp.name, E_GESTURE_KEYBOARD_NAME, UINPUT_MAX_NAME_SIZE);
23 uinp.id.bustype = BUS_USB;
25 ioctl(uinp_fd, UI_SET_EVBIT, EV_KEY);
26 ioctl(uinp_fd, UI_SET_EVBIT, EV_SYN);
27 ioctl(uinp_fd, UI_SET_EVBIT, EV_MSC);
29 ioctl(uinp_fd, UI_SET_KEYBIT, KEY_BACK);
31 ret = write(uinp_fd, &uinp, sizeof(struct uinput_user_dev));
34 GTWRN("Failed to write UINPUT device\n");
38 if (ioctl(uinp_fd, UI_DEV_CREATE))
40 GTWRN("Unable to create UINPUT device\n");
45 gesture->device.uinp_fd = uinp_fd;
49 e_gesture_device_keydev_set(char *option)
53 _e_gesture_device_keydev_create();
54 gesture->device.kbd_name = strdup(E_GESTURE_KEYBOARD_NAME);
56 else if (strncmp(option, "Any", sizeof("Any")))
58 gesture->device.kbd_name = strdup(option);
63 _e_gesture_device_ecore_device_get(char *path, unsigned int clas)
65 const Eina_List *dev_list = NULL;
67 Ecore_Device *dev = NULL;
68 const char *identifier;
70 if (!path) return NULL;
72 dev_list = ecore_device_list();
73 if (!dev_list) return NULL;
74 EINA_LIST_FOREACH(dev_list, l, dev)
77 GTINF("dev: %s\n", ecore_device_name_get(dev));
78 identifier = ecore_device_identifier_get(dev);
79 if (!identifier) continue;
80 if ((ecore_device_class_get(dev) == clas) && !(strcmp(identifier, path)))
88 e_gesture_device_add(Ecore_Event_Device_Info *ev)
90 if (ev->clas == ECORE_DEVICE_CLASS_TOUCH)
93 id = strdup(ev->identifier);
94 gesture->device.touch_devices = eina_list_append(gesture->device.touch_devices, id);
95 GTINF("%s(%s) device is touch device: add list\n", ev->name, ev->identifier);
97 if ((!gesture->device.kbd_identifier) &&
98 (ev->clas == ECORE_DEVICE_CLASS_KEYBOARD))
100 if (gesture->device.kbd_name)
102 if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name)))
104 GTINF("%s(%s) device is key generated device in gesture\n", ev->name, ev->identifier);
105 gesture->device.kbd_identifier = strdup(ev->identifier);
106 gesture->device.kbd_device = _e_gesture_device_ecore_device_get(gesture->device.kbd_identifier, ECORE_DEVICE_CLASS_KEYBOARD);
111 GTINF("%s(%s) device is key generated device in gesture\n", ev->name, ev->identifier);
112 gesture->device.kbd_name = strdup(ev->name);
113 gesture->device.kbd_identifier = strdup(ev->identifier);
114 gesture->device.kbd_device = _e_gesture_device_ecore_device_get(gesture->device.kbd_identifier, ECORE_DEVICE_CLASS_KEYBOARD);
117 return E_GESTURE_EVENT_STATE_PROPAGATE;
120 E_Gesture_Event_State
121 e_gesture_device_del(Ecore_Event_Device_Info *ev)
123 Eina_List *l, *l_next;
126 if (ev->clas == ECORE_DEVICE_CLASS_TOUCH)
128 EINA_LIST_FOREACH_SAFE(gesture->device.touch_devices, l, l_next, data)
130 if (!strncmp(data, ev->identifier, strlen(ev->identifier)))
132 GTINF("%s(%s) device is touch device: remove list\n", ev->name, ev->identifier);
133 gesture->device.touch_devices = eina_list_remove(gesture->device.touch_devices, data);
138 if ((gesture->device.kbd_identifier) &&
139 (ev->clas == ECORE_DEVICE_CLASS_KEYBOARD))
141 if (!strncmp(ev->name, gesture->device.kbd_name, strlen(gesture->device.kbd_name)))
143 GTWRN("Gesture keyboard device(%s) is disconnected. Gesture cannot create key events\n", gesture->device.kbd_name);
144 E_FREE(gesture->device.kbd_identifier);
145 E_FREE(gesture->device.kbd_name);
148 return E_GESTURE_EVENT_STATE_PROPAGATE;
152 e_gesture_is_touch_device(const Ecore_Device *dev)
154 if (ecore_device_class_get(dev) == ECORE_DEVICE_CLASS_TOUCH)
161 e_gesture_device_shutdown(void)
163 E_FREE(gesture->device.kbd_identifier);
164 E_FREE(gesture->device.kbd_name);
165 gesture->device.touch_devices = eina_list_free(gesture->device.touch_devices);