diff --git a/Makefile.common b/Makefile.common
index 2fdc341072..6b9f0b197a 100644
--- a/Makefile.common
+++ b/Makefile.common
@@ -638,6 +638,7 @@ ifeq ($(HAVE_UDEV), 1)
DEFINES += $(UDEV_CFLAGS)
LIBS += $(UDEV_LIBS)
OBJ += input/drivers/udev_input.o \
+ input/common/udev_common.o \
input/drivers_keyboard/keyboard_event_udev.o \
input/drivers_joypad/udev_joypad.o
endif
diff --git a/griffin/griffin.c b/griffin/griffin.c
index ab734ccd0d..e6cc4b3451 100644
--- a/griffin/griffin.c
+++ b/griffin/griffin.c
@@ -473,6 +473,7 @@ INPUT
#endif
#ifdef HAVE_UDEV
+#include "../input/common/udev_common.c"
#include "../input/drivers/udev_input.c"
#include "../input/drivers_keyboard/keyboard_event_udev.c"
#include "../input/drivers_joypad/udev_joypad.c"
diff --git a/input/common/udev_common.c b/input/common/udev_common.c
new file mode 100644
index 0000000000..d256f3916d
--- /dev/null
+++ b/input/common/udev_common.c
@@ -0,0 +1,34 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
+ * Copyright (C) 2011-2016 - 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 "udev_common.h"
+
+bool udev_hotplug_available(void *dev)
+{
+ struct pollfd fds;
+
+ fds.fd = udev_monitor_get_fd((struct udev_monitor*)dev);
+ fds.events = POLLIN;
+ fds.revents = 0;
+
+ return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
+}
diff --git a/input/common/udev_common.h b/input/common/udev_common.h
new file mode 100644
index 0000000000..c9ea19c191
--- /dev/null
+++ b/input/common/udev_common.h
@@ -0,0 +1,23 @@
+/* RetroArch - A frontend for libretro.
+ * Copyright (C) 2011-2016 - 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 _UDEV_COMMON_H
+#define _UDEV_COMMON_H
+
+#include
+
+bool udev_hotplug_available(void *dev);
+
+#endif
diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c
index c576f47a9b..69c3385ae0 100644
--- a/input/drivers_joypad/udev_joypad.c
+++ b/input/drivers_joypad/udev_joypad.c
@@ -23,7 +23,6 @@
#include
#include
-#include
#include
#include
#include
@@ -34,6 +33,9 @@
#include "../input_autodetect.h"
#include "../input_driver.h"
+
+#include "../common/udev_common.h"
+
#include "../../configuration.h"
#include "../../runloop.h"
#include "../../verbosity.h"
@@ -160,17 +162,6 @@ static void udev_poll_pad(struct udev_joypad *pad, unsigned p)
}
}
-static INLINE bool udev_hotplug_available(void)
-{
- struct pollfd fds;
-
- fds.fd = udev_monitor_get_fd(g_udev_mon);
- fds.events = POLLIN;
- fds.revents = 0;
-
- return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN);
-}
-
static int udev_find_vacant_pad(void)
{
unsigned i;
@@ -515,7 +506,7 @@ static void udev_joypad_poll(void)
{
unsigned i;
- while (g_udev_mon && udev_hotplug_available())
+ while (g_udev_mon && udev_hotplug_available(g_udev_mon))
{
struct udev_device *dev = udev_monitor_receive_device(g_udev_mon);
if (dev)