6 #include "eeze_udev_private.h"
9 eeze_udev_syspath_get_parent(const char *syspath)
11 _udev_device *device, *parent;
17 if (!(device = _new_device(syspath)))
19 parent = udev_device_get_parent(device);
20 ret = eina_stringshare_add(udev_device_get_syspath(parent));
21 udev_device_unref(device);
26 eeze_udev_syspath_get_parents(const char *syspath)
28 _udev_device *child, *parent, *device;
30 Eina_List *devlist = NULL;
35 if (!(device = _new_device(syspath)))
38 if (!(parent = udev_device_get_parent(device)))
41 for (; parent; child = parent, parent = udev_device_get_parent(child))
43 path = udev_device_get_syspath(parent);
44 devlist = eina_list_append(devlist, eina_stringshare_add(path));
47 udev_device_unref(device);
52 eeze_udev_syspath_get_devpath(const char *syspath)
55 const char *name = NULL;
60 if (!(device = _new_device(syspath)))
63 if (!(name = udev_device_get_devnode(device)))
66 name = eina_stringshare_add(name);
67 udev_device_unref(device);
72 eeze_udev_syspath_get_devname(const char *syspath)
75 const char *name = NULL;
80 if (!(device = _new_device(syspath)))
83 if (!(name = udev_device_get_sysname(device)))
86 name = eina_stringshare_add(name);
87 udev_device_unref(device);
92 eeze_udev_syspath_get_subsystem(const char *syspath)
95 const char *subsystem;
100 if (!(device = _new_device(syspath)))
102 subsystem = eina_stringshare_add(udev_device_get_property_value(device, "SUBSYSTEM"));
103 udev_device_unref(device);
108 eeze_udev_syspath_get_property(const char *syspath,
109 const char *property)
111 _udev_device *device;
112 const char *value = NULL, *test;
114 if (!syspath || !property)
117 if (!(device = _new_device(syspath)))
119 if ((test = udev_device_get_property_value(device, property)))
120 value = eina_stringshare_add(test);
122 udev_device_unref(device);
127 eeze_udev_syspath_get_sysattr(const char *syspath,
130 _udev_device *device;
131 const char *value = NULL, *test;
133 if (!syspath || !sysattr)
136 if (!(device = _new_device(syspath)))
139 if ((test = udev_device_get_sysattr_value(device, sysattr)))
140 value = eina_stringshare_add(test);
142 udev_device_unref(device);
147 eeze_udev_syspath_is_mouse(const char *syspath)
149 _udev_device *device = NULL;
150 Eina_Bool mouse = EINA_FALSE;
151 const char *test = NULL;
156 if (!(device = _new_device(syspath)))
158 #ifdef OLD_UDEV_RRRRRRRRRRRRRR
159 mouse = _walk_parents_test_attr(device, "bInterfaceProtocol", "02");
163 test = udev_device_get_property_value(device, "ID_CLASS");
165 if ((test) && (!strcmp(test, "mouse")))
170 test = udev_device_get_property_value(device, "ID_INPUT_MOUSE");
172 if (test && (test[0] == '1'))
176 udev_device_unref(device);
181 eeze_udev_syspath_is_kbd(const char *syspath)
183 _udev_device *device = NULL;
184 Eina_Bool kbd = EINA_FALSE;
185 const char *test = NULL;
190 if (!(device = _new_device(syspath)))
192 #ifdef OLD_UDEV_RRRRRRRRRRRRRR
193 kbd = _walk_parents_test_attr(device, "bInterfaceProtocol", "01");
197 test = udev_device_get_property_value(device, "ID_CLASS");
199 if ((test) && (!strcmp(test, "kbd")))
204 test = udev_device_get_property_value(device, "ID_INPUT_KEYBOARD");
206 if (test && (test[0] == '1'))
210 udev_device_unref(device);
215 eeze_udev_syspath_is_touchpad(const char *syspath)
217 _udev_device *device = NULL;
218 Eina_Bool touchpad = EINA_FALSE;
223 if (!(device = _new_device(syspath)))
225 #ifdef OLD_UDEV_RRRRRRRRRRRRRR
226 touchpad = _walk_parents_test_attr(device, "resolution", NULL);
229 test = udev_device_get_property_value(device, "ID_INPUT_TOUCHPAD");
231 if (test && (test[0] == '1'))
232 touchpad = EINA_TRUE;
235 udev_device_unref(device);
240 eeze_udev_syspath_is_joystick(const char *syspath)
242 _udev_device *device = NULL;
243 Eina_Bool joystick = EINA_FALSE;
249 if (!(device = _new_device(syspath)))
251 #ifdef OLD_UDEV_RRRRRRRRRRRRRR
252 test = udev_device_get_property_value(device, "ID_CLASS");
254 if ((test) && (!strcmp(test, "joystick")))
255 joystick = EINA_TRUE;
257 test = udev_device_get_property_value(device, "ID_INPUT_JOYSTICK");
259 if (test && (test[0] == '1'))
260 joystick = EINA_TRUE;
263 udev_device_unref(device);
268 eeze_udev_devpath_get_syspath(const char *devpath)
271 _udev_list_entry *devs, *cur;
272 const char *ret = NULL;
277 en = udev_enumerate_new(udev);
282 udev_enumerate_add_match_property(en, "DEVNAME", devpath);
283 udev_enumerate_scan_devices(en);
284 devs = udev_enumerate_get_list_entry(en);
285 udev_list_entry_foreach(cur, devs)
287 ret = eina_stringshare_add(udev_list_entry_get_name(cur));
288 break; /*just in case there's more than one somehow */
290 udev_enumerate_unref(en);