Switch: Add battery state
Vicki Pfau vi@endrift.com
Sat, 15 Sep 2018 11:21:46 -0700
1 files changed,
12 insertions(+),
1 deletions(-)
jump to
M
src/platform/switch/main.c
→
src/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();