all repos — mgba @ 9fb7485051241fa7939a6a88954dedbf69d7616a

mGBA Game Boy Advance Emulator

mGUI: Add BATTERY_NOT_PRESENT state
Vicki Pfau vi@endrift.com
Thu, 20 Sep 2018 11:22:58 -0700
commit

9fb7485051241fa7939a6a88954dedbf69d7616a

parent

b712a7208d0f9fc4ac2bd6648c4ee9b446f6c96b

3 files changed, 7 insertions(+), 1 deletions(-)

jump to
M include/mgba-util/gui.hinclude/mgba-util/gui.h

@@ -47,7 +47,8 @@ BATTERY_HALF = 2,

BATTERY_HIGH = 3, BATTERY_FULL = 4, - BATTERY_CHARGING = 8 + BATTERY_CHARGING = 8, + BATTERY_NOT_PRESENT = 16 }; struct GUIBackground {
M src/platform/switch/main.csrc/platform/switch/main.c

@@ -360,6 +360,8 @@ u32 charge;

int state = 0; if (R_SUCCEEDED(psmGetBatteryChargePercentage(&charge))) { state = (charge + 12) / 25; + } else { + return BATTERY_NOT_PRESENT; } ChargerType type; if (R_SUCCEEDED(psmGetChargerType(&type)) && type) {
M src/util/gui/menu.csrc/util/gui/menu.c

@@ -260,6 +260,9 @@ if (!params->batteryState) {

return; } int state = params->batteryState(); + if (state == BATTERY_NOT_PRESENT) { + return; + } uint32_t color = 0xFF000000; if (state == (BATTERY_CHARGING | BATTERY_FULL)) { color |= 0xFFC060;