all repos — mgba @ 2cbf40cc139713a2edd660b99f74b8f651dd6c0a

mGBA Game Boy Advance Emulator

PSP2: Battery status
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Sep 2015 20:27:53 -0700
commit

2cbf40cc139713a2edd660b99f74b8f651dd6c0a

parent

b8ff8d618f36ee0de63f008b90be47f51ed5b1c3

1 files changed, 12 insertions(+), 1 deletions(-)

jump to
M src/platform/psp2/main.csrc/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