ControllerInterface: replace Reinitialize with RefreshDevices

The SDL backend crashes when you close a joystick after SDL_Quit has
been called. Some backends don't need to be shutdown and
re-initialized everytime, we can just ask to enumerate devices again.
This commit is contained in:
Michael Maltese
2016-10-16 13:39:05 -07:00
parent cebb4d84f2
commit 3e69d066f5
21 changed files with 79 additions and 25 deletions

View File

@ -141,10 +141,15 @@ static void StopHotplugThread()
void Init()
{
s_devnode_name_map.clear();
PopulateDevices();
StartHotplugThread();
}
// During initialization we use udev to iterate over all /dev/input/event* devices.
// Note: the Linux kernel is currently limited to just 32 event devices. If this ever
// changes, hopefully udev will take care of this.
void PopulateDevices()
{
// We use udev to iterate over all /dev/input/event* devices.
// Note: the Linux kernel is currently limited to just 32 event devices. If
// this ever changes, hopefully udev will take care of this.
udev* udev = udev_new();
_assert_msg_(PAD, udev != nullptr, "Couldn't initialize libudev.");
@ -182,8 +187,6 @@ void Init()
}
udev_enumerate_unref(enumerate);
udev_unref(udev);
StartHotplugThread();
}
void Shutdown()