forked from enlightenment/efl
more eudev->eeze_udev cleanup, add even more legacy udev code (hurgh)
SVN revision: 48854
This commit is contained in:
parent
0cccb61516
commit
77fa364241
|
@ -11,7 +11,7 @@ typedef struct kbdmouse
|
||||||
|
|
||||||
static void
|
static void
|
||||||
/* event will always be a syspath starting with /sys */
|
/* event will always be a syspath starting with /sys */
|
||||||
catch_events(const char *device, const char *event, void *data, Eudev_Watch *watch)
|
catch_events(const char *device, const char *event, void *data, Eeze_Udev_Watch *watch)
|
||||||
{
|
{
|
||||||
kbdmouse *akbdmouse = data;
|
kbdmouse *akbdmouse = data;
|
||||||
Eina_List *l;
|
Eina_List *l;
|
||||||
|
@ -92,8 +92,8 @@ int main()
|
||||||
akbdmouse->hash = hash;
|
akbdmouse->hash = hash;
|
||||||
|
|
||||||
printf("For my first trick, I will find all of your keyboards and return their syspaths.\n");
|
printf("For my first trick, I will find all of your keyboards and return their syspaths.\n");
|
||||||
/* find all keyboards using type EUDEV_TYPE_KEYBOARD */
|
/* find all keyboards using type EEZE_UDEV_TYPE_KEYBOARD */
|
||||||
type = eeze_udev_find_by_type(EUDEV_TYPE_KEYBOARD, NULL);
|
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_KEYBOARD, NULL);
|
||||||
EINA_LIST_FOREACH(type, l, name)
|
EINA_LIST_FOREACH(type, l, name)
|
||||||
{ /* add the devpath to the hash for use in the cb later */
|
{ /* add the devpath to the hash for use in the cb later */
|
||||||
eina_hash_direct_add(hash, name, eeze_udev_syspath_get_devpath(name));
|
eina_hash_direct_add(hash, name, eeze_udev_syspath_get_devpath(name));
|
||||||
|
@ -106,8 +106,8 @@ int main()
|
||||||
akbdmouse->kbds = type;
|
akbdmouse->kbds = type;
|
||||||
|
|
||||||
printf("\nNext, I will find all of your mice and print the corresponding manufacturer.\n");
|
printf("\nNext, I will find all of your mice and print the corresponding manufacturer.\n");
|
||||||
/* find all mice using type EUDEV_TYPE_MOUSE */
|
/* find all mice using type EEZE_UDEV_TYPE_MOUSE */
|
||||||
type = eeze_udev_find_by_type(EUDEV_TYPE_MOUSE, NULL);
|
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_MOUSE, NULL);
|
||||||
EINA_LIST_FOREACH(type, l, name)
|
EINA_LIST_FOREACH(type, l, name)
|
||||||
{ /* add the devpath to the hash for use in the cb later */
|
{ /* add the devpath to the hash for use in the cb later */
|
||||||
eina_hash_direct_add(hash, name, eeze_udev_syspath_get_devpath(name)); /* get a property using the device's syspath */
|
eina_hash_direct_add(hash, name, eeze_udev_syspath_get_devpath(name)); /* get a property using the device's syspath */
|
||||||
|
@ -120,8 +120,8 @@ int main()
|
||||||
akbdmouse->mice = type;
|
akbdmouse->mice = type;
|
||||||
|
|
||||||
printf("\nNow let's try something a little more difficult. Mountable filesystems!\n");
|
printf("\nNow let's try something a little more difficult. Mountable filesystems!\n");
|
||||||
/* find all mountable drives using type EUDEV_TYPE_DRIVE_MOUNTABLE */
|
/* find all mountable drives using type EEZE_UDEV_TYPE_DRIVE_MOUNTABLE */
|
||||||
type = eeze_udev_find_by_type(EUDEV_TYPE_DRIVE_MOUNTABLE, NULL);
|
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_MOUNTABLE, NULL);
|
||||||
EINA_LIST_FOREACH(type, l, name)
|
EINA_LIST_FOREACH(type, l, name)
|
||||||
{
|
{
|
||||||
printf("Found device: %s\n", name); /* get a property using the device's syspath */
|
printf("Found device: %s\n", name); /* get a property using the device's syspath */
|
||||||
|
@ -135,26 +135,26 @@ int main()
|
||||||
eina_list_free(type);
|
eina_list_free(type);
|
||||||
|
|
||||||
printf("\nInternal drives, anyone? With serial numbers?\n");
|
printf("\nInternal drives, anyone? With serial numbers?\n");
|
||||||
/* find all internal drives using type EUDEV_TYPE_DRIVE_INTERNAL */
|
/* find all internal drives using type EEZE_UDEV_TYPE_DRIVE_INTERNAL */
|
||||||
type = eeze_udev_find_by_type(EUDEV_TYPE_DRIVE_INTERNAL, NULL);
|
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_INTERNAL, NULL);
|
||||||
EINA_LIST_FOREACH(type, l, name) /* get a property using the device's syspath */
|
EINA_LIST_FOREACH(type, l, name) /* get a property using the device's syspath */
|
||||||
printf("%s: %s\n", name, eeze_udev_syspath_get_property(name, "ID_SERIAL"));
|
printf("%s: %s\n", name, eeze_udev_syspath_get_property(name, "ID_SERIAL"));
|
||||||
eina_list_free(type);
|
eina_list_free(type);
|
||||||
|
|
||||||
printf("\nGot any removables? I'm gonna find em!\n");
|
printf("\nGot any removables? I'm gonna find em!\n");
|
||||||
/* find all removable media using type EUDEV_TYPE_DRIVE_REMOVABLE */
|
/* find all removable media using type EEZE_UDEV_TYPE_DRIVE_REMOVABLE */
|
||||||
type = eeze_udev_find_by_type(EUDEV_TYPE_DRIVE_REMOVABLE, NULL);
|
type = eeze_udev_find_by_type(EEZE_UDEV_TYPE_DRIVE_REMOVABLE, NULL);
|
||||||
EINA_LIST_FOREACH(type, l, name) /* get a property using the device's syspath */
|
EINA_LIST_FOREACH(type, l, name) /* get a property using the device's syspath */
|
||||||
printf("\tOoh, a %s attached on your %s bus!\n", eeze_udev_syspath_get_property(name, "ID_MODEL"),
|
printf("\tOoh, a %s attached on your %s bus!\n", eeze_udev_syspath_get_property(name, "ID_MODEL"),
|
||||||
eeze_udev_syspath_get_property(name, "ID_BUS"));
|
eeze_udev_syspath_get_property(name, "ID_BUS"));
|
||||||
eina_list_free(type);
|
eina_list_free(type);
|
||||||
|
|
||||||
|
|
||||||
/* set a udev watch, grab all events because no EUDEV_TYPE filter is specified,
|
/* set a udev watch, grab all events because no EEZE_UDEV_TYPE filter is specified,
|
||||||
* set the events to be sent to callback function catch_events(), and attach
|
* set the events to be sent to callback function catch_events(), and attach
|
||||||
* kbdmouse to the watch as associated data
|
* kbdmouse to the watch as associated data
|
||||||
*/
|
*/
|
||||||
eeze_udev_watch_add(EUDEV_TYPE_NONE, catch_events, akbdmouse);
|
eeze_udev_watch_add(EEZE_UDEV_TYPE_NONE, catch_events, akbdmouse);
|
||||||
printf("\nAnd now for something more complicated. Plug or unplug your keyboard or mouse for me.\n");
|
printf("\nAnd now for something more complicated. Plug or unplug your keyboard or mouse for me.\n");
|
||||||
|
|
||||||
/* main loop must be started to use ecore fd polling */
|
/* main loop must be started to use ecore fd polling */
|
||||||
|
|
|
@ -9,16 +9,15 @@
|
||||||
#ifdef EAPI
|
#ifdef EAPI
|
||||||
#undef EAPI
|
#undef EAPI
|
||||||
#endif
|
#endif
|
||||||
#ifndef _MSC_VER
|
|
||||||
# ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# if __GNUC__ >= 4
|
# if __GNUC__ >= 4
|
||||||
# define EAPI __attribute__ ((visibility("default")))
|
# define EAPI __attribute__ ((visibility("default")))
|
||||||
# else
|
|
||||||
# define EAPI
|
|
||||||
# endif
|
|
||||||
# else
|
# else
|
||||||
# define EAPI
|
# define EAPI
|
||||||
# endif
|
# endif
|
||||||
|
#else
|
||||||
|
# define EAPI
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,21 +88,21 @@
|
||||||
/*FIXME: these probably need to be bitmasks with categories*/
|
/*FIXME: these probably need to be bitmasks with categories*/
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
EUDEV_TYPE_NONE,
|
EEZE_UDEV_TYPE_NONE,
|
||||||
EUDEV_TYPE_KEYBOARD,
|
EEZE_UDEV_TYPE_KEYBOARD,
|
||||||
EUDEV_TYPE_MOUSE,
|
EEZE_UDEV_TYPE_MOUSE,
|
||||||
EUDEV_TYPE_TOUCHPAD,
|
EEZE_UDEV_TYPE_TOUCHPAD,
|
||||||
EUDEV_TYPE_DRIVE_MOUNTABLE,
|
EEZE_UDEV_TYPE_DRIVE_MOUNTABLE,
|
||||||
EUDEV_TYPE_DRIVE_INTERNAL,
|
EEZE_UDEV_TYPE_DRIVE_INTERNAL,
|
||||||
EUDEV_TYPE_DRIVE_REMOVABLE,
|
EEZE_UDEV_TYPE_DRIVE_REMOVABLE,
|
||||||
EUDEV_TYPE_DRIVE_CDROM,
|
EEZE_UDEV_TYPE_DRIVE_CDROM,
|
||||||
EUDEV_TYPE_POWER_AC,
|
EEZE_UDEV_TYPE_POWER_AC,
|
||||||
EUDEV_TYPE_POWER_BAT
|
EEZE_UDEV_TYPE_POWER_BAT
|
||||||
/* EUDEV_TYPE_ANDROID */
|
/* EEZE_UDEV_TYPE_ANDROID */
|
||||||
} Eudev_Type;
|
} Eeze_Udev_Type;
|
||||||
|
|
||||||
struct Eudev_Watch;
|
struct Eeze_Udev_Watch;
|
||||||
typedef struct Eudev_Watch Eudev_Watch;
|
typedef struct Eeze_Udev_Watch Eeze_Udev_Watch;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -112,7 +111,7 @@ extern "C" {
|
||||||
EAPI int eeze_udev_init(void);
|
EAPI int eeze_udev_init(void);
|
||||||
EAPI int eeze_udev_shutdown(void);
|
EAPI int eeze_udev_shutdown(void);
|
||||||
|
|
||||||
EAPI Eina_List *eeze_udev_find_by_type(const Eudev_Type type, const char *name);
|
EAPI Eina_List *eeze_udev_find_by_type(const Eeze_Udev_Type type, const char *name);
|
||||||
EAPI Eina_List *eeze_udev_find_by_filter(const char *subsystem, const char *type, const char *name);
|
EAPI Eina_List *eeze_udev_find_by_filter(const char *subsystem, const char *type, const char *name);
|
||||||
|
|
||||||
EAPI const char *eeze_udev_syspath_rootdev_get(const char *syspath);
|
EAPI const char *eeze_udev_syspath_rootdev_get(const char *syspath);
|
||||||
|
@ -127,8 +126,8 @@ extern "C" {
|
||||||
EAPI Eina_Bool eeze_udev_syspath_is_kbd(const char *syspath);
|
EAPI Eina_Bool eeze_udev_syspath_is_kbd(const char *syspath);
|
||||||
EAPI Eina_Bool eeze_udev_syspath_is_touchpad(const char *syspath);
|
EAPI Eina_Bool eeze_udev_syspath_is_touchpad(const char *syspath);
|
||||||
|
|
||||||
EAPI Eudev_Watch *eeze_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, void *, Eudev_Watch *), void *user_data);
|
EAPI Eeze_Udev_Watch *eeze_udev_watch_add(Eeze_Udev_Type type, void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *), void *user_data);
|
||||||
EAPI void *eeze_udev_watch_del(Eudev_Watch *watch);
|
EAPI void *eeze_udev_watch_del(Eeze_Udev_Watch *watch);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ eeze_udev_syspath_rootdev_get(const char *syspath)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find devices using a EUDEV_TYPE_* and/or a name.
|
* Find devices using a EEZE_UDEV_TYPE_* and/or a name.
|
||||||
*
|
*
|
||||||
* @param type A Eudev_Type or 0
|
* @param type A Eeze_Udev_Type or 0
|
||||||
* @param name A filter for the device name or NULL
|
* @param name A filter for the device name or NULL
|
||||||
* @return A Eina_List* of matched devices or NULL on failure
|
* @return A Eina_List* of matched devices or NULL on failure
|
||||||
*
|
*
|
||||||
|
@ -51,7 +51,7 @@ eeze_udev_syspath_rootdev_get(const char *syspath)
|
||||||
* @ingroup udev
|
* @ingroup udev
|
||||||
*/
|
*/
|
||||||
EAPI Eina_List *
|
EAPI Eina_List *
|
||||||
eeze_udev_find_by_type(const Eudev_Type etype, const char *name)
|
eeze_udev_find_by_type(const Eeze_Udev_Type etype, const char *name)
|
||||||
{
|
{
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
struct udev_enumerate *en;
|
struct udev_enumerate *en;
|
||||||
|
@ -69,50 +69,50 @@ eeze_udev_find_by_type(const Eudev_Type etype, const char *name)
|
||||||
|
|
||||||
switch (etype)
|
switch (etype)
|
||||||
{
|
{
|
||||||
case EUDEV_TYPE_NONE:
|
case EEZE_UDEV_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_KEYBOARD:
|
case EEZE_UDEV_TYPE_KEYBOARD:
|
||||||
udev_enumerate_add_match_subsystem(en, "input");
|
udev_enumerate_add_match_subsystem(en, "input");
|
||||||
udev_enumerate_add_match_property(en, "ID_INPUT_KEYBOARD", "1");
|
udev_enumerate_add_match_property(en, "ID_INPUT_KEYBOARD", "1");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_MOUSE:
|
case EEZE_UDEV_TYPE_MOUSE:
|
||||||
udev_enumerate_add_match_subsystem(en, "input");
|
udev_enumerate_add_match_subsystem(en, "input");
|
||||||
udev_enumerate_add_match_property(en, "ID_INPUT_MOUSE", "1");
|
udev_enumerate_add_match_property(en, "ID_INPUT_MOUSE", "1");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_TOUCHPAD:
|
case EEZE_UDEV_TYPE_TOUCHPAD:
|
||||||
udev_enumerate_add_match_subsystem(en, "input");
|
udev_enumerate_add_match_subsystem(en, "input");
|
||||||
udev_enumerate_add_match_property(en, "ID_INPUT_TOUCHPAD", "1");
|
udev_enumerate_add_match_property(en, "ID_INPUT_TOUCHPAD", "1");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_MOUNTABLE:
|
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
||||||
udev_enumerate_add_match_subsystem(en, "block");
|
udev_enumerate_add_match_subsystem(en, "block");
|
||||||
udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
|
udev_enumerate_add_match_property(en, "ID_FS_USAGE", "filesystem");
|
||||||
udev_enumerate_add_nomatch_sysattr(en, "capability", "52");
|
udev_enumerate_add_nomatch_sysattr(en, "capability", "52");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_INTERNAL:
|
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
||||||
udev_enumerate_add_match_subsystem(en, "block");
|
udev_enumerate_add_match_subsystem(en, "block");
|
||||||
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
||||||
udev_enumerate_add_match_property(en, "ID_BUS", "ata");
|
udev_enumerate_add_match_property(en, "ID_BUS", "ata");
|
||||||
udev_enumerate_add_match_sysattr(en, "removable", "0");
|
udev_enumerate_add_match_sysattr(en, "removable", "0");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_REMOVABLE:
|
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
|
||||||
udev_enumerate_add_match_subsystem(en, "block");
|
udev_enumerate_add_match_subsystem(en, "block");
|
||||||
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
udev_enumerate_add_match_property(en, "ID_TYPE", "disk");
|
||||||
udev_enumerate_add_match_sysattr(en, "removable", "1");
|
udev_enumerate_add_match_sysattr(en, "removable", "1");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_CDROM:
|
case EEZE_UDEV_TYPE_DRIVE_CDROM:
|
||||||
udev_enumerate_add_match_subsystem(en, "block");
|
udev_enumerate_add_match_subsystem(en, "block");
|
||||||
udev_enumerate_add_match_property(en, "ID_CDROM", "1");
|
udev_enumerate_add_match_property(en, "ID_CDROM", "1");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_POWER_AC:
|
case EEZE_UDEV_TYPE_POWER_AC:
|
||||||
udev_enumerate_add_match_subsystem(en, "power_supply");
|
udev_enumerate_add_match_subsystem(en, "power_supply");
|
||||||
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Mains");
|
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Mains");
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_POWER_BAT:
|
case EEZE_UDEV_TYPE_POWER_BAT:
|
||||||
udev_enumerate_add_match_subsystem(en, "power_supply");
|
udev_enumerate_add_match_subsystem(en, "power_supply");
|
||||||
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Battery");
|
udev_enumerate_add_match_property(en, "POWER_SUPPLY_TYPE", "Battery");
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case EUDEV_TYPE_ANDROID:
|
case EEZE_UDEV_TYPE_ANDROID:
|
||||||
udev_enumerate_add_match_subsystem(en, "block");
|
udev_enumerate_add_match_subsystem(en, "block");
|
||||||
udev_enumerate_add_match_property(en, "ID_MODEL", "Android_*");
|
udev_enumerate_add_match_property(en, "ID_MODEL", "Android_*");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2,24 +2,48 @@
|
||||||
#include <Eeze_Udev.h>
|
#include <Eeze_Udev.h>
|
||||||
|
|
||||||
/* opaque */
|
/* opaque */
|
||||||
struct Eudev_Watch
|
struct Eeze_Udev_Watch
|
||||||
{
|
{
|
||||||
struct udev_monitor *mon;
|
struct udev_monitor *mon;
|
||||||
Ecore_Fd_Handler *handler;
|
Ecore_Fd_Handler *handler;
|
||||||
Eudev_Type type;
|
Eeze_Udev_Type type;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* private */
|
/* private */
|
||||||
struct _store_data
|
struct _store_data
|
||||||
{
|
{
|
||||||
void(*func)(const char *, const char *, void *, Eudev_Watch *);
|
void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *);
|
||||||
void *data;
|
void *data;
|
||||||
struct udev_monitor *mon;
|
struct udev_monitor *mon;
|
||||||
Eudev_Type type;
|
Eeze_Udev_Type type;
|
||||||
Eudev_Watch *watch;
|
Eeze_Udev_Watch *watch;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* private function to further filter watch results based on Eudev_Type
|
|
||||||
|
/* private function to simulate udevadm info -a
|
||||||
|
* walks up the device tree checking each node for sysattr
|
||||||
|
* with value value
|
||||||
|
*/
|
||||||
|
static Eina_Bool
|
||||||
|
_walk_parents_for_attr(struct udev_device *device, const char *sysattr, const char* value)
|
||||||
|
{
|
||||||
|
struct udev_device *parent, *child = device;
|
||||||
|
const char *test;
|
||||||
|
|
||||||
|
while ((parent = udev_device_get_parent(child)))
|
||||||
|
{
|
||||||
|
if (!(test = udev_device_get_sysattr_value(parent, sysattr)))
|
||||||
|
continue;
|
||||||
|
if (!value)
|
||||||
|
return 1;
|
||||||
|
else if (!strcmp(test, value))
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* private function to further filter watch results based on Eeze_Udev_Type
|
||||||
* specified
|
* specified
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
|
@ -28,9 +52,9 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
struct _store_data *store = data;
|
struct _store_data *store = data;
|
||||||
struct udev_device *device;
|
struct udev_device *device;
|
||||||
const char *ret, *test;
|
const char *ret, *test;
|
||||||
void(*func)(const char *, const char *, void *, Eudev_Watch *) = store->func;
|
void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *) = store->func;
|
||||||
void *sdata = store->data;
|
void *sdata = store->data;
|
||||||
Eudev_Watch *watch = store->watch;
|
Eeze_Udev_Watch *watch = store->watch;
|
||||||
int cap = 0;
|
int cap = 0;
|
||||||
|
|
||||||
if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
||||||
|
@ -40,31 +64,40 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
|
|
||||||
switch (store->type)
|
switch (store->type)
|
||||||
{
|
{
|
||||||
case EUDEV_TYPE_KEYBOARD:
|
case EEZE_UDEV_TYPE_KEYBOARD:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
||||||
goto error;
|
goto error;
|
||||||
|
if (_walk_parents_for_attr(device, "bInterfaceProtocol", "01"))
|
||||||
|
break;
|
||||||
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
if (!udev_device_get_property_value(device, "ID_INPUT_KEYBOARD"))
|
if (!udev_device_get_property_value(device, "ID_INPUT_KEYBOARD"))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_MOUSE:
|
case EEZE_UDEV_TYPE_MOUSE:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
||||||
goto error;
|
goto error;
|
||||||
|
if (_walk_parents_for_attr(device, "bInterfaceProtocol", "02"))
|
||||||
|
break;
|
||||||
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
if (!udev_device_get_property_value(device, "ID_INPUT_MOUSE"))
|
if (!udev_device_get_property_value(device, "ID_INPUT_MOUSE"))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_TOUCHPAD:
|
case EEZE_UDEV_TYPE_TOUCHPAD:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "input")))
|
||||||
goto error;
|
goto error;
|
||||||
|
if (_walk_parents_for_attr(device, "resolution", NULL))
|
||||||
|
break;
|
||||||
|
goto error;
|
||||||
#endif
|
#endif
|
||||||
if (!udev_device_get_property_value(device, "ID_INPUT_TOUCHPAD"))
|
if (!udev_device_get_property_value(device, "ID_INPUT_TOUCHPAD"))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_MOUNTABLE:
|
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -75,7 +108,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
(strcmp("filesystem", test)) || (cap == 52))
|
(strcmp("filesystem", test)) || (cap == 52))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_INTERNAL:
|
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -84,7 +117,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
!(test = udev_device_get_sysattr_value(device, "removable")) || (atoi(test)))
|
!(test = udev_device_get_sysattr_value(device, "removable")) || (atoi(test)))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_REMOVABLE:
|
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -93,7 +126,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
(!(test = udev_device_get_sysattr_value(device, "capability")) || (atoi(test) != 10)))
|
(!(test = udev_device_get_sysattr_value(device, "capability")) || (atoi(test) != 10)))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_CDROM:
|
case EEZE_UDEV_TYPE_DRIVE_CDROM:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "block")))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -101,7 +134,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
if (!udev_device_get_property_value(device, "ID_CDROM"))
|
if (!udev_device_get_property_value(device, "ID_CDROM"))
|
||||||
goto error;
|
goto error;
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_POWER_AC:
|
case EEZE_UDEV_TYPE_POWER_AC:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "power_supply")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "power_supply")))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -109,7 +142,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
if (!(test = (udev_device_get_property_value(device, "POWER_SUPPLY_TYPE"))) ||
|
if (!(test = (udev_device_get_property_value(device, "POWER_SUPPLY_TYPE"))) ||
|
||||||
(strcmp("Mains", test)))
|
(strcmp("Mains", test)))
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_POWER_BAT:
|
case EEZE_UDEV_TYPE_POWER_BAT:
|
||||||
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifdef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "power_supply")))
|
if ((!(test = udev_device_get_subsystem(device))) || (strcmp(test, "power_supply")))
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -118,7 +151,7 @@ _get_syspath_from_watch(void *data, Ecore_Fd_Handler *fd_handler)
|
||||||
(strcmp("Battery", test)))
|
(strcmp("Battery", test)))
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case EUDEV_TYPE_ANDROID:
|
case EEZE_UDEV_TYPE_ANDROID:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface");
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface");
|
||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
|
@ -157,25 +190,25 @@ error:
|
||||||
* @param subsystem The subsystem type. See @ref Subsystem_Types
|
* @param subsystem The subsystem type. See @ref Subsystem_Types
|
||||||
* @param device_type The device type. See @ref Device_Types
|
* @param device_type The device type. See @ref Device_Types
|
||||||
* @param func The function to call when the watch receives data;
|
* @param func The function to call when the watch receives data;
|
||||||
* must take (const char *device, const char *event_type, void *data, Eudev_Watch *watch)
|
* must take (const char *device, const char *event_type, void *data, Eeze_Udev_Watch *watch)
|
||||||
* @param user_data Data to pass to the callback function
|
* @param user_data Data to pass to the callback function
|
||||||
*
|
*
|
||||||
* @return A watch struct for the watch type specified, or NULL on failure
|
* @return A watch struct for the watch type specified, or NULL on failure
|
||||||
*
|
*
|
||||||
* @ingroup udev
|
* @ingroup udev
|
||||||
*/
|
*/
|
||||||
EAPI Eudev_Watch *
|
EAPI Eeze_Udev_Watch *
|
||||||
eeze_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, void *, Eudev_Watch *), void *user_data)
|
eeze_udev_watch_add(Eeze_Udev_Type type, void(*func)(const char *, const char *, void *, Eeze_Udev_Watch *), void *user_data)
|
||||||
{
|
{
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
struct udev_monitor *mon;
|
struct udev_monitor *mon;
|
||||||
int fd;
|
int fd;
|
||||||
Ecore_Fd_Handler *handler;
|
Ecore_Fd_Handler *handler;
|
||||||
Eudev_Watch *watch;
|
Eeze_Udev_Watch *watch;
|
||||||
struct _store_data *store;
|
struct _store_data *store;
|
||||||
|
|
||||||
if (!(store = malloc(sizeof(struct _store_data)))) return NULL;
|
if (!(store = malloc(sizeof(struct _store_data)))) return NULL;
|
||||||
if (!(watch = malloc(sizeof(Eudev_Watch))))
|
if (!(watch = malloc(sizeof(Eeze_Udev_Watch))))
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if (!(udev = udev_new()))
|
if (!(udev = udev_new()))
|
||||||
|
@ -185,35 +218,35 @@ eeze_udev_watch_add(Eudev_Type type, void(*func)(const char *, const char *, voi
|
||||||
#ifndef OLD_UDEV_RRRRRRRRRRRRRR
|
#ifndef OLD_UDEV_RRRRRRRRRRRRRR
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case EUDEV_TYPE_KEYBOARD:
|
case EEZE_UDEV_TYPE_KEYBOARD:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_MOUSE:
|
case EEZE_UDEV_TYPE_MOUSE:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_TOUCHPAD:
|
case EEZE_UDEV_TYPE_TOUCHPAD:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_MOUNTABLE:
|
case EEZE_UDEV_TYPE_DRIVE_MOUNTABLE:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_INTERNAL:
|
case EEZE_UDEV_TYPE_DRIVE_INTERNAL:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_REMOVABLE:
|
case EEZE_UDEV_TYPE_DRIVE_REMOVABLE:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_DRIVE_CDROM:
|
case EEZE_UDEV_TYPE_DRIVE_CDROM:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "block", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_POWER_AC:
|
case EEZE_UDEV_TYPE_POWER_AC:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
||||||
break;
|
break;
|
||||||
case EUDEV_TYPE_POWER_BAT:
|
case EEZE_UDEV_TYPE_POWER_BAT:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "power_supply", NULL);
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case EUDEV_TYPE_ANDROID:
|
case EEZE_UDEV_TYPE_ANDROID:
|
||||||
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface");
|
udev_monitor_filter_add_match_subsystem_devtype(mon, "input", "usb_interface");
|
||||||
break;
|
break;
|
||||||
*/
|
*/
|
||||||
|
@ -248,7 +281,7 @@ error:
|
||||||
/**
|
/**
|
||||||
* Deletes a watch.
|
* Deletes a watch.
|
||||||
*
|
*
|
||||||
* @param watch An Eudev_Watch object
|
* @param watch An Eeze_Udev_Watch object
|
||||||
* @return The data originally associated with the watch, or NULL
|
* @return The data originally associated with the watch, or NULL
|
||||||
*
|
*
|
||||||
* Deletes a watch, closing file descriptors and freeing related udev memory.
|
* Deletes a watch, closing file descriptors and freeing related udev memory.
|
||||||
|
@ -256,7 +289,7 @@ error:
|
||||||
* @ingroup udev
|
* @ingroup udev
|
||||||
*/
|
*/
|
||||||
EAPI void *
|
EAPI void *
|
||||||
eeze_udev_watch_del(Eudev_Watch *watch)
|
eeze_udev_watch_del(Eeze_Udev_Watch *watch)
|
||||||
{
|
{
|
||||||
struct udev *udev;
|
struct udev *udev;
|
||||||
struct udev_monitor *mon = watch->mon;
|
struct udev_monitor *mon = watch->mon;
|
||||||
|
|
Loading…
Reference in New Issue