Avoid toggling backlight with Rosalina menu combo

This commit is contained in:
Michael Theall 2020-06-26 17:30:48 -05:00
parent bae8254d22
commit 0db916db66

View File

@ -72,6 +72,8 @@ platform::Mutex s_acuFence;
/// \brief Whether to power backlight /// \brief Whether to power backlight
bool s_backlight = true; bool s_backlight = true;
/// \brief Button state for toggling backlight
unsigned s_buttons = 0;
/// \brief APT hook cookie /// \brief APT hook cookie
aptHookCookie s_aptHookCookie; aptHookCookie s_aptHookCookie;
@ -439,17 +441,35 @@ bool platform::loop ()
hidScanInput (); hidScanInput ();
auto const kDown = hidKeysDown (); auto const kDown = hidKeysDown ();
auto const kHeld = hidKeysHeld ();
auto const kUp = hidKeysUp ();
// check if the user wants to exit // check if the user wants to exit
if (kDown & KEY_START) if (kDown & KEY_START)
return false; return false;
// check if the user wants to toggle the backlight // check if the user wants to toggle the backlight
if (kDown & KEY_SELECT) // avoid toggling during the Rosalina menu default combo
if (kDown == KEY_SELECT && kHeld == KEY_SELECT)
{ {
// SELECT was pressed and no other keys are held, so reset state
s_buttons = KEY_SELECT;
}
else if (kUp & KEY_SELECT)
{
// SELECT was released
if (s_buttons == KEY_SELECT)
{
// no other button was held at the same time as SELECT, so toggle
s_backlight = !s_backlight; s_backlight = !s_backlight;
enableBacklight (s_backlight); enableBacklight (s_backlight);
} }
}
else
{
// add any held buttons
s_buttons |= kHeld;
}
#ifndef CLASSIC #ifndef CLASSIC
auto &io = ImGui::GetIO (); auto &io = ImGui::GetIO ();