diff --git a/Makefile.common b/Makefile.common
index 31acfde9d7..c033de6746 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -119,7 +119,6 @@ ifneq ($(findstring Linux,$(OS)),)
LIBS += -lrt
OBJ += input/drivers/linuxraw_input.o \
input/common/linux_common.o \
- input/common/epoll_common.o \
input/drivers_joypad/linuxraw_joypad.o \
frontend/drivers/platform_linux.o
endif
diff --git a/griffin/griffin.c b/griffin/griffin.c
index 5d16cfa507..0ba72892cb 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -484,7 +484,6 @@ INPUT
#if defined(__linux__) && !defined(ANDROID)
#include "../input/common/linux_common.c"
-#include "../input/common/epoll_common.c"
#include "../input/drivers/linuxraw_input.c"
#include "../input/drivers_joypad/linuxraw_joypad.c"
#endif
diff --git a/input/common/epoll_common.c b/input/common/epoll_common.c
deleted file mode 100644
index 50e7a44420..0000000000
--- a/input/common/epoll_common.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* RetroArch - A frontend for libretro.
- * Copyright (C) 2013-2014 - pinumbernumber
- * Copyright (C) 2011-2017 - Daniel De Matteis
- *
- * RetroArch is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
- *
- * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with RetroArch.
- * If not, see .
- */
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include "epoll_common.h"
-
-bool epoll_new(int *epoll_fd)
-{
- *epoll_fd = epoll_create(32);
- if (*epoll_fd < 0)
- return false;
-
- return true;
-}
-
-void epoll_free(int *epoll_fd)
-{
- if (*epoll_fd >= 0)
- close(*epoll_fd);
-
- *epoll_fd = -1;
-}
-
-bool epoll_add(int *epoll_fd, int fd, void *device)
-{
- struct epoll_event event;
-
- event.events = EPOLLIN;
- event.data.ptr = device;
-
- /* Shouldn't happen, but just check it. */
- if (epoll_ctl(*epoll_fd, EPOLL_CTL_ADD, fd, &event) < 0)
- return false;
-
- return true;
-}
diff --git a/input/common/epoll_common.h b/input/common/epoll_common.h
deleted file mode 100644
index 8351b14989..0000000000
--- a/input/common/epoll_common.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* RetroArch - A frontend for libretro.
- * Copyright (C) 2011-2017 - Daniel De Matteis
- *
- * RetroArch is free software: you can redistribute it and/or modify it under the terms
- * of the GNU General Public License as published by the Free Software Found-
- * ation, either version 3 of the License, or (at your option) any later version.
- *
- * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
- * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- * PURPOSE. See the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along with RetroArch.
- * If not, see .
- */
-
-#ifndef _EPOLL_COMMON_H
-#define _EPOLL_COMMON_H
-
-#include
-
-#include
-
-bool epoll_new(int *epoll_fd);
-
-void epoll_free(int *epoll_fd);
-
-bool epoll_add(int *epoll_fd, int fd, void *device);
-
-#endif
diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c
index 8ff137c3c6..22cf62239e 100644
--- a/input/drivers/wayland_input.c
+++ b/input/drivers/wayland_input.c
@@ -43,7 +43,6 @@
#include "../../gfx/video_driver.h"
#include "../common/linux_common.h"
-#include "../common/epoll_common.h"
#include "../../gfx/common/wayland_common.h"
diff --git a/input/drivers_joypad/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c
index 11a5ce24a6..57595d4e99 100644
--- a/input/drivers_joypad/linuxraw_joypad.c
+++ b/input/drivers_joypad/linuxraw_joypad.c
@@ -33,7 +33,6 @@
#include "../input_config.h"
#include "../input_driver.h"
-#include "../common/epoll_common.h"
#include "../../verbosity.h"
#include "../../tasks/tasks_internal.h"
@@ -97,6 +96,8 @@ static bool linuxraw_joypad_init_pad(const char *path,
if (pad->fd >= 0)
{
+ struct epoll_event event;
+
if (ioctl(pad->fd,
JSIOCGNAME(sizeof(input_device_names[0])), pad->ident) >= 0)
{
@@ -105,13 +106,16 @@ static bool linuxraw_joypad_init_pad(const char *path,
else
RARCH_ERR("[Device]: Didn't find ident of %s.\n", path);
- if (epoll_add(&linuxraw_epoll, pad->fd, pad))
- return true;
- else
+ event.events = EPOLLIN;
+ event.data.ptr = pad;
+
+ if (epoll_ctl(linuxraw_epoll, EPOLL_CTL_ADD, pad->fd, &event) < 0)
{
RARCH_ERR("Failed to add FD (%d) to epoll list (%s).\n",
pad->fd, strerror(errno));
}
+ else
+ return true;
}
RARCH_ERR("[Device]: Failed to open pad %s (error: %s).\n",
@@ -232,10 +236,13 @@ retry:
static bool linuxraw_joypad_init(void *data)
{
unsigned i;
+ int fd = epoll_create(32);
- if (!epoll_new(&linuxraw_epoll))
+ if (fd < 0)
return false;
+ linuxraw_epoll = fd;
+
for (i = 0; i < MAX_USERS; i++)
{
char path[PATH_MAX_LENGTH];
@@ -265,9 +272,16 @@ static bool linuxraw_joypad_init(void *data)
if (linuxraw_inotify >= 0)
{
+ struct epoll_event event;
+
fcntl(linuxraw_inotify, F_SETFL, fcntl(linuxraw_inotify, F_GETFL) | O_NONBLOCK);
inotify_add_watch(linuxraw_inotify, "/dev/input", IN_DELETE | IN_CREATE | IN_ATTRIB);
- if (!epoll_add(&linuxraw_epoll, linuxraw_inotify, NULL))
+
+ event.events = EPOLLIN;
+ event.data.ptr = NULL;
+
+ /* Shouldn't happen, but just check it. */
+ if (epoll_ctl(linuxraw_epoll, EPOLL_CTL_ADD, linuxraw_inotify, &event) < 0)
{
RARCH_ERR("Failed to add FD (%d) to epoll list (%s).\n",
linuxraw_inotify, strerror(errno));
@@ -298,7 +312,9 @@ static void linuxraw_joypad_destroy(void)
close(linuxraw_inotify);
linuxraw_inotify = -1;
- epoll_free(&linuxraw_epoll);
+ if (linuxraw_epoll >= 0)
+ close(linuxraw_epoll);
+ linuxraw_epoll = -1;
linuxraw_hotplug = false;
}