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 | |
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')
-rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 25 | ||||
-rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 2 | ||||
-rw-r--r-- | src/core/hle/service/hid/hid.cpp | 8 |
3 files changed, 22 insertions, 13 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 { diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 654d97c3f..0cff6821f 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -121,7 +121,7 @@ public: void SetNpadMode(u32 npad_id, NPadAssignments assignment_mode); - void VibrateController(const std::vector<u32>& controller_ids, + void VibrateController(const std::vector<u32>& controllers, const std::vector<Vibration>& vibrations); Vibration GetLastVibration() const; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 395e83b3f..dc198791d 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -802,18 +802,18 @@ void Hid::EndPermitVibrationSession(Kernel::HLERequestContext& ctx) { void Hid::SendVibrationValue(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; - const auto controller_id{rp.Pop<u32>()}; + const auto controller{rp.Pop<u32>()}; const auto vibration_values{rp.PopRaw<Controller_NPad::Vibration>()}; const auto applet_resource_user_id{rp.Pop<u64>()}; - LOG_DEBUG(Service_HID, "called, controller_id={}, applet_resource_user_id={}", controller_id, + LOG_DEBUG(Service_HID, "called, controller={}, applet_resource_user_id={}", controller, applet_resource_user_id); IPC::ResponseBuilder rb{ctx, 2}; rb.Push(RESULT_SUCCESS); applet_resource->GetController<Controller_NPad>(HidController::NPad) - .VibrateController({controller_id}, {vibration_values}); + .VibrateController({controller}, {vibration_values}); } void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { @@ -831,8 +831,6 @@ void Hid::SendVibrationValues(Kernel::HLERequestContext& ctx) { std::memcpy(controller_list.data(), controllers.data(), controllers.size()); std::memcpy(vibration_list.data(), vibrations.data(), vibrations.size()); - std::transform(controller_list.begin(), controller_list.end(), controller_list.begin(), - [](u32 controller_id) { return controller_id - 3; }); applet_resource->GetController<Controller_NPad>(HidController::NPad) .VibrateController(controller_list, vibration_list); |