PSP2: Battery status
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Sep 2015 20:27:53 -0700
1 files changed,
12 insertions(+),
1 deletions(-)
jump to
M
src/platform/psp2/main.c
→
src/platform/psp2/main.c
@@ -16,6 +16,7 @@ #include <psp2/ctrl.h>
#include <psp2/kernel/processmgr.h> #include <psp2/kernel/threadmgr.h> #include <psp2/moduleinfo.h> +#include <psp2/power.h> #include <psp2/touch.h> #include <vita2d.h>@@ -76,6 +77,16 @@ *y = touch.report[0].y / 2;
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 @@ .params = {
PSP2_HORIZONTAL_PIXELS, PSP2_VERTICAL_PIXELS, font, "cache0:", _drawStart, _drawEnd, _pollInput, _pollCursor, - 0, + _batteryState, 0, 0, GUI_PARAMS_TRAIL