mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 12:56:06 +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
@@ -22,6 +22,7 @@ import com.droiddeck.launcher.session.SessionService
|
||||
import com.droiddeck.launcher.session.SessionState
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -72,6 +73,56 @@ class SessionSecondScreenTest {
|
||||
compose.onNodeWithText(context.getString(R.string.second_mode_keyboard_trackpad)).assertDoesNotExist()
|
||||
}
|
||||
|
||||
@Test fun provisionalBottomScreenPanelSettlesOnlyOnceTheSessionIsInFront() {
|
||||
SessionState.mode = SessionService.MODE_STEAM
|
||||
val previousMode = SessionState.secondScreenMode
|
||||
val previousProvisional = SessionState.secondScreenProvisional
|
||||
SessionState.secondScreenMode = SecondScreenMode.NONE
|
||||
try {
|
||||
val activity = Robolectric.buildActivity(SessionActivity::class.java).get()
|
||||
val pip: MutableState<Boolean> = ReflectionHelpers.getField(activity, "pipUi\$delegate")
|
||||
fun settle() = ReflectionHelpers.callInstanceMethod<Unit>(activity, "settleDualScreenControls")
|
||||
SessionState.secondScreenProvisional = true
|
||||
ReflectionHelpers.setField(activity, "started", true)
|
||||
pip.value = true
|
||||
settle()
|
||||
assertTrue(SessionState.secondScreenProvisional)
|
||||
pip.value = false
|
||||
ReflectionHelpers.setField(activity, "started", false)
|
||||
settle()
|
||||
assertTrue(SessionState.secondScreenProvisional)
|
||||
ReflectionHelpers.setField(activity, "started", true)
|
||||
settle()
|
||||
assertFalse(SessionState.secondScreenProvisional)
|
||||
} finally {
|
||||
SessionState.secondScreenMode = previousMode
|
||||
SessionState.secondScreenProvisional = previousProvisional
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun terminalOpenedBeforeItWasReadyIsRetriedButOtherPanelsAreLeftAlone() {
|
||||
SessionState.mode = SessionService.MODE_STEAM
|
||||
val activity = Robolectric.buildActivity(SessionActivity::class.java).get()
|
||||
val display = activity.getSystemService(DisplayManager::class.java).getDisplay(Display.DEFAULT_DISPLAY)
|
||||
val panel = SecondScreenPresentation(activity, display, { _, _, _, _ -> }, { _, _ -> }, {}, {}, {}, {})
|
||||
try {
|
||||
panel.show()
|
||||
panel.showMode(SecondScreenMode.KEYBOARD_TRACKPAD)
|
||||
val root = panel.window!!.decorView
|
||||
val trackpad = descendants(root).toList()
|
||||
panel.retryTerminal()
|
||||
assertEquals(trackpad, descendants(root).toList())
|
||||
panel.showMode(SecondScreenMode.TERMINAL)
|
||||
val notReady = context.getString(R.string.second_terminal_not_ready)
|
||||
val before = descendants(root).filter { (it as? TextView)?.text == notReady }.single()
|
||||
panel.retryTerminal()
|
||||
val after = descendants(root).filter { (it as? TextView)?.text == notReady }.single()
|
||||
assertTrue(before !== after)
|
||||
} finally {
|
||||
panel.closeControls()
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun desktopTrackpadOmitsSteamShortcuts() = checkShortcuts(steam = false)
|
||||
|
||||
@Test fun steamTrackpadKeepsWorkingSteamShortcuts() = checkShortcuts(steam = true)
|
||||
|
||||
Reference in new issue
Block a user