Fixed game controller hotplug support for some embedded Linux devices
When guessing the device class, it ends up being 0 for devices that have been removed (because the device node no longer exists)
parent
0874eb9713
commit
a725806662
|
@ -142,13 +142,15 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui
|
||||||
#if SDL_USE_LIBUDEV
|
#if SDL_USE_LIBUDEV
|
||||||
void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath)
|
void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath)
|
||||||
{
|
{
|
||||||
if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
|
if (devpath == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch( udev_type )
|
switch (udev_type) {
|
||||||
{
|
|
||||||
case SDL_UDEV_DEVICEADDED:
|
case SDL_UDEV_DEVICEADDED:
|
||||||
|
if (!(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
MaybeAddDevice(devpath);
|
MaybeAddDevice(devpath);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -335,7 +337,6 @@ JoystickInitWithoutUdev(void)
|
||||||
static int
|
static int
|
||||||
JoystickInitWithUdev(void)
|
JoystickInitWithUdev(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (SDL_UDEV_Init() < 0) {
|
if (SDL_UDEV_Init() < 0) {
|
||||||
return SDL_SetError("Could not initialize UDEV");
|
return SDL_SetError("Could not initialize UDEV");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue