Skip to content

Commit

Permalink
Merge pull request #542 from leo60228/master
Browse files Browse the repository at this point in the history
Allow pressing buttons on all controllers in loader (closes #541)
  • Loading branch information
SciresM authored May 17, 2019
2 parents bfd4d41 + eab2d05 commit 13a1566
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
6 changes: 5 additions & 1 deletion stratosphere/ams_mitm/source/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,11 @@ Result Utils::GetKeysHeld(u64 *keys) {
}

hidScanInput();
*keys = hidKeysHeld(CONTROLLER_P1_AUTO);
*keys = 0;

for (int controller = 0; controller < 10; controller++) {
*keys |= hidKeysHeld((HidControllerID) controller);
}

return ResultSuccess;
}
Expand Down
8 changes: 6 additions & 2 deletions stratosphere/dmnt/source/dmnt_hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ Result HidManagement::GetKeysDown(u64 *keys) {
std::scoped_lock<HosMutex> lk(g_hid_keys_down_lock);

hidScanInput();
*keys = hidKeysHeld(CONTROLLER_P1_AUTO);
*keys = 0;

for (int controller = 0; controller < 10; controller++) {
*keys |= hidKeysHeld((HidControllerID) controller);
}

return ResultSuccess;
}
}
6 changes: 5 additions & 1 deletion stratosphere/loader/source/ldr_hid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ Result HidManagement::GetKeysHeld(u64 *keys) {
}

hidScanInput();
*keys = hidKeysHeld(CONTROLLER_P1_AUTO);
*keys = 0;

for (int controller = 0; controller < 10; controller++) {
*keys |= hidKeysHeld((HidControllerID) controller);
}

return ResultSuccess;
}
8 changes: 6 additions & 2 deletions troposphere/reboot_to_payload/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ int main(int argc, char **argv)
//Scan all the inputs. This should be done once for each frame
hidScanInput();

//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
u64 kDown = 0;

for (int controller = 0; controller < 10; controller++) {
// hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
kDown |= hidKeysDown((HidControllerID) controller);
}

if (can_reboot && kDown & KEY_MINUS) {
reboot_to_payload();
Expand Down

0 comments on commit 13a1566

Please sign in to comment.