all repos — mgba @ a4d058f1263f93ed67d05f0295c5544e875e8f62

mGBA Game Boy Advance Emulator

Switch: Add battery state
Vicki Pfau vi@endrift.com
Sat, 15 Sep 2018 11:21:46 -0700
commit

a4d058f1263f93ed67d05f0295c5544e875e8f62

parent

c14e5dcb88fc7fcc9feda4af8298e89f25c912e0

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

jump to
M src/platform/switch/main.csrc/platform/switch/main.c

@@ -295,12 +295,22 @@ audioBufferActive %= N_BUFFERS;

++enqueuedBuffers; } +static int _batteryState(void) { + u32 charge; + int state = 0; + if (R_SUCCEEDED(psmGetBatteryChargePercentage(&charge))) { + state = charge / 25; + } + return state; +} + int main(int argc, char* argv[]) { socketInitializeDefault(); nxlinkStdio(); initEgl(); romfsInit(); audoutInitialize(); + psmInitialize(); struct GUIFont* font = GUIFontCreate();

@@ -391,7 +401,7 @@ width, height,

font, "/", _drawStart, _drawEnd, _pollInput, _pollCursor, - NULL, + _batteryState, NULL, NULL, }, .keySources = (struct GUIInputKeys[]) {

@@ -458,6 +468,7 @@

audoutStartAudioOut(); mGUIRunloop(&runner); + psmExit(); audoutExit(); deinitEgl(); socketExit();