mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 12:35:42 +00:00
Change Steam picture position live from the session menu (#3661)
Use independent portrait and landscape alignment, with Top and 1280×800 as the default in Steam portrait. Keep explicit resolutions and existing controls modes.
This commit is contained in:
1 parent
ebb3bb6373
commit
f761e5f1db
46 files changed
+287
-62
No files matched your search
@@ -200,7 +200,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
private var phantomProcessStatus by mutableStateOf(PhantomProcessStatus.NOT_APPLICABLE)
|
||||
private var showPhantomGate by mutableStateOf(false)
|
||||
private var directAudio by mutableStateOf(false)
|
||||
private var picturePosition by mutableStateOf("center")
|
||||
private var picturePositionLandscape by mutableStateOf("center")
|
||||
private var picturePositionPortrait by mutableStateOf("top")
|
||||
private var integerScaling by mutableStateOf(false)
|
||||
private var stretch16x9 by mutableStateOf(false)
|
||||
private var avoidNotch by mutableStateOf(false)
|
||||
@@ -2365,7 +2366,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
refreshHomeAppState()
|
||||
}
|
||||
if (settingsMode == SessionService.MODE_STEAM) refreshFoundSteamLibraries()
|
||||
settingsMode?.let { hdrOn = SessionPrefs.hdr(this, it) }
|
||||
settingsMode?.let { mode ->
|
||||
hdrOn = SessionPrefs.hdr(this, mode)
|
||||
if (mode == SessionService.MODE_STEAM) loadPicturePositions()
|
||||
}
|
||||
compatLaunchVisible = true
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.yieldTo(taskId, false)
|
||||
com.droiddeck.launcher.ui.DualScreenPanel.ownerPaused(taskId, false)
|
||||
@@ -2924,7 +2928,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
backHold = backHold,
|
||||
backActionsInverted = backActionsInverted,
|
||||
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
|
||||
picturePosition = if (mode == SessionService.MODE_STEAM) picturePosition else null,
|
||||
picturePositionLandscape = picturePositionLandscape.takeIf { mode == SessionService.MODE_STEAM },
|
||||
picturePositionPortrait = picturePositionPortrait.takeIf { mode == SessionService.MODE_STEAM },
|
||||
integerScaling = if (mode == SessionService.MODE_STEAM) integerScaling else null,
|
||||
stretch16x9 = if (mode == SessionService.MODE_STEAM) stretch16x9 else null,
|
||||
avoidNotch = if (mode == SessionService.MODE_STEAM) avoidNotch else null,
|
||||
@@ -3001,7 +3006,10 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
backActionsInverted = inverted
|
||||
},
|
||||
onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on },
|
||||
onPicturePosition = { value -> SessionPrefs.setPicturePosition(this, value); picturePosition = value },
|
||||
onPicturePosition = { portrait, value ->
|
||||
SessionPrefs.setPicturePosition(this, portrait, value)
|
||||
if (portrait) picturePositionPortrait = value else picturePositionLandscape = value
|
||||
},
|
||||
onIntegerScaling = { on -> SessionPrefs.setIntegerScaling(this, on); integerScaling = on },
|
||||
onStretch16x9 = { on -> SessionPrefs.setStretch16x9(this, on); stretch16x9 = on },
|
||||
onAvoidNotch = { on -> SessionPrefs.setAvoidNotch(this, on); avoidNotch = on },
|
||||
@@ -3318,6 +3326,11 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true)
|
||||
}
|
||||
|
||||
private fun loadPicturePositions() {
|
||||
picturePositionLandscape = SessionPrefs.picturePosition(this, portrait = false)
|
||||
picturePositionPortrait = SessionPrefs.picturePosition(this, portrait = true)
|
||||
}
|
||||
|
||||
private fun loadModeSettings(mode: String) {
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||
@@ -3353,7 +3366,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
backHold = SessionPrefs.backHold(this)
|
||||
backActionsInverted = SessionPrefs.backActionsInverted(this)
|
||||
directAudio = SessionPrefs.directAudio(this)
|
||||
picturePosition = SessionPrefs.picturePosition(this)
|
||||
loadPicturePositions()
|
||||
integerScaling = SessionPrefs.integerScaling(this)
|
||||
stretch16x9 = SessionPrefs.stretch16x9(this)
|
||||
avoidNotch = SessionPrefs.avoidNotch(this)
|
||||
|
||||
@@ -180,6 +180,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var adaptiveSticks by mutableStateOf<Boolean?>(null)
|
||||
private var quickButtons by mutableStateOf<Map<InputCommand, Boolean>>(emptyMap())
|
||||
private var picturePosition by mutableStateOf("center")
|
||||
|
||||
private fun picturePortrait(config: android.content.res.Configuration = resources.configuration): Boolean =
|
||||
config.orientation == android.content.res.Configuration.ORIENTATION_PORTRAIT
|
||||
private var integerScaling by mutableStateOf(false)
|
||||
private var gameZoom by mutableStateOf(SessionState.gameZoom)
|
||||
private var avoidNotch = false
|
||||
@@ -1717,6 +1720,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
SessionState.gameZoom = gameZoom
|
||||
runCatching { WaylandCompositor.nativeSetZoom(gameZoom) }
|
||||
},
|
||||
picturePosition = picturePosition,
|
||||
onPicturePosition = { position ->
|
||||
SessionPrefs.setPicturePosition(this@SessionActivity, picturePortrait(), position)
|
||||
picturePosition = position
|
||||
},
|
||||
integerScaling = integerScaling,
|
||||
onIntegerScaling = { enabled ->
|
||||
SessionPrefs.setIntegerScaling(this@SessionActivity, enabled)
|
||||
@@ -2793,7 +2801,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
|
||||
picturePosition = SessionPrefs.picturePosition(this)
|
||||
picturePosition = SessionPrefs.picturePosition(this, picturePortrait())
|
||||
integerScaling = SessionPrefs.integerScaling(this)
|
||||
avoidNotch = SessionPrefs.avoidNotch(this)
|
||||
applyNotchInset()
|
||||
@@ -3230,6 +3238,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
override fun onConfigurationChanged(newConfig: android.content.res.Configuration) {
|
||||
super.onConfigurationChanged(newConfig)
|
||||
picturePosition = SessionPrefs.picturePosition(this, picturePortrait(newConfig))
|
||||
if (refreshActivityDisplayId() && started) {
|
||||
SessionService.setActivityDisplay(this, sessionActivityDisplayId)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ object SessionDisplay {
|
||||
const val LINK_PORTRAIT = "link/portrait"
|
||||
|
||||
const val DEFAULT_RESOLUTION = "720p"
|
||||
const val DEFAULT_STEAM_PORTRAIT_RESOLUTION = "1280x800"
|
||||
private val PRESET_HEIGHTS = listOf(720, 900, 1080)
|
||||
|
||||
fun presetHeight(choice: String): Int? =
|
||||
|
||||
@@ -946,13 +946,21 @@ object SessionPrefs {
|
||||
}
|
||||
|
||||
|
||||
fun picturePosition(context: Context): String =
|
||||
prefs(context).getString("picturePosition", "center")
|
||||
?.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center"
|
||||
private val picturePositions = setOf("center", "top", "bottom", "left", "right")
|
||||
|
||||
fun setPicturePosition(context: Context, position: String) {
|
||||
prefs(context).edit().putString("picturePosition",
|
||||
position.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center").apply()
|
||||
private fun picturePositionKey(portrait: Boolean) =
|
||||
if (portrait) "picturePosition.portrait" else "picturePosition.landscape"
|
||||
|
||||
fun picturePosition(context: Context, portrait: Boolean): String {
|
||||
val preferences = prefs(context)
|
||||
return preferences.getString(picturePositionKey(portrait), null)?.takeIf { it in picturePositions }
|
||||
?: preferences.getString("picturePosition", null)?.takeIf { it in picturePositions }
|
||||
?: if (portrait) "top" else "center"
|
||||
}
|
||||
|
||||
fun setPicturePosition(context: Context, portrait: Boolean, position: String) {
|
||||
require(position in picturePositions)
|
||||
prefs(context).edit().putString(picturePositionKey(portrait), position).apply()
|
||||
}
|
||||
|
||||
fun integerScaling(context: Context): Boolean =
|
||||
@@ -1513,10 +1521,12 @@ object SessionPrefs {
|
||||
|
||||
fun resolutionStored(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean): String {
|
||||
if (!portrait) return landscapeResolutionStored(context, mode, panel)
|
||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return SessionDisplay.LINK_LANDSCAPE
|
||||
val fallback = if (mode == SessionService.MODE_STEAM) SessionDisplay.DEFAULT_STEAM_PORTRAIT_RESOLUTION
|
||||
else SessionDisplay.LINK_LANDSCAPE
|
||||
val value = prefs(context).getString("displayResolution.portrait.$mode", null) ?: return fallback
|
||||
if (value == SessionDisplay.LINK_LANDSCAPE || value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
|
||||
SessionDisplay.presetHeight(value) != null) return value
|
||||
return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE
|
||||
return parseOrientedResolution(value)?.let { "${it.first}x${it.second}" } ?: fallback
|
||||
}
|
||||
|
||||
fun parseOrientedResolution(text: String): Pair<Int, Int>? =
|
||||
|
||||
@@ -18,7 +18,7 @@ object SettingsReset {
|
||||
"storesInstallLanguage",
|
||||
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "dockedMenuController", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
|
||||
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"stretch16x9", "avoidNotch", "picturePosition", "picturePosition.portrait", "picturePosition.landscape", "integerScaling", "railLabels", "developerTools", "navTabOrder", "navTabShelved", "navTabHidden", "drawerPageOrder", "drawerPageHidden", "drawerSections", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
|
||||
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
|
||||
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "producerAcquireFences", "paceCores",
|
||||
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
|
||||
|
||||
@@ -87,7 +87,8 @@ class ModeSettings(
|
||||
val fexPreset: String? = null,
|
||||
val forceSsbs: Boolean = false,
|
||||
val syncBackend: String? = null,
|
||||
val picturePosition: String? = null,
|
||||
val picturePositionLandscape: String? = null,
|
||||
val picturePositionPortrait: String? = null,
|
||||
val integerScaling: Boolean? = null,
|
||||
val stretch16x9: Boolean? = null,
|
||||
val avoidNotch: Boolean? = null,
|
||||
@@ -152,7 +153,7 @@ class ModeSettingsActions(
|
||||
val onFexPreset: (String) -> Unit = {},
|
||||
val onForceSsbs: (Boolean) -> Unit = {},
|
||||
val onSyncBackend: (String) -> Unit = {},
|
||||
val onPicturePosition: (String) -> Unit = {},
|
||||
val onPicturePosition: (Boolean, String) -> Unit = { _, _ -> },
|
||||
val onIntegerScaling: (Boolean) -> Unit = {},
|
||||
val onStretch16x9: (Boolean) -> Unit = {},
|
||||
val onAvoidNotch: (Boolean) -> Unit = {},
|
||||
@@ -262,15 +263,16 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
ResolutionRow(host, "resolution-portrait", stringResource(R.string.display_resolution_portrait), s.resolutionPortrait, portraitChoice,
|
||||
com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE,
|
||||
if (sessionDisplay.isLink(s.resolution)) portraitChoice else sessionDisplay.orientCustom(s.resolution, true),
|
||||
s.panelSize, a.onResolutionPortrait, portrait = true)
|
||||
s.picturePosition?.let { position ->
|
||||
ChoiceRow(host, "picture-position", stringResource(R.string.display_picture_position), null,
|
||||
listOf("top" to stringResource(R.string.display_position_top),
|
||||
"bottom" to stringResource(R.string.display_position_bottom),
|
||||
"left" to stringResource(R.string.display_position_left),
|
||||
"right" to stringResource(R.string.display_position_right),
|
||||
"center" to stringResource(R.string.display_position_center)),
|
||||
position, onPick = a.onPicturePosition)
|
||||
s.panelSize, a.onResolutionPortrait, portrait = true,
|
||||
defaultChoice = if (s.mode == SessionService.MODE_STEAM) sessionDisplay.DEFAULT_STEAM_PORTRAIT_RESOLUTION
|
||||
else sessionDisplay.DEFAULT_RESOLUTION)
|
||||
s.picturePositionLandscape?.let { position ->
|
||||
PicturePositionRow(host, position, key = "picture-position-landscape",
|
||||
labelRes = R.string.display_picture_position_landscape) { a.onPicturePosition(false, it) }
|
||||
}
|
||||
s.picturePositionPortrait?.let { position ->
|
||||
PicturePositionRow(host, position, key = "picture-position-portrait",
|
||||
labelRes = R.string.display_picture_position_portrait) { a.onPicturePosition(true, it) }
|
||||
}
|
||||
if (s.stretch16x9 != null && (com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(s.panelSize) ||
|
||||
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize))) {
|
||||
@@ -742,3 +744,22 @@ internal fun CustomFollowScaleDialog(initial: Float?, onSave: (Float) -> Unit, o
|
||||
dismissButton = { androidx.compose.material3.TextButton(onClick = onDismiss, modifier = Modifier.focusGlide(CircleShape)) { Text(stringResource(R.string.common_cancel)) } },
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
internal fun PicturePositionRow(
|
||||
host: MenuHost, position: String,
|
||||
chipModifier: Modifier = Modifier,
|
||||
key: String = "picture-position",
|
||||
@androidx.annotation.StringRes labelRes: Int = R.string.display_picture_position,
|
||||
onPick: (String) -> Unit,
|
||||
) {
|
||||
ChoiceRow(host, key, stringResource(labelRes), null,
|
||||
listOf(
|
||||
"center" to stringResource(R.string.display_position_center),
|
||||
"top" to stringResource(R.string.display_position_top),
|
||||
"bottom" to stringResource(R.string.display_position_bottom),
|
||||
"left" to stringResource(R.string.display_position_left),
|
||||
"right" to stringResource(R.string.display_position_right),
|
||||
),
|
||||
position, chipModifier = chipModifier, onPick = onPick)
|
||||
}
|
||||
@@ -16,12 +16,14 @@ fun ResolutionRow(
|
||||
panel: Pair<Int, Int>, onPick: (String) -> Unit,
|
||||
chipModifier: Modifier = Modifier,
|
||||
portrait: Boolean = false,
|
||||
defaultChoice: String = SessionDisplay.DEFAULT_RESOLUTION,
|
||||
) {
|
||||
val custom = "custom"
|
||||
val linked = stored == link
|
||||
val size = SessionDisplay.resolveChoice(panel, choice, portrait)
|
||||
val screen = SessionDisplay.resolveChoice(panel, SessionDisplay.MATCH_SCREEN, portrait)
|
||||
val choices = SessionDisplay.resolutionOptions(panel)
|
||||
val presets = SessionDisplay.resolutionOptions(panel)
|
||||
val choices = if (defaultChoice == SessionDisplay.DEFAULT_RESOLUTION) presets else listOf(defaultChoice) + presets
|
||||
val customFollow = !linked && SessionDisplay.isFollow(choice) && choice !in choices
|
||||
val selected = if (linked) link else if (SessionDisplay.isFollow(choice)) choice
|
||||
else if (size == screen) SessionDisplay.MATCH_SCREEN else choice
|
||||
@@ -36,7 +38,7 @@ fun ResolutionRow(
|
||||
else if (value == SessionDisplay.FOLLOW_SCREEN) stringResource(R.string.display_follow_screen)
|
||||
else if (SessionDisplay.isFollow(value)) stringResource(R.string.display_follow_screen_scaled,
|
||||
SessionDisplay.formatScale(SessionDisplay.followScale(value) ?: 1f)) + " (${dimensions.first}×${dimensions.second})"
|
||||
else if (value == SessionDisplay.DEFAULT_RESOLUTION) stringResource(R.string.mode_res_default, "${dimensions.first}×${dimensions.second}")
|
||||
else if (value == defaultChoice) stringResource(R.string.mode_res_default, "${dimensions.first}×${dimensions.second}")
|
||||
else "${dimensions.first}×${dimensions.second}"
|
||||
} + listOf(SessionDisplay.FOLLOW_CUSTOM to stringResource(R.string.display_follow_screen_scaled,
|
||||
if (customFollow) SessionDisplay.formatScale(SessionDisplay.followScale(choice) ?: 1f) else "…"
|
||||
|
||||
@@ -270,6 +270,8 @@ class DrawerActions(
|
||||
val upscaleSharpness: Int = 75,
|
||||
val integerScaling: Boolean = false,
|
||||
val onIntegerScaling: (Boolean) -> Unit = {},
|
||||
val picturePosition: String = "center",
|
||||
val onPicturePosition: (String) -> Unit = {},
|
||||
val gameZoomAvailable: Boolean = false,
|
||||
val gameZoom: Float = 1.0f,
|
||||
val onGameZoom: (Float) -> Unit = {},
|
||||
@@ -935,6 +937,7 @@ private fun DrawerDisplayPage(host: MenuHost, a: DrawerActions, track: (String)
|
||||
if (a.gameZoomAvailable) GameZoomRow(a, track)
|
||||
ChoiceRow(host, "orientation", stringResource(R.string.setup_session_orientation), null,
|
||||
orientations, a.orientation, chipModifier = track("orientation"), onPick = a.onOrientation)
|
||||
if (a.steam) PicturePositionRow(host, a.picturePosition, track("picture-position"), onPick = a.onPicturePosition)
|
||||
}
|
||||
val filters = SessionPrefs.upscalerChoices(LocalContext.current)
|
||||
val integer = stringResource(if (a.integerScaling) R.string.display_scaling_integer else R.string.display_scaling_fit)
|
||||
|
||||
Reference in new issue
Block a user