diff options
Diffstat (limited to 'src/input_common/drivers/sdl_driver.cpp')
| -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: | |||
| 107 | 107 | ||
| 108 | return false; | 108 | return false; |
| 109 | } | 109 | } |
| 110 | |||
| 111 | bool HasHDRumble() const { | ||
| 112 | if (sdl_controller) { | ||
| 113 | return (SDL_GameControllerGetType(sdl_controller.get()) == | ||
| 114 | SDL_CONTROLLER_TYPE_NINTENDO_SWITCH_PRO); | ||
| 115 | } | ||
| 116 | return false; | ||
| 117 | } | ||
| 110 | /** | 118 | /** |
| 111 | * The Pad identifier of the joystick | 119 | * The Pad identifier of the joystick |
| 112 | */ | 120 | */ |
| @@ -515,16 +523,26 @@ Input::VibrationError SDLDriver::SetRumble(const PadIdentifier& identifier, | |||
| 515 | const auto process_amplitude = [](f32 amplitude) { | 523 | const auto process_amplitude = [](f32 amplitude) { |
| 516 | return (amplitude + std::pow(amplitude, 0.3f)) * 0.5f * 0xFFFF; | 524 | return (amplitude + std::pow(amplitude, 0.3f)) * 0.5f * 0xFFFF; |
| 517 | }; | 525 | }; |
| 518 | const Input::VibrationStatus new_vibration{ | 526 | const Input::VibrationStatus exponential_vibration{ |
| 519 | .low_amplitude = process_amplitude(vibration.low_amplitude), | 527 | .low_amplitude = process_amplitude(vibration.low_amplitude), |
| 520 | .low_frequency = vibration.low_frequency, | 528 | .low_frequency = vibration.low_frequency, |
| 521 | .high_amplitude = process_amplitude(vibration.high_amplitude), | 529 | .high_amplitude = process_amplitude(vibration.high_amplitude), |
| 522 | .high_frequency = vibration.high_frequency, | 530 | .high_frequency = vibration.high_frequency, |
| 531 | .type = Input::VibrationAmplificationType::Exponential, | ||
| 523 | }; | 532 | }; |
| 524 | 533 | ||
| 534 | Input::VibrationStatus new_vibration{}; | ||
| 535 | |||
| 536 | if (vibration.type == Input::VibrationAmplificationType::Linear || joystick->HasHDRumble()) { | ||
| 537 | new_vibration = vibration; | ||
| 538 | } else { | ||
| 539 | new_vibration = exponential_vibration; | ||
| 540 | } | ||
| 541 | |||
| 525 | if (!joystick->RumblePlay(new_vibration)) { | 542 | if (!joystick->RumblePlay(new_vibration)) { |
| 526 | return Input::VibrationError::Unknown; | 543 | return Input::VibrationError::Unknown; |
| 527 | } | 544 | } |
| 545 | |||
| 528 | return Input::VibrationError::None; | 546 | return Input::VibrationError::None; |
| 529 | } | 547 | } |
| 530 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, | 548 | Common::ParamPackage SDLDriver::BuildAnalogParamPackageForButton(int port, std::string guid, |