Fix hotplug regressions with udev

This commit is contained in:
twinaphex 2017-06-10 11:58:22 +02:00
parent e8c73c6683
commit c70526b7af
2 changed files with 24 additions and 16 deletions

View File

@ -450,13 +450,22 @@ static void udev_input_get_pointer_position(int *x, int *y)
}
#endif
static bool udev_input_poll_hotplug_available(struct udev_monitor *dev)
{
struct pollfd fds;
fds.fd = udev_monitor_get_fd(dev);
fds.events = POLLIN;
fds.revents = 0;
return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
}
static void udev_input_poll(void *data)
{
int i, ret;
struct pollfd fds;
struct epoll_event events[32];
udev_input_mouse_t *mouse = NULL;
bool hotplug_avail = false;
int x = 0;
int y = 0;
udev_input_t *udev = (udev_input_t*)data;
@ -485,12 +494,7 @@ static void udev_input_poll(void *data)
mouse->whd = false;
}
fds.fd = udev_monitor_get_fd(udev->monitor);
fds.events = POLLIN;
fds.revents = 0;
hotplug_avail = (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
while (udev->monitor && hotplug_avail)
while (udev->monitor && udev_input_poll_hotplug_available(udev->monitor))
udev_input_handle_hotplug(udev);
ret = epoll_wait(udev->epfd, events, ARRAY_SIZE(events), 0);

View File

@ -419,18 +419,22 @@ static bool udev_set_rumble(unsigned i,
return true;
}
static bool udev_joypad_poll_hotplug_available(struct udev_monitor *dev)
{
struct pollfd fds;
fds.fd = udev_monitor_get_fd(dev);
fds.events = POLLIN;
fds.revents = 0;
return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
}
static void udev_joypad_poll(void)
{
unsigned p;
struct pollfd fds;
bool hotplug_avail = false;
fds.fd = udev_monitor_get_fd(udev_joypad_mon);
fds.events = POLLIN;
fds.revents = 0;
hotplug_avail = (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
while (udev_joypad_mon && hotplug_avail)
while (udev_joypad_mon && udev_joypad_poll_hotplug_available(udev_joypad_mon))
{
struct udev_device *dev = udev_monitor_receive_device(udev_joypad_mon);