Use the second screen on dual-screen handhelds (#1734)

* Use the second screen on dual-screen handhelds

Detect built-in second screens such as the Retroid Pocket Duo and AYN Thor.
The sections move to a menu on the bottom screen, L2 and R2 switch sections,
and text fields type on the bottom screen so the top keeps the full view.
Sessions open the bottom-screen trackpad and keyboard when they start.
Setup gains a Dual screen choice (Automatic, On, Off) with toggles for the
bottom menu and the in-game controls. Closing the bottom menu no longer ends
a running session.

* Type into Steam from the bottom screen

While the bottom-screen trackpad and keyboard controls are open in a Steam
session, Steam's own on-screen keyboard no longer covers the top screen.
The agent keeps Steam's text target and asks the app instead, which opens
the Android keyboard on the bottom screen and hands focus back to the game
when it closes. Modal and VR keyboards, and sessions without the bottom
controls, keep Steam's keyboard. The Show keyboard button now follows the
keyboard when it is closed another way.

* Open the bottom controls after the first frame and tidy dual-screen translations

* Move the in-game menu to the bottom screen on dual-screen handhelds

Fix controller input and focus on the second screen: keys and sticks reach the game after touching the bottom controls, closing the bottom controls returns focus to the game, B closes bottom typing, and the typing panel keeps a focusable window until focus has left it.

* Let B close the open layer of the session menu first and focus the selected bottom-screen mode

* Let the Retroid Pocket Duo Home double press open its quick menu during sessions

* Open the keyboard on the bottom screen for Steam text fields and hide it on Enter or when the field loses focus

* Keep controller focus on the top screen when a section is picked on the bottom screen

* Keep LB and RB on the store tabs and let Back return from a store to its tab

* Show the Adreno 722 as supported on the Retroid Pocket Duo

* Label the Steam integration suggestion's close button Close and cover that closing it is permanent

* Close the docked menu with its presentation, keep a focus picked during the stop delay, and ignore panel picks on process-settings pages
This commit is contained in:
MaxsTechReview authored and GitHub committed 2026-10-29 07:52:18 -04:00
1 parent e9e0186e66
commit 283e3b4549
65 files changed
+2425 -350

No files matched your search

@@ -0,0 +1,27 @@
package com.droiddeck.launcher.core
import android.app.Application
import androidx.test.core.app.ApplicationProvider
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.session.SettingsReset
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [33], manifest = Config.NONE, application = Application::class)
class SteamIntegrationSuggestionTest {
private val context: Application = ApplicationProvider.getApplicationContext()
@Test fun closingTheSuggestionKeepsItHiddenForGood() {
assertTrue(SteamIntegration.read(context).suggested)
SteamIntegration.dismissSuggestion(context)
assertFalse(SteamIntegration.read(context).suggested)
SettingsReset.resetAll(context, gameProfiles = false)
assertFalse(SteamIntegration.read(context).suggested)
assertTrue(SessionPrefs.sessionPrefs(context).getBoolean("steam_integration_seen", false))
}
}
@@ -64,6 +64,18 @@ class GpuDetectionTest {
assertEquals(Support.UNSUPPORTED, info(false, 830).support)
}
@Test fun adreno722IsSupportedOnlyOnTheRetroidPocketDuo() {
assertEquals(true, GpuInfo.verifiedOn(722, "Retroid Pocket Duo"))
assertEquals(false, GpuInfo.verifiedOn(722, "Retroid Pocket 5"))
assertEquals(false, GpuInfo.verifiedOn(720, "Retroid Pocket Duo"))
assertEquals(false, GpuInfo.verifiedOn(740, "Retroid Pocket Duo"))
val duo = info(true, 722).copy(verifiedDevice = true)
assertEquals(Support.TESTED, duo.support)
assertEquals("Supported", duo.supportText)
assertEquals(Family.A7XX_LOW, duo.family)
assertEquals(Support.UNTESTED, info(true, 722).support)
}
@Test fun userFacingTextPerTier() {
assertEquals("Supported", info(true, 830).supportText)
assertEquals("Experimental Adreno 850 support: requires compatible experimental display and game drivers; not verified on this device", info(true, 850).supportText)
@@ -0,0 +1,50 @@
package com.droiddeck.launcher.input
import android.content.Context
import android.hardware.display.DisplayManager
import android.view.Display
import androidx.test.core.app.ApplicationProvider
import com.droiddeck.launcher.session.SessionPrefs
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE)
class DualScreenTest {
private val context: Context = ApplicationProvider.getApplicationContext()
private val displays = context.getSystemService(DisplayManager::class.java)
@Test fun internalPanelsCountAsBuiltIn() {
assertTrue(DualScreen.isBuiltIn(1, "Anything"))
assertFalse(DualScreen.isBuiltIn(2, "Retroid Pocket Duo"))
assertFalse(DualScreen.isBuiltIn(5, "AYN Thor"))
}
@Test fun knownModelsCountWhenTheTypeIsHidden() {
assertTrue(DualScreen.isBuiltIn(null, "Retroid Pocket Duo"))
assertTrue(DualScreen.isBuiltIn(null, " AYN Thor "))
assertFalse(DualScreen.isBuiltIn(null, "Pixel 8"))
}
@Test fun oneScreenDevicesGetNoSecondScreenInAnyMode() {
for (mode in DualScreen.modes) {
SessionPrefs.setDualScreenMode(context, mode)
assertNull(DualScreen.display(context, displays, Display.DEFAULT_DISPLAY))
assertNull(DualScreen.anyDisplay(displays, Display.DEFAULT_DISPLAY))
}
}
@Test fun modeDefaultsToAutomaticAndIgnoresUnknownValues() {
assertEquals(DualScreen.MODE_AUTO, SessionPrefs.dualScreenMode(context))
SessionPrefs.setDualScreenMode(context, "sideways")
assertEquals(DualScreen.MODE_AUTO, SessionPrefs.dualScreenMode(context))
SessionPrefs.setDualScreenMode(context, DualScreen.MODE_OFF)
assertEquals(DualScreen.MODE_OFF, SessionPrefs.dualScreenMode(context))
}
}
@@ -7,6 +7,7 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.shadows.ShadowBuild
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28, 33], manifest = Config.NONE, application = Application::class)
@@ -67,4 +68,24 @@ class HomeGuideInputTest {
assertEquals(listOf(true, false), states)
assertEquals(1, cancellations)
}
private fun quickMenu(action: Int) = KeyEvent(10, 110, action, KeyEvent.KEYCODE_HOME, 0, 0, 10, 194)
@Test fun duoQuickMenuHomePassesThroughToTheSystemAndCancelsAHeldGuide() {
ShadowBuild.setModel("Retroid Pocket Duo")
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true))
assertFalse(input.onKeyEvent(quickMenu(KeyEvent.ACTION_DOWN), true))
assertEquals(listOf(true, false), states)
assertEquals(1, cancellations)
assertFalse(input.onKeyEvent(quickMenu(KeyEvent.ACTION_UP), true))
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_UP), true))
assertEquals(listOf(true, false), states)
}
@Test fun theSameScanCodeStillHoldsGuideOnOtherDevices() {
ShadowBuild.setModel("Retroid Pocket 5")
assertTrue(input.onKeyEvent(quickMenu(KeyEvent.ACTION_DOWN), true))
assertTrue(input.onKeyEvent(quickMenu(KeyEvent.ACTION_UP), true))
assertEquals(listOf(true, false), states)
}
}
@@ -0,0 +1,64 @@
package com.droiddeck.launcher.ui
import android.view.KeyEvent
import androidx.compose.ui.text.TextRange
import androidx.compose.ui.text.input.CommitTextCommand
import androidx.compose.ui.text.input.DeleteAllCommand
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.ImeOptions
import androidx.compose.ui.text.input.SetSelectionCommand
import androidx.compose.ui.text.input.TextFieldValue
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE)
class BottomScreenTypingTest {
@Test fun editsReplaceTheWholeFieldAndKeepTheCursor() {
val edits = TypingRequest.editsFor(TextFieldValue("fall", TextRange(2, 4)))
assertEquals(3, edits.size)
assertTrue(edits[0] is DeleteAllCommand)
assertEquals("fall", (edits[1] as CommitTextCommand).text)
val selection = edits[2] as SetSelectionCommand
assertEquals(2, selection.start)
assertEquals(4, selection.end)
}
@Test fun requestForwardsTextActionAndClose() {
val sent = mutableListOf<String>()
val actions = mutableListOf<ImeAction>()
var closed = 0
val request = TypingRequest(
TextFieldValue("a"), ImeOptions(imeAction = ImeAction.Search),
{ sent += it.text }, { actions += it }, { closed++ },
)
request.send(TextFieldValue("ab"))
request.action()
request.close()
assertEquals(listOf("ab"), sent)
assertEquals("ab", request.value.text)
assertEquals(listOf(ImeAction.Search), actions)
assertEquals(1, closed)
}
@Test fun panelStopsOnlyItsOwnRequest() {
val first = TypingRequest(TextFieldValue(""), ImeOptions.Default, {}, {})
val second = TypingRequest(TextFieldValue(""), ImeOptions.Default, {}, {})
DualScreenPanel.startTyping(second)
DualScreenPanel.stopTyping(first)
assertEquals(second, DualScreenPanel.typing)
DualScreenPanel.stopTyping(second)
assertNull(DualScreenPanel.typing)
}
@Test fun triggersStepThroughSections() {
assertEquals(-1, dualPageStep(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_L2)))
assertEquals(1, dualPageStep(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_R2)))
assertNull(dualPageStep(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_L1)))
}
}
@@ -7,7 +7,7 @@ import android.view.InputDevice
import android.view.KeyEvent
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import androidx.compose.ui.test.*
import androidx.compose.ui.semantics.SemanticsProperties.StateDescription
import androidx.compose.runtime.MutableState
@@ -76,6 +76,28 @@ class SessionSecondScreenTest {
@Test fun steamTrackpadKeepsWorkingSteamShortcuts() = checkShortcuts(steam = true)
@Test fun trackpadMenuButtonOnlyAppearsWhenTheMenuCanMove() {
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 label = context.getString(R.string.touch_droiddeck_menu)
for (movable in listOf(false, true)) {
var menus = 0
val panel = SecondScreenPresentation(activity, display, { _, _, _, _ -> }, { _, _ -> }, {},
{}, {}, {}, onMenu = if (movable) ({ menus++ }) else null)
try {
panel.create()
panel.showMode(SecondScreenMode.KEYBOARD_TRACKPAD)
val buttons = descendants(panel.window!!.decorView).filter { it.contentDescription == label }.toList()
assertEquals(if (movable) 1 else 0, buttons.size)
buttons.forEach { it.performClick() }
assertEquals(if (movable) 1 else 0, menus)
} finally {
panel.closeControls()
}
}
}
@Test
@Config(sdk = [34], shadows = [PadBridgeRoutingTest.RegisteredKeyEvent::class])
fun controllerBumpersReachTheSecondScreenInBothSessionModes() {
@@ -86,7 +108,7 @@ class SessionSecondScreenTest {
SessionState.mode = mode
val activity = Robolectric.buildActivity(SessionActivity::class.java).get()
fun <T> state(name: String): MutableState<T> = ReflectionHelpers.getField(activity, "$name\$delegate")
state<Boolean>("drawerOpen").value = true
state<Boolean>("drawerOpenState").value = true
state<Boolean>("drawerControllerActive").value = true
state<List<SecondScreenDisplay>>("secondScreenDisplays").value = listOf(SecondScreenDisplay(1, "Bottom screen"))
for ((button, page) in listOf(KeyEvent.KEYCODE_BUTTON_R1 to SessionDrawerPage.SECOND_SCREEN,
@@ -106,7 +128,7 @@ class SessionSecondScreenTest {
shadowOf(context.getSystemService(InputManager::class.java)).addInputDevice(device)
SessionState.mode = SessionService.MODE_STEAM
val activity = Robolectric.buildActivity(SessionActivity::class.java).get()
val open: MutableState<Boolean> = ReflectionHelpers.getField(activity, "drawerOpen\$delegate")
val open: MutableState<Boolean> = ReflectionHelpers.getField(activity, "drawerOpenState\$delegate")
val controller: MutableState<Boolean> = ReflectionHelpers.getField(activity, "drawerControllerActive\$delegate")
controller.value = true
for (button in listOf(KeyEvent.KEYCODE_BUTTON_SELECT, KeyEvent.KEYCODE_BUTTON_START)) {
@@ -188,9 +210,9 @@ class SessionSecondScreenTest {
try {
panel.create()
panel.showMode(SecondScreenMode.KEYBOARD_TRACKPAD)
val buttons = descendants(panel.window!!.decorView).filterIsInstance<Button>().toList()
val buttons = descendants(panel.window!!.decorView).filterIsInstance<TextView>().filter { it.isClickable }.toList()
assertTrue(buttons.any { it.text == context.getString(R.string.second_show_keyboard) })
val shortcuts = buttons.filter { it.text == "STEAM" || it.text == "…" }
val shortcuts = buttons.filter { it.text == "STEAM" || it.text == "•••" }
if (steam) {
assertEquals(2, shortcuts.size)
shortcuts.forEach { it.performClick() }