mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(dual-screen): keep the bottom-screen controls up while a game loads (#1840)
* fix(dual-screen): keep the bottom-screen controls up while a game loads The session opened its bottom-screen trackpad only at the game's first frame. The launcher's bottom menu closes when a game starts, so on dual-screen handhelds the bottom screen showed whatever Android app was behind it for the whole load, which is long for Xbox games while Xodus prepares them. The controls now open when the session starts. Devices without a built-in second screen, and players who turned the in-game controls off, are unchanged. * fix(dual-screen): pick the bottom-screen panel again once the session's controller is known Opening the bottom-screen controls at session start can run before SessionService has prepared the Steam Deck pad, while SessionState.deckPad is still false, so the trackpad could be chosen where the Deck controls belong. That early choice is now provisional: at the game's first frame it switches to the panel the remembered choice and the real deckPad give, unless the player has already picked one. * fix(dual-screen): keep the loading-time panel choice through PiP, background and new sessions * fix(dual-screen): retry a terminal panel opened before it was ready and keep a manual close made during loading
This commit is contained in:
1 parent
c8c5e22a34
commit
7c49eef79f
5 files changed
+81
-4
No files matched your search
@@ -464,6 +464,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
private var secondScreenDisplays by mutableStateOf<List<SecondScreenDisplay>>(emptyList())
|
||||
private var selectedSecondScreenDisplay by mutableStateOf(SessionState.secondScreenDisplay)
|
||||
private var started = false
|
||||
private var dualControlsProvisional: Boolean
|
||||
get() = SessionState.secondScreenProvisional
|
||||
set(value) { SessionState.secondScreenProvisional = value }
|
||||
private var sessionActivityDisplayId = Display.DEFAULT_DISPLAY
|
||||
private lateinit var displayManager: DisplayManager
|
||||
private var secondScreenPresentation: SecondScreenPresentation? = null
|
||||
@@ -580,6 +583,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
SessionState.steamUi = intent.getStringExtra(SessionService.EXTRA_STEAM_UI)
|
||||
SessionState.steamUrl = intent.getStringExtra(SessionService.EXTRA_STEAM_URL)
|
||||
SessionState.steamVr = intent.getBooleanExtra(EXTRA_STEAMVR, false)
|
||||
SessionState.secondScreenAutoOpened = false
|
||||
SessionState.secondScreenProvisional = false
|
||||
} else if (intent.getBooleanExtra(EXTRA_STEAMVR, false) && SessionState.mode == SessionService.MODE_STEAM) {
|
||||
SessionState.steamVr = true
|
||||
}
|
||||
@@ -3030,6 +3035,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
SessionState.secondScreenAutoOpened = true
|
||||
selectedSecondScreenDisplay = target.displayId
|
||||
selectSecondScreenMode(SecondScreenMode.opening(SessionPrefs.secondScreenPanel(this), SessionState.deckPad))
|
||||
dualControlsProvisional = ::loading.isInitialized && loading.visible
|
||||
}
|
||||
|
||||
private fun settleDualScreenControls() {
|
||||
if (!dualControlsProvisional || pipUi || !started || (::loading.isInitialized && loading.visible)) return
|
||||
dualControlsProvisional = false
|
||||
if (secondScreenMode == SecondScreenMode.NONE) return
|
||||
val wanted = SecondScreenMode.opening(SessionPrefs.secondScreenPanel(this), SessionState.deckPad)
|
||||
if (wanted != secondScreenMode) selectSecondScreenMode(wanted) else secondScreenPresentation?.retryTerminal()
|
||||
}
|
||||
|
||||
private fun selectSecondScreenDisplay(displayId: Int) {
|
||||
@@ -3040,6 +3054,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
private fun selectSecondScreenMode(mode: SecondScreenMode) {
|
||||
dualControlsProvisional = false
|
||||
if (mode == SecondScreenMode.NONE) {
|
||||
closeSecondScreen(reset = true)
|
||||
return
|
||||
@@ -3818,7 +3833,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
updateOnScreenControls()
|
||||
if (resumed) { sessionClipboard.start(); updatePadMotion() }
|
||||
if (started) refreshSecondScreenDisplays()
|
||||
if (started) {
|
||||
settleDualScreenControls()
|
||||
refreshSecondScreenDisplays()
|
||||
}
|
||||
if (CompositorHost.isStarted) applyFrameGen()
|
||||
}
|
||||
}
|
||||
@@ -3854,9 +3872,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
for (name in arrayOf("peak_refresh_rate", "min_refresh_rate")) {
|
||||
contentResolver.registerContentObserver(android.provider.Settings.System.getUriFor(name), false, refreshSettingObserver)
|
||||
}
|
||||
settleDualScreenControls()
|
||||
refreshSecondScreenDisplays()
|
||||
if (secondScreenMode != SecondScreenMode.NONE && secondScreenPresentation == null) showSecondScreen(secondScreenMode)
|
||||
else if (::loading.isInitialized && !loading.visible) openDualScreenControls()
|
||||
else openDualScreenControls()
|
||||
startedScreens++
|
||||
SessionService.setActivityVisible(this, true, sessionActivityDisplayId)
|
||||
Glasses.rescan()
|
||||
@@ -4384,7 +4403,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
loading.visible = false
|
||||
hud.start()
|
||||
memoryHud.start()
|
||||
if (started) openDualScreenControls()
|
||||
if (started) {
|
||||
settleDualScreenControls()
|
||||
openDualScreenControls()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -543,7 +543,6 @@ class SessionService : Service() {
|
||||
val fakeInputDir = File(sessionRoot, "dev/input").apply { mkdirs() }
|
||||
val controllersOn = !File(Environment.getExternalStorageDirectory(), NO_PAD_SWITCH).exists()
|
||||
SessionState.deckPad = false
|
||||
SessionState.secondScreenAutoOpened = false
|
||||
deckBinds = emptyList()
|
||||
inputSysfs = null
|
||||
if (controllersOn) {
|
||||
|
||||
@@ -92,6 +92,7 @@ object SessionState {
|
||||
@Volatile var secondScreenMode = com.droiddeck.launcher.input.SecondScreenMode.NONE
|
||||
@Volatile var secondScreenDisplay = -1
|
||||
@Volatile var secondScreenAutoOpened = false
|
||||
@Volatile var secondScreenProvisional = false
|
||||
|
||||
@Volatile
|
||||
var mode = "steam"
|
||||
|
||||
@@ -141,6 +141,10 @@ class SecondScreenPresentation(
|
||||
if (created) renderMode()
|
||||
}
|
||||
|
||||
fun retryTerminal() {
|
||||
if (created && isShowing && currentMode == SecondScreenMode.TERMINAL && terminalSession == null) renderMode()
|
||||
}
|
||||
|
||||
val showsKeyboard: Boolean get() = isShowing && !menuShown && currentMode == SecondScreenMode.KEYBOARD_TRACKPAD
|
||||
|
||||
val showsControls: Boolean get() = isShowing && currentMode != SecondScreenMode.NONE
|
||||
|
||||
Reference in new issue
Block a user