PSP2: Battery status

This commit is contained in:
Jeffrey Pfau 2015-09-20 20:27:53 -07:00
parent b8ff8d618f
commit 2cbf40cc13
1 changed files with 12 additions and 1 deletions

View File

@ -16,6 +16,7 @@
#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 @@ 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