feat(dual-screen): game name in the stats strip; each Steam start opens on Chat

- The Tiles and Rings strips' top line has the DroidDeck mark and name on the
  left, the clock on the right and, in the middle, the running game's name
  (from its Steam app manifest or non-Steam shortcut), or "Steam Client ARM" /
  "Steam Client x86" while no game runs in a Steam session.
- The dashboard opens on Chat at every Steam session start. The tab picked
  during a session is remembered for that session only (the bottomPage
  preference is gone); a game start still switches to In-game stats.
This commit is contained in:
The412Banner committed 2026-11-01 00:02:04 +00:00
1 parent f8fb1db3c8
commit 1861bd4b9a
7 files changed
+60 -15

No files matched your search

@@ -3132,9 +3132,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
dashboard = if (bottomPages().isEmpty()) null else ({
DroidDeckTheme {
BottomDashboard(
bottomPages(), SessionPrefs.bottomPage(this),
bottomPages(), com.droiddeck.launcher.ui.SessionBottomTab.picked(SessionState.sessionId),
gameStarts = gameStarts,
onPage = { SessionPrefs.setBottomPage(this, it) },
onPage = { com.droiddeck.launcher.ui.SessionBottomTab.pick(SessionState.sessionId, it) },
onClose = { selectSecondScreenMode(SecondScreenMode.NONE) },
onMenu = if (dockDrawer()) ({ drawerOpen = true }) else null,
)
@@ -100,12 +100,6 @@ object SessionPrefs {
prefs(context).edit().putString("secondScreenPanel", mode).apply()
}
fun bottomPage(context: Context): String? = prefs(context).getString("bottomPage", null)
fun setBottomPage(context: Context, page: String) {
prefs(context).edit().putString("bottomPage", page).apply()
}
fun statsStrip(context: Context): String? = prefs(context).getString("statsStrip", null)
fun setStatsStrip(context: Context, id: String) {
@@ -56,7 +56,25 @@ class BottomPage(
internal fun pickBottomPage(remembered: String?, ids: List<String>): String? =
ids.firstOrNull { it == remembered } ?: ids.firstOrNull { it == DEFAULT_PAGE } ?: ids.firstOrNull()
/** The page a game start switches to; not saved, so the page the user picked still opens next time. */
/**
* The tab picked during one session. Each Steam session starts with no pick, so the dashboard opens on Chat; reopened
* later in the same session it shows the tab picked last.
*/
internal object SessionBottomTab {
private var session: String? = null
private var tab: String? = null
@Synchronized
fun picked(sessionId: String?): String? = tab.takeIf { sessionId != null && sessionId == session }
@Synchronized
fun pick(sessionId: String?, id: String) {
session = sessionId
tab = id
}
}
/** The page a game start switches to; not remembered as the user's pick. */
internal fun pageForGameStart(ids: List<String>): String? = GAME_PAGE.takeIf { it in ids }
private const val DEFAULT_PAGE = "chat"
@@ -47,7 +47,9 @@ import com.droiddeck.launcher.hud.MangoReadings
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.GameStatusFiles
import com.droiddeck.launcher.session.GameTelemetry
import com.droiddeck.launcher.input.SteamTouchConfig
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.session.SessionService
import com.droiddeck.launcher.session.SessionState
import com.droiddeck.launcher.session.SpeedUnit
import com.droiddeck.launcher.session.StatsDash
@@ -96,6 +98,8 @@ fun BottomTelemetryPage(fps: () -> Float?, runningGame: () -> String? = { null }
var outputs by remember { mutableStateOf<List<TelemetryOutput.Game>>(emptyList()) }
var menuGames by remember { mutableStateOf<List<TelemetryOutput.MenuGame>>(emptyList()) }
var running by remember { mutableStateOf<String?>(null) }
var gameName by remember { mutableStateOf<String?>(null) }
val steamClient = remember { if (SessionState.mode == SessionService.MODE_STEAM) SessionPrefs.activeSteamClientArch(context) else null }
var outputFailed by remember { mutableStateOf<String?>(null) }
var rescan by remember { mutableIntStateOf(0) }
var auto by remember { mutableStateOf(SessionPrefs.telemetryAuto(context)) }
@@ -216,6 +220,11 @@ fun BottomTelemetryPage(fps: () -> Float?, runningGame: () -> String? = { null }
runCatching { Library.steamGames(context).mapNotNull { TelemetryOutput.MENU_GAMES[it.appId] }.distinct() }.getOrDefault(emptyList())
}
}
LaunchedEffect(running) {
val id = running?.toLongOrNull()
gameName = if (id == null) null
else withContext(Dispatchers.IO) { runCatching { SteamTouchConfig.gameName(context, id.toInt()) }.getOrNull() }
}
LaunchedEffect(rescan) {
while (isActive) {
outputs = withContext(Dispatchers.IO) { runCatching { TelemetryOutput.scan(Library.compatdataDirs(context)) }.getOrDefault(emptyList()) }
@@ -226,7 +235,8 @@ fun BottomTelemetryPage(fps: () -> Float?, runningGame: () -> String? = { null }
Column(Modifier.fillMaxSize().verticalScroll(rememberScrollState()), verticalArrangement = Arrangement.spacedBy(10.dp)) {
perfTick.let {
StatsStripView(strip, StripData(fpsNow, device, fpsHistory.snapshot(), cpuHistory.snapshot(), gpuHistory.snapshot(), wattsHistory.snapshot(), clock)) {
StatsStripView(strip, StripData(fpsNow, device, fpsHistory.snapshot(), cpuHistory.snapshot(), gpuHistory.snapshot(), wattsHistory.snapshot(), clock,
if (running != null) gameName else steamClient?.let { stringResource(steamClientLabel(it)) })) {
strip = strip.next()
SessionPrefs.setStatsStrip(context, strip.id)
}
@@ -325,6 +335,9 @@ private fun httpGet(url: String): String {
}
/** The Steam client the session runs, shown in the strip's top line while no game runs. */
internal fun steamClientLabel(arch: String): Int = if (arch == "x86_64") R.string.stats_steam_client_x86 else R.string.stats_steam_client_arm
@Composable
private fun ChoiceRow(title: String, value: String, onClick: () -> Unit) {
val colors = MaterialTheme.colorScheme
@@ -39,6 +39,7 @@ import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
@@ -95,13 +96,16 @@ private fun LogoBadge(size: Dp) {
}
}
/** The mark and "DroidDeck" on the left, the running game's name in the middle, the clock on the right. */
@Composable
private fun LogoHeader(clock: String) {
private fun LogoHeader(clock: String, game: String?) {
val colors = MaterialTheme.colorScheme
Row(verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp), modifier = Modifier.padding(horizontal = 2.dp)) {
Row(Modifier.fillMaxWidth().padding(horizontal = 2.dp), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(6.dp)) {
DroidDeckLogo(16.dp)
Text("DroidDeck", fontSize = 13.sp, fontWeight = FontWeight.Bold, color = colors.onBackground)
if (clock.isNotEmpty()) Text("· $clock", fontSize = 12.sp, fontFamily = FontFamily.Monospace, color = colors.onSurfaceVariant)
Text(game.orEmpty(), fontSize = 13.sp, fontWeight = FontWeight.Bold, color = colors.onBackground, textAlign = TextAlign.Center,
maxLines = 1, overflow = TextOverflow.Ellipsis, modifier = Modifier.weight(1f))
if (clock.isNotEmpty()) Text(clock, fontSize = 12.sp, fontFamily = FontFamily.Monospace, color = colors.onSurfaceVariant)
}
}
@@ -146,6 +150,7 @@ internal class StripData(
val gpuHistory: List<Float>,
val wattsHistory: List<Float>,
val clock: String,
val game: String? = null,
)
private fun percentTemp(percent: Int?, temp: Int?): String =
@@ -212,7 +217,7 @@ private fun TilesStrip(d: StripData) {
val gpuPercent: Int? = s?.gpuPercent
val gpuTemp: Int? = s?.gpuTempC
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(6.dp)) {
LogoHeader(d.clock)
LogoHeader(d.clock, d.game)
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
HistoryTile("FPS", accent, fpsText(d.fps), "fps", d.fpsHistory, 75f)
HistoryTile("CPU", StatsColors.cpu, s?.cpuPercent?.let { "$it%" } ?: "–", s?.cpuTempC?.let { "$it°" } ?: "", d.cpuHistory, 100f)
@@ -248,7 +253,7 @@ private fun RingsStrip(d: StripData) {
val gpuPercent: Int? = s?.gpuPercent
val gpuTemp: Int? = s?.gpuTempC
Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(6.dp)) {
LogoHeader(d.clock)
LogoHeader(d.clock, d.game)
Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.spacedBy(8.dp)) {
RingTile("CPU", StatsColors.cpu, s?.cpuPercent?.let { it / 100f }, s?.cpuPercent?.let { "$it%" } ?: "–", s?.cpuTempC?.let { "$it °C" } ?: "")
RingTile("GPU", StatsColors.gpu, gpuPercent?.let { it / 100f }, gpuPercent?.let { "$it%" } ?: gpuTemp?.let { "$it°" } ?: "–",
+2
View File
@@ -1903,6 +1903,8 @@
<string name="stats_gear">Gear</string>
<string name="stats_speed_units">Speed units</string>
<string name="stats_speed_units_auto">Automatic (%1$s)</string>
<string name="stats_steam_client_arm">Steam Client ARM</string>
<string name="stats_steam_client_x86">Steam Client x86</string>
<string name="stats_throttle">Throttle</string>
<string name="stats_brake">Brake</string>
<string name="stats_lights">Dashboard</string>
@@ -55,4 +55,17 @@ class BottomTelemetryLapTimeTest {
assertEquals("1:23.456", lapTime(83.456f))
assertEquals("0:05.000", lapTime(5f))
}
@Test fun eachSessionStartsWithoutAPickedTab() {
SessionBottomTab.pick("2026-11-01-01-steam", "screenshots")
assertEquals("screenshots", SessionBottomTab.picked("2026-11-01-01-steam"))
assertNull(SessionBottomTab.picked("2026-11-01-02-steam"))
assertNull(SessionBottomTab.picked(null))
assertEquals("chat", pickBottomPage(SessionBottomTab.picked("2026-11-01-02-steam"), listOf("telemetry", "chat", "screenshots")))
}
@Test fun theStripNamesTheSteamClient() {
assertEquals(com.droiddeck.launcher.R.string.stats_steam_client_x86, steamClientLabel("x86_64"))
assertEquals(com.droiddeck.launcher.R.string.stats_steam_client_arm, steamClientLabel("arm64"))
}
}