Change stuff with MCUHWC, reboot functionality

This commit is contained in:
2017-09-02 10:05:42 -04:00
parent 2a8e3176a8
commit 9442afb608
3 changed files with 20 additions and 13 deletions

View File

@@ -41,6 +41,9 @@
static const int THEMES_PER_SCREEN = 4;
Handle mcuhwc_handle;
bool mcuhwc_on;
enum TextureID {
TEXTURE_FONT_RESERVED = 0, //used by pp2d for the font
TEXTURE_ARROW,

View File

@@ -56,17 +56,12 @@ void exit_screens(void)
static Result MCUHWC_GetBatteryLevel(u8 *out) // Code taken from daedreth's fork of lpp-3ds
{
#define TRY(expr) if(R_FAILED(res = (expr))) { svcCloseHandle(mcuhwcHandle); return res; }
Result res;
Handle mcuhwcHandle;
TRY(srvGetServiceHandle(&mcuhwcHandle, "mcu::HWC"));
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x50000;
TRY(svcSendSyncRequest(mcuhwcHandle));
svcSendSyncRequest(mcuhwc_handle);
*out = (u8) cmdbuf[2];
svcCloseHandle(mcuhwcHandle);
svcCloseHandle(mcuhwc_handle);
return cmdbuf[1];
#undef TRY
}
static int theme_vertical_scroll = 0;
@@ -84,9 +79,12 @@ void draw_base_interface(void)
pp2d_draw_text(28, 2, 0.6, 0.6, COLOR_WHITE, (tm.tm_sec % 2 == 1) ? ":" : " ");
pp2d_draw_textf(34, 2, 0.6, 0.6, COLOR_WHITE, "%.2i", tm.tm_min);
if (mcuhwc_on)
{
u8 battery_val = 0;
MCUHWC_GetBatteryLevel(&battery_val);
pp2d_draw_textf(350, 2, 0.6, 0.6, COLOR_WHITE, "%i%%", battery_val);
}
pp2d_draw_on(GFX_BOTTOM);
pp2d_draw_rectangle(0, 0, 320, 24, COLOR_ACCENT);

View File

@@ -28,12 +28,17 @@
#include "themes.h"
#include "splashes.h"
#include "draw.h"
#include "common.h"
int init_services(void)
{
cfguInit();
open_archives();
ptmSysmInit();
if (R_FAILED(srvGetServiceHandle(&mcuhwc_handle, "mcu::HWC")))
{
mcuhwc_on = false;
ptmuInit();
} else mcuhwc_on = true;
return 0;
}
@@ -41,6 +46,8 @@ int exit_services(void)
{
close_archives();
cfguExit();
if (mcuhwc_on) svcCloseHandle(mcuhwc_handle);
else ptmuExit();
return 0;
}
@@ -88,8 +95,7 @@ int main(void)
{
exit_screens();
exit_services();
PTMSYSM_RebootAsync(0);
ptmSysmExit();
APT_HardwareResetAsync();
}
else if (kDown & KEY_L)
{