SDLControllerInterface: Add option for PS4/PS5 enhanced mode

This commit is contained in:
Connor McLaughlin
2021-09-08 11:28:40 +10:00
parent 396b4a48f2
commit 4b31806bc9
3 changed files with 44 additions and 27 deletions

View File

@ -3169,6 +3169,7 @@ void CommonHostInterface::SetDefaultSettings(SettingsInterface& si)
si.SetStringValue("Main", "ControllerBackend",
ControllerInterface::GetBackendName(ControllerInterface::GetDefaultBackend()));
si.SetBoolValue("Main", "ControllerEnhancedMode", false);
si.SetBoolValue("Display", "InternalResolutionScreenshots", false);

View File

@ -39,6 +39,16 @@ bool SDLControllerInterface::Initialize(CommonHostInterface* host_interface)
}
}
const bool ds4_rumble_enabled = host_interface->GetBoolSettingValue("Main", "ControllerEnhancedMode", false);
if (ds4_rumble_enabled)
{
Log_InfoPrintf("Enabling PS4/PS5 enhanced mode.");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "true");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "true");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "true");
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "true");
}
if (SDL_InitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) < 0)
{
Log_ErrorPrintf("SDL_InitSubSystem(SDL_INIT_JOYSTICK |SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC) failed");