summaryrefslogtreecommitdiffstats
path: root/src/input_common/drivers/sdl_driver.cpp
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-01-24 15:29:37 +0100
committerGitHub <noreply@github.com>2023-01-24 15:29:37 +0100
commita68af583ea378b48e2ed5a19f519a815ba89e40f (patch)
tree2983c14a7d4bc2797259c7d97462a439bec629f3 /src/input_common/drivers/sdl_driver.cpp
parentMerge pull request #9555 from abouvier/catch2-update (diff)
parentcore: hid: Make use of SCOPE_EXIT and SCOPE_GUARD where applicable (diff)
downloadyuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar
yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.gz
yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.bz2
yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.lz
yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.xz
yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.tar.zst
yuzu-a68af583ea378b48e2ed5a19f519a815ba89e40f.zip
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
-rw-r--r--src/input_common/drivers/sdl_driver.cpp23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp
index 9835d99d2..d975eb815 100644
--- a/src/input_common/drivers/sdl_driver.cpp
+++ b/src/input_common/drivers/sdl_driver.cpp
@@ -334,6 +334,15 @@ void SDLDriver::InitJoystick(int joystick_index) {
const auto guid = GetGUID(sdl_joystick);
+ if (Settings::values.enable_joycon_driver) {
+ if (guid.uuid[5] == 0x05 && guid.uuid[4] == 0x7e &&
+ (guid.uuid[8] == 0x06 || guid.uuid[8] == 0x07)) {
+ LOG_WARNING(Input, "Preferring joycon driver for device index {}", joystick_index);
+ SDL_JoystickClose(sdl_joystick);
+ return;
+ }
+ }
+
std::scoped_lock lock{joystick_map_mutex};
if (joystick_map.find(guid) == joystick_map.end()) {
auto joystick = std::make_shared<SDLJoystick>(guid, 0, sdl_joystick, sdl_gamecontroller);
@@ -456,9 +465,13 @@ SDLDriver::SDLDriver(std::string input_engine_) : InputEngine(std::move(input_en
SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1");
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
- // Use hidapi driver for joycons. This will allow joycons to be detected as a GameController and
- // not a generic one
- SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
+ // Disable hidapi drivers for switch controllers when the custom joycon driver is enabled
+ if (Settings::values.enable_joycon_driver) {
+ SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "0");
+ } else {
+ SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1");
+ }
+ SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1");
// Disable hidapi driver for xbox. Already default on Windows, this causes conflict with native
// driver on Linux.
@@ -548,7 +561,7 @@ std::vector<Common::ParamPackage> SDLDriver::GetInputDevices() const {
return devices;
}
-Common::Input::VibrationError SDLDriver::SetVibration(
+Common::Input::DriverResult SDLDriver::SetVibration(
const PadIdentifier& identifier, const Common::Input::VibrationStatus& vibration) {
const auto joystick =
GetSDLJoystickByGUID(identifier.guid.RawString(), static_cast<int>(identifier.port));
@@ -582,7 +595,7 @@ Common::Input::VibrationError SDLDriver::SetVibration(
.vibration = new_vibration,
});
- return Common::Input::VibrationError::None;
+ return Common::Input::DriverResult::Success;
}
bool SDLDriver::IsVibrationEnabled(const PadIdentifier& identifier) {