Feat: adds a interger scalling (another option) (#2620)

* Add integer scaling mode

* Add Fit and Auto options for integer scaling

* Update vk_present.c ( removed comentarios)

* Fix integer scaling view-space input bounds

* Fix integer scaling view coordinate ratios

* Fix glasses touch and effective Cardboard alignment

* Translate integer scaling settings

* Fix glasses picture bounds scaling
This commit is contained in:
LunaDL authored and GitHub committed 2026-11-15 14:51:24 -05:00
1 parent 1cada9ad50
commit c7ff93ec19
39 files changed
+147 -25

No files matched your search

@@ -195,6 +195,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
private var showPhantomGate by mutableStateOf(false)
private var directAudio by mutableStateOf(false)
private var picturePosition by mutableStateOf("center")
private var integerScaling by mutableStateOf(false)
private var stretch16x9 by mutableStateOf(false)
private var orientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE)
private var launcherOrientation by mutableStateOf(android.content.pm.ActivityInfo.SCREEN_ORIENTATION_USER)
@@ -2551,6 +2552,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
backActionsInverted = backActionsInverted,
directAudio = if (mode == SessionService.MODE_STEAM) directAudio else null,
picturePosition = if (mode == SessionService.MODE_STEAM) picturePosition else null,
integerScaling = if (mode == SessionService.MODE_STEAM) integerScaling else null,
stretch16x9 = if (mode == SessionService.MODE_STEAM) stretch16x9 else null,
mic = if (mode == SessionService.MODE_STEAM) mic else null,
gameStorage = if (mode == SessionService.MODE_STEAM) gameStorage else null,
@@ -2612,6 +2614,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
},
onDirectAudio = { on -> SessionPrefs.setDirectAudio(this, on); directAudio = on },
onPicturePosition = { value -> SessionPrefs.setPicturePosition(this, value); picturePosition = value },
onIntegerScaling = { on -> SessionPrefs.setIntegerScaling(this, on); integerScaling = on },
onStretch16x9 = { on -> SessionPrefs.setStretch16x9(this, on); stretch16x9 = on },
onMic = { on ->
SessionPrefs.setMicEnabled(this, on)
@@ -2949,6 +2952,7 @@ class FrontEndActivity : ComponentActivity(), com.droiddeck.launcher.ui.AgentPet
backActionsInverted = SessionPrefs.backActionsInverted(this)
directAudio = SessionPrefs.directAudio(this)
picturePosition = SessionPrefs.picturePosition(this)
integerScaling = SessionPrefs.integerScaling(this)
stretch16x9 = SessionPrefs.stretch16x9(this)
mic = SessionPrefs.micEnabled(this)
refreshWifiDiscovery()
@@ -173,11 +173,12 @@ 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 var integerScaling by mutableStateOf(false)
private fun applyGameAlignment() {
if (!CompositorHost.isStarted) return
val active = SessionState.mode == SessionService.MODE_STEAM &&
!pipUi && !isInPictureInPictureMode && !cardboard.enabled
!pipUi && !isInPictureInPictureMode && !activeCardboard.enabled
val alignment = if (!active) ALIGN_CENTER else when (picturePosition) {
"top" -> ALIGN_PICTURE_TOP
"bottom" -> ALIGN_PICTURE_BOTTOM
@@ -185,7 +186,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
"right" -> ALIGN_PICTURE_RIGHT
else -> ALIGN_CENTER
}
WaylandCompositor.nativeSetScaleMode(SCALE_FIT, alignment)
WaylandCompositor.nativeSetScaleMode(if (active && integerScaling) SCALE_INTEGER else SCALE_FIT, alignment)
}
private var unfoldedPanel by mutableStateOf<OnScreenControls?>(null)
private var unfoldedColumn: android.widget.LinearLayout? = null
@@ -1085,7 +1086,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
secondScreenPresentation?.closeFieldKeyboard()
}
}
androidx.compose.runtime.LaunchedEffect(picturePosition, SessionState.running, pipUi, cardboard.enabled) { applyGameAlignment() }
androidx.compose.runtime.LaunchedEffect(picturePosition, integerScaling, SessionState.running, pipUi, cardboard.enabled) { applyGameAlignment() }
DroidDeckTheme {
if (pipUi) {
if (SessionState.suspended) androidx.compose.foundation.layout.Box(
@@ -2399,6 +2400,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
unfoldedControls = SessionPrefs.unfoldedControls(this)
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
picturePosition = SessionPrefs.picturePosition(this)
integerScaling = SessionPrefs.integerScaling(this)
hudOn = SessionPrefs.hudEnabled(this)
hudConfig = DroidDeckHudConfig.load(this)
hudColor = SessionPrefs.hudColor(this)
@@ -2654,7 +2656,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
runCatching { GameEnvironmentStore.publish(this) }
.onFailure { Log.e(TAG, "Could not update game environment", it) }
}, "game-env-publish").start()
WaylandCompositor.nativeSetScaleMode(SCALE_FIT, ALIGN_CENTER)
applyGameAlignment()
val activeProfileId = currentScreenEffectsProfileId()
val activeUpscaler = SessionPrefs.screenEffectsUpscaler(this, activeProfileId)
val activeEffects = SessionPrefs.screenEffects(this, activeProfileId)
@@ -4636,25 +4638,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
gamePictureBounds[2], gamePictureBounds[3]
)
val nativeWidth: Int
val nativeHeight: Int
if (glassesOutputActive) {
val mode = glassesScreen?.display?.mode ?: return null
val outputWidth = mode.physicalWidth.takeIf { it > 0 } ?: return null
val outputHeight = mode.physicalHeight.takeIf { it > 0 } ?: return null
val scaleX = width.toFloat() / outputWidth
val scaleY = height.toFloat() / outputHeight
return android.graphics.RectF(
rect.left * scaleX,
rect.top * scaleY,
rect.right * scaleX,
rect.bottom * scaleY
)
nativeWidth = mode.physicalWidth.takeIf { it > 0 } ?: return null
nativeHeight = mode.physicalHeight.takeIf { it > 0 } ?: return null
} else {
val nativeSize = IntArray(2)
if (!WaylandCompositor.nativeOutputSize(nativeSize)) return null
nativeWidth = nativeSize[0].takeIf { it > 0 } ?: return null
nativeHeight = nativeSize[1].takeIf { it > 0 } ?: return null
}
val nativeSize = IntArray(2)
if (!WaylandCompositor.nativeOutputSize(nativeSize)) return null
val nativeWidth = nativeSize[0].takeIf { it > 0 } ?: return null
val nativeHeight = nativeSize[1].takeIf { it > 0 } ?: return null
val scaleX = width.toFloat() / nativeWidth
val scaleY = height.toFloat() / nativeHeight
@@ -4863,7 +4858,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun dispatchDirectTouch(event: MotionEvent): Boolean {
val rect = drawnRect() ?: return false
if (event.actionMasked == MotionEvent.ACTION_DOWN)
ignoreGameTouch = topPictureMapped && !rect.contains(event.x, event.y)
ignoreGameTouch = topPictureMapped && !glassesOutputActive &&
!rect.contains(event.x, event.y)
if (ignoreGameTouch) {
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
directTouchHold.cancel()
@@ -5389,7 +5385,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
listOf(PointerGestures.BTN_LEFT, PointerGestures.BTN_RIGHT, PointerGestures.BTN_MIDDLE).forEach {
heldButtons.set(1, it, false)
}
WaylandCompositor.nativeSetScaleMode(SCALE_FIT, ALIGN_CENTER)
applyGameAlignment()
}
} else if (!isFinishing && !isDestroyed) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
@@ -5750,6 +5746,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
cardboard = c
val e = effectiveCardboard(c)
activeCardboard = e
applyGameAlignment()
if (CompositorHost.isStarted) pushCardboard(e)
if (e.enabled && !was.enabled) headTracker?.recenter()
updateHeadTracker()
@@ -6369,6 +6366,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private val steamVrWorker = java.util.concurrent.ThreadPoolExecutor(0, 1, 30, java.util.concurrent.TimeUnit.SECONDS,
java.util.concurrent.LinkedBlockingQueue()) { Thread(it, "steamvr") }
private const val SCALE_FIT = 1
private const val SCALE_INTEGER = 4
private const val ALIGN_CENTER = 0
private const val ALIGN_PICTURE_TOP = 3
private const val ALIGN_PICTURE_BOTTOM = 4
@@ -641,6 +641,13 @@ object SessionPrefs {
position.takeIf { it in listOf("top", "bottom", "left", "right", "center") } ?: "center").apply()
}
fun integerScaling(context: Context): Boolean =
prefs(context).getBoolean("integerScaling", false)
fun setIntegerScaling(context: Context, enabled: Boolean) {
prefs(context).edit().putBoolean("integerScaling", enabled).apply()
}
fun returnAfterGame(context: Context): Boolean = prefs(context).getBoolean("returnAfterGame", true)
fun setReturnAfterGame(context: Context, on: Boolean) {
@@ -18,7 +18,7 @@ object SettingsReset {
"storesInstallLanguage",
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backHold", "backActionsInverted", "backDoubleTapMs", "touch", "pen", "penButton", "osc", "shape", "steamController",
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
"stretch16x9", "picturePosition", "railLabels", "agentTab", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
"stretch16x9", "picturePosition", "integerScaling", "railLabels", "agentTab", "navTabOrder", "navTabShelved", "navTabHidden", "pcKeyboardSize", "pcKeyboardOpacity", "pcKeyboardHiddenKeys",
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
"tuSysmem", "glThread", "noGlError", "zinkLazy", "mangoapp", "gpuClockPin", "gamescopeRealtime", "paceCores", "ramCapMb", "vramCapMb", "zramClient", "zramIdle",
"directAudio", "mic", "wifiDiscovery", "clientCpusOverride", "clientCpus", "gameCpus",
@@ -83,6 +83,7 @@ class ModeSettings(
val forceSsbs: Boolean = false,
val syncBackend: String? = null,
val picturePosition: String? = null,
val integerScaling: Boolean? = null,
val stretch16x9: Boolean? = null,
val steamClientArch: String? = null,
val returnAfterGame: Boolean? = null,
@@ -139,6 +140,7 @@ class ModeSettingsActions(
val onForceSsbs: (Boolean) -> Unit = {},
val onSyncBackend: (String) -> Unit = {},
val onPicturePosition: (String) -> Unit = {},
val onIntegerScaling: (Boolean) -> Unit = {},
val onStretch16x9: (Boolean) -> Unit = {},
val onSteamRepair: () -> Unit = {},
val onSteamClientArch: (String) -> Unit = {},
@@ -242,6 +244,18 @@ fun ModeSheetRows(s: ModeSettings, a: ModeSettingsActions, tab: String, extras:
}
}
SettingsGroup(stringResource(R.string.display_image_scaling)) {
s.integerScaling?.let { enabled ->
ChoiceRow(
host, "integer-scaling",
stringResource(R.string.display_integer_scaling),
stringResource(R.string.display_integer_scaling_hint),
listOf(
false to stringResource(R.string.display_scaling_fit),
true to stringResource(R.string.display_scaling_auto),
),
enabled, onPick = a.onIntegerScaling,
)
}
ChoiceRow(
host, "upscaler", stringResource(R.string.display_filter), null,
SessionPrefs.upscalerChoices(LocalContext.current), s.upscaler,