(CTR/3DS) shut down the LCD backlight when toggling the buttom display

off.
courtesy of @thedax.
This commit is contained in:
aliaspider 2015-10-01 18:12:59 +01:00
parent 4c27cd6b5c
commit 63ab3b02b8
3 changed files with 32 additions and 5 deletions

View File

@ -186,6 +186,7 @@ AccessControlInfo:
- frd:u
- fs:USER
- gsp::Gpu
- gsp::Lcd
- hid:USER
- http:C
- mic:u

View File

@ -182,6 +182,8 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[],
static void frontend_ctr_deinit(void *data)
{
extern PrintConsole* currentConsole;
Handle lcd_handle;
(void)data;
#ifndef IS_SALAMANDER
global_t *global = global_get_ptr();
@ -193,7 +195,17 @@ static void frontend_ctr_deinit(void *data)
global->log_file = NULL;
#endif
wait_for_input();
if(gfxBottomFramebuffers[0] == (u8*)currentConsole->frameBuffer)
wait_for_input();
if(srvGetServiceHandle(&lcd_handle, "gsp::Lcd") >= 0)
{
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = 0x00110040;
cmdbuf[1] = 2;
svcSendSyncRequest(lcd_handle);
svcCloseHandle(lcd_handle);
}
csndExit();
gfxExit();

View File

@ -85,6 +85,7 @@ typedef struct ctr_video
unsigned rotation;
bool keep_aspect;
bool should_resize;
bool lcd_buttom_on;
void* empty_framebuffer;
} ctr_video_t;
@ -341,6 +342,7 @@ static void* ctr_init(const video_info_t* video,
ctr->keep_aspect = true;
ctr->should_resize = true;
ctr->smooth = true;
ctr->lcd_buttom_on = true;
ctr->empty_framebuffer = linearAlloc(320 * 240 * 2);
memset(ctr->empty_framebuffer, 0, 320 * 240 * 2);
@ -390,11 +392,23 @@ static bool ctr_frame(void* data, const void* frame,
hidTouchRead(&state_tmp_touch);
if((state_tmp & KEY_TOUCH) && (state_tmp_touch.py < 120))
{
Handle lcd_handle;
extern PrintConsole* currentConsole;
if ((u8*)currentConsole->frameBuffer == gfxBottomFramebuffers[0])
gfxBottomFramebuffers[0] = (u8*)ctr->empty_framebuffer;
else
gfxBottomFramebuffers[0] = (u8*)currentConsole->frameBuffer;
gfxBottomFramebuffers[0] = ctr->lcd_buttom_on ? (u8*)ctr->empty_framebuffer:
(u8*)currentConsole->frameBuffer;
if(srvGetServiceHandle(&lcd_handle, "gsp::Lcd") >= 0)
{
printf("here !!\n");
u32 *cmdbuf = getThreadCommandBuffer();
cmdbuf[0] = ctr->lcd_buttom_on? 0x00120040: 0x00110040;
cmdbuf[1] = 2;
svcSendSyncRequest(lcd_handle);
svcCloseHandle(lcd_handle);
}
ctr->lcd_buttom_on = !ctr->lcd_buttom_on;
}
svcWaitSynchronization(gspEvents[GSPEVENT_P3D], 20000000);