From ff540f2ad1b75d134ee3d831fe6bec46923db717 Mon Sep 17 00:00:00 2001 From: Joel Date: Sun, 6 Aug 2017 11:43:09 -0400 Subject: [PATCH] More GSPLCD functions Implemented these using the information from 3D BREW. Did test to make sure they're working. --- libctru/include/3ds/services/gsplcd.h | 12 +++++++++ libctru/source/services/gsplcd.c | 37 +++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/libctru/include/3ds/services/gsplcd.h b/libctru/include/3ds/services/gsplcd.h index fdb219e..398247a 100644 --- a/libctru/include/3ds/services/gsplcd.h +++ b/libctru/include/3ds/services/gsplcd.h @@ -19,6 +19,12 @@ Result gspLcdInit(void); /// Exits GSPLCD. void gspLcdExit(void); +/// Powers on both backlights. +Result GSPLCD_PowerOnAllBacklights(void); + +/// Powers off both backlights. +Result GSPLCD_PowerOffAllBacklights(void); + /** * @brief Powers on the backlight. * @param screen Screen to power on. @@ -31,6 +37,12 @@ Result GSPLCD_PowerOnBacklight(u32 screen); */ Result GSPLCD_PowerOffBacklight(u32 screen); +/** + * @brief Sets 3D_LEDSTATE to the input state value. + * @param state 0 = 3D LED enable, 1 = 3D LED disable. + */ +Result GSPLCD_SetLedForceOff(u8 state); + /** * @brief Gets the LCD screens' vendors. Stubbed on old 3ds. * @param vendor Pointer to output the screen vendors to. diff --git a/libctru/source/services/gsplcd.c b/libctru/source/services/gsplcd.c index 0183e56..7777da5 100644 --- a/libctru/source/services/gsplcd.c +++ b/libctru/source/services/gsplcd.c @@ -26,6 +26,30 @@ void gspLcdExit(void) svcCloseHandle(gspLcdHandle); } +Result GSPLCD_PowerOnAllBacklights(void) +{ + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x0F,0,0); // 0x0F0000 + + Result ret=0; + if (R_FAILED(ret = svcSendSyncRequest(gspLcdHandle))) return ret; + + return cmdbuf[1]; +} + +Result GSPLCD_PowerOffAllBacklights(void) +{ + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x10,0,0); // 0x100000 + + Result ret=0; + if (R_FAILED(ret = svcSendSyncRequest(gspLcdHandle))) return ret; + + return cmdbuf[1]; +} + Result GSPLCD_PowerOnBacklight(u32 screen) { u32 *cmdbuf = getThreadCommandBuffer(); @@ -52,6 +76,19 @@ Result GSPLCD_PowerOffBacklight(u32 screen) return cmdbuf[1]; } +Result GSPLCD_SetLedForceOff(u8 state) +{ + u32 *cmdbuf = getThreadCommandBuffer(); + + cmdbuf[0] = IPC_MakeHeader(0x13,1,0); // 0x130040 + cmdbuf[1] = state; + + Result ret=0; + if (R_FAILED(ret = svcSendSyncRequest(gspLcdHandle))) return ret; + + return cmdbuf[1]; +} + Result GSPLCD_GetVendors(u8 *vendors) { u32 *cmdbuf = getThreadCommandBuffer();