Display IP in menus when either gdb/inputredir is enabled
This commit is contained in:
parent
12b561a27d
commit
9ccfacd06d
@ -41,6 +41,8 @@
|
||||
extern Handle SOCU_handle;
|
||||
extern Handle socMemhandle;
|
||||
|
||||
extern bool miniSocEnabled;
|
||||
|
||||
Result miniSocInit();
|
||||
Result miniSocExit(void);
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "menus.h"
|
||||
#include "utils.h"
|
||||
#include "menus/n3ds.h"
|
||||
#include "minisoc.h"
|
||||
|
||||
u32 waitInputWithTimeout(u32 msec)
|
||||
{
|
||||
@ -241,6 +242,15 @@ static void menuDraw(Menu *menu, u32 selected)
|
||||
Draw_DrawCharacter(10, 30 + i * SPACING_Y, COLOR_TITLE, i == selected ? '>' : ' ');
|
||||
}
|
||||
|
||||
if(miniSocEnabled)
|
||||
{
|
||||
char ipBuffer[17];
|
||||
u32 ip = gethostid();
|
||||
u8 *addr = (u8 *)&ip;
|
||||
int n = sprintf(ipBuffer, "%hhu.%hhu.%hhu.%hhu", addr[0], addr[1], addr[2], addr[3]);
|
||||
Draw_DrawString(SCREEN_BOT_WIDTH - 10 - SPACING_X * n, 10, COLOR_WHITE, ipBuffer);
|
||||
}
|
||||
|
||||
if(batteryLevel != 255)
|
||||
Draw_DrawFormattedString(SCREEN_BOT_WIDTH - 10 - 4 * SPACING_X, SCREEN_BOT_HEIGHT - 20, COLOR_WHITE, "%02hhu%%", batteryLevel);
|
||||
else
|
||||
|
@ -71,6 +71,8 @@ static u32 socContextSize = 0x60000;
|
||||
// SOCU_handle from ctrulib
|
||||
// socMemhandle from ctrulib
|
||||
|
||||
bool miniSocEnabled = false;
|
||||
|
||||
Result miniSocInit()
|
||||
{
|
||||
if(AtomicPostIncrement(&miniSocRefCount))
|
||||
@ -94,6 +96,7 @@ Result miniSocInit()
|
||||
if(ret != 0) goto cleanup;
|
||||
|
||||
svcKernelSetState(0x10000, 2);
|
||||
miniSocEnabled = true;
|
||||
return 0;
|
||||
|
||||
cleanup:
|
||||
@ -136,7 +139,10 @@ Result miniSocExit(void)
|
||||
|
||||
svcControlMemory(&tmp, socContextAddr, socContextAddr, socContextSize, MEMOP_FREE, MEMPERM_DONTCARE);
|
||||
if(ret == 0)
|
||||
{
|
||||
svcKernelSetState(0x10000, 2);
|
||||
miniSocEnabled = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user