From 2cbf40cc139713a2edd660b99f74b8f651dd6c0a Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 20 Sep 2015 20:27:53 -0700 Subject: [PATCH] PSP2: Battery status --- src/platform/psp2/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/platform/psp2/main.c b/src/platform/psp2/main.c index fcc0552cf..b9d5a6f70 100644 --- a/src/platform/psp2/main.c +++ b/src/platform/psp2/main.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -76,6 +77,16 @@ static enum GUICursorState _pollCursor(int* x, int* y) { return GUI_CURSOR_DOWN; } +static int _batteryState(void) { + int charge = scePowerGetBatteryLifePercent(); + int adapter = scePowerIsPowerOnline(); + int state = 0; + if (adapter) { + state |= BATTERY_CHARGING; + } + charge /= 25; + return state | charge; +} int main() { vita2d_init(); @@ -85,7 +96,7 @@ int main() { PSP2_HORIZONTAL_PIXELS, PSP2_VERTICAL_PIXELS, font, "cache0:", _drawStart, _drawEnd, _pollInput, _pollCursor, - 0, + _batteryState, 0, 0, GUI_PARAMS_TRAIL