diff options
author | german77 <juangerman-13@hotmail.com> | 2021-10-20 21:41:56 +0200 |
---|---|---|
committer | Narr the Reg <juangerman-13@hotmail.com> | 2021-11-25 03:30:24 +0100 |
commit | c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048 (patch) | |
tree | 9ecde3ad19cbbb29f418655fc0125cef6c7b31ab /src/input_common | |
parent | core/hid: Only signal when needed (diff) | |
download | yuzu-c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048.tar yuzu-c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048.tar.gz yuzu-c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048.tar.bz2 yuzu-c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048.tar.lz yuzu-c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048.tar.xz yuzu-c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048.tar.zst yuzu-c3ff0a8ac0d1c3f9c0791b5263dae53c06ad6048.zip |
Diffstat (limited to 'src/input_common')
-rw-r--r-- | src/input_common/drivers/sdl_driver.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/input_common/drivers/sdl_driver.cpp b/src/input_common/drivers/sdl_driver.cpp index cee2d965f..d56351815 100644 --- a/src/input_common/drivers/sdl_driver.cpp +++ b/src/input_common/drivers/sdl_driver.cpp @@ -107,6 +107,14 @@ public: return false; } + + bool HasHDRumble() const { + if (sdl_controller) { + return (SDL_GameControllerGetType(sdl_controller.get()) == + SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO); + } + return false; + } /** * The Pad identifier of the joystick */ @@ -515,16 +523,26 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, const auto process_amplitude = [](f32 amplitude) { return (amplitude + std::pow(amplitude, 0.3f)) * 0.5f * 0xFFFF; }; - const Input::VibrationStatus new_vibration{ + const Input::VibrationStatus exponential_vibration{ .low_amplitude = process_amplitude(vibration.low_amplitude), .low_frequency = vibration.low_frequency, .high_amplitude = process_amplitude(vibration.high_amplitude), .high_frequency = vibration.high_frequency, + .type = Input::VibrationAmplificationType::Exponential, }; + Input::VibrationStatus new_vibration{}; + + if (vibration.type == Input::VibrationAmplificationType::Linear || joystick->HasHDRumble()) { + new_vibration = vibration; + } else { + new_vibration = exponential_vibration; + } + if (!joystick->RumblePlay(new_vibration)) { return Input::VibrationError::Unknown; } + return Input::VibrationError::None; } Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, |