Document that it's not possible to use the HIDAPI driver for PS3 controllers on Windows

This commit is contained in:
Sam Lantinga 2022-08-24 06:38:36 -07:00
parent 5eb0f4328d
commit 1fc7f68118
2 changed files with 20 additions and 5 deletions
include
src/joystick/hidapi

View File

@ -712,7 +712,10 @@ extern "C" {
* "0" - HIDAPI driver is not used * "0" - HIDAPI driver is not used
* "1" - HIDAPI driver is used * "1" - HIDAPI driver is used
* *
* The default is the value of SDL_HINT_JOYSTICK_HIDAPI * The default is the value of SDL_HINT_JOYSTICK_HIDAPI on macOS, and "0" on other platforms.
*
* It is not possible to use this driver on Windows, due to limitations in the default drivers
* installed. See https://github.com/ViGEm/DsHidMini for an alternative driver on Windows.
*/ */
#define SDL_HINT_JOYSTICK_HIDAPI_PS3 "SDL_JOYSTICK_HIDAPI_PS3" #define SDL_HINT_JOYSTICK_HIDAPI_PS3 "SDL_JOYSTICK_HIDAPI_PS3"

View File

@ -79,14 +79,26 @@ HIDAPI_DriverPS3_UnregisterHints(SDL_HintCallback callback, void *userdata)
static SDL_bool static SDL_bool
HIDAPI_DriverPS3_IsEnabled(void) HIDAPI_DriverPS3_IsEnabled(void)
{ {
#ifdef __MACOSX__ #if defined(__MACOSX__)
/* This works well on macOS */
return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3,
SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI, SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI,
SDL_HIDAPI_DEFAULT)); SDL_HIDAPI_DEFAULT));
#else #elif defined(__WINDOWS__)
/* Linux already has good PS3 drivers and controller initialization fails on Windows, /* You can't initialize the controller with the stock Windows drivers
* so don't bother using this driver on other platforms. * See https://github.com/ViGEm/DsHidMini as an alternative driver
*/ */
return SDL_FALSE;
#elif defined(__LINUX__)
/* Linux drivers do a better job of managing the transition between
* USB and Bluetooth. There are also some quirks in communicating
* with PS3 controllers that have been implemented in SDL's hidapi
* for libusb, but are not possible to support using hidraw if the
* kernel doesn't already know about them.
*/
return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_FALSE);
#else
/* Untested, default off */
return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_FALSE); return SDL_GetHintBoolean(SDL_HINT_JOYSTICK_HIDAPI_PS3, SDL_FALSE);
#endif #endif
} }