From ce58d8a3c28822488078bad22709f80cb2cea8a3 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sat, 10 Sep 2022 18:56:16 +0200 Subject: [PATCH] Add button combo to shut the GamePad off Currently, wut needs to be compiled from source to build this. --- README.md | 4 ++-- src/main.cpp | 32 ++++++++++++++++++++------------ 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 3fe4d30..832e1e4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Padcon Plugin for the Wii U Plugin System -This plugin for the Wii U Plugin System turns the Wii U GamePad screen off, but keeps it on as a controller. Modified version of the [Padcon plugin](https://github.com/Maschell/WUPSPluginPlayground/tree/master/padcon) by Maschell. I just cleaned it up and changed the button combination. +This plugin for the Wii U Plugin System turns the Wii U GamePad screen off, but keeps it on as a controller. Alternatively, it can also be turned off completely. Modified version of the [Padcon plugin](https://github.com/Maschell/WUPSPluginPlayground/tree/master/padcon) by Maschell. ## Installation @@ -11,7 +11,7 @@ This plugin for the Wii U Plugin System turns the Wii U GamePad screen off, but ## Usage -While the plugin is active, press `ZL` + `ZR` + `L` + `R` + `PLUS` together to turn off the screen. The GamePad will still be usable as a controller. +While the plugin is active, press `ZL` + `ZR` + `L` + `R` + `PLUS` together to turn off the screen. The GamePad will still be usable as a controller. Press `ZL` + `ZR` + `L` + `R` + `MINUS` together to shut the GamePad off completely. You can turn it on again via the POWER button. ## Building diff --git a/src/main.cpp b/src/main.cpp index 38eb5d1..e3a8423 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,11 @@ +#include #include #include WUPS_PLUGIN_NAME("Padcon"); -WUPS_PLUGIN_DESCRIPTION( - "Turns the gamepad screen on/off when ZL + ZR + L + R + Plus."); -WUPS_PLUGIN_VERSION("v1.1-Mod"); +WUPS_PLUGIN_DESCRIPTION("Turns the gamepad screen on/off or shuts the GamePad " + "off when pressing ZL + ZR + L + R + Plus/Minus."); +WUPS_PLUGIN_VERSION("v1.2-Mod"); WUPS_PLUGIN_AUTHOR("Maschell, Brawl"); WUPS_PLUGIN_LICENSE("GPL"); @@ -15,17 +16,24 @@ DECL_FUNCTION(int32_t, VPADRead, VPADChan chan, VPADStatus *buffer, int32_t result = real_VPADRead(chan, buffer, buffer_size, error); if (result > 0 && *error == VPAD_READ_SUCCESS) { - if (buffer[0].hold == (VPAD_BUTTON_ZL | VPAD_BUTTON_ZR | VPAD_BUTTON_L | - VPAD_BUTTON_R | VPAD_BUTTON_PLUS) && - cooldown == 0) { + if (cooldown == 0) { cooldown = 60; // 1 second cooldown - VPADLcdMode lcdMode; - VPADGetLcdMode(VPAD_CHAN_0, &lcdMode); - if (lcdMode == VPAD_LCD_ON) { - VPADSetLcdMode(VPAD_CHAN_0, VPAD_LCD_OFF); - } else { - VPADSetLcdMode(VPAD_CHAN_0, VPAD_LCD_ON); + uint32_t hold = buffer[0].hold; + + if (hold == (VPAD_BUTTON_ZL | VPAD_BUTTON_ZR | VPAD_BUTTON_L | + VPAD_BUTTON_R | VPAD_BUTTON_PLUS)) { + VPADLcdMode lcdMode; + VPADGetLcdMode(VPAD_CHAN_0, &lcdMode); + + if (lcdMode == VPAD_LCD_ON) { + VPADSetLcdMode(VPAD_CHAN_0, VPAD_LCD_OFF); + } else { + VPADSetLcdMode(VPAD_CHAN_0, VPAD_LCD_ON); + } + } else if (hold == (VPAD_BUTTON_ZL | VPAD_BUTTON_ZR | VPAD_BUTTON_L | + VPAD_BUTTON_R | VPAD_BUTTON_MINUS)) { + CCRSysDRCShutdown(); } } }