From 162a16ed3a59df35c5a8eff70b50ff24a2b5bb30 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 30 Sep 2018 13:52:38 -0700 Subject: [PATCH] Allow settings to be activated when an app or PC is in focus --- app/gui/main.qml | 7 +++++++ app/gui/sdlgamepadkeynavigation.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/gui/main.qml b/app/gui/main.qml index ba56480c..98845249 100644 --- a/app/gui/main.qml +++ b/app/gui/main.qml @@ -47,6 +47,13 @@ ApplicationWindow { Keys.onMenuPressed: { settingsButton.clicked() } + + // This is a keypress we've reserved for letting the + // SdlGamepadKeyNavigation object tell us to show settings + // when Menu is consumed by a focused control. + Keys.onHangupPressed: { + settingsButton.clicked() + } } onVisibilityChanged: { diff --git a/app/gui/sdlgamepadkeynavigation.cpp b/app/gui/sdlgamepadkeynavigation.cpp index 347136db..f3819dc3 100644 --- a/app/gui/sdlgamepadkeynavigation.cpp +++ b/app/gui/sdlgamepadkeynavigation.cpp @@ -142,9 +142,14 @@ void SdlGamepadKeyNavigation::onPollingTimerFired() sendKey(type, Qt::Key_Escape); break; case SDL_CONTROLLER_BUTTON_X: + sendKey(type, Qt::Key_Menu); + break; case SDL_CONTROLLER_BUTTON_Y: case SDL_CONTROLLER_BUTTON_START: - sendKey(type, Qt::Key_Menu); + // HACK: We use this keycode to inform main.qml + // to show the settings when Key_Menu is handled + // by the control in focus. + sendKey(type, Qt::Key_Hangup); break; default: break;