diff options
| -rw-r--r-- | src/core/hid/hid_core.cpp | 10 | ||||
| -rw-r--r-- | src/core/hid/hid_core.h | 3 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.cpp | 165 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/npad.h | 8 | ||||
| -rw-r--r-- | src/core/hle/service/hid/hid.cpp | 26 |
5 files changed, 174 insertions, 38 deletions
diff --git a/src/core/hid/hid_core.cpp b/src/core/hid/hid_core.cpp index 0c3eb5a62..a1c3bbb57 100644 --- a/src/core/hid/hid_core.cpp +++ b/src/core/hid/hid_core.cpp | |||
| @@ -145,6 +145,16 @@ NpadIdType HIDCore::GetFirstNpadId() const { | |||
| 145 | return NpadIdType::Player1; | 145 | return NpadIdType::Player1; |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | NpadIdType HIDCore::GetFirstDisconnectedNpadId() const { | ||
| 149 | for (std::size_t player_index = 0; player_index < available_controllers; ++player_index) { | ||
| 150 | const auto* const controller = GetEmulatedControllerByIndex(player_index); | ||
| 151 | if (!controller->IsConnected()) { | ||
| 152 | return controller->GetNpadIdType(); | ||
| 153 | } | ||
| 154 | } | ||
| 155 | return NpadIdType::Player1; | ||
| 156 | } | ||
| 157 | |||
| 148 | void HIDCore::EnableAllControllerConfiguration() { | 158 | void HIDCore::EnableAllControllerConfiguration() { |
| 149 | player_1->EnableConfiguration(); | 159 | player_1->EnableConfiguration(); |
| 150 | player_2->EnableConfiguration(); | 160 | player_2->EnableConfiguration(); |
diff --git a/src/core/hid/hid_core.h b/src/core/hid/hid_core.h index 2fb0f7e19..837f7de49 100644 --- a/src/core/hid/hid_core.h +++ b/src/core/hid/hid_core.h | |||
| @@ -45,6 +45,9 @@ public: | |||
| 45 | /// Returns the first connected npad id | 45 | /// Returns the first connected npad id |
| 46 | NpadIdType GetFirstNpadId() const; | 46 | NpadIdType GetFirstNpadId() const; |
| 47 | 47 | ||
| 48 | /// Returns the first disconnected npad id | ||
| 49 | NpadIdType GetFirstDisconnectedNpadId() const; | ||
| 50 | |||
| 48 | /// Sets all emulated controllers into configuring mode. | 51 | /// Sets all emulated controllers into configuring mode. |
| 49 | void EnableAllControllerConfiguration(); | 52 | void EnableAllControllerConfiguration(); |
| 50 | 53 | ||
diff --git a/src/core/hle/service/hid/controllers/npad.cpp b/src/core/hle/service/hid/controllers/npad.cpp index ae56f10cf..2705e9dcb 100644 --- a/src/core/hle/service/hid/controllers/npad.cpp +++ b/src/core/hle/service/hid/controllers/npad.cpp | |||
| @@ -110,7 +110,7 @@ void Controller_NPad::ControllerUpdate(Core::HID::ControllerTriggerType type, | |||
| 110 | UpdateControllerAt(npad_type, npad_id, is_connected); | 110 | UpdateControllerAt(npad_type, npad_id, is_connected); |
| 111 | break; | 111 | break; |
| 112 | case Core::HID::ControllerTriggerType::Battery: { | 112 | case Core::HID::ControllerTriggerType::Battery: { |
| 113 | if (!controller.is_connected) { | 113 | if (!controller.device->IsConnected()) { |
| 114 | return; | 114 | return; |
| 115 | } | 115 | } |
| 116 | auto& shared_memory = controller.shared_memory_entry; | 116 | auto& shared_memory = controller.shared_memory_entry; |
| @@ -150,7 +150,6 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { | |||
| 150 | shared_memory.system_properties.is_vertical.Assign(1); | 150 | shared_memory.system_properties.is_vertical.Assign(1); |
| 151 | shared_memory.system_properties.use_plus.Assign(1); | 151 | shared_memory.system_properties.use_plus.Assign(1); |
| 152 | shared_memory.system_properties.use_minus.Assign(1); | 152 | shared_memory.system_properties.use_minus.Assign(1); |
| 153 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | ||
| 154 | shared_memory.applet_footer.type = AppletFooterUiType::SwitchProController; | 153 | shared_memory.applet_footer.type = AppletFooterUiType::SwitchProController; |
| 155 | break; | 154 | break; |
| 156 | case Core::HID::NpadStyleIndex::Handheld: | 155 | case Core::HID::NpadStyleIndex::Handheld: |
| @@ -166,21 +165,30 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { | |||
| 166 | break; | 165 | break; |
| 167 | case Core::HID::NpadStyleIndex::JoyconDual: | 166 | case Core::HID::NpadStyleIndex::JoyconDual: |
| 168 | shared_memory.style_tag.joycon_dual.Assign(1); | 167 | shared_memory.style_tag.joycon_dual.Assign(1); |
| 169 | shared_memory.device_type.joycon_left.Assign(1); | 168 | if (controller.is_dual_left_connected) { |
| 170 | shared_memory.device_type.joycon_right.Assign(1); | 169 | shared_memory.device_type.joycon_left.Assign(1); |
| 171 | shared_memory.system_properties.is_vertical.Assign(1); | 170 | shared_memory.system_properties.use_minus.Assign(1); |
| 172 | shared_memory.system_properties.use_plus.Assign(1); | 171 | } |
| 173 | shared_memory.system_properties.use_minus.Assign(1); | 172 | if (controller.is_dual_right_connected) { |
| 173 | shared_memory.device_type.joycon_right.Assign(1); | ||
| 174 | shared_memory.system_properties.use_plus.Assign(1); | ||
| 175 | } | ||
| 174 | shared_memory.system_properties.use_directional_buttons.Assign(1); | 176 | shared_memory.system_properties.use_directional_buttons.Assign(1); |
| 177 | shared_memory.system_properties.is_vertical.Assign(1); | ||
| 175 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; | 178 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Dual; |
| 176 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDual; | 179 | if (controller.is_dual_left_connected && controller.is_dual_right_connected) { |
| 180 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDual; | ||
| 181 | } else if (controller.is_dual_left_connected) { | ||
| 182 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDualLeftOnly; | ||
| 183 | } else { | ||
| 184 | shared_memory.applet_footer.type = AppletFooterUiType::JoyDualRightOnly; | ||
| 185 | } | ||
| 177 | break; | 186 | break; |
| 178 | case Core::HID::NpadStyleIndex::JoyconLeft: | 187 | case Core::HID::NpadStyleIndex::JoyconLeft: |
| 179 | shared_memory.style_tag.joycon_left.Assign(1); | 188 | shared_memory.style_tag.joycon_left.Assign(1); |
| 180 | shared_memory.device_type.joycon_left.Assign(1); | 189 | shared_memory.device_type.joycon_left.Assign(1); |
| 181 | shared_memory.system_properties.is_horizontal.Assign(1); | 190 | shared_memory.system_properties.is_horizontal.Assign(1); |
| 182 | shared_memory.system_properties.use_minus.Assign(1); | 191 | shared_memory.system_properties.use_minus.Assign(1); |
| 183 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | ||
| 184 | shared_memory.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal; | 192 | shared_memory.applet_footer.type = AppletFooterUiType::JoyLeftHorizontal; |
| 185 | break; | 193 | break; |
| 186 | case Core::HID::NpadStyleIndex::JoyconRight: | 194 | case Core::HID::NpadStyleIndex::JoyconRight: |
| @@ -188,7 +196,6 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { | |||
| 188 | shared_memory.device_type.joycon_right.Assign(1); | 196 | shared_memory.device_type.joycon_right.Assign(1); |
| 189 | shared_memory.system_properties.is_horizontal.Assign(1); | 197 | shared_memory.system_properties.is_horizontal.Assign(1); |
| 190 | shared_memory.system_properties.use_plus.Assign(1); | 198 | shared_memory.system_properties.use_plus.Assign(1); |
| 191 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | ||
| 192 | shared_memory.applet_footer.type = AppletFooterUiType::JoyRightHorizontal; | 199 | shared_memory.applet_footer.type = AppletFooterUiType::JoyRightHorizontal; |
| 193 | break; | 200 | break; |
| 194 | case Core::HID::NpadStyleIndex::GameCube: | 201 | case Core::HID::NpadStyleIndex::GameCube: |
| @@ -200,7 +207,6 @@ void Controller_NPad::InitNewlyAddedController(Core::HID::NpadIdType npad_id) { | |||
| 200 | case Core::HID::NpadStyleIndex::Pokeball: | 207 | case Core::HID::NpadStyleIndex::Pokeball: |
| 201 | shared_memory.style_tag.palma.Assign(1); | 208 | shared_memory.style_tag.palma.Assign(1); |
| 202 | shared_memory.device_type.palma.Assign(1); | 209 | shared_memory.device_type.palma.Assign(1); |
| 203 | shared_memory.assignment_mode = NpadJoyAssignmentMode::Single; | ||
| 204 | break; | 210 | break; |
| 205 | case Core::HID::NpadStyleIndex::NES: | 211 | case Core::HID::NpadStyleIndex::NES: |
| 206 | shared_memory.style_tag.lark.Assign(1); | 212 | shared_memory.style_tag.lark.Assign(1); |
| @@ -443,11 +449,15 @@ void Controller_NPad::OnUpdate(const Core::Timing::CoreTiming& core_timing, u8* | |||
| 443 | case Core::HID::NpadStyleIndex::JoyconDual: | 449 | case Core::HID::NpadStyleIndex::JoyconDual: |
| 444 | pad_state.connection_status.raw = 0; | 450 | pad_state.connection_status.raw = 0; |
| 445 | pad_state.connection_status.is_connected.Assign(1); | 451 | pad_state.connection_status.is_connected.Assign(1); |
| 446 | pad_state.connection_status.is_left_connected.Assign(1); | 452 | if (controller.is_dual_left_connected) { |
| 447 | pad_state.connection_status.is_right_connected.Assign(1); | 453 | pad_state.connection_status.is_left_connected.Assign(1); |
| 454 | libnx_state.connection_status.is_left_connected.Assign(1); | ||
| 455 | } | ||
| 456 | if (controller.is_dual_right_connected) { | ||
| 457 | pad_state.connection_status.is_right_connected.Assign(1); | ||
| 458 | libnx_state.connection_status.is_right_connected.Assign(1); | ||
| 459 | } | ||
| 448 | 460 | ||
| 449 | libnx_state.connection_status.is_left_connected.Assign(1); | ||
| 450 | libnx_state.connection_status.is_right_connected.Assign(1); | ||
| 451 | pad_state.sampling_number = | 461 | pad_state.sampling_number = |
| 452 | npad.joy_dual_lifo.ReadCurrentEntry().state.sampling_number + 1; | 462 | npad.joy_dual_lifo.ReadCurrentEntry().state.sampling_number + 1; |
| 453 | npad.joy_dual_lifo.WriteNextEntry(pad_state); | 463 | npad.joy_dual_lifo.WriteNextEntry(pad_state); |
| @@ -687,7 +697,7 @@ Controller_NPad::NpadCommunicationMode Controller_NPad::GetNpadCommunicationMode | |||
| 687 | return communication_mode; | 697 | return communication_mode; |
| 688 | } | 698 | } |
| 689 | 699 | ||
| 690 | void Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id, | 700 | void Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type, |
| 691 | NpadJoyAssignmentMode assignment_mode) { | 701 | NpadJoyAssignmentMode assignment_mode) { |
| 692 | if (!IsNpadIdValid(npad_id)) { | 702 | if (!IsNpadIdValid(npad_id)) { |
| 693 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); | 703 | LOG_ERROR(Service_HID, "Invalid NpadIdType npad_id:{}", npad_id); |
| @@ -698,6 +708,62 @@ void Controller_NPad::SetNpadMode(Core::HID::NpadIdType npad_id, | |||
| 698 | if (controller.shared_memory_entry.assignment_mode != assignment_mode) { | 708 | if (controller.shared_memory_entry.assignment_mode != assignment_mode) { |
| 699 | controller.shared_memory_entry.assignment_mode = assignment_mode; | 709 | controller.shared_memory_entry.assignment_mode = assignment_mode; |
| 700 | } | 710 | } |
| 711 | |||
| 712 | if (!controller.device->IsConnected()) { | ||
| 713 | return; | ||
| 714 | } | ||
| 715 | |||
| 716 | if (assignment_mode == NpadJoyAssignmentMode::Dual) { | ||
| 717 | if (controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft) { | ||
| 718 | DisconnectNpad(npad_id); | ||
| 719 | controller.is_dual_left_connected = true; | ||
| 720 | controller.is_dual_right_connected = false; | ||
| 721 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id, true); | ||
| 722 | return; | ||
| 723 | } | ||
| 724 | if (controller.device->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight) { | ||
| 725 | DisconnectNpad(npad_id); | ||
| 726 | controller.is_dual_left_connected = false; | ||
| 727 | controller.is_dual_right_connected = true; | ||
| 728 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id, true); | ||
| 729 | return; | ||
| 730 | } | ||
| 731 | return; | ||
| 732 | } | ||
| 733 | |||
| 734 | // This is for NpadJoyAssignmentMode::Single | ||
| 735 | |||
| 736 | // Only JoyconDual get affected by this function | ||
| 737 | if (controller.device->GetNpadStyleIndex() != Core::HID::NpadStyleIndex::JoyconDual) { | ||
| 738 | return; | ||
| 739 | } | ||
| 740 | |||
| 741 | if (controller.is_dual_left_connected && !controller.is_dual_right_connected) { | ||
| 742 | DisconnectNpad(npad_id); | ||
| 743 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconLeft, npad_id, true); | ||
| 744 | return; | ||
| 745 | } | ||
| 746 | if (!controller.is_dual_left_connected && controller.is_dual_right_connected) { | ||
| 747 | DisconnectNpad(npad_id); | ||
| 748 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconRight, npad_id, true); | ||
| 749 | return; | ||
| 750 | } | ||
| 751 | |||
| 752 | // We have two controllers connected to the same npad_id we need to split them | ||
| 753 | const auto npad_id_2 = hid_core.GetFirstDisconnectedNpadId(); | ||
| 754 | auto& controller_2 = GetControllerFromNpadIdType(npad_id_2); | ||
| 755 | DisconnectNpad(npad_id); | ||
| 756 | if (npad_device_type == NpadJoyDeviceType::Left) { | ||
| 757 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconLeft, npad_id, true); | ||
| 758 | controller_2.is_dual_left_connected = false; | ||
| 759 | controller_2.is_dual_right_connected = true; | ||
| 760 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id_2, true); | ||
| 761 | } else { | ||
| 762 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconRight, npad_id, true); | ||
| 763 | controller_2.is_dual_left_connected = true; | ||
| 764 | controller_2.is_dual_right_connected = false; | ||
| 765 | UpdateControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id_2, true); | ||
| 766 | } | ||
| 701 | } | 767 | } |
| 702 | 768 | ||
| 703 | bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, | 769 | bool Controller_NPad::VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, |
| @@ -907,6 +973,7 @@ void Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) { | |||
| 907 | } | 973 | } |
| 908 | 974 | ||
| 909 | auto& shared_memory_entry = controller.shared_memory_entry; | 975 | auto& shared_memory_entry = controller.shared_memory_entry; |
| 976 | // Don't reset shared_memory_entry.assignment_mode this value is persistent | ||
| 910 | shared_memory_entry.style_tag.raw = Core::HID::NpadStyleSet::None; // Zero out | 977 | shared_memory_entry.style_tag.raw = Core::HID::NpadStyleSet::None; // Zero out |
| 911 | shared_memory_entry.device_type.raw = 0; | 978 | shared_memory_entry.device_type.raw = 0; |
| 912 | shared_memory_entry.system_properties.raw = 0; | 979 | shared_memory_entry.system_properties.raw = 0; |
| @@ -923,9 +990,10 @@ void Controller_NPad::DisconnectNpad(Core::HID::NpadIdType npad_id) { | |||
| 923 | .left = {}, | 990 | .left = {}, |
| 924 | .right = {}, | 991 | .right = {}, |
| 925 | }; | 992 | }; |
| 926 | shared_memory_entry.assignment_mode = NpadJoyAssignmentMode::Dual; | ||
| 927 | shared_memory_entry.applet_footer.type = AppletFooterUiType::None; | 993 | shared_memory_entry.applet_footer.type = AppletFooterUiType::None; |
| 928 | 994 | ||
| 995 | controller.is_dual_left_connected = true; | ||
| 996 | controller.is_dual_right_connected = true; | ||
| 929 | controller.is_connected = false; | 997 | controller.is_connected = false; |
| 930 | controller.device->Disconnect(); | 998 | controller.device->Disconnect(); |
| 931 | SignalStyleSetChangedEvent(npad_id); | 999 | SignalStyleSetChangedEvent(npad_id); |
| @@ -1022,19 +1090,70 @@ void Controller_NPad::MergeSingleJoyAsDualJoy(Core::HID::NpadIdType npad_id_1, | |||
| 1022 | npad_id_2); | 1090 | npad_id_2); |
| 1023 | return; | 1091 | return; |
| 1024 | } | 1092 | } |
| 1025 | auto& controller_1 = GetControllerFromNpadIdType(npad_id_1).device; | 1093 | auto& controller_1 = GetControllerFromNpadIdType(npad_id_1); |
| 1026 | auto& controller_2 = GetControllerFromNpadIdType(npad_id_2).device; | 1094 | auto& controller_2 = GetControllerFromNpadIdType(npad_id_2); |
| 1095 | const auto controller_style_1 = controller_1.device->GetNpadStyleIndex(); | ||
| 1096 | const auto controller_style_2 = controller_2.device->GetNpadStyleIndex(); | ||
| 1097 | bool merge_controllers = false; | ||
| 1027 | 1098 | ||
| 1028 | // If the controllers at both npad indices form a pair of left and right joycons, merge them. | 1099 | // If the controllers at both npad indices form a pair of left and right joycons, merge them. |
| 1029 | // Otherwise, do nothing. | 1100 | // Otherwise, do nothing. |
| 1030 | if ((controller_1->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft && | 1101 | if (controller_style_1 == Core::HID::NpadStyleIndex::JoyconLeft && |
| 1031 | controller_2->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight) || | 1102 | controller_style_2 == Core::HID::NpadStyleIndex::JoyconRight) { |
| 1032 | (controller_2->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconLeft && | 1103 | merge_controllers = true; |
| 1033 | controller_1->GetNpadStyleIndex() == Core::HID::NpadStyleIndex::JoyconRight)) { | 1104 | } |
| 1105 | if (controller_style_2 == Core::HID::NpadStyleIndex::JoyconLeft && | ||
| 1106 | controller_style_1 == Core::HID::NpadStyleIndex::JoyconRight) { | ||
| 1107 | merge_controllers = true; | ||
| 1108 | } | ||
| 1109 | if (controller_style_1 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1110 | controller_style_2 == Core::HID::NpadStyleIndex::JoyconRight && | ||
| 1111 | controller_1.is_dual_left_connected && !controller_1.is_dual_right_connected) { | ||
| 1112 | merge_controllers = true; | ||
| 1113 | } | ||
| 1114 | if (controller_style_1 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1115 | controller_style_2 == Core::HID::NpadStyleIndex::JoyconLeft && | ||
| 1116 | !controller_1.is_dual_left_connected && controller_1.is_dual_right_connected) { | ||
| 1117 | merge_controllers = true; | ||
| 1118 | } | ||
| 1119 | if (controller_style_2 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1120 | controller_style_1 == Core::HID::NpadStyleIndex::JoyconRight && | ||
| 1121 | controller_2.is_dual_left_connected && !controller_2.is_dual_right_connected) { | ||
| 1122 | merge_controllers = true; | ||
| 1123 | } | ||
| 1124 | if (controller_style_2 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1125 | controller_style_1 == Core::HID::NpadStyleIndex::JoyconLeft && | ||
| 1126 | !controller_2.is_dual_left_connected && controller_2.is_dual_right_connected) { | ||
| 1127 | merge_controllers = true; | ||
| 1128 | } | ||
| 1129 | if (controller_style_1 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1130 | controller_style_2 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1131 | controller_1.is_dual_left_connected && !controller_1.is_dual_right_connected && | ||
| 1132 | !controller_2.is_dual_left_connected && controller_2.is_dual_right_connected) { | ||
| 1133 | merge_controllers = true; | ||
| 1134 | } | ||
| 1135 | if (controller_style_1 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1136 | controller_style_2 == Core::HID::NpadStyleIndex::JoyconDual && | ||
| 1137 | !controller_1.is_dual_left_connected && controller_1.is_dual_right_connected && | ||
| 1138 | controller_2.is_dual_left_connected && !controller_2.is_dual_right_connected) { | ||
| 1139 | merge_controllers = true; | ||
| 1140 | } | ||
| 1141 | |||
| 1142 | if (merge_controllers) { | ||
| 1034 | // Disconnect the joycon at the second id and connect the dual joycon at the first index. | 1143 | // Disconnect the joycon at the second id and connect the dual joycon at the first index. |
| 1035 | DisconnectNpad(npad_id_2); | 1144 | DisconnectNpad(npad_id_2); |
| 1145 | controller_1.is_dual_left_connected = true; | ||
| 1146 | controller_1.is_dual_right_connected = true; | ||
| 1036 | AddNewControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id_1); | 1147 | AddNewControllerAt(Core::HID::NpadStyleIndex::JoyconDual, npad_id_1); |
| 1148 | return; | ||
| 1037 | } | 1149 | } |
| 1150 | LOG_WARNING(Service_HID, | ||
| 1151 | "Controllers can't be merged npad_id_1:{}, npad_id_2:{}, type_1:{}, type_2:{}, " | ||
| 1152 | "dual_1(left/right):{}/{}, dual_2(left/right):{}/{}", | ||
| 1153 | npad_id_1, npad_id_2, controller_1.device->GetNpadStyleIndex(), | ||
| 1154 | controller_2.device->GetNpadStyleIndex(), controller_1.is_dual_left_connected, | ||
| 1155 | controller_1.is_dual_right_connected, controller_2.is_dual_left_connected, | ||
| 1156 | controller_2.is_dual_right_connected); | ||
| 1038 | } | 1157 | } |
| 1039 | 1158 | ||
| 1040 | void Controller_NPad::StartLRAssignmentMode() { | 1159 | void Controller_NPad::StartLRAssignmentMode() { |
diff --git a/src/core/hle/service/hid/controllers/npad.h b/src/core/hle/service/hid/controllers/npad.h index de5fa5a64..63281cb35 100644 --- a/src/core/hle/service/hid/controllers/npad.h +++ b/src/core/hle/service/hid/controllers/npad.h | |||
| @@ -113,7 +113,8 @@ public: | |||
| 113 | void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_); | 113 | void SetNpadCommunicationMode(NpadCommunicationMode communication_mode_); |
| 114 | NpadCommunicationMode GetNpadCommunicationMode() const; | 114 | NpadCommunicationMode GetNpadCommunicationMode() const; |
| 115 | 115 | ||
| 116 | void SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyAssignmentMode assignment_mode); | 116 | void SetNpadMode(Core::HID::NpadIdType npad_id, NpadJoyDeviceType npad_device_type, |
| 117 | NpadJoyAssignmentMode assignment_mode); | ||
| 117 | 118 | ||
| 118 | bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index, | 119 | bool VibrateControllerAtIndex(Core::HID::NpadIdType npad_id, std::size_t device_index, |
| 119 | const Core::HID::VibrationValue& vibration_value); | 120 | const Core::HID::VibrationValue& vibration_value); |
| @@ -464,7 +465,10 @@ private: | |||
| 464 | std::array<VibrationData, 2> vibration{}; | 465 | std::array<VibrationData, 2> vibration{}; |
| 465 | bool unintended_home_button_input_protection{}; | 466 | bool unintended_home_button_input_protection{}; |
| 466 | bool is_connected{}; | 467 | bool is_connected{}; |
| 467 | Core::HID::NpadStyleIndex npad_type{Core::HID::NpadStyleIndex::None}; | 468 | |
| 469 | // Dual joycons can have only one side connected | ||
| 470 | bool is_dual_left_connected{true}; | ||
| 471 | bool is_dual_right_connected{true}; | ||
| 468 | 472 | ||
| 469 | // Motion parameters | 473 | // Motion parameters |
| 470 | bool sixaxis_at_rest{true}; | 474 | bool sixaxis_at_rest{true}; |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index b36689552..ea5b2680d 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -975,35 +975,35 @@ void Hid::SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx | |||
| 975 | const auto parameters{rp.PopRaw<Parameters>()}; | 975 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 976 | 976 | ||
| 977 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 977 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
| 978 | .SetNpadMode(parameters.npad_id, Controller_NPad::NpadJoyAssignmentMode::Single); | 978 | .SetNpadMode(parameters.npad_id, Controller_NPad::NpadJoyDeviceType::Left, |
| 979 | Controller_NPad::NpadJoyAssignmentMode::Single); | ||
| 979 | 980 | ||
| 980 | LOG_WARNING(Service_HID, "(STUBBED) called, npad_id={}, applet_resource_user_id={}", | 981 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, |
| 981 | parameters.npad_id, parameters.applet_resource_user_id); | 982 | parameters.applet_resource_user_id); |
| 982 | 983 | ||
| 983 | IPC::ResponseBuilder rb{ctx, 2}; | 984 | IPC::ResponseBuilder rb{ctx, 2}; |
| 984 | rb.Push(ResultSuccess); | 985 | rb.Push(ResultSuccess); |
| 985 | } | 986 | } |
| 986 | 987 | ||
| 987 | void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { | 988 | void Hid::SetNpadJoyAssignmentModeSingle(Kernel::HLERequestContext& ctx) { |
| 988 | // TODO: Check the differences between this and SetNpadJoyAssignmentModeSingleByDefault | ||
| 989 | IPC::RequestParser rp{ctx}; | 989 | IPC::RequestParser rp{ctx}; |
| 990 | struct Parameters { | 990 | struct Parameters { |
| 991 | Core::HID::NpadIdType npad_id; | 991 | Core::HID::NpadIdType npad_id; |
| 992 | INSERT_PADDING_WORDS_NOINIT(1); | 992 | INSERT_PADDING_WORDS_NOINIT(1); |
| 993 | u64 applet_resource_user_id; | 993 | u64 applet_resource_user_id; |
| 994 | u64 npad_joy_device_type; | 994 | Controller_NPad::NpadJoyDeviceType npad_joy_device_type; |
| 995 | }; | 995 | }; |
| 996 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); | 996 | static_assert(sizeof(Parameters) == 0x18, "Parameters has incorrect size."); |
| 997 | 997 | ||
| 998 | const auto parameters{rp.PopRaw<Parameters>()}; | 998 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 999 | 999 | ||
| 1000 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 1000 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
| 1001 | .SetNpadMode(parameters.npad_id, Controller_NPad::NpadJoyAssignmentMode::Single); | 1001 | .SetNpadMode(parameters.npad_id, parameters.npad_joy_device_type, |
| 1002 | Controller_NPad::NpadJoyAssignmentMode::Single); | ||
| 1002 | 1003 | ||
| 1003 | LOG_WARNING(Service_HID, | 1004 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", |
| 1004 | "(STUBBED) called, npad_id={}, applet_resource_user_id={}, npad_joy_device_type={}", | 1005 | parameters.npad_id, parameters.applet_resource_user_id, |
| 1005 | parameters.npad_id, parameters.applet_resource_user_id, | 1006 | parameters.npad_joy_device_type); |
| 1006 | parameters.npad_joy_device_type); | ||
| 1007 | 1007 | ||
| 1008 | IPC::ResponseBuilder rb{ctx, 2}; | 1008 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1009 | rb.Push(ResultSuccess); | 1009 | rb.Push(ResultSuccess); |
| @@ -1021,10 +1021,10 @@ void Hid::SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx) { | |||
| 1021 | const auto parameters{rp.PopRaw<Parameters>()}; | 1021 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 1022 | 1022 | ||
| 1023 | applet_resource->GetController<Controller_NPad>(HidController::NPad) | 1023 | applet_resource->GetController<Controller_NPad>(HidController::NPad) |
| 1024 | .SetNpadMode(parameters.npad_id, Controller_NPad::NpadJoyAssignmentMode::Dual); | 1024 | .SetNpadMode(parameters.npad_id, {}, Controller_NPad::NpadJoyAssignmentMode::Dual); |
| 1025 | 1025 | ||
| 1026 | LOG_WARNING(Service_HID, "(STUBBED) called, npad_id={}, applet_resource_user_id={}", | 1026 | LOG_INFO(Service_HID, "called, npad_id={}, applet_resource_user_id={}", parameters.npad_id, |
| 1027 | parameters.npad_id, parameters.applet_resource_user_id); | 1027 | parameters.applet_resource_user_id); |
| 1028 | 1028 | ||
| 1029 | IPC::ResponseBuilder rb{ctx, 2}; | 1029 | IPC::ResponseBuilder rb{ctx, 2}; |
| 1030 | rb.Push(ResultSuccess); | 1030 | rb.Push(ResultSuccess); |