hid: Implement MergeSingleJoyasDualJoy

- Used in multiple games such as Super Mario Odyssey.
This commit is contained in:
Morph
2020-08-27 13:27:03 -04:00
parent 045f50bc7f
commit 0e33b19ae0
3 changed files with 24 additions and 5 deletions

View File

@ -574,6 +574,22 @@ Controller_NPad::GyroscopeZeroDriftMode Controller_NPad::GetGyroscopeZeroDriftMo
return gyroscope_zero_drift_mode;
}
void Controller_NPad::MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2) {
const auto npad_index_1 = NPadIdToIndex(npad_id_1);
const auto npad_index_2 = NPadIdToIndex(npad_id_2);
// If the controllers at both npad indices form a pair of left and right joycons, merge them.
// Otherwise, do nothing.
if ((connected_controllers[npad_index_1].type == NPadControllerType::JoyLeft &&
connected_controllers[npad_index_2].type == NPadControllerType::JoyRight) ||
(connected_controllers[npad_index_2].type == NPadControllerType::JoyLeft &&
connected_controllers[npad_index_1].type == NPadControllerType::JoyRight)) {
// Disconnect the joycon at the second id and connect the dual joycon at the first index.
DisconnectNPad(npad_id_2);
AddNewControllerAt(NPadControllerType::JoyDual, npad_index_1);
}
}
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

View File

@ -134,6 +134,7 @@ public:
void ConnectAllDisconnectedControllers();
void ClearAllControllers();
void MergeSingleJoyAsDualJoy(u32 npad_id_1, u32 npad_id_2);
void StartLRAssignmentMode();
void StopLRAssignmentMode();
bool SwapNpadAssignment(u32 npad_id_1, u32 npad_id_2);