mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-22 06:15:58 +00:00
feat(session): split the display resolution into landscape and portrait
Landscape and Portrait resolution rows with the same options, each with a Follow option so one can mirror the other. Existing choices stay as the landscape resolution and portrait follows landscape by default, so nothing changes until portrait is set.
This commit is contained in:
41 files changed
+305
-64
No files matched your search
@@ -585,6 +585,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}
|
||||
private var settingsMode by mutableStateOf<String?>(null)
|
||||
private var resolution by mutableStateOf(com.droiddeck.launcher.session.SessionDisplay.DEFAULT_RESOLUTION)
|
||||
private var resolutionPortrait by mutableStateOf(com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE)
|
||||
private var fexPreset by mutableStateOf("")
|
||||
private var forceSsbs by mutableStateOf(false)
|
||||
private var steamClientArch by mutableStateOf("arm64")
|
||||
@@ -2588,7 +2589,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
if (settingsMode != mode) return
|
||||
com.droiddeck.launcher.ui.ModeSheetRows(
|
||||
ModeSettings(
|
||||
mode = mode, resolution = resolution,
|
||||
mode = mode, resolution = resolution, resolutionPortrait = resolutionPortrait,
|
||||
panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
||||
hdr = hdrOn, hdrReason = hdrReason, hdrDisplay = hdrDisplay, zeroCopy = zeroCopyOn,
|
||||
upscaler = upscaler, upscaleSharpness = upscaleSharpness,
|
||||
@@ -2643,7 +2644,8 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
onIntegration = ::configureIntegration,
|
||||
onIntegrationAppInfo = ::openAppInfo,
|
||||
onIntegrationLocation = ::openWifiDiscoverySettings,
|
||||
onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); resolution = value },
|
||||
onResolution = { value -> SessionPrefs.setResolutionChoice(this, mode, value); loadResolutions(mode) },
|
||||
onResolutionPortrait = { value -> SessionPrefs.setResolutionChoice(this, mode, value, portrait = true); loadResolutions(mode) },
|
||||
onHdr = { on -> com.droiddeck.launcher.session.SessionHdr.set(this, mode, on); hdrOn = on },
|
||||
onZeroCopy = { on ->
|
||||
SessionPrefs.setZeroCopy(this, mode, on); zeroCopyOn = on
|
||||
@@ -2976,11 +2978,17 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
|
||||
}, "shader-precache").start()
|
||||
}
|
||||
|
||||
private fun loadResolutions(mode: String) {
|
||||
val panel = com.droiddeck.launcher.session.SessionDisplay.panelSize(this)
|
||||
resolution = SessionPrefs.resolutionStored(this, mode, panel, false)
|
||||
resolutionPortrait = SessionPrefs.resolutionStored(this, mode, panel, true)
|
||||
}
|
||||
|
||||
private fun loadModeSettings(mode: String) {
|
||||
pipAutoEnter = SessionPrefs.pipAutoEnter(this)
|
||||
unfoldedControls = SessionPrefs.unfoldedControls(this)
|
||||
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
|
||||
resolution = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
loadResolutions(mode)
|
||||
fexPreset = SessionPrefs.fexPreset(this)
|
||||
forceSsbs = SessionPrefs.forceSsbs(this)
|
||||
fastSync = SessionPrefs.fastSync(this)
|
||||
|
||||
@@ -2958,14 +2958,14 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
|
||||
private fun followScale(): Float {
|
||||
val mode = displayMode()
|
||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
val choice = SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), portraitOutput())
|
||||
return com.droiddeck.launcher.session.SessionDisplay.followScale(choice) ?: 1f
|
||||
}
|
||||
|
||||
private fun followChoice(): Boolean {
|
||||
val mode = displayMode()
|
||||
return com.droiddeck.launcher.session.SessionDisplay.isFollow(
|
||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this)))
|
||||
SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), portraitOutput()))
|
||||
}
|
||||
|
||||
private fun applyFollowOrientation(config: android.content.res.Configuration) {
|
||||
@@ -3031,17 +3031,21 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private fun displayMode(): String = SessionPrefs.displayMode(this,
|
||||
intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM, intent.getStringExtra(SessionService.EXTRA_PROGRAM))
|
||||
|
||||
private fun outputSize(): Pair<Int, Int> =
|
||||
com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
||||
resolutionChoice(), SessionPrefs.portrait(this) && !controlsBelowWanted())
|
||||
private fun portraitOutput(): Boolean = SessionPrefs.portrait(this) && !controlsBelowWanted()
|
||||
|
||||
private fun resolutionChoice(): String {
|
||||
private fun outputSize(): Pair<Int, Int> {
|
||||
val portrait = portraitOutput()
|
||||
return com.droiddeck.launcher.session.SessionDisplay.resolveChoice(com.droiddeck.launcher.session.SessionDisplay.panelSize(this),
|
||||
resolutionChoice(portrait), portrait)
|
||||
}
|
||||
|
||||
private fun resolutionChoice(portrait: Boolean = portraitOutput()): String {
|
||||
val mode = displayMode()
|
||||
val program = intent.getStringExtra(SessionService.EXTRA_PROGRAM)
|
||||
return if (intent.getStringExtra(SessionService.EXTRA_MODE) == SessionService.MODE_RUN &&
|
||||
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode))
|
||||
Library.drawsAtPanel(program) && !SessionPrefs.resolutionChosen(this, mode, portrait))
|
||||
com.droiddeck.launcher.session.SessionDisplay.MATCH_SCREEN
|
||||
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this))
|
||||
else SessionPrefs.resolutionChoice(this, mode, com.droiddeck.launcher.session.SessionDisplay.panelSize(this), portrait)
|
||||
}
|
||||
|
||||
private fun refreshHz(): Float = refreshHz(null)
|
||||
|
||||
@@ -207,9 +207,11 @@ object DeviceReport {
|
||||
k("refresh_rate_mode", runCatching { Settings.Secure.getString(context.contentResolver, "refresh_rate_mode") }.getOrNull() ?: "not set")
|
||||
val panelSize = com.droiddeck.launcher.session.SessionDisplay.panelSize(context)
|
||||
for ((label, mode) in listOf("Resolution (Steam)" to SessionService.MODE_STEAM, "Resolution (Desktop)" to SessionService.MODE_DESKTOP)) {
|
||||
val choice = SessionPrefs.resolutionChoice(context, mode, panelSize)
|
||||
val size = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(panelSize, choice)
|
||||
k(label, "$choice (${size.first}x${size.second})")
|
||||
for ((suffix, portrait) in listOf("landscape" to false, "portrait" to true)) {
|
||||
val choice = SessionPrefs.resolutionChoice(context, mode, panelSize, portrait)
|
||||
val size = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(panelSize, choice, portrait)
|
||||
k("$label $suffix", "$choice (${size.first}x${size.second})")
|
||||
}
|
||||
}
|
||||
k("Foldable", context.packageManager.hasSystemFeature("android.hardware.sensor.hinge_angle"))
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ object SessionDisplay {
|
||||
const val FOLLOW_SCALE_MAX = 8f
|
||||
private const val FOLLOW_SCALED_PREFIX = "follow/"
|
||||
|
||||
const val LINK_LANDSCAPE = "link/landscape"
|
||||
const val LINK_PORTRAIT = "link/portrait"
|
||||
|
||||
const val DEFAULT_RESOLUTION = "720p"
|
||||
private val PRESET_HEIGHTS = listOf(720, 900, 1080)
|
||||
|
||||
@@ -35,6 +38,23 @@ object SessionDisplay {
|
||||
else -> null
|
||||
}
|
||||
|
||||
fun isLink(choice: String): Boolean = choice == LINK_LANDSCAPE || choice == LINK_PORTRAIT
|
||||
|
||||
fun orientCustom(choice: String, portrait: Boolean): String {
|
||||
val parts = choice.split('x').map { it.toIntOrNull() }
|
||||
if (parts.size != 2 || parts.any { it == null || it <= 0 }) return choice
|
||||
val width = parts[0]!!
|
||||
val height = parts[1]!!
|
||||
return if ((portrait && width > height) || (!portrait && height > width)) "${height}x$width" else choice
|
||||
}
|
||||
|
||||
fun effectiveChoice(landscape: String, portrait: String, forPortrait: Boolean): String {
|
||||
val own = if (forPortrait) portrait else landscape
|
||||
if (!isLink(own)) return own
|
||||
val other = if (forPortrait) landscape else portrait
|
||||
return if (isLink(other)) DEFAULT_RESOLUTION else orientCustom(other, forPortrait)
|
||||
}
|
||||
|
||||
fun screenSize(panel: Pair<Int, Int>): Pair<Int, Int> =
|
||||
(maxOf(panel.first, panel.second) and 1.inv()) to (minOf(panel.first, panel.second) and 1.inv())
|
||||
|
||||
|
||||
@@ -1296,14 +1296,27 @@ object SessionPrefs {
|
||||
|
||||
private fun resolutionCap(context: Context, mode: String): Int = prefs(context).getInt("resolutionCap.$mode", 720)
|
||||
|
||||
fun resolutionChosen(context: Context, mode: String): Boolean =
|
||||
fun resolutionChosen(context: Context, mode: String, portrait: Boolean = false): Boolean =
|
||||
prefs(context).contains("displayResolution.$mode") ||
|
||||
prefs(context).contains("resolutionCap.$mode") || customResolution(context, mode) != null
|
||||
prefs(context).contains("resolutionCap.$mode") || customResolution(context, mode) != null ||
|
||||
(portrait && prefs(context).contains("displayResolution.portrait.$mode"))
|
||||
|
||||
fun resolutionChoice(context: Context, mode: String, panel: Pair<Int, Int>): String {
|
||||
fun resolutionChoice(context: Context, mode: String, panel: Pair<Int, Int>, portrait: Boolean = false): String =
|
||||
SessionDisplay.effectiveChoice(
|
||||
resolutionStored(context, mode, panel, false), resolutionStored(context, mode, panel, true), portrait)
|
||||
|
||||
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
|
||||
if (value == SessionDisplay.LINK_LANDSCAPE || value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
|
||||
SessionDisplay.presetHeight(value) != null) return value
|
||||
return parseResolution(value)?.let { "${it.first}x${it.second}" } ?: SessionDisplay.LINK_LANDSCAPE
|
||||
}
|
||||
|
||||
private fun landscapeResolutionStored(context: Context, mode: String, panel: Pair<Int, Int>): String {
|
||||
val saved = prefs(context)
|
||||
saved.getString("displayResolution.$mode", null)?.let { value ->
|
||||
if (value == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(value) ||
|
||||
if (value == SessionDisplay.MATCH_SCREEN || value == SessionDisplay.LINK_PORTRAIT || SessionDisplay.isFollow(value) ||
|
||||
SessionDisplay.presetHeight(value) != null) return value
|
||||
parseResolution(value)?.let { return "${it.first}x${it.second}" }
|
||||
}
|
||||
@@ -1315,13 +1328,22 @@ object SessionPrefs {
|
||||
else "${legacy.first}x${legacy.second}"
|
||||
}
|
||||
|
||||
fun setResolutionChoice(context: Context, mode: String, choice: String) {
|
||||
val value = if (choice == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(choice) ||
|
||||
fun setResolutionChoice(context: Context, mode: String, choice: String, portrait: Boolean = false) {
|
||||
val link = if (portrait) SessionDisplay.LINK_LANDSCAPE else SessionDisplay.LINK_PORTRAIT
|
||||
val value = if (choice == link || choice == SessionDisplay.MATCH_SCREEN || SessionDisplay.isFollow(choice) ||
|
||||
SessionDisplay.presetHeight(choice) != null) choice else {
|
||||
val size = requireNotNull(parseResolution(choice)) { "Invalid resolution" }
|
||||
"${size.first}x${size.second}"
|
||||
}
|
||||
prefs(context).edit().putString("displayResolution.$mode", value).apply()
|
||||
val panel = SessionDisplay.panelSize(context)
|
||||
val landscapeStored = resolutionStored(context, mode, panel, false)
|
||||
val portraitStored = resolutionStored(context, mode, panel, true)
|
||||
val edit = prefs(context).edit()
|
||||
if (value == link && SessionDisplay.isLink(if (portrait) landscapeStored else portraitStored)) {
|
||||
val concrete = SessionDisplay.effectiveChoice(landscapeStored, portraitStored, !portrait)
|
||||
edit.putString(if (portrait) "displayResolution.$mode" else "displayResolution.portrait.$mode", concrete)
|
||||
}
|
||||
edit.putString(if (portrait) "displayResolution.portrait.$mode" else "displayResolution.$mode", value).apply()
|
||||
}
|
||||
|
||||
fun fexPreset(context: Context): String = prefs(context).getString("fexPreset", DEFAULT_FEX_PRESET) ?: DEFAULT_FEX_PRESET
|
||||
|
||||
@@ -56,6 +56,7 @@ class DownloadRow(val key: String, val label: String, val detail: String, val pr
|
||||
class ModeSettings(
|
||||
val mode: String,
|
||||
val resolution: String,
|
||||
val resolutionPortrait: String = com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE,
|
||||
val panelSize: Pair<Int, Int> = 1280 to 720,
|
||||
val hdr: Boolean,
|
||||
val hdrReason: String?,
|
||||
@@ -116,6 +117,7 @@ class ModeSettings(
|
||||
|
||||
class ModeSettingsActions(
|
||||
val onResolution: (String) -> Unit,
|
||||
val onResolutionPortrait: (String) -> Unit = {},
|
||||
val onHdr: (Boolean) -> Unit,
|
||||
val onZeroCopy: (Boolean) -> Unit = {},
|
||||
val onGpuDrivers: () -> Unit = {},
|
||||
@@ -234,9 +236,16 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
val controlsBelow = SessionPrefs.controlsBelowWanted(context, s.mode,
|
||||
if (portraitWindow) shortSide else longSide, if (portraitWindow) longSide else shortSide)
|
||||
val portrait = portraitWindow && !controlsBelow
|
||||
val displaySize = com.droiddeck.launcher.session.SessionDisplay.resolveChoice(s.panelSize, s.resolution, portrait)
|
||||
val sessionDisplay = com.droiddeck.launcher.session.SessionDisplay
|
||||
val landscapeChoice = sessionDisplay.effectiveChoice(s.resolution, s.resolutionPortrait, false)
|
||||
val portraitChoice = sessionDisplay.effectiveChoice(s.resolution, s.resolutionPortrait, true)
|
||||
val activeChoice = if (portrait) portraitChoice else landscapeChoice
|
||||
val displaySize = sessionDisplay.resolveChoice(s.panelSize, activeChoice, portrait)
|
||||
SettingsGroup(stringResource(R.string.display_session)) {
|
||||
ResolutionRow(host, s.resolution, s.panelSize, a.onResolution, portrait = portrait)
|
||||
ResolutionRow(host, "resolution", stringResource(R.string.display_resolution_landscape), s.resolution, landscapeChoice,
|
||||
com.droiddeck.launcher.session.SessionDisplay.LINK_PORTRAIT, s.panelSize, a.onResolution, portrait = false)
|
||||
ResolutionRow(host, "resolution-portrait", stringResource(R.string.display_resolution_portrait), s.resolutionPortrait, portraitChoice,
|
||||
com.droiddeck.launcher.session.SessionDisplay.LINK_LANDSCAPE, 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),
|
||||
@@ -248,7 +257,7 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
|
||||
}
|
||||
if (s.stretch16x9 != null && (com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(s.panelSize) ||
|
||||
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize))) {
|
||||
val canStretch = !com.droiddeck.launcher.session.SessionDisplay.isFollow(s.resolution) &&
|
||||
val canStretch = !com.droiddeck.launcher.session.SessionDisplay.isFollow(activeChoice) &&
|
||||
com.droiddeck.launcher.session.SessionDisplay.canStretch16x9(displaySize)
|
||||
ChoiceRow(host, "game-fit", stringResource(R.string.display_game_fit),
|
||||
stringResource(if (canStretch) R.string.display_game_fit_hint else R.string.display_game_fit_unavailable),
|
||||
|
||||
@@ -12,20 +12,24 @@ import com.droiddeck.launcher.session.SessionDisplay
|
||||
|
||||
@Composable
|
||||
fun ResolutionRow(
|
||||
host: MenuHost, choice: String, panel: Pair<Int, Int>, onPick: (String) -> Unit,
|
||||
host: MenuHost, id: String, title: String, stored: String, choice: String, link: String,
|
||||
panel: Pair<Int, Int>, onPick: (String) -> Unit,
|
||||
chipModifier: Modifier = Modifier,
|
||||
portrait: Boolean = false,
|
||||
) {
|
||||
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 customFollow = SessionDisplay.isFollow(choice) && choice !in choices
|
||||
val selected = if (SessionDisplay.isFollow(choice)) choice
|
||||
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
|
||||
var editCustom by remember { mutableStateOf(false) }
|
||||
var editFollow by remember { mutableStateOf(false) }
|
||||
val options = choices.map { value ->
|
||||
val linkLabel = stringResource(if (link == SessionDisplay.LINK_LANDSCAPE) R.string.display_follow_landscape else R.string.display_follow_portrait,
|
||||
size.first, size.second)
|
||||
val options = listOf(link to linkLabel) + choices.map { value ->
|
||||
val dimensions = SessionDisplay.resolveChoice(panel, value, portrait)
|
||||
value to if (value == SessionDisplay.MATCH_SCREEN) stringResource(R.string.display_match_screen, screen.first, screen.second)
|
||||
else if (value == SessionDisplay.FOLLOW_SCREEN) stringResource(R.string.display_follow_screen)
|
||||
@@ -35,11 +39,11 @@ fun ResolutionRow(
|
||||
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 "…"
|
||||
) + if (customFollow) " (${size.first}×${size.second})" else "") + (custom to if (selected in choices) stringResource(R.string.mode_res_custom)
|
||||
) + if (customFollow) " (${size.first}×${size.second})" else "") + (custom to if (selected in choices || linked) stringResource(R.string.mode_res_custom)
|
||||
else stringResource(R.string.mode_res_custom_value, size.first, size.second))
|
||||
ChoiceRow(host, "resolution", stringResource(R.string.display_resolution),
|
||||
ChoiceRow(host, id, title,
|
||||
stringResource(R.string.common_applies_next_session),
|
||||
options, if (selected in choices) selected else if (customFollow) SessionDisplay.FOLLOW_CUSTOM else custom, chipModifier = chipModifier,
|
||||
options, if (linked || selected in choices) selected else if (customFollow) SessionDisplay.FOLLOW_CUSTOM else custom, chipModifier = chipModifier,
|
||||
onPick = { value ->
|
||||
if (value == custom) editCustom = true
|
||||
else if (value == SessionDisplay.FOLLOW_CUSTOM) editFollow = true
|
||||
|
||||
Reference in new issue
Block a user