Skip to content

Commit 9c20684

Browse files
committed
InputBindings: allow exiting via back/B button
1 parent f838506 commit 9c20684

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/input_manager.cpp

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ class InputManager
214214
std::array<InputState, size_t(ADChannel::Count)> volumes;
215215
uint32_t switch_current;
216216
uint32_t switch_previous;
217+
uint32_t switch_overlay;
217218

218219
public:
219220
~InputManager()
@@ -468,8 +469,14 @@ class InputManager
468469
switch_previous = switch_current;
469470
switch_current = 0;
470471

472+
// hacks to hide inputs until all buttons are released
473+
static bool disableOverlayInputs = false;
474+
static bool disableGameInputs = false;
475+
476+
if (bindDialog.isListeningForInput == ListenState::Listening)
477+
disableOverlayInputs = true;
471478
if (Overlay::IsBindingDialogActive)
472-
bindDialog.disableGameInputsUntilReleased = true;
479+
disableGameInputs = true;
473480

474481
for (size_t i = 0; i < volumeBindings.size(); ++i)
475482
{
@@ -491,10 +498,17 @@ class InputManager
491498
if (switchBindings[i].update().isPressed())
492499
switch_current |= (1 << i);
493500

494-
if (bindDialog.disableGameInputsUntilReleased && switch_current == 0) [[unlikely]]
495-
bindDialog.disableGameInputsUntilReleased = false;
501+
if (disableOverlayInputs && switch_current == 0) [[unlikely]]
502+
disableOverlayInputs = false;
503+
if (disableGameInputs && switch_current == 0) [[unlikely]]
504+
disableGameInputs = false;
496505

497-
if (bindDialog.disableGameInputsUntilReleased) [[unlikely]]
506+
if (disableOverlayInputs) [[unlikely]]
507+
switch_current = 0;
508+
509+
switch_overlay = switch_current;
510+
511+
if (disableGameInputs || Overlay::IsBindingDialogActive) [[unlikely]]
498512
switch_current = 0;
499513
}
500514

@@ -584,7 +598,6 @@ class InputManager
584598
{
585599
ListenState isListeningForInput = ListenState::False;
586600
bool issListeningForInput = false;
587-
bool disableGameInputsUntilReleased = false;
588601
std::string currentlyBinding;
589602
ADChannel currentVolumeChannel;
590603
SwitchId currentSwitchId;
@@ -847,6 +860,9 @@ class InputManager
847860
bool RenderBindingDialog()
848861
{
849862
bool dialogOpen = true;
863+
if ((switch_overlay & (1 << int(SwitchId::Back) | 1 << int(SwitchId::B))) != 0)
864+
dialogOpen = false;
865+
850866
if (ImGui::Begin("Input Bindings", &dialogOpen))
851867
{
852868
if (ImGui::BeginTable("Controllers", 2, ImGuiTableFlags_Borders))

0 commit comments

Comments
 (0)