diff --git a/arm9/source/common/hid.c b/arm9/source/common/hid.c index d1c87f0..4ca9c8f 100644 --- a/arm9/source/common/hid.c +++ b/arm9/source/common/hid.c @@ -1,6 +1,7 @@ #include "hid.h" #include "i2c.h" #include "timer.h" +#include "colors.h" #include "screenshot.h" // for screenshots #include "arm.h" @@ -11,6 +12,14 @@ #define HID_TOUCH_MIDPOINT (HID_TOUCH_MAXPOINT / 2) +static void SetNotificationLED(u32 period_ms, u32 bgr_color) +{ + u32 rgb_color = + ((bgr_color >> 16) & 0xFF) | (bgr_color & 0xFF00) | ((bgr_color & 0xFF) << 16); + u32 args[] = {period_ms, rgb_color}; + PXI_DoCMD(PXI_NOTIFY_LED, args, 2); +} + // there's some weird thing going on when reading this // with an LDRD instruction so for now they'll be two // separate things - hopefully LTO won't get in the way @@ -105,6 +114,13 @@ u32 InputWait(u32 timeout_sec) { u32 oldcart = CART_STATE; u32 oldsd = SD_STATE; + // enable notification LED if shell is closed + // (this means we're waiting for user input) + if (oldpad & SHELL_CLOSED) { + SetNotificationLED(1000, COLOR_GREEN); + while (HID_ReadState() & SHELL_CLOSED); + } + delay = delay ? 72 : 128; do { @@ -133,6 +149,12 @@ u32 InputWait(u32 timeout_sec) { (delay && (timer_msec(timer) < delay)))) continue; + // handle closed shell (wait for open) + if (newpad & SHELL_CLOSED) { + while (HID_ReadState() & SHELL_CLOSED); + continue; + } + u32 t_pressed = 0; while((t_pressed++ < 0x13000) && (newpad == HID_ReadState())); if (t_pressed >= 0x13000) {