We need to check for the instance where udev is only initialized

for the joypad part and not the general input driver
This commit is contained in:
twinaphex 2015-11-30 16:56:32 +01:00
parent 62260cf892
commit 6d90c42bb5
4 changed files with 12 additions and 8 deletions

View File

@ -5,14 +5,17 @@
#include "udev_common.h"
static bool udev_mon_inited;
static bool udev_mon_first_inited_is_joypad;
static struct udev_monitor *g_udev_mon;
static struct udev *g_udev;
bool udev_mon_new(void)
bool udev_mon_new(bool is_joypad)
{
if (udev_mon_inited)
return true;
udev_mon_first_inited_is_joypad = is_joypad;
g_udev = udev_new();
if (!g_udev)
return false;
@ -31,7 +34,7 @@ bool udev_mon_new(void)
void udev_mon_free(bool is_joypad)
{
if (!udev_mon_inited || is_joypad)
if (!udev_mon_inited || (is_joypad && !udev_mon_first_inited_is_joypad))
return;
if (g_udev_mon)
@ -39,9 +42,10 @@ void udev_mon_free(bool is_joypad)
if (g_udev)
udev_unref(g_udev);
g_udev_mon = NULL;
g_udev = NULL;
udev_mon_inited = false;
g_udev_mon = NULL;
g_udev = NULL;
udev_mon_inited = false;
udev_mon_first_inited_is_joypad = false;
}
bool udev_mon_hotplug_available(void)

View File

@ -21,7 +21,7 @@
#include <boolean.h>
bool udev_mon_new(void);
bool udev_mon_new(bool is_joypad);
void udev_mon_free(bool is_joypad);

View File

@ -621,7 +621,7 @@ static void *udev_input_init(void)
if (!udev)
return NULL;
if (!udev_mon_new())
if (!udev_mon_new(false))
goto error;
#ifdef HAVE_XKBCOMMON

View File

@ -515,7 +515,7 @@ static bool udev_joypad_init(void *data)
for (i = 0; i < MAX_USERS; i++)
udev_pads[i].fd = -1;
if (!udev_mon_new())
if (!udev_mon_new(true))
goto error;
enumerate = udev_mon_enumerate();