Refactor SdlGamepadKeyNavigation to avoid multiple reinitializations of SDL

This commit is contained in:
Cameron Gutman
2019-03-23 14:15:55 -07:00
parent 03c0be0720
commit d2cff86c97
7 changed files with 27 additions and 45 deletions
+11 -8
View File
@@ -94,16 +94,12 @@ Item {
}
}
// It's important that we don't call enable() here
// or it may interfere with the Session instance
// getting notified of initial connected gamepads.
SdlGamepadKeyNavigation {
id: gamepadKeyNav
}
StackView.onDeactivating: {
// Show the toolbar again when popped off the stack
toolBar.visible = true
// Enable GUI gamepad usage now
SdlGamepadKeyNavigation.enable()
}
StackView.onActivated: {
@@ -133,10 +129,13 @@ Item {
// in the hintText control itself to synchronize
// with Session.exec() which requires no concurrent
// gamepad usage.
hintText.text = gamepadKeyNav.getConnectedGamepads() > 0 ?
hintText.text = SdlGamepadKeyNavigation.getConnectedGamepads() > 0 ?
"Tip: Press Start+Select+L1+R1 to disconnect your session" :
"Tip: Press Ctrl+Alt+Shift+Q to disconnect your session"
// Stop GUI gamepad usage now
SdlGamepadKeyNavigation.disable()
// Run the streaming session to completion
session.exec(Screen.virtualX, Screen.virtualY)
}
@@ -181,6 +180,10 @@ Item {
if (!visible) {
Qt.quit()
}
else {
// Enable GUI gamepad usage now
SdlGamepadKeyNavigation.enable()
}
}
onHelp: {