hub: join open Kart LAN games straight from the discovery list
- Commit
adc30be5eab3e3852587a2b6a67e1f5c500a6b42- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-05 14:03 UTC (1 day ago)
- Parents
4443443
The discovery list is now the Kart LAN join path. Each found host row shows what its beacon carries: the game being hosted, seated-of-capacity drivers and the track label. Tapping an open Kart host connects and pairs on the spot (the controller client skips AWAITING_CODE for open beacons), so the pad lands on the name pane with no six digits to type and nothing for the host to approve. A full game stays visible with a disabled Full button so the list explains itself instead of accepting a tap it would refuse; expired games drop off the list as their beacons stop, via the discovery tracker. The generic pad flow is untouched for hosts that still pair with a code: the PIN pane, PlayOnTvSession.proveCode and the remembered-device path all behave as before, and only hosts that broadcast open (Kart) bypass them. Verified: :games:hub:lint and :games:hub:testDevUnitTest pass alongside the kart and controller suites.
Diff
games/hub/src/main/java/com/vayunmathur/games/hub/network/PlayOnTvSession.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/network/PlayOnTvSession.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/network/PlayOnTvSession.ktindex bb95e80f86..d3ff2d3580 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/network/PlayOnTvSession.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/network/PlayOnTvSession.kt@@ -118,7 +118,11 @@ class PlayOnTvSession(context: Context) { startDiscovery() } - /** Connect to [host]. The client's handshake moves IDLE → CONNECTING → AWAITING_CODE/PAIRED. */+ /**+ * Connect to [host]. Open LAN games (Kart, `host.openJoin`) move+ * IDLE → CONNECTING → PAIRED with no code step; coded hosts still stop+ * at AWAITING_CODE until [proveCode].+ */ fun connect(host: ControllerHostInfo) { client.connect(host) }
games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ControllerPad.kt
diff --git a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ControllerPad.kt b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ControllerPad.ktindex 1066c75d92..1e1fbcadb0 100644--- a/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ControllerPad.kt+++ b/games/hub/src/main/java/com/vayunmathur/games/hub/ui/screens/ControllerPad.kt@@ -56,7 +56,10 @@ data class ControllerPadState( ) /**- * The reusable phone-as-controller screen: find a TV, type the PIN, take a seat, drive.+ * The reusable phone-as-controller screen: find a game, take a seat, drive.+ *+ * Open LAN games (Kart) pair on connect, so tapping one goes straight to+ * the name pane; hosts that still pair with a code show the PIN pane first. * * The left stick steers and throttles on the same axis slots the TV's `GameInputLoop` reads; the * curve matches the voxels `Joystick` feel (0.15 deadzone, then `0.2a + 0.8a³`), so a phone stick@@ -131,8 +134,35 @@ private fun DiscoveryPane( color = MaterialTheme.colorScheme.onSurfaceVariant, ) }+ if (host.capacity > 0) {+ Text(+ stringResource(+ R.string.pad_lobby_count, host.playerCount, host.capacity,+ ),+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ if (host.track.isNotEmpty()) {+ Text(+ host.track,+ style = MaterialTheme.typography.bodySmall,+ color = MaterialTheme.colorScheme.onSurfaceVariant,+ )+ }+ }+ // A full open game stays visible so the list explains itself, but+ // it cannot be tapped into a refusal.+ Button(+ onClick = { onConnect(host) },+ enabled = !host.isFull,+ ) {+ Text(+ stringResource(+ if (host.isFull) R.string.pad_full else R.string.pad_connect,+ ),+ ) }- Button(onClick = { onConnect(host) }) { Text(stringResource(R.string.pad_connect)) } } } OutlinedButton(onClick = onRescan, modifier = Modifier.fillMaxWidth()) { Text(stringResource(R.string.pad_rescan)) }
games/hub/src/main/res/values/strings.xml
diff --git a/games/hub/src/main/res/values/strings.xml b/games/hub/src/main/res/values/strings.xmlindex 6251ecf44c..40f0073dca 100644--- a/games/hub/src/main/res/values/strings.xml+++ b/games/hub/src/main/res/values/strings.xml@@ -164,6 +164,10 @@ <string name="pad_hosting">Hosting <xliff:g id="game_name" example="Kart">%1$s</xliff:g></string> <!-- Button to connect to a found TV. Verb --> <string name="pad_connect">Connect</string>+ <!-- Under a found game: seats taken of seats offered. %1$d = drivers seated, %2$d = capacity. Phrase -->+ <string name="pad_lobby_count"><xliff:g id="seated" example="2">%1$d</xliff:g> of <xliff:g id="capacity" example="8">%2$d</xliff:g> drivers</string>+ <!-- Button on a full open game: visible but disabled. Label -->+ <string name="pad_full">Full</string> <!-- Button to search for TVs again. Verb --> <string name="pad_rescan">Rescan</string> <!-- Pairing prompt. %1$d = number of digits e.g. 6. Imperative sentence -->