diff options
author | german <german@thesoftwareartisans.com> | 2020-07-11 04:20:50 +0200 |
---|---|---|
committer | Morph <39850852+Morph1984@users.noreply.github.com> | 2020-09-29 16:38:25 +0200 |
commit | ab88c2f6112edba35bfa91ee8864e760728d16e8 (patch) | |
tree | 4c7647f97153276733896cbc6e35d929db926b82 /src/core/hle/service/hid/controllers/npad.cpp | |
parent | Merge pull request #4719 from lioncash/audio-warn (diff) | |
download | yuzu-ab88c2f6112edba35bfa91ee8864e760728d16e8.tar yuzu-ab88c2f6112edba35bfa91ee8864e760728d16e8.tar.gz yuzu-ab88c2f6112edba35bfa91ee8864e760728d16e8.tar.bz2 yuzu-ab88c2f6112edba35bfa91ee8864e760728d16e8.tar.lz yuzu-ab88c2f6112edba35bfa91ee8864e760728d16e8.tar.xz yuzu-ab88c2f6112edba35bfa91ee8864e760728d16e8.tar.zst yuzu-ab88c2f6112edba35bfa91ee8864e760728d16e8.zip |
Diffstat (limited to 'src/core/hle/service/hid/controllers/npad.cpp')
-rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 620386cd1..83c3beab6 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -609,20 +609,31 @@ void Controller_NPad::SetNpadMode(u32 npad_id, NPadAssignments assignment_mode) } } -void Controller_NPad::VibrateController(const std::vector<u32>& controller_ids, +void Controller_NPad::VibrateController(const std::vector<u32>& controllers, const std::vector<Vibration>& vibrations) { - LOG_DEBUG(Service_HID, "(STUBBED) called"); + LOG_TRACE(Service_HID, "called"); if (!Settings::values.vibration_enabled || !can_controllers_vibrate) { return; } - for (std::size_t i = 0; i < controller_ids.size(); i++) { - std::size_t controller_pos = NPadIdToIndex(static_cast<u32>(i)); - if (connected_controllers[controller_pos].is_connected) { - // TODO(ogniK): Vibrate the physical controller + bool success = true; + for (std::size_t i = 0; i < controllers.size(); ++i) { + if (!connected_controllers[i].is_connected) { + continue; + } + using namespace Settings::NativeButton; + const auto& button_state = buttons[i]; + if (button_state[A - BUTTON_HID_BEGIN]) { + if (button_state[A - BUTTON_HID_BEGIN]->SetRumblePlay( + vibrations[0].amp_high, vibrations[0].amp_low, vibrations[0].freq_high, + vibrations[0].freq_low)) { + success = false; + } } } - last_processed_vibration = vibrations.back(); + if (success) { + last_processed_vibration = vibrations.back(); + } } Controller_NPad::Vibration Controller_NPad::GetLastVibration() const { |