Get actual battery percentage thanks to Spaqin

Removed ir:u service because it isn't required in this program. Besides
I had to make room for mcu::HWC.

I also forgot to mention I got the ACTU functions from MrCheeze.
Many thanks to him.
This commit is contained in:
Joel 2016-09-23 00:24:14 -05:00
parent 7a36f136f2
commit 827f1772d2
5 changed files with 40 additions and 6 deletions

View File

@ -170,6 +170,7 @@ AccessControlInfo:
- gsp::Gpu - gsp::Gpu
- hid:USER - hid:USER
- http:C - http:C
- mcu::HWC
- mic:u - mic:u
- ndm:u - ndm:u
- news:s - news:s
@ -181,7 +182,6 @@ AccessControlInfo:
- y2r:u - y2r:u
- ldr:ro - ldr:ro
- ir:USER - ir:USER
- ir:u
- csnd:SND - csnd:SND
- am:u - am:u
- ns:s - ns:s

View File

@ -3,15 +3,18 @@
static Handle actHandle; static Handle actHandle;
Result actInit(void) { Result actInit(void)
{
return srvGetServiceHandle(&actHandle, "act:u"); return srvGetServiceHandle(&actHandle, "act:u");
} }
Result actExit(void) { Result actExit(void)
{
return svcCloseHandle(actHandle); return svcCloseHandle(actHandle);
} }
Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle) { Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle)
{
Result ret = 0; Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer(); u32 *cmdbuf = getThreadCommandBuffer();
@ -28,7 +31,8 @@ Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle) {
return (Result)cmdbuf[1]; return (Result)cmdbuf[1];
} }
Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output) { Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output)
{
Result ret = 0; Result ret = 0;
u32 *cmdbuf = getThreadCommandBuffer(); u32 *cmdbuf = getThreadCommandBuffer();

View File

@ -4,6 +4,7 @@
#include <malloc.h> #include <malloc.h>
#include "actu.h" #include "actu.h"
#include "mcu.h"
#include "screenshot.h" #include "screenshot.h"
int vaPrint(char *format, ...) int vaPrint(char *format, ...)
@ -176,6 +177,7 @@ int main(int argc, char *argv[])
fsInit(); fsInit();
sdmcInit(); sdmcInit();
ptmuInit(); ptmuInit();
mcuInit();
amInit(); amInit();
psInit(); psInit();
aptInit(); aptInit();
@ -187,7 +189,7 @@ int main(int argc, char *argv[])
char *str_ver = malloc(255), *str_sysver = malloc(255); char *str_ver = malloc(255), *str_sysver = malloc(255);
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion(); u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion();
printf("\x1b[32m3DSident 0.4\x1b[0m\n\n"); printf("\x1b[32m3DSident 0.5\x1b[0m\n\n");
snprintf(str_ver, 255, "\x1b[33m*\x1b[0m Kernel version: %lu.%lu-%lu\n\x1b[33m*\x1b[0m FIRM version is %lu.%lu-%lu\n", snprintf(str_ver, 255, "\x1b[33m*\x1b[0m Kernel version: %lu.%lu-%lu\n\x1b[33m*\x1b[0m FIRM version is %lu.%lu-%lu\n",
GET_VERSION_MAJOR(os_ver), GET_VERSION_MINOR(os_ver), GET_VERSION_REVISION(os_ver), GET_VERSION_MAJOR(os_ver), GET_VERSION_MINOR(os_ver), GET_VERSION_REVISION(os_ver),

21
source/mcu.c Normal file
View File

@ -0,0 +1,21 @@
#include "mcu.h"
Result mcuInit()
{
return srvGetServiceHandle(&mcuhwcHandle, "mcu::HWC");
}
Result mcuExit()
{
return svcCloseHandle(mcuhwcHandle);
}
Result mcuGetBatteryLevel(u8* out)
{
u32* ipc = getThreadCommandBuffer();
ipc[0] = 0x50000;
Result ret = svcSendSyncRequest(mcuhwcHandle);
if(ret < 0) return ret;
*out = ipc[2];
return ipc[1];
}

7
source/mcu.h Normal file
View File

@ -0,0 +1,7 @@
#include <3ds.h>
Handle mcuhwcHandle;
Result mcuInit();
Result mcuExit();
Result mcuGetBatteryLevel(u8* out);