Make sure HIDAPI is initialized whenever we call HIDAPI_IsDevicePresent()
authorSam Lantinga <slouken@libsdl.org>
Wed, 31 Jul 2019 10:20:37 -0700
changeset 12973c52f7214f707
parent 12972 c3c029a0b94b
child 12974 0fef4b21fa1d
Make sure HIDAPI is initialized whenever we call HIDAPI_IsDevicePresent()
src/joystick/hidapi/SDL_hidapijoystick.c
src/joystick/linux/SDL_sysjoystick.c
     1.1 --- a/src/joystick/hidapi/SDL_hidapijoystick.c	Wed Jul 31 11:14:48 2019 -0500
     1.2 +++ b/src/joystick/hidapi/SDL_hidapijoystick.c	Wed Jul 31 10:20:37 2019 -0700
     1.3 @@ -918,6 +918,11 @@
     1.4  {
     1.5      SDL_HIDAPI_Device *device;
     1.6  
     1.7 +    /* Make sure we're initialized, as this could be called from other drivers during startup */
     1.8 +    if (HIDAPI_JoystickInit() < 0) {
     1.9 +        return SDL_FALSE;
    1.10 +    }
    1.11 +
    1.12      /* Don't update the device list for devices we know aren't supported */
    1.13      if (!HIDAPI_IsDeviceSupported(vendor_id, product_id, version)) {
    1.14          return SDL_FALSE;
     2.1 --- a/src/joystick/linux/SDL_sysjoystick.c	Wed Jul 31 11:14:48 2019 -0500
     2.2 +++ b/src/joystick/linux/SDL_sysjoystick.c	Wed Jul 31 10:20:37 2019 -0700
     2.3 @@ -120,8 +120,6 @@
     2.4      }
     2.5  
     2.6  #ifdef SDL_JOYSTICK_HIDAPI
     2.7 -    SDL_HIDAPI_JoystickDriver.Init();
     2.8 -
     2.9      if (HIDAPI_IsDevicePresent(inpid.vendor, inpid.product, inpid.version)) {
    2.10          /* The HIDAPI driver is taking care of this device */
    2.11          return 0;