Skip to content

Commit

Permalink
Make sure HIDAPI is initialized whenever we call HIDAPI_IsDevicePrese…
Browse files Browse the repository at this point in the history
…nt()
  • Loading branch information
slouken committed Jul 31, 2019
1 parent c172f36 commit c10a874
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/joystick/hidapi/SDL_hidapijoystick.c
Expand Up @@ -918,6 +918,11 @@ HIDAPI_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version)
{
SDL_HIDAPI_Device *device;

/* Make sure we're initialized, as this could be called from other drivers during startup */
if (HIDAPI_JoystickInit() < 0) {
return SDL_FALSE;
}

/* Don't update the device list for devices we know aren't supported */
if (!HIDAPI_IsDeviceSupported(vendor_id, product_id, version)) {
return SDL_FALSE;
Expand Down
2 changes: 0 additions & 2 deletions src/joystick/linux/SDL_sysjoystick.c
Expand Up @@ -120,8 +120,6 @@ IsJoystick(int fd, char *namebuf, const size_t namebuflen, SDL_JoystickGUID *gui
}

#ifdef SDL_JOYSTICK_HIDAPI
SDL_HIDAPI_JoystickDriver.Init();

if (HIDAPI_IsDevicePresent(inpid.vendor, inpid.product, inpid.version)) {
/* The HIDAPI driver is taking care of this device */
return 0;
Expand Down

0 comments on commit c10a874

Please sign in to comment.