Merge branch 'master' into toggle-power-button
This commit is contained in:
@@ -28,8 +28,8 @@ INCLUDES := include include/gdb include/menus include/redshift
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
DEFINES := -DARM11 -D_3DS
|
||||
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -Wno-unused-value -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections \
|
||||
CFLAGS := -g -std=gnu11 -Wall -Wextra -Werror -Wno-unused-value -Os -mword-relocations \
|
||||
-fomit-frame-pointer -ffunction-sections -fdata-sections -fno-math-errno \
|
||||
$(ARCH) $(DEFINES)
|
||||
|
||||
CFLAGS += $(INCLUDE)
|
||||
@@ -39,7 +39,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map),--section-start,.text=0x14000000
|
||||
|
||||
LIBS := -lctru -lm
|
||||
LIBS := -lctru
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
|
||||
@@ -27,5 +27,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include "MyThread.h"
|
||||
|
||||
void ERRF_HandleCommands(void *ctx);
|
||||
MyThread *errDispCreateThread(void);
|
||||
void ERRF_HandleCommands(void);
|
||||
void errDispThreadMain(void);
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
|
||||
#define MAX_DEBUG 3
|
||||
#define MAX_DEBUG_THREAD 127
|
||||
#define MAX_BREAKPOINT 256
|
||||
#define MAX_BREAKPOINT 64
|
||||
|
||||
#define MAX_TIO_OPEN_FILE 32
|
||||
|
||||
// 512+24 is the ideal size as IDA will try to read exactly 0x100 bytes at a time. Add 4 to this, for $#<checksum>, see below.
|
||||
// IDA seems to want additional bytes as well.
|
||||
// 1024 is fine enough to put all regs in the 'T' stop reply packets
|
||||
#define GDB_BUF_LEN 2048
|
||||
#define GDB_BUF_LEN 1024
|
||||
|
||||
#define GDB_HANDLER(name) GDB_Handle##name
|
||||
#define GDB_QUERY_HANDLER(name) GDB_HANDLER(Query##name)
|
||||
|
||||
@@ -34,3 +34,4 @@ extern Menu sysconfigMenu;
|
||||
void SysConfigMenu_ToggleLEDs(void);
|
||||
void SysConfigMenu_ToggleWireless(void);
|
||||
void SysConfigMenu_TogglePowerButton(void);
|
||||
void SysConfigMenu_ControlWifi(void);
|
||||
|
||||
@@ -32,13 +32,26 @@
|
||||
#include "fmt.h"
|
||||
#include "ifile.h"
|
||||
|
||||
extern Handle terminationRequestEvent;
|
||||
|
||||
static inline void assertSuccess(Result res)
|
||||
{
|
||||
if(R_FAILED(res))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
}
|
||||
|
||||
static MyThread errDispThread;
|
||||
static u8 ALIGN(8) errDispThreadStack[0xD00];
|
||||
|
||||
static char userString[0x100 + 1] = {0};
|
||||
static char staticBuf[0x100 + 1] = {0};
|
||||
|
||||
MyThread *errDispCreateThread(void)
|
||||
{
|
||||
if(R_FAILED(MyThread_Create(&errDispThread, errDispThreadMain, errDispThreadStack, 0xD00, 0x18, CORE_SYSTEM)))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
return &errDispThread;
|
||||
}
|
||||
|
||||
static inline u32 ERRF_DisplayRegisterValue(u32 posX, u32 posY, const char *name, u32 value)
|
||||
{
|
||||
@@ -50,6 +63,11 @@ static inline int ERRF_FormatRegisterValue(char *out, const char *name, u32 valu
|
||||
return sprintf(out, "%-9s %08lx", name, value);
|
||||
}
|
||||
|
||||
static inline void ERRF_GetErrInfo(ERRF_FatalErrInfo* info, u32* in, u32 size)
|
||||
{
|
||||
memcpy(info, in, size);
|
||||
}
|
||||
|
||||
static int ERRF_FormatError(char *out, ERRF_FatalErrInfo *info)
|
||||
{
|
||||
char *outStart = out;
|
||||
@@ -154,7 +172,7 @@ static int ERRF_FormatError(char *out, ERRF_FatalErrInfo *info)
|
||||
desc = "The System Memory has been damaged.";
|
||||
break;
|
||||
case ERRF_ERRTYPE_FAILURE:
|
||||
info->data.failure_mesg[0x60] = 0; // make sure the last byte in the IPC buffer is NULL
|
||||
info->data.failure_mesg[0x5F] = 0; // make sure the last byte in the IPC buffer is NULL
|
||||
desc = info->data.failure_mesg;
|
||||
break;
|
||||
default:
|
||||
@@ -225,18 +243,18 @@ static Result ERRF_SaveErrorToFile(ERRF_FatalErrInfo *info)
|
||||
return res;
|
||||
}
|
||||
|
||||
void ERRF_HandleCommands(void *ctx)
|
||||
void ERRF_HandleCommands(void)
|
||||
{
|
||||
(void)ctx;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
ERRF_FatalErrInfo info;
|
||||
|
||||
switch(cmdbuf[0] >> 16)
|
||||
{
|
||||
case 1: // Throw
|
||||
{
|
||||
ERRF_FatalErrInfo *info = (ERRF_FatalErrInfo *)(cmdbuf + 1);
|
||||
ERRF_SaveErrorToFile(info);
|
||||
if(info->type != ERRF_ERRTYPE_LOGGED || info->procId == 0)
|
||||
ERRF_GetErrInfo(&info, (cmdbuf + 1), sizeof(ERRF_FatalErrInfo));
|
||||
ERRF_SaveErrorToFile(&info);
|
||||
if(info.type != ERRF_ERRTYPE_LOGGED || info.procId == 0)
|
||||
{
|
||||
menuEnter();
|
||||
|
||||
@@ -244,7 +262,7 @@ void ERRF_HandleCommands(void *ctx)
|
||||
Draw_ClearFramebuffer();
|
||||
Draw_FlushFramebuffer();
|
||||
|
||||
ERRF_DisplayError(info);
|
||||
ERRF_DisplayError(&info);
|
||||
|
||||
/*
|
||||
If we ever wanted to return:
|
||||
@@ -258,26 +276,98 @@ void ERRF_HandleCommands(void *ctx)
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
cmdbuf[0] = 0x10040;
|
||||
cmdbuf[0] = IPC_MakeHeader(1, 1, 0);
|
||||
cmdbuf[1] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
case 2: // SetUserString
|
||||
{
|
||||
if(cmdbuf[0] != 0x20042 || (cmdbuf[2] & 0x3C0F) != 2)
|
||||
if(cmdbuf[0] != IPC_MakeHeader(2, 1, 2) || (cmdbuf[2] & 0x3C0F) != 2)
|
||||
{
|
||||
cmdbuf[0] = 0x40;
|
||||
cmdbuf[0] = IPC_MakeHeader(0, 1, 0);
|
||||
cmdbuf[1] = 0xD9001830;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmdbuf[0] = 0x20040;
|
||||
u32 sz = cmdbuf[1] <= 0x100 ? sz : 0x100;
|
||||
u32 sz = cmdbuf[1] <= 0x100 ? cmdbuf[1] : 0x100;
|
||||
memcpy(userString, cmdbuf + 3, sz);
|
||||
userString[sz] = 0;
|
||||
|
||||
cmdbuf[0] = IPC_MakeHeader(2, 1, 0);
|
||||
cmdbuf[1] = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void errDispThreadMain(void)
|
||||
{
|
||||
Handle handles[3];
|
||||
Handle serverHandle, clientHandle, sessionHandle = 0;
|
||||
|
||||
u32 replyTarget = 0;
|
||||
s32 index;
|
||||
|
||||
Result res;
|
||||
u32 *cmdbuf = getThreadCommandBuffer();
|
||||
u32 *sbuf = getThreadStaticBuffers();
|
||||
|
||||
sbuf[0] = IPC_Desc_StaticBuffer(0x100, 0);
|
||||
sbuf[1] = (u32)staticBuf;
|
||||
|
||||
assertSuccess(svcCreatePort(&serverHandle, &clientHandle, "err:f", 1));
|
||||
|
||||
do
|
||||
{
|
||||
handles[0] = terminationRequestEvent;
|
||||
handles[1] = serverHandle;
|
||||
handles[2] = sessionHandle;
|
||||
|
||||
if(replyTarget == 0) // k11
|
||||
cmdbuf[0] = 0xFFFF0000;
|
||||
res = svcReplyAndReceive(&index, handles, 1 + (sessionHandle == 0 ? 1 : 2), replyTarget);
|
||||
|
||||
if(R_FAILED(res))
|
||||
{
|
||||
if((u32)res == 0xC920181A) // session closed by remote
|
||||
{
|
||||
svcCloseHandle(sessionHandle);
|
||||
sessionHandle = 0;
|
||||
replyTarget = 0;
|
||||
}
|
||||
|
||||
else
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(index == 1)
|
||||
{
|
||||
Handle session;
|
||||
assertSuccess(svcAcceptSession(&session, serverHandle));
|
||||
|
||||
if(sessionHandle == 0)
|
||||
sessionHandle = session;
|
||||
else
|
||||
svcCloseHandle(session);
|
||||
}
|
||||
else
|
||||
{
|
||||
ERRF_HandleCommands();
|
||||
replyTarget = sessionHandle;
|
||||
}
|
||||
}
|
||||
}
|
||||
while(!terminationRequest);
|
||||
|
||||
svcCloseHandle(sessionHandle);
|
||||
svcCloseHandle(clientHandle);
|
||||
svcCloseHandle(serverHandle);
|
||||
}
|
||||
|
||||
@@ -136,9 +136,9 @@ GDBContext *GDB_SelectAvailableContext(GDBServer *server, u16 minPort, u16 maxPo
|
||||
{
|
||||
ctx->flags |= GDB_FLAG_SELECTED;
|
||||
ctx->localPort = port;
|
||||
ctx->parent = server;
|
||||
}
|
||||
|
||||
ctx->parent = server;
|
||||
GDB_UnlockAllContexts(server);
|
||||
return ctx;
|
||||
}
|
||||
|
||||
@@ -90,11 +90,15 @@ void __appInit()
|
||||
|
||||
if (R_FAILED(pmDbgInit()))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
|
||||
if (R_FAILED(acInit()))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
}
|
||||
|
||||
// this is called after main exits
|
||||
void __appExit()
|
||||
{
|
||||
acExit();
|
||||
pmDbgExit();
|
||||
fsExit();
|
||||
svcCloseHandle(*fsRegGetSessionHandle());
|
||||
@@ -166,7 +170,6 @@ static void handleNextApplicationDebuggedByForce(u32 notificationId)
|
||||
}
|
||||
|
||||
static const ServiceManagerServiceEntry services[] = {
|
||||
{ "err:f", 1, ERRF_HandleCommands, true },
|
||||
{ "hb:ldr", 2, HBLDR_HandleCommands, true },
|
||||
{ NULL },
|
||||
};
|
||||
@@ -194,12 +197,14 @@ int main(void)
|
||||
|
||||
MyThread *menuThread = menuCreateThread();
|
||||
MyThread *taskRunnerThread = taskRunnerCreateThread();
|
||||
MyThread *errDispThread = errDispCreateThread();
|
||||
|
||||
if (R_FAILED(ServiceManager_Run(services, notifications, NULL)))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
|
||||
MyThread_Join(menuThread, -1LL);
|
||||
MyThread_Join(taskRunnerThread, -1LL);
|
||||
MyThread_Join(errDispThread, -1LL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -125,12 +125,12 @@ u32 waitCombo(void)
|
||||
}
|
||||
|
||||
static MyThread menuThread;
|
||||
static u8 ALIGN(8) menuThreadStack[0x3000];
|
||||
static u8 ALIGN(8) menuThreadStack[0x1000];
|
||||
static u8 batteryLevel = 255;
|
||||
|
||||
MyThread *menuCreateThread(void)
|
||||
{
|
||||
if(R_FAILED(MyThread_Create(&menuThread, menuThreadMain, menuThreadStack, 0x3000, 52, CORE_SYSTEM)))
|
||||
if(R_FAILED(MyThread_Create(&menuThread, menuThreadMain, menuThreadStack, 0x1000, 52, CORE_SYSTEM)))
|
||||
svcBreak(USERBREAK_PANIC);
|
||||
return &menuThread;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ static u8 ReadWriteBuffer8 = 0;
|
||||
static bool Cheat_Write8(const Handle processHandle, u32 offset, u8 value)
|
||||
{
|
||||
u32 addr = *activeOffset() + offset;
|
||||
if (addr >= 0x01E81000 && addr + 1 < 0x01E82000)
|
||||
if (addr >= 0x01E81000 && addr < 0x01E82000)
|
||||
{
|
||||
cheatPage[addr - 0x01E81000] = value;
|
||||
return true;
|
||||
@@ -184,7 +184,7 @@ static bool Cheat_Write8(const Handle processHandle, u32 offset, u8 value)
|
||||
static bool Cheat_Write16(const Handle processHandle, u32 offset, u16 value)
|
||||
{
|
||||
u32 addr = *activeOffset() + offset;
|
||||
if (addr >= 0x01E81000 && addr + 2 < 0x01E82000)
|
||||
if (addr >= 0x01E81000 && addr + 1 < 0x01E82000)
|
||||
{
|
||||
*(u16*)(cheatPage + addr - 0x01E81000) = value;
|
||||
return true;
|
||||
@@ -200,7 +200,7 @@ static bool Cheat_Write16(const Handle processHandle, u32 offset, u16 value)
|
||||
static bool Cheat_Write32(const Handle processHandle, u32 offset, u32 value)
|
||||
{
|
||||
u32 addr = *activeOffset() + offset;
|
||||
if (addr >= 0x01E81000 && addr + 4 < 0x01E82000)
|
||||
if (addr >= 0x01E81000 && addr + 3 < 0x01E82000)
|
||||
{
|
||||
*(u32*)(cheatPage + addr - 0x01E81000) = value;
|
||||
return true;
|
||||
@@ -216,7 +216,7 @@ static bool Cheat_Write32(const Handle processHandle, u32 offset, u32 value)
|
||||
static bool Cheat_Read8(const Handle processHandle, u32 offset, u8* retValue)
|
||||
{
|
||||
u32 addr = *activeOffset() + offset;
|
||||
if (addr >= 0x01E81000 && addr + 1 < 0x01E82000)
|
||||
if (addr >= 0x01E81000 && addr < 0x01E82000)
|
||||
{
|
||||
*retValue = cheatPage[addr - 0x01E81000];
|
||||
return true;
|
||||
@@ -233,7 +233,7 @@ static bool Cheat_Read8(const Handle processHandle, u32 offset, u8* retValue)
|
||||
static bool Cheat_Read16(const Handle processHandle, u32 offset, u16* retValue)
|
||||
{
|
||||
u32 addr = *activeOffset() + offset;
|
||||
if (addr >= 0x01E81000 && addr + 2 < 0x01E82000)
|
||||
if (addr >= 0x01E81000 && addr + 1 < 0x01E82000)
|
||||
{
|
||||
*retValue = *(u16*)(cheatPage + addr - 0x01E81000);
|
||||
return true;
|
||||
@@ -250,7 +250,7 @@ static bool Cheat_Read16(const Handle processHandle, u32 offset, u16* retValue)
|
||||
static bool Cheat_Read32(const Handle processHandle, u32 offset, u32* retValue)
|
||||
{
|
||||
u32 addr = *activeOffset() + offset;
|
||||
if (addr >= 0x01E81000 && addr + 4 < 0x01E82000)
|
||||
if (addr >= 0x01E81000 && addr + 3 < 0x01E82000)
|
||||
{
|
||||
*retValue = *(u32*)(cheatPage + addr - 0x01E81000);
|
||||
return true;
|
||||
|
||||
@@ -336,6 +336,7 @@ void MiscellaneousMenu_SyncTimeDate(void)
|
||||
cantStart = R_FAILED(res) || !isSocURegistered;
|
||||
|
||||
int utcOffset = 12;
|
||||
int utcOffsetMinute = 0;
|
||||
int absOffset;
|
||||
do
|
||||
{
|
||||
@@ -344,14 +345,15 @@ void MiscellaneousMenu_SyncTimeDate(void)
|
||||
|
||||
absOffset = utcOffset - 12;
|
||||
absOffset = absOffset < 0 ? -absOffset : absOffset;
|
||||
posY = Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Current UTC offset: %c%02d", utcOffset < 12 ? '-' : '+', absOffset);
|
||||
posY = Draw_DrawFormattedString(10, posY + SPACING_Y, COLOR_WHITE, "Use DPAD Left/Right to change offset.\nPress A when done.") + SPACING_Y;
|
||||
posY = Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Current UTC offset: %c%02d%02d", utcOffset < 12 ? '-' : '+', absOffset, utcOffsetMinute);
|
||||
posY = Draw_DrawFormattedString(10, posY + SPACING_Y, COLOR_WHITE, "Use DPAD Left/Right to change hour offset.\nUse DPAD Up/Down to change minute offset.\nPress A when done.") + SPACING_Y;
|
||||
|
||||
input = waitInput();
|
||||
|
||||
if(input & BUTTON_LEFT) utcOffset = (24 + utcOffset - 1) % 24; // ensure utcOffset >= 0
|
||||
if(input & BUTTON_RIGHT) utcOffset = (utcOffset + 1) % 24;
|
||||
|
||||
if(input & BUTTON_UP) utcOffsetMinute = (utcOffsetMinute + 1) % 60;
|
||||
if(input & BUTTON_DOWN) utcOffsetMinute = (60 + utcOffsetMinute - 1) % 60;
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
}
|
||||
@@ -371,6 +373,7 @@ void MiscellaneousMenu_SyncTimeDate(void)
|
||||
if(R_SUCCEEDED(res))
|
||||
{
|
||||
t += 3600 * utcOffset;
|
||||
t += 60 * utcOffsetMinute;
|
||||
gmtime_r(&t, &localt);
|
||||
res = ntpSetTimeDate(&localt);
|
||||
}
|
||||
|
||||
@@ -55,37 +55,38 @@ typedef struct {
|
||||
u8 z;
|
||||
} Pixel;
|
||||
|
||||
static u16 g_c[0x600];
|
||||
static Pixel g_px[0x400];
|
||||
|
||||
void applyColorSettings(color_setting_t* cs)
|
||||
{
|
||||
u16 c[0x600];
|
||||
Pixel px[0x400];
|
||||
u8 i = 0;
|
||||
|
||||
memset(c, 0, sizeof(c));
|
||||
memset(px, 0, sizeof(px));
|
||||
memset(g_c, 0, sizeof(g_c));
|
||||
memset(g_px, 0, sizeof(g_px));
|
||||
|
||||
do {
|
||||
px[i].r = i;
|
||||
px[i].g = i;
|
||||
px[i].b = i;
|
||||
px[i].z = 0;
|
||||
g_px[i].r = i;
|
||||
g_px[i].g = i;
|
||||
g_px[i].b = i;
|
||||
g_px[i].z = 0;
|
||||
} while(++i);
|
||||
|
||||
do {
|
||||
*(c + i + 0x000) = px[i].r | (px[i].r << 8);
|
||||
*(c + i + 0x100) = px[i].g | (px[i].g << 8);
|
||||
*(c + i + 0x200) = px[i].b | (px[i].b << 8);
|
||||
*(g_c + i + 0x000) = g_px[i].r | (g_px[i].r << 8);
|
||||
*(g_c + i + 0x100) = g_px[i].g | (g_px[i].g << 8);
|
||||
*(g_c + i + 0x200) = g_px[i].b | (g_px[i].b << 8);
|
||||
} while(++i);
|
||||
|
||||
colorramp_fill(c + 0x000, c + 0x100, c + 0x200, 0x100, cs);
|
||||
colorramp_fill(g_c + 0x000, g_c + 0x100, g_c + 0x200, 0x100, cs);
|
||||
|
||||
do {
|
||||
px[i].r = *(c + i + 0x000) >> 8;
|
||||
px[i].g = *(c + i + 0x100) >> 8;
|
||||
px[i].b = *(c + i + 0x200) >> 8;
|
||||
g_px[i].r = *(g_c + i + 0x000) >> 8;
|
||||
g_px[i].g = *(g_c + i + 0x100) >> 8;
|
||||
g_px[i].b = *(g_c + i + 0x200) >> 8;
|
||||
} while(++i);
|
||||
|
||||
writeLut((u32*)px);
|
||||
writeLut((u32*)g_px);
|
||||
}
|
||||
|
||||
Menu screenFiltersMenu = {
|
||||
@@ -143,10 +144,10 @@ void screenFiltersSetTemperature(int temperature)
|
||||
memset(&cs, 0, sizeof(cs));
|
||||
|
||||
cs.temperature = temperature;
|
||||
cs.gamma[0] = 1.0F;
|
||||
/*cs.gamma[0] = 1.0F;
|
||||
cs.gamma[1] = 1.0F;
|
||||
cs.gamma[2] = 1.0F;
|
||||
cs.brightness = 1.0F;
|
||||
cs.brightness = 1.0F;*/
|
||||
|
||||
applyColorSettings(&cs);
|
||||
}
|
||||
|
||||
@@ -34,11 +34,12 @@
|
||||
|
||||
Menu sysconfigMenu = {
|
||||
"System configuration menu",
|
||||
.nbItems = 3,
|
||||
.nbItems = 4,
|
||||
{
|
||||
{ "Toggle LEDs", METHOD, .method = &SysConfigMenu_ToggleLEDs },
|
||||
{ "Toggle Wireless", METHOD, .method = &SysConfigMenu_ToggleWireless },
|
||||
{ "Toggle Power Button", METHOD, .method=&SysConfigMenu_TogglePowerButton },
|
||||
{ "Control Wireless connection", METHOD, .method = &SysConfigMenu_ControlWifi },
|
||||
}
|
||||
};
|
||||
|
||||
@@ -148,15 +149,69 @@ void SysConfigMenu_ToggleWireless(void)
|
||||
while(!terminationRequest);
|
||||
}
|
||||
|
||||
void SysConfigMenu_TogglePowerButton(void)
|
||||
static void SysConfigMenu_ForceWifiConnection(int slot)
|
||||
{
|
||||
u32 mcuIRQMask;
|
||||
|
||||
char ssid[0x20 + 1] = {0};
|
||||
|
||||
acuConfig config = {0};
|
||||
ACU_CreateDefaultConfig(&config);
|
||||
ACU_SetNetworkArea(&config, 2);
|
||||
ACU_SetAllowApType(&config, 1 << slot);
|
||||
ACU_SetRequestEulaVersion(&config);
|
||||
|
||||
Handle connectEvent = 0;
|
||||
svcCreateEvent(&connectEvent, RESET_ONESHOT);
|
||||
|
||||
bool forcedConnection = false;
|
||||
if(R_SUCCEEDED(ACU_ConnectAsync(&config, connectEvent)))
|
||||
{
|
||||
if(R_SUCCEEDED(svcWaitSynchronization(connectEvent, -1)))
|
||||
{
|
||||
ACU_GetSSID(ssid);
|
||||
forcedConnection = true;
|
||||
}
|
||||
}
|
||||
svcCloseHandle(connectEvent);
|
||||
|
||||
char infoString[80] = {0};
|
||||
u32 infoStringColor = forcedConnection ? COLOR_GREEN : COLOR_RED;
|
||||
if(forcedConnection)
|
||||
sprintf(infoString, "Succesfully forced a connection to: %s", ssid);
|
||||
else
|
||||
sprintf(infoString, "Failed to connect to slot %d", slot + 1);
|
||||
|
||||
Draw_Lock();
|
||||
Draw_ClearFramebuffer();
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
Draw_Lock();
|
||||
Draw_DrawString(10, 10, COLOR_TITLE, "System configuration menu");
|
||||
Draw_DrawString(10, 30, infoStringColor, infoString);
|
||||
Draw_DrawString(10, 40, COLOR_WHITE, "Press B to go back.");
|
||||
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
|
||||
u32 pressed = waitInputWithTimeout(1000);
|
||||
|
||||
if(pressed & BUTTON_B)
|
||||
return;
|
||||
}
|
||||
while(!terminationRequest);
|
||||
}
|
||||
|
||||
void SysConfigMenu_TogglePowerButton(void)
|
||||
{
|
||||
u32 mcuIRQMask;
|
||||
|
||||
Draw_Lock();
|
||||
Draw_ClearFramebuffer();
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
|
||||
mcuHwcInit();
|
||||
MCUHWC_ReadRegister(0x18, (u8*)&mcuIRQMask, 4);
|
||||
mcuHwcExit();
|
||||
@@ -169,10 +224,10 @@ void SysConfigMenu_TogglePowerButton(void)
|
||||
|
||||
Draw_DrawString(10, 50, COLOR_WHITE, "Current status:");
|
||||
Draw_DrawString(100, 50, (((mcuIRQMask & 0x00000001) == 0x00000001) ? COLOR_RED : COLOR_GREEN), (((mcuIRQMask & 0x00000001) == 0x00000001) ? " DISABLED" : " ENABLED "));
|
||||
|
||||
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
|
||||
|
||||
u32 pressed = waitInputWithTimeout(1000);
|
||||
|
||||
if(pressed & BUTTON_A)
|
||||
@@ -188,3 +243,61 @@ void SysConfigMenu_TogglePowerButton(void)
|
||||
}
|
||||
while(!terminationRequest);
|
||||
}
|
||||
|
||||
void SysConfigMenu_ControlWifi(void)
|
||||
{
|
||||
Draw_Lock();
|
||||
Draw_ClearFramebuffer();
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
|
||||
int slot = 0;
|
||||
char slotString[12] = {0};
|
||||
sprintf(slotString, ">1< 2 3 ");
|
||||
do
|
||||
{
|
||||
Draw_Lock();
|
||||
Draw_DrawString(10, 10, COLOR_TITLE, "System configuration menu");
|
||||
Draw_DrawString(10, 30, COLOR_WHITE, "Press A to force a connection to slot:");
|
||||
Draw_DrawString(10, 40, COLOR_WHITE, slotString);
|
||||
Draw_DrawString(10, 60, COLOR_WHITE, "Press B to go back.");
|
||||
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
|
||||
u32 pressed = waitInputWithTimeout(1000);
|
||||
|
||||
if(pressed & BUTTON_A)
|
||||
{
|
||||
SysConfigMenu_ForceWifiConnection(slot);
|
||||
|
||||
Draw_Lock();
|
||||
Draw_ClearFramebuffer();
|
||||
Draw_FlushFramebuffer();
|
||||
Draw_Unlock();
|
||||
}
|
||||
else if(pressed & BUTTON_LEFT)
|
||||
{
|
||||
slotString[slot * 4] = ' ';
|
||||
slotString[(slot * 4) + 2] = ' ';
|
||||
slot--;
|
||||
if(slot == -1)
|
||||
slot = 2;
|
||||
slotString[slot * 4] = '>';
|
||||
slotString[(slot * 4) + 2] = '<';
|
||||
}
|
||||
else if(pressed & BUTTON_RIGHT)
|
||||
{
|
||||
slotString[slot * 4] = ' ';
|
||||
slotString[(slot * 4) + 2] = ' ';
|
||||
slot++;
|
||||
if(slot == 3)
|
||||
slot = 0;
|
||||
slotString[slot * 4] = '>';
|
||||
slotString[(slot * 4) + 2] = '<';
|
||||
}
|
||||
else if(pressed & BUTTON_B)
|
||||
return;
|
||||
}
|
||||
while(!terminationRequest);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
//#include <math.h>
|
||||
|
||||
#include "redshift/redshift.h"
|
||||
|
||||
@@ -282,8 +282,10 @@ interpolate_color(float a, const float *c1, const float *c2, float *c)
|
||||
}
|
||||
|
||||
/* Helper macro used in the fill functions */
|
||||
#define F(Y, C) pow((Y) * setting->brightness * \
|
||||
white_point[C], 1.0/setting->gamma[C])
|
||||
#define F(Y, C) ((Y) * white_point[C])
|
||||
|
||||
/*#define F(Y, C) pow((Y) * setting->brightness * \
|
||||
white_point[C], 1.0/setting->gamma[C])*/
|
||||
|
||||
void
|
||||
colorramp_fill(uint16_t *gamma_r, uint16_t *gamma_g, uint16_t *gamma_b,
|
||||
@@ -324,4 +326,4 @@ colorramp_fill_float(float *gamma_r, float *gamma_g, float *gamma_b,
|
||||
}
|
||||
}
|
||||
|
||||
#undef F
|
||||
#undef F
|
||||
|
||||
Reference in New Issue
Block a user