diff options
| author | 2021-10-26 23:37:46 -0500 | |
|---|---|---|
| committer | 2021-11-24 20:30:26 -0600 | |
| commit | 7348e205d94e2fff777781498a2ef7931163703a (patch) | |
| tree | e0a29217bbc2108d2ee0841652d1f37dd7a65060 /src/core/hid/emulated_controller.cpp | |
| parent | core/hid: Rework battery mappings (diff) | |
| download | yuzu-7348e205d94e2fff777781498a2ef7931163703a.tar.gz yuzu-7348e205d94e2fff777781498a2ef7931163703a.tar.xz yuzu-7348e205d94e2fff777781498a2ef7931163703a.zip | |
input_common: Add multiple vibration curves
Diffstat (limited to 'src/core/hid/emulated_controller.cpp')
| -rw-r--r-- | src/core/hid/emulated_controller.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/hid/emulated_controller.cpp b/src/core/hid/emulated_controller.cpp index 83ced5635..916368c68 100644 --- a/src/core/hid/emulated_controller.cpp +++ b/src/core/hid/emulated_controller.cpp | |||
| @@ -251,7 +251,8 @@ void EmulatedController::RestoreConfig() { | |||
| 251 | ReloadFromSettings(); | 251 | ReloadFromSettings(); |
| 252 | } | 252 | } |
| 253 | 253 | ||
| 254 | std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices(DeviceIndex device_index) const { | 254 | std::vector<Common::ParamPackage> EmulatedController::GetMappedDevices( |
| 255 | DeviceIndex device_index) const { | ||
| 255 | std::vector<Common::ParamPackage> devices; | 256 | std::vector<Common::ParamPackage> devices; |
| 256 | for (const auto& param : button_params) { | 257 | for (const auto& param : button_params) { |
| 257 | if (!param.Has("engine")) { | 258 | if (!param.Has("engine")) { |
| @@ -658,6 +659,10 @@ bool EmulatedController::SetVibration(std::size_t device_index, VibrationValue v | |||
| 658 | const auto& player = Settings::values.players.GetValue()[player_index]; | 659 | const auto& player = Settings::values.players.GetValue()[player_index]; |
| 659 | const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; | 660 | const f32 strength = static_cast<f32>(player.vibration_strength) / 100.0f; |
| 660 | 661 | ||
| 662 | if (!player.vibration_enabled) { | ||
| 663 | return false; | ||
| 664 | } | ||
| 665 | |||
| 661 | // Exponential amplification is too strong at low amplitudes. Switch to a linear | 666 | // Exponential amplification is too strong at low amplitudes. Switch to a linear |
| 662 | // amplification if strength is set below 0.7f | 667 | // amplification if strength is set below 0.7f |
| 663 | const Input::VibrationAmplificationType type = | 668 | const Input::VibrationAmplificationType type = |
| @@ -860,6 +865,9 @@ AnalogSticks EmulatedController::GetSticks() const { | |||
| 860 | } | 865 | } |
| 861 | // Some drivers like stick from buttons need constant refreshing | 866 | // Some drivers like stick from buttons need constant refreshing |
| 862 | for (auto& device : stick_devices) { | 867 | for (auto& device : stick_devices) { |
| 868 | if (!device) { | ||
| 869 | continue; | ||
| 870 | } | ||
| 863 | device->SoftUpdate(); | 871 | device->SoftUpdate(); |
| 864 | } | 872 | } |
| 865 | return controller.analog_stick_state; | 873 | return controller.analog_stick_state; |