Merge remote-tracking branch 'origin/main' into android-apps-in-steam

This commit is contained in:
Kurt Himebauch committed 2026-12-06 07:34:45 -05:00
commit f80be06061
62 files changed
+2347 -12

No files matched your search

@@ -185,6 +185,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private var unfoldedControls by mutableStateOf(false)
private var unfoldedControlsWithController by mutableStateOf(false)
private var adaptiveSticks by mutableStateOf<Boolean?>(null)
private var directController by mutableStateOf<Boolean?>(null)
private var quickButtons by mutableStateOf<Map<InputCommand, Boolean>>(emptyMap())
private var picturePosition by mutableStateOf("center")
@@ -586,6 +587,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
drawerLayerOpen = false
drawerPinned = false
if (value) {
directController = com.droiddeck.launcher.session.DirectControllerSwitch.state(this)
releaseHeldKeys()
drawerXr = com.droiddeck.launcher.session.xr.XrPanels.showMenu()
drawerDocked = !drawerXr && dockDrawer() && openDockedMenu()
@@ -2141,6 +2143,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
primaryInputLayout?.let { com.droiddeck.launcher.input.InputLibraries.setAdaptiveSticks(this@SessionActivity, it.id, on) }
refreshInputProfile()
},
directController = directController,
onDirectController = { on ->
com.droiddeck.launcher.session.DirectControllerSwitch.set(this@SessionActivity, on)
directController = on
},
showFloatingSteamControls = SessionState.mode == SessionService.MODE_STEAM && SessionState.deckPad && unfoldedPanel == null &&
oscMode != SessionPrefs.OSC_NEVER && oscMode != SessionPrefs.OSC_STEAM_QAM &&
!steamTouchInUse && OnScreenLayout.supportsFloatingSteamControls(padType, primaryInputLayout),
@@ -50,6 +50,17 @@ object GameEnvironment {
return withScopeValue(config, scope, NO_STEAM, if (on) "1" else null)
}
/** dd-directcontroller on DroidDeck-Bionic: "0" starts the game in pass-through (Wine's own xinput); unset = the pad state. */
const val DIRECT_CONTROLLER = "DD_DIRECTCONTROLLER"
fun gameDirectController(config: Config, scope: String): Boolean =
scope.isEmpty() || config.games[scope]?.get(DIRECT_CONTROLLER) != "0"
fun withGameDirectController(config: Config, scope: String, on: Boolean): Config {
require(scope.isNotEmpty() && validScope(scope))
return withScopeValue(config, scope, DIRECT_CONTROLLER, if (on) null else "0")
}
const val GAME_RESOLUTION = "DROIDDECK_GAME_RESOLUTION"
fun gameResolution(config: Config, scope: String): GameResolution.Choice? =
@@ -28,7 +28,8 @@ object AutoComponents {
else -> game.appId.takeIf { it > 0 }?.toString()
}
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>): Map<String, WinComponents.AutoReason> {
fun autoPicks(findings: List<WinCompSources.Finding>, catalog: Map<String, WinComponents.Component>,
user: Map<String, Boolean> = emptyMap()): Map<String, WinComponents.AutoReason> {
val out = LinkedHashMap<String, WinComponents.AutoReason>()
for (f in findings) {
if (!f.auto || f.component == null) continue
@@ -37,6 +38,13 @@ object AutoComponents {
if (WinComponents.support(c, catalog) != WinComponents.Support.READY) continue
if (id !in out) out[id] = WinComponents.AutoReason(f.origin.name, listOf(f.original) + f.args)
}
if (user["d3dx9"] != false && (user["d3dx9"] == true || "d3dx9" in out)) {
val reason = out["d3dx9"] ?: WinComponents.AutoReason(WinCompSources.Origin.FOLDER.name, listOf("d3dx9"))
for (id in listOf("d3dcompiler_42", "d3dcompiler_43")) {
val c = catalog[id] ?: continue
if (WinComponents.support(c, catalog) == WinComponents.Support.READY) out.putIfAbsent(id, reason)
}
}
return out
}
@@ -228,8 +236,8 @@ object AutoComponents {
val findings = findings(context, game)
val refreshed = if (knownCatalog == null && asked && online(context)) catalogOf(context, true) else null
val catalog = knownCatalog ?: (refreshed ?: catalogOf(context, false) ?: catalogOf(context, true))?.associateBy { it.name } ?: return
val wanted = autoPicks(findings, catalog)
val user = WinComponents.selection(context, key).user
val wanted = autoPicks(findings, catalog, user)
val before = WinComponents.selection(context, key).auto
val installed = installedOf(context)
val kept = LinkedHashMap<String, WinComponents.AutoReason>()
@@ -452,9 +460,9 @@ object AutoComponents {
}
return pendingSaved && pending.isEmpty()
}
val wanted = autoPicks(findings, catalog)
val selection = WinComponents.selection(context, key)
val user = selection.user
val wanted = autoPicks(findings, catalog, user)
val installed = installedOf(context)
val roots = selection.effective + wanted.keys.filter { user[it] != false }
val required = withParts(roots.filter { WinComponents.validId(it) }, catalog)
@@ -0,0 +1,46 @@
package com.droiddeck.launcher.session
import android.content.Context
import com.droiddeck.launcher.core.GameEnvironment
import com.droiddeck.launcher.runtime.LinuxRuntime
import java.io.File
/**
* dd-directcontroller's mode file. DroidDeck-Bionic's launch.sh writes it beside the controller folder when a game set to start
* without Steam reads XInput through dd-directcontroller; the game's DLLs read it while it runs ('1' the pad state, '0' Wine's own
* xinput). No file = the session's game does not use dd-directcontroller.
*/
object DirectControllerSwitch {
const val FILE = "dd-directcontroller.mode"
fun file(context: Context): File = File(LinuxRuntime.sessionRoot(context), "dev/$FILE")
/** The running game's mode, or null when it does not use dd-directcontroller. */
fun state(context: Context): Boolean? = runCatching {
when (file(context).takeIf { it.isFile }?.readText()?.trim()) {
"1" -> true
"0" -> false
else -> null
}
}.getOrNull()
/** One request after another, in call order: the last switch sets both the live mode and the saved choice. */
private val queue = java.util.concurrent.Executors.newSingleThreadExecutor { Thread(it, "dd-directcontroller") }
/** Switches the running game now and remembers the choice for its next start. */
fun set(context: Context, on: Boolean) {
val app = context.applicationContext
queue.execute {
runCatching { file(app).takeIf { it.isFile }?.writeText(if (on) "1\n" else "0\n") }
val scope = NoSteamLaunch.scopeOf(SessionState.program, SessionState.programArgs) { NoSteamLaunch.battleNetTitleScope(app, it) }
if (!scope.isNullOrEmpty() && GameEnvironment.validScope(scope)) runCatching {
GameEnvironmentStore.setGameDirectController(app, scope, on)
}
}
}
/** A session starts without the file: only a launch that uses dd-directcontroller writes it again. */
fun clear(context: Context) {
file(context).delete()
}
}
@@ -91,6 +91,13 @@ object GameEnvironmentStore {
return config
}
@Synchronized
fun setGameDirectController(context: Context, scope: String, on: Boolean): GameEnvironment.Config {
val config = GameEnvironment.withGameDirectController(read(context), scope, on)
save(context, config)
return config
}
@Synchronized
fun setGameResolution(context: Context, scope: String, choice: com.droiddeck.launcher.core.GameResolution.Choice?): GameEnvironment.Config {
val config = GameEnvironment.withGameResolution(read(context), scope, choice)
@@ -1252,6 +1252,7 @@ class SessionService : Service() {
}
private fun addControllerEnvironment(guest: MutableList<String>, fakeInputDir: File, sessionDir: File) {
DirectControllerSwitch.clear(this)
FakeInputWriter.prepareRingSlots(fakeInputDir, 5)
val builtinPad = SessionPrefs.builtinPad(this)
val hiddenPad = SessionState.mode == MODE_STEAM && !builtinPad &&
@@ -189,7 +189,7 @@ object StoreLaunchRequests {
///
/// The message is the only thing that separates a stale sign-in from a title
/// that is not installed, so it is kept, minus anything that could carry a
/// device path or a token: segments lookng like a path are dropped and the
/// device path or a token: segments looking like a path are dropped and the
/// rest is folded to plain text.
internal fun reasonFor(error: Throwable): String {
val text = error.message.orEmpty()
@@ -414,6 +414,9 @@ class DrawerActions(
val unfoldedControls: Boolean? = null,
val adaptiveSticks: Boolean? = null,
val onAdaptiveSticks: (Boolean) -> Unit = {},
/** dd-directcontroller's mode for the running game; null = the game does not use it. */
val directController: Boolean? = null,
val onDirectController: (Boolean) -> Unit = {},
val showFloatingSteamControls: Boolean = false,
val oscRearButtons: Boolean = false,
val oscTrackpads: Boolean = false,
@@ -792,10 +795,12 @@ private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected:
val rumbleLabel = stringResource(R.string.ctrl_rumble)
val airTriggers = a.airTriggers
val airTriggersLabel = stringResource(R.string.air_triggers_title)
if (a.padType != null || c != null || airTriggers != null) SettingsGroup(
val directControllerLabel = stringResource(R.string.ctrl_direct_controller)
if (a.padType != null || c != null || airTriggers != null || a.directController != null) SettingsGroup(
stringResource(R.string.input_device_settings), key = "controller-pad", tag = padTag,
detail = summary(a.padType?.let { padTypes.labelOf(it) }, c?.let { "$rumbleLabel ${if (it.rumble) on else off}" },
airTriggers?.let { "$airTriggersLabel ${if (it.enabled) on else off}" }),
airTriggers?.let { "$airTriggersLabel ${if (it.enabled) on else off}" },
a.directController?.let { "$directControllerLabel ${if (it) on else off}" }),
) {
a.padType?.let { type ->
ChoiceRow(host, "pad-type", stringResource(R.string.input_virtual_controller), stringResource(R.string.input_virtual_controller_hint),
@@ -804,6 +809,9 @@ private fun DrawerControllerPage(host: MenuHost, a: DrawerActions, padConnected:
c?.let {
ToggleRow(host, "rumble", rumbleLabel, null, it.rumble, chipModifier = track("rumble"), onChange = a.onRumble)
}
a.directController?.let {
ToggleRow(host, "direct-controller", directControllerLabel, null, it, chipModifier = track("direct-controller"), onChange = a.onDirectController)
}
airTriggers?.let {
ActionRow(airTriggersLabel, if (it.enabled) on else off, stringResource(R.string.air_triggers_open), onAirTriggers,
modifier = track("air-triggers"))