mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
Feat: Adds Screen zoom buttons in DD side menu (#3361)
This commit is contained in:
1 parent
e3ba2bc68d
commit
771f7cb8c3
76 files changed
+650
-13
No files matched your search
@@ -179,6 +179,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var quickButtons by mutableStateOf<Map<InputCommand, Boolean>>(emptyMap())
|
||||
private var picturePosition by mutableStateOf("center")
|
||||
private var integerScaling by mutableStateOf(false)
|
||||
private var gameZoom by mutableStateOf(SessionState.gameZoom)
|
||||
private var avoidNotch = false
|
||||
|
||||
private fun applyNotchInset(insets: android.view.WindowInsets? = window.decorView.rootWindowInsets) {
|
||||
@@ -265,6 +266,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
InputCommand.KEYBOARD -> if (role == InputRole.PRIMARY || secondScreenPresentation?.showKeyboard() != true) togglePcKeyboard()
|
||||
InputCommand.STEAM -> tapSteamButton()
|
||||
InputCommand.QUICK_ACCESS -> tapQam()
|
||||
InputCommand.GAME_ZOOM_IN -> {
|
||||
gameZoom = (gameZoom + 0.25f).coerceAtMost(3.0f)
|
||||
SessionState.gameZoom = gameZoom
|
||||
runCatching { WaylandCompositor.nativeSetZoom(gameZoom) }
|
||||
}
|
||||
InputCommand.GAME_ZOOM_OUT -> {
|
||||
gameZoom = (gameZoom - 0.25f).coerceAtLeast(1.0f)
|
||||
SessionState.gameZoom = gameZoom
|
||||
runCatching { WaylandCompositor.nativeSetZoom(gameZoom) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1154,6 +1165,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
isFocusableInTouchMode = true
|
||||
defaultFocusHighlightEnabled = false
|
||||
setContent {
|
||||
androidx.compose.runtime.LaunchedEffect(SessionState.running, SessionState.sessionId) {
|
||||
if (SessionState.running) {
|
||||
gameZoom = SessionState.gameZoom
|
||||
runCatching { WaylandCompositor.nativeSetZoom(gameZoom) }
|
||||
} else {
|
||||
gameZoom = 1.0f
|
||||
SessionState.gameZoom = 1.0f
|
||||
runCatching { WaylandCompositor.nativeSetZoom(1.0f) }
|
||||
}
|
||||
}
|
||||
|
||||
val activeEffectsProfileId = currentScreenEffectsProfileId()
|
||||
val effectsEditorTarget = if (drawerOpen) screenEffectsTarget else null
|
||||
val effectsEditorProfileId = activeEffectsProfileId.takeIf {
|
||||
@@ -1221,6 +1243,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
CursorOverlay({ cursorPos }, cursorVisible && (!cursorHidden || onlyPcKeyboardOpen()) && !bottomOutputActive,
|
||||
resources.displayMetrics.density,
|
||||
cursorImage, cursorHotX, cursorHotY, cursorImageScale)
|
||||
|
||||
if (memoryHud.text.isNotEmpty()) HudText(memoryHud.text, hudColor, hudOpacity)
|
||||
if (bottomOutputActive && !loading.visible) SwappedTopPanel()
|
||||
val phonePanel = glassesOutputActive && !loading.visible && !drawerOpen && !pcKeyboardOpen
|
||||
@@ -1596,6 +1619,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() },
|
||||
onHudOrderReset = { hudConfig = DroidDeckHudConfig.clearOrder(this@SessionActivity); hud.applyConfig() },
|
||||
onHudExport = { exportHudDiagnostics() },
|
||||
gameZoomAvailable = SessionState.running,
|
||||
gameZoom = gameZoom,
|
||||
onGameZoom = { value ->
|
||||
gameZoom = value.coerceIn(1.0f, 3.0f)
|
||||
SessionState.gameZoom = gameZoom
|
||||
runCatching { WaylandCompositor.nativeSetZoom(gameZoom) }
|
||||
},
|
||||
integerScaling = integerScaling,
|
||||
onIntegerScaling = { enabled ->
|
||||
SessionPrefs.setIntegerScaling(this@SessionActivity, enabled)
|
||||
|
||||
@@ -21,7 +21,7 @@ enum class InputControl(val id: String, val label: String, val dimensions: Int =
|
||||
}
|
||||
}
|
||||
|
||||
enum class InputCommand { MENU, KEYBOARD, STEAM, QUICK_ACCESS }
|
||||
enum class InputCommand { MENU, KEYBOARD, STEAM, QUICK_ACCESS, GAME_ZOOM_IN, GAME_ZOOM_OUT }
|
||||
|
||||
sealed interface InputAction {
|
||||
data class Native(val target: InputControl? = null) : InputAction
|
||||
|
||||
@@ -420,6 +420,7 @@ class SessionService : Service() {
|
||||
val gen = synchronized(SessionState.startLock) {
|
||||
synchronized(stopLock) {
|
||||
SessionState.steamClientArch = null
|
||||
SessionState.gameZoom = 1.0f
|
||||
SessionState.running = true
|
||||
++sessionGen
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ object SessionState {
|
||||
|
||||
@Volatile
|
||||
var running = false
|
||||
/** Zoom level retained across activity recreation for the active session. */
|
||||
@Volatile
|
||||
var gameZoom = 1.0f
|
||||
@Volatile
|
||||
var activityDisplayId = 0
|
||||
@Volatile
|
||||
|
||||
@@ -33,6 +33,8 @@ internal fun commandLabel(command: InputCommand) = stringResource(when (command)
|
||||
InputCommand.KEYBOARD -> R.string.input_command_keyboard
|
||||
InputCommand.STEAM -> R.string.input_command_steam
|
||||
InputCommand.QUICK_ACCESS -> R.string.input_command_qam
|
||||
InputCommand.GAME_ZOOM_IN -> R.string.input_command_zoom_in
|
||||
InputCommand.GAME_ZOOM_OUT -> R.string.input_command_zoom_out
|
||||
})
|
||||
|
||||
@Composable
|
||||
|
||||
@@ -258,6 +258,9 @@ class DrawerActions(
|
||||
val upscaleSharpness: Int = 75,
|
||||
val integerScaling: Boolean = false,
|
||||
val onIntegerScaling: (Boolean) -> Unit = {},
|
||||
val gameZoomAvailable: Boolean = false,
|
||||
val gameZoom: Float = 1.0f,
|
||||
val onGameZoom: (Float) -> Unit = {},
|
||||
val effects: ScreenEffects = ScreenEffects.OFF,
|
||||
val screenEffectsTarget: String = "auto",
|
||||
val screenEffectsTargets: List<Pair<String, String>> = emptyList(),
|
||||
@@ -665,6 +668,45 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
SessionDrawerPage.HUD -> DroidDeckHudSettings(host, a) { key -> focus.track(page, key) }
|
||||
SessionDrawerPage.DISPLAY -> {
|
||||
SettingsGroup(stringResource(R.string.drawer_page_display)) {
|
||||
if (a.gameZoomAvailable) SettingsRow(
|
||||
stringResource(R.string.game_zoom_title),
|
||||
stringResource(R.string.game_zoom_hint),
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
val zoomOutEnabled = a.gameZoom > 1.0f
|
||||
val zoomInEnabled = a.gameZoom < 3.0f
|
||||
val zoomResetEnabled = a.gameZoom > 1.0f
|
||||
val zoomOut = { a.onGameZoom((a.gameZoom - 0.25f).coerceAtLeast(1.0f)) }
|
||||
val zoomIn = { a.onGameZoom((a.gameZoom + 0.25f).coerceAtMost(3.0f)) }
|
||||
val zoomReset = { a.onGameZoom(1.0f) }
|
||||
|
||||
OutlinedButton(
|
||||
onClick = zoomOut,
|
||||
enabled = zoomOutEnabled,
|
||||
modifier = focus.track(page, "game-zoom-out").width(42.dp)
|
||||
.controllerConfirm(enabled = zoomOutEnabled, onClick = zoomOut),
|
||||
contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp),
|
||||
) { Text("−") }
|
||||
Text("${(a.gameZoom * 100.0f).toInt()}%", fontSize = 12.sp)
|
||||
OutlinedButton(
|
||||
onClick = zoomIn,
|
||||
enabled = zoomInEnabled,
|
||||
modifier = focus.track(page, "game-zoom-in").width(42.dp)
|
||||
.controllerConfirm(enabled = zoomInEnabled, onClick = zoomIn),
|
||||
contentPadding = PaddingValues(horizontal = 4.dp, vertical = 0.dp),
|
||||
) { Text("+") }
|
||||
OutlinedButton(
|
||||
onClick = zoomReset,
|
||||
enabled = zoomResetEnabled,
|
||||
modifier = focus.track(page, "game-zoom-reset").width(48.dp)
|
||||
.controllerConfirm(enabled = zoomResetEnabled, onClick = zoomReset),
|
||||
contentPadding = PaddingValues(horizontal = 2.dp, vertical = 0.dp),
|
||||
) { Text("1×") }
|
||||
}
|
||||
}
|
||||
val fgOpen = host.open == "fg"
|
||||
val offLabel = stringResource(R.string.frame_gen_off)
|
||||
val fgLabel = FrameGen.label(LocalContext.current, a.frameGen)
|
||||
|
||||
@@ -371,6 +371,7 @@ public final class WaylandCompositor {
|
||||
public static native void nativeHdrNoteHeadroomRequest(float ratio);
|
||||
|
||||
public static native void nativeSetScaleMode(int fullscreenMode, int screenAlignment);
|
||||
public static native void nativeSetZoom(float zoom);
|
||||
|
||||
|
||||
public static native void nativeSetUpscaler(int mode);
|
||||
|
||||
Reference in new issue
Block a user