Merge branch 'master' into toggle-power-button
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user