mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2025-01-03 16:11:49 +01:00
Press select/minus to toggle backlight
This commit is contained in:
parent
f46efc9286
commit
900df7882d
@ -8,6 +8,9 @@ FTP Server for 3DS/Switch/Linux.
|
|||||||
- Supports multiple simultaneous clients. The 3DS itself only appears to support enough sockets to perform 4-5 simultaneous data transfers, so it will help if you limit your FTP client to this many parallel requests.
|
- Supports multiple simultaneous clients. The 3DS itself only appears to support enough sockets to perform 4-5 simultaneous data transfers, so it will help if you limit your FTP client to this many parallel requests.
|
||||||
- Cutting-edge graphics.
|
- Cutting-edge graphics.
|
||||||
|
|
||||||
|
- Toggle backlight on 3DS with SELECT button
|
||||||
|
- Toggle backlight on Switch with MINUS button
|
||||||
|
|
||||||
## Latest Builds
|
## Latest Builds
|
||||||
NDS: https://mtheall.com/~mtheall/ftpd.nds
|
NDS: https://mtheall.com/~mtheall/ftpd.nds
|
||||||
|
|
||||||
|
@ -70,6 +70,12 @@ u32 *s_socuBuffer = nullptr;
|
|||||||
/// \brief ac:u fence
|
/// \brief ac:u fence
|
||||||
platform::Mutex s_acuFence;
|
platform::Mutex s_acuFence;
|
||||||
|
|
||||||
|
/// \brief Whether to power backlight
|
||||||
|
bool s_backlight = true;
|
||||||
|
|
||||||
|
/// \brief APT hook cookie
|
||||||
|
aptHookCookie s_aptHookCookie;
|
||||||
|
|
||||||
#ifdef CLASSIC
|
#ifdef CLASSIC
|
||||||
in_addr_t s_addr = 0;
|
in_addr_t s_addr = 0;
|
||||||
#else
|
#else
|
||||||
@ -118,6 +124,43 @@ C3D_Tex s_gfxTexture;
|
|||||||
Tex3DS_Texture s_gfxT3x;
|
Tex3DS_Texture s_gfxT3x;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// \brief Enable backlight
|
||||||
|
/// \param enable_ Whether to enable backligh
|
||||||
|
void enableBacklight (bool const enable_)
|
||||||
|
{
|
||||||
|
if (R_FAILED (gspLcdInit ()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
(enable_ ? GSPLCD_PowerOnBacklight : GSPLCD_PowerOffBacklight) (GSPLCD_SCREEN_BOTH);
|
||||||
|
|
||||||
|
gspLcdExit ();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief Handle APT cookie
|
||||||
|
/// \param type_ Hook type
|
||||||
|
/// \param param_ User param
|
||||||
|
void handleAPTHook (APT_HookType const type_, void *const param_)
|
||||||
|
{
|
||||||
|
switch (type_)
|
||||||
|
{
|
||||||
|
case APTHOOK_ONSUSPEND:
|
||||||
|
case APTHOOK_ONSLEEP:
|
||||||
|
// turn on backlight, or you can't see the home menu!
|
||||||
|
if (!s_backlight)
|
||||||
|
enableBacklight (true);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case APTHOOK_ONRESTORE:
|
||||||
|
case APTHOOK_ONWAKEUP:
|
||||||
|
// restore backlight setting
|
||||||
|
enableBacklight (s_backlight);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Get network visibility
|
/// \brief Get network visibility
|
||||||
bool getNetworkVisibility ()
|
bool getNetworkVisibility ()
|
||||||
{
|
{
|
||||||
@ -328,6 +371,8 @@ bool platform::init ()
|
|||||||
std::setvbuf (stderr, nullptr, _IOLBF, 0);
|
std::setvbuf (stderr, nullptr, _IOLBF, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
aptHook (&s_aptHookCookie, handleAPTHook, nullptr);
|
||||||
|
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
// initialize citro3d
|
// initialize citro3d
|
||||||
C3D_Init (2 * C3D_DEFAULT_CMDBUF_SIZE);
|
C3D_Init (2 * C3D_DEFAULT_CMDBUF_SIZE);
|
||||||
@ -392,9 +437,19 @@ bool platform::loop ()
|
|||||||
|
|
||||||
hidScanInput ();
|
hidScanInput ();
|
||||||
|
|
||||||
if (hidKeysDown () & KEY_START)
|
auto const kDown = hidKeysDown ();
|
||||||
|
|
||||||
|
// check if the user wants to exit
|
||||||
|
if (kDown & KEY_START)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// check if the user wants to toggle the backlight
|
||||||
|
if (kDown & KEY_SELECT)
|
||||||
|
{
|
||||||
|
s_backlight = !s_backlight;
|
||||||
|
enableBacklight (s_backlight);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
auto &io = ImGui::GetIO ();
|
auto &io = ImGui::GetIO ();
|
||||||
|
|
||||||
@ -455,6 +510,12 @@ void platform::exit ()
|
|||||||
s_socuActive = false;
|
s_socuActive = false;
|
||||||
std::free (s_socuBuffer);
|
std::free (s_socuBuffer);
|
||||||
|
|
||||||
|
aptUnhook (&s_aptHookCookie);
|
||||||
|
|
||||||
|
// turn backlight back on
|
||||||
|
if (!s_backlight)
|
||||||
|
enableBacklight (true);
|
||||||
|
|
||||||
gfxExit ();
|
gfxExit ();
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
romfsExit ();
|
romfsExit ();
|
||||||
|
@ -40,6 +40,8 @@ PrintConsole g_sessionConsole;
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
struct in_addr s_addr = {0};
|
struct in_addr s_addr = {0};
|
||||||
|
/// \brief Whether to power backlight
|
||||||
|
bool s_backlight = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool platform::networkVisible ()
|
bool platform::networkVisible ()
|
||||||
@ -99,9 +101,18 @@ bool platform::loop ()
|
|||||||
{
|
{
|
||||||
scanKeys ();
|
scanKeys ();
|
||||||
|
|
||||||
if (keysDown () & KEY_START)
|
// check if the user wants to exit
|
||||||
|
auto const kDown = keysDown ();
|
||||||
|
if (kDown & KEY_START)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// check if the user wants to toggle the backlight
|
||||||
|
if (kDown & KEY_SELECT)
|
||||||
|
{
|
||||||
|
s_backlight = !s_backlight;
|
||||||
|
(s_backlight ? powerOn : powerOff) (POWER_LCD);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,12 +123,5 @@ void platform::render ()
|
|||||||
|
|
||||||
void platform::exit ()
|
void platform::exit ()
|
||||||
{
|
{
|
||||||
info ("Press any key to exit\n");
|
powerOn (POWER_LCD);
|
||||||
render ();
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
swiWaitForVBlank ();
|
|
||||||
scanKeys ();
|
|
||||||
} while (!keysDown ());
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,12 @@ PrintConsole g_sessionConsole;
|
|||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
/// \brief Whether to power backlight
|
||||||
|
bool s_backlight = true;
|
||||||
|
|
||||||
|
/// \brief Applet hook cookie
|
||||||
|
AppletHookCookie s_appletHookCookie;
|
||||||
|
|
||||||
#ifdef CLASSIC
|
#ifdef CLASSIC
|
||||||
in_addr_t s_addr = 0;
|
in_addr_t s_addr = 0;
|
||||||
#else
|
#else
|
||||||
@ -397,6 +403,24 @@ void deko3dExit ()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// \brief Handle applet hook
|
||||||
|
/// \param hook_ Callback reason
|
||||||
|
/// \param param_ User param
|
||||||
|
void handleAppletHook (AppletHookType const hook_, void *const param_)
|
||||||
|
{
|
||||||
|
(void)param_;
|
||||||
|
switch (hook_)
|
||||||
|
{
|
||||||
|
case AppletHookType_OnFocusState:
|
||||||
|
if (appletGetFocusState () == AppletFocusState_Focused)
|
||||||
|
appletSetLcdBacklightOffEnabled (!s_backlight);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// \brief Draw status
|
/// \brief Draw status
|
||||||
void drawStatus ()
|
void drawStatus ()
|
||||||
{
|
{
|
||||||
@ -503,6 +527,8 @@ void drawStatus ()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool platform::init ()
|
bool platform::init ()
|
||||||
{
|
{
|
||||||
#ifdef CLASSIC
|
#ifdef CLASSIC
|
||||||
@ -534,6 +560,8 @@ bool platform::init ()
|
|||||||
FB_NUM);
|
FB_NUM);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
appletHook (&s_appletHookCookie, handleAppletHook, nullptr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,9 +589,18 @@ bool platform::loop ()
|
|||||||
hidScanInput ();
|
hidScanInput ();
|
||||||
|
|
||||||
auto const keysDown = hidKeysDown (CONTROLLER_P1_AUTO);
|
auto const keysDown = hidKeysDown (CONTROLLER_P1_AUTO);
|
||||||
|
|
||||||
|
// check if the user wants to exit
|
||||||
if (keysDown & KEY_PLUS)
|
if (keysDown & KEY_PLUS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// check if the user wants to toggle the backlight
|
||||||
|
if (keysDown & KEY_MINUS)
|
||||||
|
{
|
||||||
|
s_backlight = !s_backlight;
|
||||||
|
appletSetLcdBacklightOffEnabled (!s_backlight);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef CLASSIC
|
#ifndef CLASSIC
|
||||||
imgui::nx::newFrame ();
|
imgui::nx::newFrame ();
|
||||||
ImGui::NewFrame ();
|
ImGui::NewFrame ();
|
||||||
@ -647,6 +684,11 @@ void platform::exit ()
|
|||||||
imgui::deko3d::exit ();
|
imgui::deko3d::exit ();
|
||||||
deko3dExit ();
|
deko3dExit ();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
appletUnhook (&s_appletHookCookie);
|
||||||
|
|
||||||
|
if (!s_backlight)
|
||||||
|
appletSetLcdBacklightOffEnabled (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user