mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-21 13:22:40 +02:00
Updated notification-led example for using hidsysSetNotificationLedPatternWithTimeout.
This commit is contained in:
parent
188b41ff9e
commit
9b44df4132
@ -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,11 +116,17 @@ 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]);
|
||||||
|
|
||||||
|
// 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]);
|
rc = hidsysSetNotificationLedPattern(&pattern, UniquePadIds[i]);
|
||||||
printf("hidsysSetNotificationLedPattern(): 0x%x\n", rc);
|
printf("hidsysSetNotificationLedPattern(): 0x%x\n", rc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the console, sending a new frame to the display
|
// Update the console, sending a new frame to the display
|
||||||
consoleUpdate(NULL);
|
consoleUpdate(NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user