mirror of
https://github.com/joel16/3DSident.git
synced 2024-11-26 21:10:24 +00:00
Merge upstream changes from GUI
This commit is contained in:
parent
0ee6f749ba
commit
669b5d0115
4
Makefile
4
Makefile
@ -30,9 +30,9 @@ include $(DEVKITARM)/3ds_rules
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
RESOURCES := resources
|
||||
SOURCES := source
|
||||
SOURCES := source source/services
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
INCLUDES := include include/services
|
||||
|
||||
APP_TITLE := 3DSident
|
||||
APP_DESCRIPTION := Get more info about your 3DS, firmware, region etc.
|
||||
|
13
include/config.h
Normal file
13
include/config.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
const char * getUsername();
|
||||
char * getBirthday();
|
||||
char * getEulaVersion();
|
||||
|
||||
#endif
|
@ -1,3 +1,6 @@
|
||||
#ifndef FS_H
|
||||
#define FS_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -10,4 +13,6 @@ void closeSdArchive();
|
||||
int makeDir(const char * path);
|
||||
bool fileExists(char * path);
|
||||
bool dirExists(const char * path);
|
||||
bool deleteFile(const char *path);
|
||||
bool deleteFile(const char *path);
|
||||
|
||||
#endif
|
@ -1,5 +0,0 @@
|
||||
#include <3ds.h>
|
||||
|
||||
Handle gspLcdHandle;
|
||||
|
||||
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness);
|
11
include/kernel.h
Normal file
11
include/kernel.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef KERNEL_H
|
||||
#define KERNEL_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char * getNNIDNum();
|
||||
char * getVersion(int version);
|
||||
char * getCID(int type);
|
||||
|
||||
#endif
|
@ -1,4 +1,12 @@
|
||||
#ifndef MISC_H
|
||||
#define MISC_H
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
u32 titleCount(FS_MediaType mediaType);
|
||||
bool detectSD();
|
||||
bool detectSD();
|
||||
u64 getFreeStorage(FS_SystemMediaType mediaType);
|
||||
u64 getTotalStorage(FS_SystemMediaType mediaType);
|
||||
u64 getUsedStorage(FS_SystemMediaType mediaType);
|
||||
|
||||
#endif
|
@ -1,3 +1,8 @@
|
||||
#ifndef POWER_H
|
||||
#define POWER_H
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
const char * batteryStatus();
|
||||
const char * batteryStatus();
|
||||
|
||||
#endif
|
@ -1,4 +1,5 @@
|
||||
#pragma once
|
||||
#ifndef SCREENSHOT_H
|
||||
#define SCREENSHOT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -15,3 +16,5 @@ int level, screenCapture;
|
||||
unsigned int format_choice;
|
||||
GSPGPU_FramebufferFormats format; // = GSP_RGBA8_OES
|
||||
void captureScreenshot();
|
||||
|
||||
#endif
|
@ -1,3 +1,6 @@
|
||||
#ifndef ACTU_H
|
||||
#define ACTU_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <malloc.h>
|
||||
#include <stdio.h>
|
||||
@ -18,4 +21,6 @@ Result ACT_GetAccountInfo(void *buffer, u32 size, u32 blkId);
|
||||
Result actuInit(void);
|
||||
Result actuExit(void);
|
||||
Result ACTU_Initialize(u32 sdkVersion, u32 unknown, Handle handle);
|
||||
Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output);
|
||||
Result ACTU_GetAccountDataBlock(u32 unknown, u32 size, u32 blockId, void* output);
|
||||
|
||||
#endif
|
@ -1,3 +1,6 @@
|
||||
#ifndef AM_H
|
||||
#define AM_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@ -6,3 +9,5 @@ Handle amHandle;
|
||||
|
||||
char * base64encode(const char * input);
|
||||
Result amNetGetDeviceCert(u8 const * buffer);
|
||||
|
||||
#endif
|
@ -1,3 +1,6 @@
|
||||
#ifndef CFGS_H
|
||||
#define CFGS_H
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
Handle cfgHandle;
|
||||
@ -5,4 +8,6 @@ Handle cfgHandle;
|
||||
Result cfgsInit();
|
||||
Result cfgsExit();
|
||||
Result CFG_GetConfig(u32 size, u32 blkID, u8* outData);
|
||||
Result cfgsSecureInfoGetSerialNo(char *serial);
|
||||
Result cfgsSecureInfoGetSerialNo(char *serial);
|
||||
|
||||
#endif
|
10
include/services/gsplcd.h
Normal file
10
include/services/gsplcd.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef GSPLCD_H
|
||||
#define GSPLCD_H
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
Handle gspLcdHandle;
|
||||
|
||||
Result GSPLCD_GetBrightness(u32 screen, u32 *brightness);
|
||||
|
||||
#endif
|
@ -1,3 +1,6 @@
|
||||
#ifndef MCU_H
|
||||
#define MCU_H
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
Handle mcuhwcHandle;
|
||||
@ -7,4 +10,6 @@ Result mcuExit();
|
||||
Result mcuGetBatteryLevel(u8* out);
|
||||
Result mcuGetBatteryVoltage(u8* out);
|
||||
Result GetMcuFwVerHigh(u8* out);
|
||||
Result GetMcuFwVerLow(u8* out);
|
||||
Result GetMcuFwVerLow(u8* out);
|
||||
|
||||
#endif
|
@ -1,3 +1,6 @@
|
||||
#ifndef SYSTEM_H
|
||||
#define SYSTEM_H
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
const char * getModel();
|
||||
@ -13,6 +16,6 @@ char * getDeviceCert(void);
|
||||
char * getNNID(void);
|
||||
char * isDebugModeEnabled();
|
||||
char * getBrightness(u32 screen);
|
||||
const char * getUsername();
|
||||
char * getBirthday();
|
||||
char * getEulaVersion();
|
||||
char * getCardSlotStatus();
|
||||
|
||||
#endif
|
46
source/config.c
Normal file
46
source/config.c
Normal file
@ -0,0 +1,46 @@
|
||||
#include "config.h"
|
||||
|
||||
const char * getUsername()
|
||||
{
|
||||
int i;
|
||||
size_t size = 0x16;
|
||||
u8 * temp = (u8*)malloc(size);
|
||||
char * username = (char*)malloc(size / 2);
|
||||
|
||||
for(i = 0; i < (size / 2); i++)
|
||||
username[i] = 0;
|
||||
|
||||
CFGU_GetConfigInfoBlk2(0x1C, 0xA0000, temp);
|
||||
|
||||
for(i = 0; i < (size / 2); i++)
|
||||
username[i] = (char)((u16*)temp)[i];
|
||||
|
||||
return username;
|
||||
}
|
||||
|
||||
char * getBirthday()
|
||||
{
|
||||
u16 date = 0;
|
||||
static char birthday[6];
|
||||
|
||||
CFGU_GetConfigInfoBlk2(0x2, 0xA0001, (u8*)&date);
|
||||
|
||||
u8 month = date / 256;
|
||||
u8 day = date % 256;
|
||||
|
||||
sprintf(birthday, "%u/%u", day, month);
|
||||
|
||||
return birthday;
|
||||
}
|
||||
|
||||
char * getEulaVersion()
|
||||
{
|
||||
u8 eulaData[4];
|
||||
static char version[5];
|
||||
|
||||
CFGU_GetConfigInfoBlk2(4, 0xD0000, eulaData);
|
||||
|
||||
sprintf(version, "%02X.%02X", eulaData[1], eulaData[0]);
|
||||
|
||||
return version;
|
||||
}
|
79
source/kernel.c
Normal file
79
source/kernel.c
Normal file
@ -0,0 +1,79 @@
|
||||
#include "actu.h"
|
||||
#include "kernel.h"
|
||||
|
||||
char * getNNIDNum()
|
||||
{
|
||||
s32 ret = 0;
|
||||
static char nnidNumStr[30];
|
||||
u32 nnidNum = 0xFFFFFFFF;
|
||||
|
||||
ret = ACTU_Initialize(0xB0002C8, 0, 0);
|
||||
ret = ACTU_GetAccountDataBlock(0xFE, 4, 12, &nnidNum);
|
||||
if ((ret != 0 ) && (nnidNum != 0xFFFFFFFF))
|
||||
sprintf(nnidNumStr, "%08X", (int) nnidNum);
|
||||
|
||||
else
|
||||
sprintf(nnidNumStr, "could not retreive NNID num.");
|
||||
|
||||
return nnidNumStr;
|
||||
}
|
||||
|
||||
char * getVersion(int version)
|
||||
{
|
||||
char *str_kernel = (char *)malloc(sizeof(char) * 255), *str_ver = (char *)malloc(sizeof(char) * 255), *str_sysver = (char *)malloc(sizeof(char) * 255);
|
||||
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion();
|
||||
OS_VersionBin *nver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin)), *cver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin));
|
||||
s32 ret;
|
||||
|
||||
snprintf(str_kernel, 255, "%lu.%lu-%lu",
|
||||
GET_VERSION_MAJOR(os_ver),
|
||||
GET_VERSION_MINOR(os_ver),
|
||||
GET_VERSION_REVISION(os_ver)
|
||||
);
|
||||
|
||||
snprintf(str_ver, 255, "%lu.%lu-%lu\n",
|
||||
GET_VERSION_MAJOR(firm_ver),
|
||||
GET_VERSION_MINOR(firm_ver),
|
||||
GET_VERSION_REVISION(firm_ver)
|
||||
);
|
||||
|
||||
memset(nver, 0, sizeof(OS_VersionBin));
|
||||
memset(cver, 0, sizeof(OS_VersionBin));
|
||||
ret = osGetSystemVersionData(nver, cver);
|
||||
|
||||
if (ret)
|
||||
snprintf(str_sysver, 100, "0x%08liX", ret);
|
||||
else
|
||||
snprintf(str_sysver, 100, "%d.%d.%d-%d",
|
||||
cver->mainver,
|
||||
cver->minor,
|
||||
cver->build,
|
||||
nver->mainver
|
||||
);
|
||||
|
||||
if (version == 0)
|
||||
return str_kernel;
|
||||
else if(version == 1)
|
||||
return str_ver;
|
||||
else
|
||||
return str_sysver;
|
||||
}
|
||||
|
||||
char * getCID(int type)
|
||||
{
|
||||
u8 buf[16];
|
||||
static char cid[32];
|
||||
|
||||
if (type == 0) //SDMC
|
||||
FSUSER_GetSdmcCid(buf, 0x10);
|
||||
|
||||
else if (type == 1) //NAND
|
||||
FSUSER_GetNandCid(buf, 0x10);
|
||||
|
||||
sprintf(cid, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
|
||||
buf[6], buf[7], buf[8], buf[9], buf[10], buf[11],
|
||||
buf[12], buf[13], buf[14], buf[15]);
|
||||
|
||||
return cid;
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
#include "actu.h"
|
||||
#include "am.h"
|
||||
#include "cfgs.h"
|
||||
#include "config.h"
|
||||
#include "gsplcd.h"
|
||||
#include "mcu.h"
|
||||
#include "misc.h"
|
||||
@ -77,19 +78,15 @@ int main(int argc, char *argv[])
|
||||
|
||||
char *str_ver = (char *)malloc(sizeof(char) * 255), *str_sysver = (char *)malloc(sizeof(char) * 255);
|
||||
double wifiPercent, volPercent, _3dSliderPercent;
|
||||
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion(), installedTitles = titleCount(MEDIATYPE_SD), nnidNum = 0xFFFFFFFF;
|
||||
u32 os_ver = osGetKernelVersion(), firm_ver = osGetKernelVersion(), nnidNum = 0xFFFFFFFF;
|
||||
u8 buf[16], batteryPercent, batteryVolt, volume;
|
||||
OS_VersionBin *nver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin)), *cver = (OS_VersionBin *)malloc(sizeof(OS_VersionBin));
|
||||
char sdFreeSize[16], sdTotalSize[16];
|
||||
char ctrFreeSize[16], ctrTotalSize[16];
|
||||
s32 ret;
|
||||
FS_ArchiveResource resource = {0};
|
||||
|
||||
printf("\x1b[0;0H"); //Move the cursor to the top left corner of the screen
|
||||
printf("\x1b[32;1m3DSident 0.7.5\x1b[0m\n\n");
|
||||
|
||||
//u32 brightness = 0;
|
||||
//GSPLCD_GetBrightness(brightness);
|
||||
|
||||
//printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%i\x1b[0m\n", (int)brightness);
|
||||
printf("\x1b[32;1m3DSident 0.7.6\x1b[0m\n\n");
|
||||
|
||||
//=====================================================================//
|
||||
//------------------------------Firm Info------------------------------//
|
||||
@ -173,29 +170,23 @@ int main(int argc, char *argv[])
|
||||
GetMcuFwVerHigh(&mcuFwMajor);
|
||||
GetMcuFwVerLow(&mcuFwMinor);
|
||||
|
||||
//if (CFG_UNITINFO == 0)
|
||||
printf("\x1b[34;1m*\x1b[0m MCU firmware: \x1b[34;1m%u.%u\x1b[0m\n\n", (mcuFwMajor - 16), mcuFwMinor);
|
||||
|
||||
//=====================================================================//
|
||||
//------------------------------Misc Info------------------------------//
|
||||
//=====================================================================//
|
||||
|
||||
char sdFreeSize[16], sdTotalSize[16];
|
||||
char ctrFreeSize[16], ctrTotalSize[16];
|
||||
|
||||
FSUSER_GetArchiveResource(&resource, SYSTEM_MEDIATYPE_SD);
|
||||
getSizeString(sdFreeSize, (((u64) resource.freeClusters * (u64) resource.clusterSize)));
|
||||
getSizeString(sdTotalSize, (((u64) resource.totalClusters * (u64) resource.clusterSize)));
|
||||
getSizeString(sdFreeSize, getFreeStorage(SYSTEM_MEDIATYPE_SD));
|
||||
getSizeString(sdTotalSize, getTotalStorage(SYSTEM_MEDIATYPE_SD));
|
||||
printf("\x1b[32;1m*\x1b[0m SD Size: \x1b[32;1m%s\x1b[0m / \x1b[32;1m%s\x1b[0m \n", sdFreeSize, sdTotalSize);
|
||||
|
||||
FSUSER_GetArchiveResource(&resource, SYSTEM_MEDIATYPE_CTR_NAND);
|
||||
getSizeString(ctrFreeSize, (((u64) resource.freeClusters * (u64) resource.clusterSize)));
|
||||
getSizeString(ctrTotalSize, (((u64) resource.totalClusters * (u64) resource.clusterSize)));
|
||||
getSizeString(ctrFreeSize, getFreeStorage(SYSTEM_MEDIATYPE_CTR_NAND));
|
||||
getSizeString(ctrTotalSize, getTotalStorage(SYSTEM_MEDIATYPE_CTR_NAND));
|
||||
printf("\x1b[32;1m*\x1b[0m CTR Size: \x1b[32;1m%s\x1b[0m / \x1b[32;1m%s\x1b[0m \n", ctrFreeSize, ctrTotalSize);
|
||||
|
||||
printf("\x1b[32;1m*\x1b[0m Installed titles: \x1b[32;1m%i\x1b[0m\n", (int)installedTitles);
|
||||
printf("\x1b[32;1m*\x1b[0m Installed titles: SD: \x1b[32;1m%i\x1b[0m (NAND: \x1b[32;1m%i\x1b[0m)\n", (int)titleCount(MEDIATYPE_SD), (int)titleCount(MEDIATYPE_NAND));
|
||||
|
||||
wifiPercent = (osGetWifiStrength() * 33.3333333333);
|
||||
/*wifiPercent = (osGetWifiStrength() * 33.3333333333);
|
||||
printf("\x1b[32;1m*\x1b[0m WiFi signal strength: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent);
|
||||
|
||||
HIDUSER_GetSoundVolume(&volume);
|
||||
@ -205,7 +196,7 @@ int main(int argc, char *argv[])
|
||||
_3dSliderPercent = (osGet3DSliderState() * 100.0);
|
||||
printf("\x1b[32;1m*\x1b[0m 3D slider state: \x1b[32;1m%.1lf\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
|
||||
|
||||
printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%s\x1b[0m \n", getBrightness(1));
|
||||
printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%s\x1b[0m \n", getBrightness(1));*/
|
||||
|
||||
while (aptMainLoop())
|
||||
{
|
||||
@ -224,19 +215,22 @@ int main(int argc, char *argv[])
|
||||
//------------------------------Misc Info------------------------------//
|
||||
//=====================================================================//
|
||||
|
||||
printf("\x1b[24;0H"); // Move the cursor
|
||||
printf("\x1b[25;0H"); // Move the cursor
|
||||
wifiPercent = (osGetWifiStrength() * 33.3333333333);
|
||||
printf("\x1b[32;1m*\x1b[0m WiFi signal strength: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGetWifiStrength(), wifiPercent);
|
||||
|
||||
printf("\x1b[25;0H"); //Move the cursor
|
||||
printf("\x1b[26;0H"); //Move the cursor
|
||||
HIDUSER_GetSoundVolume(&volume);
|
||||
volPercent = (volume * 1.5873015873);
|
||||
printf("\x1b[32;1m*\x1b[0m Volume slider state: \x1b[32;1m%d\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", volume, volPercent);
|
||||
|
||||
printf("\x1b[26;0H"); //Move the cursor
|
||||
printf("\x1b[27;0H"); //Move the cursor
|
||||
_3dSliderPercent = (osGet3DSliderState() * 100.0);
|
||||
printf("\x1b[32;1m*\x1b[0m 3D slider state: \x1b[32;1m%.1lf\x1b[0m (\x1b[32;1m%.0lf%%\x1b[0m) \n", osGet3DSliderState(), _3dSliderPercent);
|
||||
|
||||
printf("\x1b[28;0H"); //Move the cursor
|
||||
printf("\x1b[32;1m*\x1b[0m Brightness: \x1b[32;1m%s\x1b[0m \n", getBrightness(1));
|
||||
|
||||
gspWaitForVBlank();
|
||||
hidScanInput();
|
||||
u32 kHeld = hidKeysHeld();
|
||||
|
@ -14,4 +14,31 @@ bool detectSD()
|
||||
bool isSD;
|
||||
FSUSER_IsSdmcDetected(&isSD);
|
||||
return isSD;
|
||||
}
|
||||
|
||||
u64 getFreeStorage(FS_SystemMediaType mediaType)
|
||||
{
|
||||
FS_ArchiveResource resource = {0};
|
||||
|
||||
FSUSER_GetArchiveResource(&resource, mediaType);
|
||||
|
||||
return (((u64) resource.freeClusters * (u64) resource.clusterSize));
|
||||
}
|
||||
|
||||
u64 getTotalStorage(FS_SystemMediaType mediaType)
|
||||
{
|
||||
FS_ArchiveResource resource = {0};
|
||||
|
||||
FSUSER_GetArchiveResource(&resource, mediaType);
|
||||
|
||||
return (((u64) resource.totalClusters * (u64) resource.clusterSize));
|
||||
}
|
||||
|
||||
u64 getUsedStorage(FS_SystemMediaType mediaType)
|
||||
{
|
||||
FS_ArchiveResource resource = {0};
|
||||
|
||||
FSUSER_GetArchiveResource(&resource, mediaType);
|
||||
|
||||
return ((((u64) resource.totalClusters * (u64) resource.clusterSize)) - (((u64) resource.freeClusters * (u64) resource.clusterSize)));
|
||||
}
|
@ -228,47 +228,22 @@ char * getBrightness(u32 screen)
|
||||
return "n3DS only";
|
||||
}
|
||||
|
||||
const char * getUsername()
|
||||
char * getCardSlotStatus()
|
||||
{
|
||||
int i;
|
||||
size_t size = 0x16;
|
||||
u8 * temp = (u8*)malloc(size);
|
||||
char * username = (char*)malloc(size / 2);
|
||||
bool isInserted = false;
|
||||
FS_CardType cardType = 0;
|
||||
|
||||
for(i = 0; i < (size / 2); i++)
|
||||
username[i] = 0;
|
||||
static char card[20];
|
||||
|
||||
CFGU_GetConfigInfoBlk2(0x1C, 0xA0000, temp);
|
||||
FSUSER_CardSlotIsInserted(&isInserted);
|
||||
|
||||
for(i = 0; i < (size / 2); i++)
|
||||
username[i] = (char)((u16*)temp)[i];
|
||||
if (isInserted)
|
||||
{
|
||||
FSUSER_GetCardType(&cardType);
|
||||
sprintf(card, "inserted %s", cardType? "(TWL)" : "(CTR)");
|
||||
return card;
|
||||
}
|
||||
|
||||
return username;
|
||||
}
|
||||
|
||||
char * getBirthday()
|
||||
{
|
||||
u16 date = 0;
|
||||
static char birthday[6];
|
||||
|
||||
CFGU_GetConfigInfoBlk2(0x2, 0xA0001, (u8*)&date);
|
||||
|
||||
u8 month = date / 256;
|
||||
u8 day = date % 256;
|
||||
|
||||
sprintf(birthday, "%u/%u", day, month);
|
||||
|
||||
return birthday;
|
||||
}
|
||||
|
||||
char * getEulaVersion()
|
||||
{
|
||||
u8 eulaData[4];
|
||||
static char version[5];
|
||||
|
||||
CFGU_GetConfigInfoBlk2(4, 0xD0000, eulaData);
|
||||
|
||||
sprintf(version, "%02X.%02X", eulaData[1], eulaData[0]);
|
||||
|
||||
return version;
|
||||
sprintf(card, "not inserted");
|
||||
return card;
|
||||
}
|
Loading…
Reference in New Issue
Block a user