mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 22:05:59 +00:00
Add per-game screen effects profiles
This commit is contained in:
1 parent
30d103280b
commit
6b1af8f2aa
3 files changed
+90
-7
No files matched your search
@@ -545,6 +545,13 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private val cardboardPrefListener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
if (key == SessionPrefs.CARDBOARD_KEY) uiHandler.post { applyCardboard(SessionPrefs.cardboard(this)) }
|
||||
}
|
||||
private val screenEffectsProfilePrefListener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
if (key == SessionPrefs.SCREEN_EFFECTS_ACTIVE_PROFILE_KEY) uiHandler.post {
|
||||
val profileId = SessionPrefs.activeScreenEffectsProfileId(this@SessionActivity)
|
||||
effects = SessionPrefs.screenEffects(this@SessionActivity, profileId)
|
||||
effects.push(upscaler)
|
||||
}
|
||||
}
|
||||
private val shortcutPrefListener = android.content.SharedPreferences.OnSharedPreferenceChangeListener { _, key ->
|
||||
if (key == null || key == PhysicalShortcuts.KEY) {
|
||||
physicalShortcuts.bindings = PhysicalShortcuts.read(this)
|
||||
@@ -1342,7 +1349,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
WaylandCompositor.nativeSetUpscaleSharpness(pct)
|
||||
},
|
||||
onEffects = { e ->
|
||||
SessionPrefs.setScreenEffects(this@SessionActivity, e); effects = e
|
||||
SessionPrefs.setScreenEffects(this@SessionActivity, currentScreenEffectsProfileId(), e)
|
||||
effects = e
|
||||
e.push(upscaler)
|
||||
},
|
||||
onTextureAnisotropy = { value ->
|
||||
@@ -1966,6 +1974,16 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}, "drawer-game-no-steam").start()
|
||||
}
|
||||
|
||||
private fun currentScreenEffectsProfileId(): String? {
|
||||
if (SessionState.running) return SessionPrefs.activeScreenEffectsProfileId(this)
|
||||
val mode = intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM
|
||||
return SessionPrefs.screenEffectsProfileId(
|
||||
mode,
|
||||
intent.getStringExtra(SessionService.EXTRA_GAME_ID),
|
||||
intent.getStringExtra(SessionService.EXTRA_PROGRAM),
|
||||
)
|
||||
}
|
||||
|
||||
private fun loadingMode(): String =
|
||||
if (SessionState.running) SessionState.mode
|
||||
else intent.getStringExtra(SessionService.EXTRA_MODE) ?: SessionService.MODE_STEAM
|
||||
@@ -2062,7 +2080,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
hudOpacity = SessionPrefs.hudOpacity(this)
|
||||
upscaler = SessionPrefs.upscaler(this)
|
||||
upscaleSharpness = SessionPrefs.upscaleSharpness(this)
|
||||
effects = SessionPrefs.screenEffects(this)
|
||||
effects = SessionPrefs.screenEffects(this, currentScreenEffectsProfileId())
|
||||
applyCardboard(SessionPrefs.cardboard(this))
|
||||
if (SessionPrefs.cardboardSourceBeforeSteamVr(this) >= 0 && !steamVrSwitchedPicture) {
|
||||
steamVrSwitchedPicture = true
|
||||
@@ -2300,7 +2318,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
WaylandCompositor.nativeSetScaleMode(SCALE_FIT, ALIGN_CENTER)
|
||||
WaylandCompositor.nativeSetUpscaler(SessionPrefs.upscaler(this))
|
||||
WaylandCompositor.nativeSetUpscaleSharpness(SessionPrefs.upscaleSharpness(this))
|
||||
SessionPrefs.screenEffects(this).push(SessionPrefs.upscaler(this))
|
||||
SessionPrefs.screenEffects(this, currentScreenEffectsProfileId()).push(SessionPrefs.upscaler(this))
|
||||
activeCardboard = effectiveCardboard(SessionPrefs.cardboard(this))
|
||||
pushCardboard(activeCardboard)
|
||||
WaylandCompositor.nativeSetCardboardPoseFile(File(filesDir, ".wayland-rt/droiddeck-headpose").path)
|
||||
@@ -5020,6 +5038,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (::pip.isInitialized) pip.resumed()
|
||||
if (CompositorHost.isStarted) applyFrameGen()
|
||||
SessionPrefs.sessionPrefs(this).registerOnSharedPreferenceChangeListener(cardboardPrefListener)
|
||||
SessionPrefs.sessionPrefs(this).registerOnSharedPreferenceChangeListener(screenEffectsProfilePrefListener)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
@@ -5062,6 +5081,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
updatePadMotion()
|
||||
keyboard?.takeIf { it.shown }?.hide()
|
||||
SessionPrefs.sessionPrefs(this).unregisterOnSharedPreferenceChangeListener(cardboardPrefListener)
|
||||
SessionPrefs.sessionPrefs(this).unregisterOnSharedPreferenceChangeListener(screenEffectsProfilePrefListener)
|
||||
ControllerPrefs.prefs(this).unregisterOnSharedPreferenceChangeListener(shortcutPrefListener)
|
||||
updateHeadTracker()
|
||||
super.onPause()
|
||||
|
||||
Reference in new issue
Block a user