From a83eb90a78c4ee3aac3636e22bebc8ab460b46f2 Mon Sep 17 00:00:00 2001 From: Morph1984 <39850852+Morph1984@users.noreply.github.com> Date: Wed, 4 Sep 2019 02:42:22 -0400 Subject: [PATCH 1/7] Update hid.cpp --- src/core/hle/service/hid/hid.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 0bd24b8eb1..6446edae30 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -216,8 +216,8 @@ Hid::Hid() : ServiceFramework("hid") { {201, &Hid::SendVibrationValue, "SendVibrationValue"}, {202, &Hid::GetActualVibrationValue, "GetActualVibrationValue"}, {203, &Hid::CreateActiveVibrationDeviceList, "CreateActiveVibrationDeviceList"}, - {204, nullptr, "PermitVibration"}, - {205, nullptr, "IsVibrationPermitted"}, + {204, &Hid::PermitVibration, "PermitVibration"}, + {205, &Hid::IsVibrationPermitted, "IsVibrationPermitted"}, {206, &Hid::SendVibrationValues, "SendVibrationValues"}, {207, nullptr, "SendVibrationGcErmCommand"}, {208, nullptr, "GetActualVibrationGcErmCommand"}, @@ -679,6 +679,27 @@ void Hid::CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx) { rb.PushIpcInterface(); } +void Hid::PermitVibration(Kernel::HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto can_vibrate{rp.Pop()}; + applet_resource->GetController(HidController::NPad) + .SetVibrationEnabled(can_vibrate); + + LOG_DEBUG(Service_HID, "called, can_vibrate={}", can_vibrate); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(RESULT_SUCCESS); +} + +void Hid::IsVibrationPermitted(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_HID, "called"); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(RESULT_SUCCESS); + rb.Push(applet_resource->GetController(HidController::NPad) + .IsVibrationEnabled()); +} + void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto applet_resource_user_id{rp.Pop()}; From 155947774063494aec2c3f113b9438fafd4ac813 Mon Sep 17 00:00:00 2001 From: Morph1984 <39850852+Morph1984@users.noreply.github.com> Date: Wed, 4 Sep 2019 02:42:42 -0400 Subject: [PATCH 2/7] Update hid.h --- src/core/hle/service/hid/hid.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 28260ef1b8..2fd6d9fc70 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -114,6 +114,8 @@ private: void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx); void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx); void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx); + void PermitVibration(Kernel::HLERequestContext& ctx); + void IsVibrationPermitted(Kernel::HLERequestContext& ctx); void ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx); void StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx); void StopSixAxisSensor(Kernel::HLERequestContext& ctx); From 5130b8a6a919d711e558f8ab7bd03655a38d3f09 Mon Sep 17 00:00:00 2001 From: Morph1984 <39850852+Morph1984@users.noreply.github.com> Date: Wed, 4 Sep 2019 02:42:58 -0400 Subject: [PATCH 3/7] Update npad.cpp --- src/core/hle/service/hid/controllers/npad.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index 1e81f776f0..eb44b60268 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -636,10 +636,15 @@ Controller_NPad::LedPattern Controller_NPad::GetLedPattern(u32 npad_id) { return LedPattern{0, 0, 0, 0}; }; } + void Controller_NPad::SetVibrationEnabled(bool can_vibrate) { can_controllers_vibrate = can_vibrate; } +bool Controller_NPad::IsVibrationEnabled() { + return can_controllers_vibrate; +} + void Controller_NPad::ClearAllConnectedControllers() { for (auto& controller : connected_controllers) { if (controller.is_connected && controller.type != NPadControllerType::None) { @@ -648,6 +653,7 @@ void Controller_NPad::ClearAllConnectedControllers() { } } } + void Controller_NPad::DisconnectAllConnectedControllers() { std::for_each(connected_controllers.begin(), connected_controllers.end(), [](ControllerHolder& controller) { controller.is_connected = false; }); From ee35f7adf7864df4a9b511c71b08e8fc980e484f Mon Sep 17 00:00:00 2001 From: Morph1984 <39850852+Morph1984@users.noreply.github.com> Date: Wed, 4 Sep 2019 02:43:17 -0400 Subject: [PATCH 4/7] Update npad.h --- src/core/hle/service/hid/controllers/npad.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 4b6c1083fb..5572a9a14c 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -119,6 +119,7 @@ public: void DisconnectNPad(u32 npad_id); LedPattern GetLedPattern(u32 npad_id); void SetVibrationEnabled(bool can_vibrate); + bool IsVibrationEnabled(); void ClearAllConnectedControllers(); void DisconnectAllConnectedControllers(); void ConnectAllDisconnectedControllers(); From d6969fa7d4fed7460530ab2e17f48043c8613f6b Mon Sep 17 00:00:00 2001 From: Morph1984 <39850852+Morph1984@users.noreply.github.com> Date: Wed, 4 Sep 2019 10:06:38 -0400 Subject: [PATCH 5/7] clang-format --- src/core/hle/service/hid/hid.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 6446edae30..f8b1ca8166 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -696,8 +696,8 @@ void Hid::IsVibrationPermitted(Kernel::HLERequestContext& ctx) { IPC::ResponseBuilder rb{ctx, 3}; rb.Push(RESULT_SUCCESS); - rb.Push(applet_resource->GetController(HidController::NPad) - .IsVibrationEnabled()); + rb.Push( + applet_resource->GetController(HidController::NPad).IsVibrationEnabled()); } void Hid::ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx) { From ef98828d40378f9c020f59dec25b4e21fe0dbc39 Mon Sep 17 00:00:00 2001 From: Morph1984 <39850852+Morph1984@users.noreply.github.com> Date: Wed, 4 Sep 2019 10:15:49 -0400 Subject: [PATCH 6/7] IsVibrationEnabled() as a const member func --- src/core/hle/service/hid/controllers/npad.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index eb44b60268..e47fe81885 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp @@ -641,7 +641,7 @@ void Controller_NPad::SetVibrationEnabled(bool can_vibrate) { can_controllers_vibrate = can_vibrate; } -bool Controller_NPad::IsVibrationEnabled() { +bool Controller_NPad::IsVibrationEnabled() const { return can_controllers_vibrate; } From cd81194fc00af3cdc30d7221785c18e536982b4c Mon Sep 17 00:00:00 2001 From: Morph1984 <39850852+Morph1984@users.noreply.github.com> Date: Wed, 4 Sep 2019 10:16:22 -0400 Subject: [PATCH 7/7] ditto Co-Authored-By: David <25727384+ogniK5377@users.noreply.github.com> --- src/core/hle/service/hid/controllers/npad.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 5572a9a14c..f28b368066 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h @@ -119,7 +119,7 @@ public: void DisconnectNPad(u32 npad_id); LedPattern GetLedPattern(u32 npad_id); void SetVibrationEnabled(bool can_vibrate); - bool IsVibrationEnabled(); + bool IsVibrationEnabled() const; void ClearAllConnectedControllers(); void DisconnectAllConnectedControllers(); void ConnectAllDisconnectedControllers();