mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 03:32:46 +00:00
Create udev_ctl
This commit is contained in:
parent
24f5275001
commit
32ee695f9d
@ -24,29 +24,6 @@ static bool udev_mon_first_inited_is_joypad;
|
||||
static struct udev_monitor *g_udev_mon;
|
||||
static struct udev *g_udev;
|
||||
|
||||
bool udev_mon_new(bool is_joypad)
|
||||
{
|
||||
if (udev_mon_inited)
|
||||
return true;
|
||||
|
||||
udev_mon_first_inited_is_joypad = is_joypad;
|
||||
|
||||
g_udev = udev_new();
|
||||
if (!g_udev)
|
||||
return false;
|
||||
|
||||
g_udev_mon = udev_monitor_new_from_netlink(g_udev, "udev");
|
||||
if (g_udev_mon)
|
||||
{
|
||||
udev_monitor_filter_add_match_subsystem_devtype(g_udev_mon, "input", NULL);
|
||||
udev_monitor_enable_receiving(g_udev_mon);
|
||||
}
|
||||
|
||||
udev_mon_inited = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void udev_mon_free(bool is_joypad)
|
||||
{
|
||||
if (!udev_mon_inited || (is_joypad && !udev_mon_first_inited_is_joypad))
|
||||
@ -63,7 +40,7 @@ void udev_mon_free(bool is_joypad)
|
||||
udev_mon_first_inited_is_joypad = false;
|
||||
}
|
||||
|
||||
bool udev_mon_hotplug_available(void)
|
||||
static bool udev_mon_hotplug_available(void)
|
||||
{
|
||||
struct pollfd fds = {0};
|
||||
|
||||
@ -92,3 +69,17 @@ struct udev_device *udev_mon_device_new(const char *name)
|
||||
{
|
||||
return udev_device_new_from_syspath(g_udev, name);
|
||||
}
|
||||
|
||||
bool udev_ctl(enum udev_ctl_state state, void *data)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case UDEV_CTL_MONITOR_HOTPLUG_AVAIL:
|
||||
return udev_mon_hotplug_available();
|
||||
case UDEV_CTL_NONE:
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -21,12 +21,16 @@
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
bool udev_mon_new(bool is_joypad);
|
||||
enum udev_ctl_state
|
||||
{
|
||||
UDEV_CTL_NONE = 0,
|
||||
UDEV_CTL_MONITOR_HOTPLUG_AVAIL
|
||||
};
|
||||
|
||||
bool udev_ctl(enum udev_ctl_state state, void *data);
|
||||
|
||||
void udev_mon_free(bool is_joypad);
|
||||
|
||||
bool udev_mon_hotplug_available(void);
|
||||
|
||||
struct udev_device *udev_mon_receive_device(void);
|
||||
|
||||
struct udev_enumerate *udev_mon_enumerate(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user