mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
Fix screen effects profile switching
This commit is contained in:
1 parent
9bd407c4c5
commit
cfb52ded61
2 files changed
+76
-17
No files matched your search
@@ -1388,19 +1388,46 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
|||||||
onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() },
|
onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() },
|
||||||
onHudExport = { exportHudDiagnostics() },
|
onHudExport = { exportHudDiagnostics() },
|
||||||
onUpscaler = { m ->
|
onUpscaler = { m ->
|
||||||
SessionPrefs.setUpscaler(this@SessionActivity, m); upscaler = m
|
SessionPrefs.setUpscaler(this@SessionActivity, m)
|
||||||
WaylandCompositor.nativeSetUpscaler(m)
|
val activeProfileId =
|
||||||
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(effects, m)?.name)
|
SessionPrefs.activeScreenEffectsProfileId(this@SessionActivity)
|
||||||
|
val activeEffects =
|
||||||
|
SessionPrefs.screenEffects(this@SessionActivity, activeProfileId)
|
||||||
|
val activeUpscaler =
|
||||||
|
SessionPrefs.screenEffectsUpscaler(this@SessionActivity, activeProfileId)
|
||||||
|
|
||||||
|
if ((effectsEditorTarget ?: screenEffectsTarget) == SCREEN_EFFECTS_TARGET_AUTO) {
|
||||||
|
effects = activeEffects
|
||||||
|
upscaler = activeUpscaler
|
||||||
|
}
|
||||||
|
|
||||||
|
WaylandCompositor.nativeSetUpscaler(activeUpscaler)
|
||||||
|
WaylandCompositor.nativeSetLookName(
|
||||||
|
ScreenEffectLooks.match(activeEffects, activeUpscaler)?.name
|
||||||
|
)
|
||||||
|
activeEffects.push(activeUpscaler)
|
||||||
},
|
},
|
||||||
onPresetUpscaler = { m ->
|
onPresetUpscaler = { m ->
|
||||||
val target = effectsEditorTarget ?: screenEffectsTarget
|
val target = effectsEditorTarget ?: screenEffectsTarget
|
||||||
val profileId = screenEffectsProfileIdForTarget(target)
|
val activeProfileId = if (target == SCREEN_EFFECTS_TARGET_AUTO) {
|
||||||
SessionPrefs.setScreenEffectsUpscaler(this@SessionActivity, profileId, m)
|
SessionPrefs.activeScreenEffectsProfileId(this@SessionActivity)
|
||||||
if (target == screenEffectsTarget) {
|
} else null
|
||||||
upscaler = m
|
|
||||||
if (screenEffectsTargetAppliesToLiveOutput(target)) {
|
if (activeProfileId != null && activeProfileId != effectsEditorProfileId) {
|
||||||
WaylandCompositor.nativeSetUpscaler(m)
|
Log.w(TAG, "Screen effects profile changed while editing; discarding stale upscaler edit")
|
||||||
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(effects, m)?.name)
|
observedScreenEffectsProfileId = activeProfileId
|
||||||
|
val activeEffects = SessionPrefs.screenEffects(this@SessionActivity, activeProfileId)
|
||||||
|
effects = activeEffects
|
||||||
|
activeEffects.push(upscaler)
|
||||||
|
} else {
|
||||||
|
val profileId = screenEffectsProfileIdForTarget(target)
|
||||||
|
SessionPrefs.setScreenEffectsUpscaler(this@SessionActivity, profileId, m)
|
||||||
|
if (target == screenEffectsTarget) {
|
||||||
|
upscaler = m
|
||||||
|
if (screenEffectsTargetAppliesToLiveOutput(target)) {
|
||||||
|
WaylandCompositor.nativeSetUpscaler(m)
|
||||||
|
WaylandCompositor.nativeSetLookName(ScreenEffectLooks.match(effects, m)?.name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1516,7 +1516,7 @@ class SessionService : Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
val accepted = gameId!!
|
val accepted = gameId!!
|
||||||
if (pendingSteamGameId == null) pendingSteamPreviousGameId = SessionState.gameId
|
if (pendingSteamPreviousGameId == null) pendingSteamPreviousGameId = SessionState.gameId
|
||||||
if (pendingSteamGameId != null) Log.i(TAG, "replacing a queued game launch with $accepted")
|
if (pendingSteamGameId != null) Log.i(TAG, "replacing a queued game launch with $accepted")
|
||||||
pendingSteamGameExitWatchToken = ++gameExitWatchToken
|
pendingSteamGameExitWatchToken = ++gameExitWatchToken
|
||||||
SessionState.gameId = accepted
|
SessionState.gameId = accepted
|
||||||
@@ -1582,15 +1582,19 @@ class SessionService : Service() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
pendingSteamGameId = null
|
pendingSteamGameId = null
|
||||||
pendingSteamPreviousGameId = null
|
|
||||||
pendingSteamGameGeneration = -1
|
pendingSteamGameGeneration = -1
|
||||||
pendingSteamGameExitWatchToken = -1
|
pendingSteamGameExitWatchToken = -1
|
||||||
SessionEvents.record("steam.game_launch_requested", mapOf("gameId" to gameId, "generation" to gen))
|
SessionEvents.record("steam.game_launch_requested", mapOf("gameId" to gameId, "generation" to gen))
|
||||||
watchGameExit(gameId, gen, exitWatchToken)
|
watchGameExit(gameId, gen, exitWatchToken, pendingSteamPreviousGameId)
|
||||||
Log.i(TAG, "queued Steam game $gameId for the running client")
|
Log.i(TAG, "queued Steam game $gameId for the running client")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun watchGameExit(gameId: String, gen: Int, token: Int) {
|
private fun watchGameExit(
|
||||||
|
gameId: String,
|
||||||
|
gen: Int,
|
||||||
|
token: Int,
|
||||||
|
previousGameId: String? = null
|
||||||
|
) {
|
||||||
Thread({
|
Thread({
|
||||||
val startBy = android.os.SystemClock.elapsedRealtime() + GAME_START_TIMEOUT_MS
|
val startBy = android.os.SystemClock.elapsedRealtime() + GAME_START_TIMEOUT_MS
|
||||||
var seen = false
|
var seen = false
|
||||||
@@ -1598,13 +1602,41 @@ class SessionService : Service() {
|
|||||||
while (token == gameExitWatchToken && gen == sessionGen && SessionState.running && !SessionState.stopRequested) {
|
while (token == gameExitWatchToken && gen == sessionGen && SessionState.running && !SessionState.stopRequested) {
|
||||||
val now = android.os.SystemClock.elapsedRealtime()
|
val now = android.os.SystemClock.elapsedRealtime()
|
||||||
if (steamGameRunning(gameId)) {
|
if (steamGameRunning(gameId)) {
|
||||||
if (!seen) Log.i(TAG, "game $gameId started; tracking its exit")
|
if (!seen) {
|
||||||
|
Log.i(TAG, "game $gameId started; tracking its exit")
|
||||||
|
mainHandler.post {
|
||||||
|
if (token == gameExitWatchToken && gen == sessionGen &&
|
||||||
|
pendingSteamPreviousGameId == previousGameId) {
|
||||||
|
pendingSteamPreviousGameId = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
seen = true
|
seen = true
|
||||||
goneSince = 0L
|
goneSince = 0L
|
||||||
} else if (!seen) {
|
} else if (!seen) {
|
||||||
if (now > startBy) {
|
if (now > startBy) {
|
||||||
Log.i(TAG, "game $gameId did not start; clearing its screen effects profile")
|
mainHandler.post {
|
||||||
mainHandler.post { clearActiveScreenEffectsProfile(gameId, gen, token) }
|
if (token != gameExitWatchToken || gen != sessionGen ||
|
||||||
|
!SessionState.running || SessionState.stopRequested) {
|
||||||
|
return@post
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previousGameId != null && steamGameRunning(previousGameId)) {
|
||||||
|
Log.w(TAG, "game $gameId did not start; restoring previous game $previousGameId")
|
||||||
|
SessionState.gameId = previousGameId
|
||||||
|
val previousProfileId =
|
||||||
|
SessionPrefs.screenEffectsProfileId(MODE_STEAM, previousGameId, null)
|
||||||
|
SessionPrefs.setActiveScreenEffectsProfile(this@SessionService, previousProfileId)
|
||||||
|
SessionPrefs.screenEffects(this@SessionService, previousProfileId)
|
||||||
|
.push(SessionPrefs.screenEffectsUpscaler(this@SessionService, previousProfileId))
|
||||||
|
pendingSteamPreviousGameId = null
|
||||||
|
watchGameExit(previousGameId, gen, token)
|
||||||
|
} else {
|
||||||
|
Log.i(TAG, "game $gameId did not start; clearing its screen effects profile")
|
||||||
|
pendingSteamPreviousGameId = null
|
||||||
|
clearActiveScreenEffectsProfile(gameId, gen, token)
|
||||||
|
}
|
||||||
|
}
|
||||||
return@Thread
|
return@Thread
|
||||||
}
|
}
|
||||||
} else if (goneSince == 0L) {
|
} else if (goneSince == 0L) {
|
||||||
|
|||||||
Reference in new issue
Block a user