From 472210bf72e1509f7266e49bf50be7a681078552 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Mon, 1 Jul 2019 15:12:57 +1000 Subject: 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 --- src/core/hle/service/hid/controllers/npad.cpp | 30 +++++++++++++++++++++++++++ src/core/hle/service/hid/controllers/npad.h | 5 +++++ 2 files changed, 35 insertions(+) (limited to 'src/core/hle/service/hid/controllers') 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) { connected_controllers[NPadIdToIndex(npad_id)].is_connected = false; } +void Controller_NPad::StartLRAssignmentMode() { + // Nothing internally is used for lr assignment mode. Since we have the ability to set the + // controller types from boot, it doesn't really matter about showing a selection screen + is_in_lr_assignment_mode = true; +} + +void Controller_NPad::StopLRAssignmentMode() { + is_in_lr_assignment_mode = false; +} + +bool Controller_NPad::SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2) { + if (npad_id_1 == NPAD_HANDHELD || npad_id_2 == NPAD_HANDHELD || npad_id_1 == NPAD_UNKNOWN || + npad_id_2 == NPAD_UNKNOWN) { + return true; + } + + if (!IsControllerSupported(connected_controllers[NPadIdToIndex(npad_id_1)].type) || + !IsControllerSupported(connected_controllers[NPadIdToIndex(npad_id_2)].type)) { + return false; + } + + std::swap(connected_controllers[NPadIdToIndex(npad_id_1)].type, + connected_controllers[NPadIdToIndex(npad_id_2)].type); + + InitNewlyAddedControler(NPadIdToIndex(npad_id_1)); + InitNewlyAddedControler(NPadIdToIndex(npad_id_2)); + + return true; +} + bool Controller_NPad::IsControllerSupported(NPadControllerType controller) { if (controller == NPadControllerType::Handheld) { // 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: void ConnectAllDisconnectedControllers(); void ClearAllControllers(); + void StartLRAssignmentMode(); + void StopLRAssignmentMode(); + bool SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2); + // Logical OR for all buttons presses on all controllers // Specifically for cheat engine and other features. u32 GetAndResetPressState(); @@ -321,5 +325,6 @@ private: void RequestPadStateUpdate(u32 npad_id); std::array npad_pad_states{}; bool IsControllerSupported(NPadControllerType controller); + bool is_in_lr_assignment_mode{false}; }; } // namespace Service::HID -- cgit v1.2.3