From 50c7bfdffcd997556cef4463de9283a36883f860 Mon Sep 17 00:00:00 2001 From: subtervisor Date: Mon, 5 Jan 2026 17:17:58 -0800 Subject: [PATCH] Register for and forward low battery events This adds a new extra HID key for the low battery notification to allow receiving the event. Similar to the battery charging start/stop events, we register for the interrupt and forward it whenever the event comes in. --- include/arm11/drivers/hid.h | 3 ++- include/arm11/drivers/mcu.h | 2 +- source/arm11/drivers/hid.c | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/arm11/drivers/hid.h b/include/arm11/drivers/hid.h index a27ff83..09d7ef5 100644 --- a/include/arm11/drivers/hid.h +++ b/include/arm11/drivers/hid.h @@ -81,7 +81,8 @@ enum KEY_WIFI = BIT(3), KEY_SHELL = BIT(4), // Auto clears on open KEY_BAT_CHARGING = BIT(5), // Auto clears when charging stops - KEY_VOL_SLIDER = BIT(6) + KEY_VOL_SLIDER = BIT(6), + KEY_LOW_BATTERY = BIT(7) }; typedef struct diff --git a/include/arm11/drivers/mcu.h b/include/arm11/drivers/mcu.h index 1c58b3a..8368936 100644 --- a/include/arm11/drivers/mcu.h +++ b/include/arm11/drivers/mcu.h @@ -33,7 +33,7 @@ extern "C" MCU_IRQ_BATT_CHARGE_STOP | MCU_IRQ_ACC_DATA_READY | MCU_IRQ_ACC_RW_DONE | \ MCU_IRQ_WATCHDOG | MCU_IRQ_SHELL_OPEN | MCU_IRQ_SHELL_CLOSE | \ MCU_IRQ_WIFI_PRESS | MCU_IRQ_HOME_RELEASE | MCU_IRQ_HOME_PRESS | \ - MCU_IRQ_POWER_HELD | MCU_IRQ_POWER_PRESS)) + MCU_IRQ_POWER_HELD | MCU_IRQ_POWER_PRESS | MCU_IRQ_LOW_BATT)) typedef struct diff --git a/source/arm11/drivers/hid.c b/source/arm11/drivers/hid.c index 5aa4dce..ca5769b 100644 --- a/source/arm11/drivers/hid.c +++ b/source/arm11/drivers/hid.c @@ -33,7 +33,8 @@ MCU_IRQ_BATT_CHARGE_STOP | MCU_IRQ_SHELL_OPEN | \ MCU_IRQ_SHELL_CLOSE | MCU_IRQ_WIFI_PRESS | \ MCU_IRQ_HOME_RELEASE | MCU_IRQ_HOME_PRESS | \ - MCU_IRQ_POWER_HELD | MCU_IRQ_POWER_PRESS) + MCU_IRQ_POWER_HELD | MCU_IRQ_POWER_PRESS | \ + MCU_IRQ_LOW_BATT) #define CPAD_THRESHOLD (400) @@ -75,6 +76,7 @@ static void updateMcuHidState(void) tmp |= state>>10 & KEY_BAT_CHARGING; // Battery started charging if(state & BIT(14)) tmp &= ~KEY_BAT_CHARGING; // Battery stopped charging tmp |= state>>16 & KEY_VOL_SLIDER; // Volume slider update + tmp |= state>>6 & KEY_LOW_BATTERY; // Low battery notification g_extraKeys = tmp; }