Kirby expects handheld controllers to be at position 8

This commit is contained in:
David Marcec 2018-10-10 14:21:56 +11:00
parent f43815af5d
commit 46cdeb4549
1 changed files with 8 additions and 2 deletions

View File

@ -104,7 +104,8 @@ void Controller_NPad::OnInit() {
} }
std::memcpy(supported_npad_id_types.data(), npad_id_list.data(), std::memcpy(supported_npad_id_types.data(), npad_id_list.data(),
npad_id_list.size() * sizeof(u32)); npad_id_list.size() * sizeof(u32));
if (controller_count == 0) { if (std::none_of(connected_controllers.begin(), connected_controllers.end(),
[](const ControllerHolder& controller) { return controller.is_connected; })) {
AddNewController(NPadControllerType::Handheld); AddNewController(NPadControllerType::Handheld);
} }
} }
@ -272,7 +273,7 @@ void Controller_NPad::OnUpdate(u8* data, std::size_t data_len) {
} }
std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(), std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(),
shared_memory_entries.size() * sizeof(NPadEntry)); shared_memory_entries.size() * sizeof(NPadEntry));
} } // namespace Service::HID
void Controller_NPad::SetSupportedStyleSet(NPadType style_set) { void Controller_NPad::SetSupportedStyleSet(NPadType style_set) {
style.raw = style_set.raw; style.raw = style_set.raw;
@ -333,6 +334,11 @@ void Controller_NPad::AddNewController(NPadControllerType controller) {
LOG_ERROR(Service_HID, "Cannot connect any more controllers!"); LOG_ERROR(Service_HID, "Cannot connect any more controllers!");
return; return;
} }
if (controller == NPadControllerType::Handheld) {
connected_controllers[8] = {controller, true};
InitNewlyAddedControler(8);
return;
}
connected_controllers[controller_count] = {controller, true}; connected_controllers[controller_count] = {controller, true};
InitNewlyAddedControler(controller_count++); InitNewlyAddedControler(controller_count++);
} }