Controls below the game: drop the second-screen bar, Steam and Quick Access under the pad (#3653)

* Controls below the game: drop the second-screen bar, Steam and Quick Access under the pad

* Test the keys under the unfolded pad instead of the removed bar

* Keep a touch drawer button below the game
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-12-03 16:54:04 -05:00
1 parent 68af03ac74
commit 5a18f69c7e
7 files changed
+86 -24

No files matched your search

@@ -230,6 +230,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
}
private var unfoldedPanel by mutableStateOf<OnScreenControls?>(null)
private var unfoldedColumn: android.widget.LinearLayout? = null
private var unfoldedKeys: View? = null
private var unfoldedDeckSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null
private var swappedInputSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null
private var unfoldedDeckPanel by mutableStateOf<com.droiddeck.launcher.input.DeckPanel?>(null)
@@ -2049,6 +2050,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
},
unfoldedControls = unfoldedControls,
onUnfoldedControls = ::chooseUnfoldedControls,
deckPanel = unfoldedDeckPanel,
onDeckPanel = ::selectDeckPanel,
adaptiveSticks = adaptiveSticks.takeIf {
unfoldedPanel != null || oscMode != SessionPrefs.OSC_NEVER && oscMode != SessionPrefs.OSC_STEAM_QAM && !steamTouchInUse
},
@@ -4058,7 +4061,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
steamTouchControls?.let { takes(it, it::takesTouchAt) } == true ||
unfoldedPanel?.let { takes(it, it::takesTouchAt) } == true ||
unfoldedDeckSurface?.let { takes(it, it::takesTouchAt) } == true ||
unfoldedColumn?.getChildAt(0)?.let { takes(it) { _, _ -> true } } == true
unfoldedKeys?.let { takes(it) { _, _ -> true } } == true
}
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
@@ -5102,12 +5105,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
val width = rootContentWidth()
val height = rootContentHeight()
val wanted = controlsBelowWanted()
val tabRow = unfoldedColumn?.getChildAt(0)?.height?.let {
it - (com.droiddeck.launcher.ui.BAR_HEIGHT.value * resources.displayMetrics.density + 0.5f).toInt()
} ?: 0
val outputAspect = if (!wanted || SessionState.followScreen) 0f
else outputSize().let { it.first.toFloat() / it.second.coerceAtLeast(1) }
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, tabRow, outputAspect)
val gameHeight = if (wanted) com.droiddeck.launcher.session.SessionDisplay.unfoldedGameHeight(width, height, aspect = outputAspect)
else FrameLayout.LayoutParams.MATCH_PARENT
val params = surfaceView.layoutParams as FrameLayout.LayoutParams
if (params.height != gameHeight) {
@@ -5124,6 +5124,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
if (panel != null && (!wanted || panel.dock != dock)) {
sessionRoot.removeView(unfoldedColumn)
unfoldedColumn = null
unfoldedKeys = null
unfoldedDeckSurface = null
unfoldedDeckPanel = null
unfoldedPanel = null
@@ -5135,13 +5136,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
panel = OnScreenControls(this, padBridge, dock).also { it.updateLayout(primaryInputLayout) }
val column = android.widget.LinearLayout(this).apply {
orientation = android.widget.LinearLayout.VERTICAL
addView(unfoldedBar().apply {
addOnLayoutChangeListener { _, _, top, _, bottom, _, oldTop, _, oldBottom ->
if (bottom - top != oldBottom - oldTop) post { applyUnfoldedControls() }
}
}, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT))
addView(panel, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f))
unfoldedKeys = com.droiddeck.launcher.ui.padKeysView(
this@SessionActivity, SessionState.mode == SessionService.MODE_STEAM,
{ releasePads(); drawerOpen = true }, ::tapSteamButton, ::tapQam,
).also {
addView(it, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT,
android.widget.LinearLayout.LayoutParams.WRAP_CONTENT))
}
}
sessionRoot.addView(column, sessionRoot.indexOfChild(surfaceView) + 1)
unfoldedColumn = column
@@ -5152,13 +5154,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
unfoldedColumn?.layoutParams = FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, height - gameHeight, Gravity.BOTTOM)
}
private fun unfoldedBar(): View = com.droiddeck.launcher.ui.bottomScreenBarView(this) {
val deck = unfoldedDeckPanel
com.droiddeck.launcher.ui.sessionBarModel(getString(if (deck != null) R.string.second_mode_deck_controls else R.string.deck_tab_gamepad),
{ chooseUnfoldedControls(false) }, { drawerOpen = true }, ::tapSteamButton, ::tapQam,
tabs = deck?.let { com.droiddeck.launcher.ui.deckPanelTabs(this, it, ::selectDeckPanel) })
}
private fun showUnfoldedDeckPanel() {
val column = unfoldedColumn
val panel = unfoldedPanel
@@ -5174,7 +5169,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
panel.visibility = View.GONE
unfoldedDeckSurface = com.droiddeck.launcher.ui.InputSurfaceView(this, padBridge, layout.elements, InputRole.PRIMARY, layout.style, haptics = true).also {
it.tag = layout
column.addView(it, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f))
column.addView(it, column.indexOfChild(panel) + 1, android.widget.LinearLayout.LayoutParams(android.widget.LinearLayout.LayoutParams.MATCH_PARENT, 0, 1f))
}
}
@@ -46,7 +46,14 @@ internal class ControllerPortraitGeometry(
}
row(shoulders, top + pad + buttonHeight / 2f, buttonHeight, 4f * unit)
var bodyTop = top + pad + buttonHeight + gap
if (presented.any { it.control in REAR && isStock(it) }) {
if (presented.any { it.control in REAR && isStock(it) } && docked) {
val chipHeight = 36f * unit
val cell = (w - 2f * pad - 5f * gap) / 6f
listOf(0, 1, 4, 5).zip(REAR).forEach { (index, control) ->
put(control, Box(safe.left + pad + cell / 2f + index * (cell + gap), bodyTop + chipHeight / 2f, cell, chipHeight))
}
bodyTop += chipHeight + gap
} else if (presented.any { it.control in REAR && isStock(it) }) {
val rearHeight = min(56f * unit, (panel - bodyTop + top) * .12f).coerceAtLeast(buttonHeight)
row(REAR, bodyTop + rearHeight / 2f, rearHeight, gap)
bodyTop += rearHeight + gap
@@ -36,6 +36,13 @@ object OnScreenLayout {
fun elements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
buttonsOnly: Boolean = false, dock: Dock? = null, rearButtons: Boolean? = null,
trackpads: Boolean? = null): List<InputSurfaceElement> {
val placed = placeElements(context, saved, width, height, safe, buttonsOnly, dock, rearButtons, trackpads)
// Below the game a stick covers nothing, so it keeps its base in view instead of appearing only under the thumb.
return if (dock == null) placed else placed.map { if (it.kind == InputElementKind.STICK) it.copy(hideWhenIdle = false) else it }
}
private fun placeElements(context: Context, saved: SavedInputLayout?, width: Int, height: Int, safe: Rect,
buttonsOnly: Boolean, dock: Dock?, rearButtons: Boolean?, trackpads: Boolean?): List<InputSurfaceElement> {
if (saved == null) return emptyList()
if (width <= 0 || height <= 0) return saved.elements
val layout = oriented(saved, dock?.portrait ?: (height > width))
@@ -338,6 +338,24 @@ internal fun sessionBarModel(
internal fun deckPanelTabs(context: Context, selected: DeckPanel, onSelect: (DeckPanel) -> Unit) =
BarTabs(DeckPanel.entries.map { context.getString(it.label) }, selected.ordinal) { onSelect(DeckPanel.entries[it]) }
internal fun padKeysView(
context: Context, steam: Boolean, onMenu: () -> Unit, onSteam: () -> Unit, onQam: () -> Unit,
): ComposeView = ComposeView(context).apply {
setContent { DroidDeckTheme { PadKeys(steam, onMenu, onSteam, onQam) } }
}
@Composable
internal fun PadKeys(steam: Boolean, onMenu: () -> Unit, onSteam: () -> Unit, onQam: () -> Unit) {
Row(
Modifier.fillMaxWidth().padding(horizontal = 16.dp, vertical = 8.dp),
horizontalArrangement = if (steam) Arrangement.SpaceBetween else Arrangement.Center,
) {
if (steam) BarActions(null, false, onSteam, null)
BarActions(onMenu, false, null, null)
if (steam) BarActions(null, false, null, onQam)
}
}
internal fun bottomScreenBarView(context: Context, model: () -> BottomBarModel): ComposeView = ComposeView(context).apply {
setContent { DroidDeckTheme { BottomScreenBar(model()) } }
}
@@ -390,6 +390,8 @@ class DrawerActions(
val quickButtons: Map<com.droiddeck.launcher.input.InputCommand, Boolean> = emptyMap(),
val onQuickButton: (com.droiddeck.launcher.input.InputCommand, Boolean) -> Unit = { _, _ -> },
val onUnfoldedControls: (Boolean) -> Unit = {},
val deckPanel: com.droiddeck.launcher.input.DeckPanel? = null,
val onDeckPanel: (com.droiddeck.launcher.input.DeckPanel) -> Unit = {},
val unfoldedControlsWithController: Boolean = false,
val onUnfoldedControlsWithController: (Boolean) -> Unit = {},
val onShareLogs: () -> Unit,
@@ -768,6 +770,11 @@ private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected:
if (a.steam && a.unfoldedControls != null) ToggleRow(host, "unfolded-controls", stringResource(R.string.unfolded_controls),
stringResource(R.string.unfolded_controls_hint), a.unfoldedControls,
chipModifier = track("unfolded-controls"), onChange = a.onUnfoldedControls)
a.deckPanel?.let { panel ->
ChoiceRow(host, "deck-panel", stringResource(R.string.ctrl_layout), null,
com.droiddeck.launcher.input.DeckPanel.entries.map { it to stringResource(it.label) }, panel,
chipModifier = track("deck-panel"), onPick = a.onDeckPanel)
}
if (a.steam && a.unfoldedControls == true) ToggleRow(host, "unfolded-controls-with-controller",
stringResource(R.string.unfolded_controls_with_controller),
stringResource(R.string.unfolded_controls_with_controller_hint), a.unfoldedControlsWithController,