diff options
| author | 2019-07-01 15:12:57 +1000 | |
|---|---|---|
| committer | 2019-07-01 15:12:57 +1000 | |
| commit | 472210bf72e1509f7266e49bf50be7a681078552 (patch) | |
| tree | 16647a42c9f71f764a5bf501422c16b4c09e4cdc /src/core | |
| parent | Merge pull request #2583 from FernandoS27/core-timing-safe (diff) | |
| download | yuzu-472210bf72e1509f7266e49bf50be7a681078552.tar.gz yuzu-472210bf72e1509f7266e49bf50be7a681078552.tar.xz yuzu-472210bf72e1509f7266e49bf50be7a681078552.zip | |
hid:StartLrAssignmentMode, hid:StopLrAssignmentMode, hid:SwapNpadAssignment
StartLrAssignmentMode and StopLrAssignmentMode don't require any implementation as it's just used for showing the screen of changing the controller orientation if the user wishes to do so. Ever since #1634 this has not been needed as users can specify the controller orientation from the config and swap at any time. We store a private member just in case this gets used for anything extra in the future
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 30 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 5 | ||||
| -rw-r--r-- | src/core/hle/service/hid/errors.h | 13 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 50 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.h | 3 |
6 files changed, 99 insertions, 3 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index cb77b99ee..7439018d9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -291,6 +291,7 @@ add_library(core STATIC | |||
| 291 | hle/service/hid/irs.h | 291 | hle/service/hid/irs.h |
| 292 | hle/service/hid/xcd.cpp | 292 | hle/service/hid/xcd.cpp |
| 293 | hle/service/hid/xcd.h | 293 | hle/service/hid/xcd.h |
| 294 | hle/service/hid/errors.h | ||
| 294 | hle/service/hid/controllers/controller_base.cpp | 295 | hle/service/hid/controllers/controller_base.cpp |
| 295 | hle/service/hid/controllers/controller_base.h | 296 | hle/service/hid/controllers/controller_base.h |
| 296 | hle/service/hid/controllers/debug_pad.cpp | 297 | hle/service/hid/controllers/debug_pad.cpp |
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index fdd6d79a2..99af0469d 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -548,6 +548,36 @@ void Controller_NPad::DisconnectNPad(u32 npad_id) { | |||
| 548 | connected_controllers[NPadIdToIndex(npad_id)].is_connected = false; | 548 | connected_controllers[NPadIdToIndex(npad_id)].is_connected = false; |
| 549 | } | 549 | } |
| 550 | 550 | ||
| 551 | void Controller_NPad::StartLRAssignmentMode() { | ||
| 552 | // Nothing internally is used for lr assignment mode. Since we have the ability to set the | ||
| 553 | // controller types from boot, it doesn't really matter about showing a selection screen | ||
| 554 | is_in_lr_assignment_mode = true; | ||
| 555 | } | ||
| 556 | |||
| 557 | void Controller_NPad::StopLRAssignmentMode() { | ||
| 558 | is_in_lr_assignment_mode = false; | ||
| 559 | } | ||
| 560 | |||
| 561 | bool Controller_NPad::SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2) { | ||
| 562 | if (npad_id_1 == NPAD_HANDHELD || npad_id_2 == NPAD_HANDHELD || npad_id_1 == NPAD_UNKNOWN || | ||
| 563 | npad_id_2 == NPAD_UNKNOWN) { | ||
| 564 | return true; | ||
| 565 | } | ||
| 566 | |||
| 567 | if (!IsControllerSupported(connected_controllers[NPadIdToIndex(npad_id_1)].type) || | ||
| 568 | !IsControllerSupported(connected_controllers[NPadIdToIndex(npad_id_2)].type)) { | ||
| 569 | return false; | ||
| 570 | } | ||
| 571 | |||
| 572 | std::swap(connected_controllers[NPadIdToIndex(npad_id_1)].type, | ||
| 573 | connected_controllers[NPadIdToIndex(npad_id_2)].type); | ||
| 574 | |||
| 575 | InitNewlyAddedControler(NPadIdToIndex(npad_id_1)); | ||
| 576 | InitNewlyAddedControler(NPadIdToIndex(npad_id_2)); | ||
| 577 | |||
| 578 | return true; | ||
| 579 | } | ||
| 580 | |||
| 551 | bool Controller_NPad::IsControllerSupported(NPadControllerType controller) { | 581 | bool Controller_NPad::IsControllerSupported(NPadControllerType controller) { |
| 552 | if (controller == NPadControllerType::Handheld) { | 582 | if (controller == NPadControllerType::Handheld) { |
| 553 | // Handheld is not even a supported type, lets stop here | 583 | // Handheld is not even a supported type, lets stop here |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index 4ff50b3cd..4b6c1083f 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -124,6 +124,10 @@ public: | |||
| 124 | void ConnectAllDisconnectedControllers(); | 124 | void ConnectAllDisconnectedControllers(); |
| 125 | void ClearAllControllers(); | 125 | void ClearAllControllers(); |
| 126 | 126 | ||
| 127 | void StartLRAssignmentMode(); | ||
| 128 | void StopLRAssignmentMode(); | ||
| 129 | bool SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2); | ||
| 130 | |||
| 127 | // Logical OR for all buttons presses on all controllers | 131 | // Logical OR for all buttons presses on all controllers |
| 128 | // Specifically for cheat engine and other features. | 132 | // Specifically for cheat engine and other features. |
| 129 | u32 GetAndResetPressState(); | 133 | u32 GetAndResetPressState(); |
| @@ -321,5 +325,6 @@ private: | |||
| 321 | void RequestPadStateUpdate(u32 npad_id); | 325 | void RequestPadStateUpdate(u32 npad_id); |
| 322 | std::array<ControllerPad, 10> npad_pad_states{}; | 326 | std::array<ControllerPad, 10> npad_pad_states{}; |
| 323 | bool IsControllerSupported(NPadControllerType controller); | 327 | bool IsControllerSupported(NPadControllerType controller); |
| 328 | bool is_in_lr_assignment_mode{false}; | ||
| 324 | }; | 329 | }; |
| 325 | } // namespace Service::HID | 330 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/errors.h b/src/core/hle/service/hid/errors.h new file mode 100644 index 000000000..3583642e7 --- /dev/null +++ b/src/core/hle/service/hid/errors.h | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | // Copyright 2019 yuzu emulator team | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "core/hle/result.h" | ||
| 8 | |||
| 9 | namespace Service::HID { | ||
| 10 | |||
| 11 | constexpr ResultCode ERR_NPAD_NOT_CONNECTED{ErrorModule::HID, 710}; | ||
| 12 | |||
| 13 | } // namespace Service::HID | ||
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index a4ad95d96..0bd24b8eb 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include "core/hle/kernel/readable_event.h" | 16 | #include "core/hle/kernel/readable_event.h" |
| 17 | #include "core/hle/kernel/shared_memory.h" | 17 | #include "core/hle/kernel/shared_memory.h" |
| 18 | #include "core/hle/kernel/writable_event.h" | 18 | #include "core/hle/kernel/writable_event.h" |
| 19 | #include "core/hle/service/hid/errors.h" | ||
| 19 | #include "core/hle/service/hid/hid.h" | 20 | #include "core/hle/service/hid/hid.h" |
| 20 | #include "core/hle/service/hid/irs.h" | 21 | #include "core/hle/service/hid/irs.h" |
| 21 | #include "core/hle/service/hid/xcd.h" | 22 | #include "core/hle/service/hid/xcd.h" |
| @@ -202,11 +203,11 @@ Hid::Hid() : ServiceFramework("hid") { | |||
| 202 | {123, nullptr, "SetNpadJoyAssignmentModeSingleByDefault"}, | 203 | {123, nullptr, "SetNpadJoyAssignmentModeSingleByDefault"}, |
| 203 | {124, &Hid::SetNpadJoyAssignmentModeDual, "SetNpadJoyAssignmentModeDual"}, | 204 | {124, &Hid::SetNpadJoyAssignmentModeDual, "SetNpadJoyAssignmentModeDual"}, |
| 204 | {125, &Hid::MergeSingleJoyAsDualJoy, "MergeSingleJoyAsDualJoy"}, | 205 | {125, &Hid::MergeSingleJoyAsDualJoy, "MergeSingleJoyAsDualJoy"}, |
| 205 | {126, nullptr, "StartLrAssignmentMode"}, | 206 | {126, &Hid::StartLrAssignmentMode, "StartLrAssignmentMode"}, |
| 206 | {127, nullptr, "StopLrAssignmentMode"}, | 207 | {127, &Hid::StopLrAssignmentMode, "StopLrAssignmentMode"}, |
| 207 | {128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"}, | 208 | {128, &Hid::SetNpadHandheldActivationMode, "SetNpadHandheldActivationMode"}, |
| 208 | {129, nullptr, "GetNpadHandheldActivationMode"}, | 209 | {129, nullptr, "GetNpadHandheldActivationMode"}, |
| 209 | {130, nullptr, "SwapNpadAssignment"}, | 210 | {130, &Hid::SwapNpadAssignment, "SwapNpadAssignment"}, |
| 210 | {131, nullptr, "IsUnintendedHomeButtonInputProtectionEnabled"}, | 211 | {131, nullptr, "IsUnintendedHomeButtonInputProtectionEnabled"}, |
| 211 | {132, nullptr, "EnableUnintendedHomeButtonInputProtection"}, | 212 | {132, nullptr, "EnableUnintendedHomeButtonInputProtection"}, |
| 212 | {133, nullptr, "SetNpadJoyAssignmentModeSingleWithDestination"}, | 213 | {133, nullptr, "SetNpadJoyAssignmentModeSingleWithDestination"}, |
| @@ -733,6 +734,49 @@ void Hid::SetPalmaBoostMode(Kernel::HLERequestContext& ctx) { | |||
| 733 | rb.Push(RESULT_SUCCESS); | 734 | rb.Push(RESULT_SUCCESS); |
| 734 | } | 735 | } |
| 735 | 736 | ||
| 737 | void Hid::StartLrAssignmentMode(Kernel::HLERequestContext& ctx) { | ||
| 738 | IPC::RequestParser rp{ctx}; | ||
| 739 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 740 | |||
| 741 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 742 | auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad); | ||
| 743 | controller.StartLRAssignmentMode(); | ||
| 744 | |||
| 745 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 746 | rb.Push(RESULT_SUCCESS); | ||
| 747 | } | ||
| 748 | |||
| 749 | void Hid::StopLrAssignmentMode(Kernel::HLERequestContext& ctx) { | ||
| 750 | IPC::RequestParser rp{ctx}; | ||
| 751 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 752 | |||
| 753 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}", applet_resource_user_id); | ||
| 754 | auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad); | ||
| 755 | controller.StopLRAssignmentMode(); | ||
| 756 | |||
| 757 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 758 | rb.Push(RESULT_SUCCESS); | ||
| 759 | } | ||
| 760 | |||
| 761 | void Hid::SwapNpadAssignment(Kernel::HLERequestContext& ctx) { | ||
| 762 | IPC::RequestParser rp{ctx}; | ||
| 763 | const auto npad_1{rp.Pop<u32>()}; | ||
| 764 | const auto npad_2{rp.Pop<u32>()}; | ||
| 765 | const auto applet_resource_user_id{rp.Pop<u64>()}; | ||
| 766 | |||
| 767 | LOG_DEBUG(Service_HID, "called, applet_resource_user_id={}, npad_1={}, npad_2={}", | ||
| 768 | applet_resource_user_id, npad_1, npad_2); | ||
| 769 | |||
| 770 | auto& controller = applet_resource->GetController<Controller_NPad>(HidController::NPad); | ||
| 771 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 772 | if (controller.SwapNpadAssignment(npad_1, npad_2)) { | ||
| 773 | rb.Push(RESULT_SUCCESS); | ||
| 774 | } else { | ||
| 775 | LOG_ERROR(Service_HID, "Npads are not connected!"); | ||
| 776 | rb.Push(ERR_NPAD_NOT_CONNECTED); | ||
| 777 | } | ||
| 778 | } | ||
| 779 | |||
| 736 | class HidDbg final : public ServiceFramework<HidDbg> { | 780 | class HidDbg final : public ServiceFramework<HidDbg> { |
| 737 | public: | 781 | public: |
| 738 | explicit HidDbg() : ServiceFramework{"hid:dbg"} { | 782 | explicit HidDbg() : ServiceFramework{"hid:dbg"} { |
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index d3660cad2..28260ef1b 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -119,6 +119,9 @@ private: | |||
| 119 | void StopSixAxisSensor(Kernel::HLERequestContext& ctx); | 119 | void StopSixAxisSensor(Kernel::HLERequestContext& ctx); |
| 120 | void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); | 120 | void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx); |
| 121 | void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); | 121 | void SetPalmaBoostMode(Kernel::HLERequestContext& ctx); |
| 122 | void StartLrAssignmentMode(Kernel::HLERequestContext& ctx); | ||
| 123 | void StopLrAssignmentMode(Kernel::HLERequestContext& ctx); | ||
| 124 | void SwapNpadAssignment(Kernel::HLERequestContext& ctx); | ||
| 122 | 125 | ||
| 123 | std::shared_ptr<IAppletResource> applet_resource; | 126 | std::shared_ptr<IAppletResource> applet_resource; |
| 124 | }; | 127 | }; |