mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 19:20:35 +00:00
Make g_epoll static
This commit is contained in:
parent
54655c37cd
commit
7cb78cca58
@ -1,9 +1,13 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "epoll_common.h"
|
||||
|
||||
int g_epoll;
|
||||
#include "../../verbosity.h"
|
||||
|
||||
static int g_epoll;
|
||||
static bool epoll_inited;
|
||||
static bool epoll_first_inited_is_joypad;
|
||||
|
||||
@ -39,3 +43,21 @@ int epoll_waiting(struct epoll_event *events, int maxevents, int timeout)
|
||||
{
|
||||
return epoll_wait(g_epoll, events, maxevents, timeout);
|
||||
}
|
||||
|
||||
bool epoll_add(int fd, void *device)
|
||||
{
|
||||
struct epoll_event event = {0};
|
||||
|
||||
event.events = EPOLLIN;
|
||||
event.data.ptr = device;
|
||||
|
||||
/* Shouldn't happen, but just check it. */
|
||||
if (epoll_ctl(g_epoll, EPOLL_CTL_ADD, fd, &event) < 0)
|
||||
{
|
||||
RARCH_ERR("Failed to add FD (%d) to epoll list (%s).\n",
|
||||
fd, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -23,12 +23,12 @@
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
extern int g_epoll;
|
||||
|
||||
bool epoll_new(bool is_joypad);
|
||||
|
||||
void epoll_free(bool is_joypad);
|
||||
|
||||
int epoll_waiting(struct epoll_event *events, int maxevents, int timeout);
|
||||
|
||||
bool epoll_add(int fd, void *device);
|
||||
|
||||
#endif
|
||||
|
@ -224,7 +224,6 @@ static bool add_device(udev_input_t *udev,
|
||||
udev_input_device_t **tmp;
|
||||
udev_input_device_t *device = NULL;
|
||||
struct stat st = {0};
|
||||
struct epoll_event event = {0};
|
||||
|
||||
if (stat(devnode, &st) < 0)
|
||||
return false;
|
||||
@ -258,13 +257,7 @@ static bool add_device(udev_input_t *udev,
|
||||
tmp[udev->num_devices++] = device;
|
||||
udev->devices = tmp;
|
||||
|
||||
event.events = EPOLLIN;
|
||||
event.data.ptr = device;
|
||||
|
||||
/* Shouldn't happen, but just check it. */
|
||||
if (epoll_ctl(g_epoll, EPOLL_CTL_ADD, fd, &event) < 0)
|
||||
RARCH_ERR("Failed to add FD (%d) to epoll list (%s).\n",
|
||||
fd, strerror(errno));
|
||||
epoll_add(fd, device);
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -89,8 +89,6 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
|
||||
*pad->ident = '\0';
|
||||
if (pad->fd >= 0)
|
||||
{
|
||||
struct epoll_event event;
|
||||
|
||||
if (ioctl(pad->fd, JSIOCGNAME(sizeof(settings->input.device_names[0])), pad->ident) >= 0)
|
||||
{
|
||||
RARCH_LOG("[Device]: Found pad: %s on %s.\n", pad->ident, path);
|
||||
@ -103,16 +101,16 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
|
||||
rarch_main_msg_queue_push(msg, 0, 60, false);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
RARCH_ERR("[Device]: Didn't find ident of %s.\n", path);
|
||||
|
||||
event.events = EPOLLIN;
|
||||
event.data.ptr = pad;
|
||||
epoll_ctl(g_epoll, EPOLL_CTL_ADD, pad->fd, &event);
|
||||
if (!epoll_add(pad->fd, pad))
|
||||
goto error;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
error:
|
||||
RARCH_ERR("[Device]: Failed to open pad %s (error: %s).\n", path, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
@ -253,15 +251,11 @@ static bool linuxraw_joypad_init(void *data)
|
||||
}
|
||||
|
||||
g_notify = inotify_init();
|
||||
|
||||
if (g_notify >= 0)
|
||||
{
|
||||
struct epoll_event event;
|
||||
|
||||
linuxraw_joypad_setup_notify();
|
||||
|
||||
event.events = EPOLLIN;
|
||||
event.data.ptr = NULL;
|
||||
epoll_ctl(g_epoll, EPOLL_CTL_ADD, g_notify, &event);
|
||||
epoll_add(g_notify, NULL);
|
||||
}
|
||||
|
||||
g_hotplug = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user