mirror of https://github.com/mgba-emu/mgba.git
mGUI: Add BATTERY_NOT_PRESENT state
This commit is contained in:
parent
b712a7208d
commit
9fb7485051
|
@ -47,7 +47,8 @@ enum {
|
|||
BATTERY_HIGH = 3,
|
||||
BATTERY_FULL = 4,
|
||||
|
||||
BATTERY_CHARGING = 8
|
||||
BATTERY_CHARGING = 8,
|
||||
BATTERY_NOT_PRESENT = 16
|
||||
};
|
||||
|
||||
struct GUIBackground {
|
||||
|
|
|
@ -360,6 +360,8 @@ static int _batteryState(void) {
|
|||
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) {
|
||||
|
|
|
@ -260,6 +260,9 @@ void GUIDrawBattery(struct GUIParams* params) {
|
|||
return;
|
||||
}
|
||||
int state = params->batteryState();
|
||||
if (state == BATTERY_NOT_PRESENT) {
|
||||
return;
|
||||
}
|
||||
uint32_t color = 0xFF000000;
|
||||
if (state == (BATTERY_CHARGING | BATTERY_FULL)) {
|
||||
color |= 0xFFC060;
|
||||
|
|
Loading…
Reference in New Issue