Updated notification-led example for using hidsysSetNotificationLedPatternWithTimeout.

This commit is contained in:
yellows8 2019-10-19 19:53:56 -04:00
parent 188b41ff9e
commit 9b44df4132
No known key found for this signature in database
GPG Key ID: 0AF90DA3F1E60E43

View File

@ -50,7 +50,7 @@ int main(int argc, char* argv[])
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
if (kDown & KEY_PLUS) { if (kDown & KEY_PLUS) {
// Disable notification led. // Disable notification led. Only needed with hidsysSetNotificationLedPattern, with hidsysSetNotificationLedPatternWithTimeout the LED will be automatically disabled via the timeout.
memset(&pattern, 0, sizeof(pattern)); memset(&pattern, 0, sizeof(pattern));
} }
else if (kDown & KEY_A) { else if (kDown & KEY_A) {
@ -106,7 +106,7 @@ int main(int argc, char* argv[])
total_entries = 0; total_entries = 0;
memset(UniquePadIds, 0, sizeof(UniquePadIds)); memset(UniquePadIds, 0, sizeof(UniquePadIds));
// Get the UniquePadIds for the specified controller, which will then be used with hidsysSetNotificationLedPattern. // Get the UniquePadIds for the specified controller, which will then be used with hidsysSetNotificationLedPattern*.
// If you want to get the UniquePadIds for all controllers, you can use hidsysGetUniquePadIds instead. // If you want to get the UniquePadIds for all controllers, you can use hidsysGetUniquePadIds instead.
rc = hidsysGetUniquePadsFromNpad(hidGetHandheldMode() ? CONTROLLER_HANDHELD : CONTROLLER_PLAYER_1, UniquePadIds, 2, &total_entries); rc = hidsysGetUniquePadsFromNpad(hidGetHandheldMode() ? CONTROLLER_HANDHELD : CONTROLLER_PLAYER_1, UniquePadIds, 2, &total_entries);
printf("hidsysGetUniquePadsFromNpad(): 0x%x", rc); printf("hidsysGetUniquePadsFromNpad(): 0x%x", rc);
@ -116,8 +116,14 @@ int main(int argc, char* argv[])
if (R_SUCCEEDED(rc)) { if (R_SUCCEEDED(rc)) {
for(i=0; i<total_entries; i++) { // System will skip sending the subcommand to controllers where this isn't available. for(i=0; i<total_entries; i++) { // System will skip sending the subcommand to controllers where this isn't available.
printf("[%d] = 0x%lx ", i, UniquePadIds[i]); printf("[%d] = 0x%lx ", i, UniquePadIds[i]);
rc = hidsysSetNotificationLedPattern(&pattern, UniquePadIds[i]);
printf("hidsysSetNotificationLedPattern(): 0x%x\n", rc); // Attempt to use hidsysSetNotificationLedPatternWithTimeout first with a 2 second timeout, then fallback to hidsysSetNotificationLedPattern on failure. See hidsys.h for the requirements for using these.
rc = hidsysSetNotificationLedPatternWithTimeout(&pattern, UniquePadIds[i], 2000000000ULL);
printf("hidsysSetNotificationLedPatternWithTimeout(): 0x%x\n", rc);
if (R_FAILED(rc)) {
rc = hidsysSetNotificationLedPattern(&pattern, UniquePadIds[i]);
printf("hidsysSetNotificationLedPattern(): 0x%x\n", rc);
}
} }
} }
} }