mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 09:40:06 +00:00
Create udev_mon_hotplug_available
This commit is contained in:
parent
2db1197942
commit
b76481b21e
@ -1,4 +1,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <sys/poll.h>
|
||||||
|
|
||||||
#include "udev_common.h"
|
#include "udev_common.h"
|
||||||
|
|
||||||
static bool udev_mon_inited;
|
static bool udev_mon_inited;
|
||||||
@ -40,3 +43,16 @@ void udev_mon_free(bool is_joypad)
|
|||||||
g_udev = NULL;
|
g_udev = NULL;
|
||||||
udev_mon_inited = false;
|
udev_mon_inited = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool udev_mon_hotplug_available(void)
|
||||||
|
{
|
||||||
|
struct pollfd fds = {0};
|
||||||
|
|
||||||
|
if (!g_udev_mon)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fds.fd = udev_monitor_get_fd(g_udev_mon);
|
||||||
|
fds.events = POLLIN;
|
||||||
|
|
||||||
|
return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
|
||||||
|
}
|
||||||
|
@ -28,4 +28,6 @@ bool udev_mon_new(void);
|
|||||||
|
|
||||||
void udev_mon_free(bool is_joypad);
|
void udev_mon_free(bool is_joypad);
|
||||||
|
|
||||||
|
bool udev_mon_hotplug_available(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -220,19 +220,6 @@ static void udev_handle_mouse(void *data,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool udev_input_hotplug_available(udev_input_t *udev)
|
|
||||||
{
|
|
||||||
struct pollfd fds = {0};
|
|
||||||
|
|
||||||
if (!udev || !g_udev_mon)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
fds.fd = udev_monitor_get_fd(g_udev_mon);
|
|
||||||
fds.events = POLLIN;
|
|
||||||
|
|
||||||
return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool add_device(udev_input_t *udev,
|
static bool add_device(udev_input_t *udev,
|
||||||
const char *devnode, device_handle_cb cb)
|
const char *devnode, device_handle_cb cb)
|
||||||
{
|
{
|
||||||
@ -312,7 +299,6 @@ static void udev_input_remove_device(udev_input_t *udev, const char *devnode)
|
|||||||
static void udev_input_handle_hotplug(udev_input_t *udev)
|
static void udev_input_handle_hotplug(udev_input_t *udev)
|
||||||
{
|
{
|
||||||
bool is_keyboard, is_mouse, is_touchpad;
|
bool is_keyboard, is_mouse, is_touchpad;
|
||||||
struct udev_device *dev = udev_monitor_receive_device(g_udev_mon);
|
|
||||||
device_handle_cb cb = NULL;
|
device_handle_cb cb = NULL;
|
||||||
const char *devtype = NULL;
|
const char *devtype = NULL;
|
||||||
const char *val_keyboard = NULL;
|
const char *val_keyboard = NULL;
|
||||||
@ -320,6 +306,7 @@ static void udev_input_handle_hotplug(udev_input_t *udev)
|
|||||||
const char *val_touchpad = NULL;
|
const char *val_touchpad = NULL;
|
||||||
const char *action = NULL;
|
const char *action = NULL;
|
||||||
const char *devnode = NULL;
|
const char *devnode = NULL;
|
||||||
|
struct udev_device *dev = udev_monitor_receive_device(g_udev_mon);
|
||||||
|
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return;
|
return;
|
||||||
@ -378,7 +365,7 @@ static void udev_input_poll(void *data)
|
|||||||
udev->mouse_wu = udev->mouse_wd = 0;
|
udev->mouse_wu = udev->mouse_wd = 0;
|
||||||
udev->mouse_whu = udev->mouse_whd = 0;
|
udev->mouse_whu = udev->mouse_whd = 0;
|
||||||
|
|
||||||
while (udev_input_hotplug_available(udev))
|
while (udev_mon_hotplug_available())
|
||||||
udev_input_handle_hotplug(udev);
|
udev_input_handle_hotplug(udev);
|
||||||
|
|
||||||
ret = epoll_wait(udev->epfd, events, ARRAY_SIZE(events), 0);
|
ret = epoll_wait(udev->epfd, events, ARRAY_SIZE(events), 0);
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/poll.h>
|
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
|
|
||||||
@ -153,19 +152,6 @@ static void udev_poll_pad(struct udev_joypad *pad, unsigned p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool udev_hotplug_available(void)
|
|
||||||
{
|
|
||||||
struct pollfd fds = {0};
|
|
||||||
|
|
||||||
if (!g_udev_mon)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
fds.fd = udev_monitor_get_fd(g_udev_mon);
|
|
||||||
fds.events = POLLIN;
|
|
||||||
|
|
||||||
return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int udev_find_vacant_pad(void)
|
static int udev_find_vacant_pad(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -408,10 +394,10 @@ static void udev_joypad_destroy(void)
|
|||||||
|
|
||||||
static void udev_joypad_handle_hotplug(void)
|
static void udev_joypad_handle_hotplug(void)
|
||||||
{
|
{
|
||||||
struct udev_device *dev = udev_monitor_receive_device(g_udev_mon);
|
|
||||||
const char *val;
|
const char *val;
|
||||||
const char *action;
|
const char *action;
|
||||||
const char *devnode;
|
const char *devnode;
|
||||||
|
struct udev_device *dev = udev_monitor_receive_device(g_udev_mon);
|
||||||
if (!dev)
|
if (!dev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -509,7 +495,7 @@ static bool udev_set_rumble(unsigned i, enum retro_rumble_effect effect, uint16_
|
|||||||
static void udev_joypad_poll(void)
|
static void udev_joypad_poll(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
while (udev_hotplug_available())
|
while (udev_mon_hotplug_available())
|
||||||
udev_joypad_handle_hotplug();
|
udev_joypad_handle_hotplug();
|
||||||
|
|
||||||
for (i = 0; i < MAX_USERS; i++)
|
for (i = 0; i < MAX_USERS; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user