Display IP in menus when either gdb/inputredir is enabled

This commit is contained in:
TuxSH 2017-06-15 17:38:45 +02:00
parent 12b561a27d
commit 9ccfacd06d
3 changed files with 20 additions and 2 deletions

View File

@ -41,6 +41,8 @@
extern Handle SOCU_handle; extern Handle SOCU_handle;
extern Handle socMemhandle; extern Handle socMemhandle;
extern bool miniSocEnabled;
Result miniSocInit(); Result miniSocInit();
Result miniSocExit(void); Result miniSocExit(void);

View File

@ -33,6 +33,7 @@
#include "menus.h" #include "menus.h"
#include "utils.h" #include "utils.h"
#include "menus/n3ds.h" #include "menus/n3ds.h"
#include "minisoc.h"
u32 waitInputWithTimeout(u32 msec) 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 ? '>' : ' '); 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) if(batteryLevel != 255)
Draw_DrawFormattedString(SCREEN_BOT_WIDTH - 10 - 4 * SPACING_X, SCREEN_BOT_HEIGHT - 20, COLOR_WHITE, "%02hhu%%", batteryLevel); Draw_DrawFormattedString(SCREEN_BOT_WIDTH - 10 - 4 * SPACING_X, SCREEN_BOT_HEIGHT - 20, COLOR_WHITE, "%02hhu%%", batteryLevel);
else else

View File

@ -71,6 +71,8 @@ static u32 socContextSize = 0x60000;
// SOCU_handle from ctrulib // SOCU_handle from ctrulib
// socMemhandle from ctrulib // socMemhandle from ctrulib
bool miniSocEnabled = false;
Result miniSocInit() Result miniSocInit()
{ {
if(AtomicPostIncrement(&miniSocRefCount)) if(AtomicPostIncrement(&miniSocRefCount))
@ -94,6 +96,7 @@ Result miniSocInit()
if(ret != 0) goto cleanup; if(ret != 0) goto cleanup;
svcKernelSetState(0x10000, 2); svcKernelSetState(0x10000, 2);
miniSocEnabled = true;
return 0; return 0;
cleanup: cleanup:
@ -136,7 +139,10 @@ Result miniSocExit(void)
svcControlMemory(&tmp, socContextAddr, socContextAddr, socContextSize, MEMOP_FREE, MEMPERM_DONTCARE); svcControlMemory(&tmp, socContextAddr, socContextAddr, socContextSize, MEMOP_FREE, MEMPERM_DONTCARE);
if(ret == 0) if(ret == 0)
{
svcKernelSetState(0x10000, 2); svcKernelSetState(0x10000, 2);
miniSocEnabled = false;
}
return ret; return ret;
} }