Apply screen filter when waking up from standby

This commit is contained in:
panicbit 2018-04-15 16:26:20 +02:00
parent d13cde3d7b
commit d0306609c3
7 changed files with 137 additions and 10 deletions

View File

@ -26,8 +26,12 @@
#pragma once
#include "menu.h"
extern Menu screenFiltersMenu;
int screenFiltersCurrentTemperature;
void screenFiltersSetDisabled(void);
void screenFiltersReduceBlueLevel1(void);
void screenFiltersReduceBlueLevel2(void);

View File

@ -0,0 +1,30 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH, panicbit
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include <MyThread.h>
MyThread *shellOpenCreateThread(void);
void shellOpenThreadMain(void);

View File

@ -50,8 +50,12 @@ AccessControlInfo:
# The kernel extension removes svc perms checks, so below is just to avoid a makerom error
Backdoor: 123
KernelSetState: 124
BindInterrupt: 80
UnbindInterrupt: 81
InterruptNumbers:
- 0x60 # Shell opened
ServiceAccessControl:
- fs:USER # Not strictly needed as rosalina has access to everything, it's rather to avoid a makerom warning
FileSystemAccess:

View File

@ -35,6 +35,8 @@
#include "MyThread.h"
#include "menus/process_patches.h"
#include "menus/miscellaneous.h"
#include "menus/screen_filters.h"
#include "shell_open.h"
// this is called before main
bool isN3DS;
@ -99,14 +101,15 @@ int main(void)
Result res = 0;
Handle notificationHandle;
MyThread *menuThread = menuCreateThread(), *errDispThread = errDispCreateThread(), *hbldrThread = hbldrCreateThread();
if(R_FAILED(srvEnableNotification(&notificationHandle)))
svcBreak(USERBREAK_ASSERT);
if(R_FAILED(svcCreateEvent(&terminationRequestEvent, RESET_STICKY)))
svcBreak(USERBREAK_ASSERT);
MyThread *menuThread = menuCreateThread(), *errDispThread = errDispCreateThread(), *hbldrThread = hbldrCreateThread();
MyThread *shellOpenThread = shellOpenCreateThread();
do
{
res = svcWaitSynchronization(notificationHandle, -1LL);
@ -131,6 +134,7 @@ int main(void)
MyThread_Join(menuThread, -1LL);
MyThread_Join(errDispThread, -1LL);
MyThread_Join(hbldrThread, -1LL);
MyThread_Join(shellOpenThread, -1LL);
svcCloseHandle(notificationHandle);
return 0;

View File

@ -129,7 +129,7 @@ static u8 batteryLevel = 255;
MyThread *menuCreateThread(void)
{
if(R_FAILED(MyThread_Create(&menuThread, menuThreadMain, menuThreadStack, THREAD_STACK_SIZE, 52, CORE_SYSTEM)))
if(R_FAILED(MyThread_Create(&menuThread, menuThreadMain, menuThreadStack, 0x3000, 52, CORE_SYSTEM)))
svcBreak(USERBREAK_PANIC);
return &menuThread;
}

View File

@ -34,6 +34,8 @@
#define TEMP_DEFAULT NEUTRAL_TEMP
int screenFiltersCurrentTemperature = TEMP_DEFAULT;
void writeLut(u32* lut)
{
u8 idx = 0;
@ -101,32 +103,38 @@ Menu screenFiltersMenu = {
void screenFiltersSetDisabled(void)
{
screenFiltersSetTemperature(TEMP_DEFAULT);
screenFiltersCurrentTemperature = TEMP_DEFAULT;
screenFiltersSetTemperature(screenFiltersCurrentTemperature);
}
void screenFiltersReduceBlueLevel1(void)
{
screenFiltersSetTemperature(4300);
screenFiltersCurrentTemperature = 4300;
screenFiltersSetTemperature(screenFiltersCurrentTemperature);
}
void screenFiltersReduceBlueLevel2(void)
{
screenFiltersSetTemperature(3200);
screenFiltersCurrentTemperature = 3200;
screenFiltersSetTemperature(screenFiltersCurrentTemperature);
}
void screenFiltersReduceBlueLevel3(void)
{
screenFiltersSetTemperature(2100);
screenFiltersCurrentTemperature = 2100;
screenFiltersSetTemperature(screenFiltersCurrentTemperature);
}
void screenFiltersReduceBlueLevel4(void)
{
screenFiltersSetTemperature(1550);
screenFiltersCurrentTemperature = 1550;
screenFiltersSetTemperature(screenFiltersCurrentTemperature);
}
void screenFiltersReduceBlueLevel5(void)
{
screenFiltersSetTemperature(1000);
screenFiltersCurrentTemperature = 1000;
screenFiltersSetTemperature(screenFiltersCurrentTemperature);
}
void screenFiltersSetTemperature(int temperature)

View File

@ -0,0 +1,77 @@
/*
* This file is part of Luma3DS
* Copyright (C) 2016-2017 Aurora Wright, TuxSH, panicbit
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Additional Terms 7.b and 7.c of GPLv3 apply to this file:
* * Requiring preservation of specified reasonable legal notices or
* author attributions in that material or in the Appropriate Legal
* Notices displayed by works containing it.
* * Prohibiting misrepresentation of the origin of that material,
* or requiring that modified versions of such material be marked in
* reasonable ways as different from the original version.
*/
#include "shell_open.h"
#include "menus/screen_filters.h"
#include "draw.h"
#define INT_SHELL_OPEN 0x60
#define STACK_SIZE 0x3000
static MyThread shellOpenThread;
static u8 ALIGN(8) shellOpenStack[STACK_SIZE];
static Handle shellOpenEvent;
extern Handle terminationRequestEvent;
MyThread *shellOpenCreateThread(void)
{
if (R_FAILED(MyThread_Create(&shellOpenThread, shellOpenThreadMain, shellOpenStack, STACK_SIZE, 0x3F, CORE_SYSTEM)))
svcBreak(USERBREAK_PANIC);
return &shellOpenThread;
}
void shellOpenThreadMain(void) {
if (R_FAILED(svcCreateEvent(&shellOpenEvent, RESET_ONESHOT)))
svcBreak(USERBREAK_ASSERT);
if (R_FAILED(svcBindInterrupt(INT_SHELL_OPEN, shellOpenEvent, 0, false)))
svcBreak(USERBREAK_ASSERT);
Handle handles[2] = {terminationRequestEvent, shellOpenEvent};
while (true) {
s32 idx = -1;
svcWaitSynchronizationN(&idx, handles, 2, false, U64_MAX);
if (idx < 0) {
continue;
}
if (handles[idx] == terminationRequestEvent) {
break;
}
// Need to wait for the GPU to get initialized
svcSleepThread(16 * 1000 * 1000LL);
screenFiltersSetTemperature(screenFiltersCurrentTemperature);
}
svcUnbindInterrupt(INT_SHELL_OPEN, shellOpenEvent);
svcCloseHandle(shellOpenEvent);
}