feat: the HUD is DroidDeck HUD, pinch resizes it, and pushing it off an edge docks it as an FPS tab (#1868)

This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-10-30 22:44:23 -04:00
1 parent e3c3471d2f
commit 6eef0721c9
48 files changed
+394 -169

No files matched your search

@@ -92,8 +92,8 @@ import com.droiddeck.launcher.input.TouchscreenGestures
import com.droiddeck.launcher.input.ScrollTouchGestures
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.LoadingState
import com.droiddeck.launcher.hud.FusionHudConfig
import com.droiddeck.launcher.hud.FusionHudHost
import com.droiddeck.launcher.hud.DroidDeckHudConfig
import com.droiddeck.launcher.hud.DroidDeckHudHost
import com.droiddeck.launcher.session.PerfMode
import com.droiddeck.launcher.session.SteamRepair
import com.droiddeck.launcher.session.GameEnvironmentStore
@@ -161,7 +161,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
private lateinit var surfaceView: SurfaceView
private lateinit var sessionOverlay: ComposeView
private lateinit var loading: LoadingState
private lateinit var hud: FusionHudHost
private lateinit var hud: DroidDeckHudHost
private lateinit var memoryHud: com.droiddeck.launcher.session.MemoryHud
private var padBridge: PadBridge? = null
private val physicalShortcuts = PhysicalShortcutRouter()
@@ -746,8 +746,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
val needProton = protonUser && com.droiddeck.launcher.runtime.DesktopCatalog.protonSeedNeeded(this)
if (needRuntime || needResume || needDesktop || needProton) installThenStart(needRuntime, needDesktop, needProton, needResume)
}
hud = FusionHudHost(this)
hud.onConfigChanged = { hudConfig = FusionHudConfig.load(this) }
hud = DroidDeckHudHost(this)
hud.onConfigChanged = { hudConfig = DroidDeckHudConfig.load(this) }
hud.passesTouchAt = ::controlTakesTouchAt
hud.attach(root, root.childCount)
memoryHud = com.droiddeck.launcher.session.MemoryHud(this)
@@ -1180,8 +1180,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
secondScreenDisplays = secondScreenDisplays,
selectedSecondScreenDisplay = selectedSecondScreenDisplay,
onHud = { on -> SessionPrefs.setHudEnabled(this@SessionActivity, on); hudOn = on; hud.refresh() },
onHudSetting = { key, value -> hudConfig = FusionHudConfig.set(this@SessionActivity, key, value); hud.applyConfig() },
onHudReset = { hudConfig = FusionHudConfig.reset(this@SessionActivity); hud.applyConfig() },
onHudSetting = { key, value -> hudConfig = DroidDeckHudConfig.set(this@SessionActivity, key, value); hud.applyConfig() },
onHudReset = { hudConfig = DroidDeckHudConfig.reset(this@SessionActivity); hud.applyConfig() },
onHudExport = { exportHudDiagnostics() },
onUpscaler = { m ->
SessionPrefs.setUpscaler(this@SessionActivity, m); upscaler = m
@@ -1821,7 +1821,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
unfoldedControlsWithController = SessionPrefs.unfoldedControlsWithController(this)
picturePosition = SessionPrefs.picturePosition(this)
hudOn = SessionPrefs.hudEnabled(this)
hudConfig = FusionHudConfig.load(this)
hudConfig = DroidDeckHudConfig.load(this)
hudColor = SessionPrefs.hudColor(this)
hudOpacity = SessionPrefs.hudOpacity(this)
upscaler = SessionPrefs.upscaler(this)
@@ -3,14 +3,14 @@ package com.droiddeck.launcher.hud
import android.content.Context
import com.droiddeck.launcher.session.SessionPrefs
/** FusionHUD's settings as one "key=value,…" string (FusionHudView.applyConfig), stored in SessionPrefs. */
internal object FusionHudConfig {
/** DroidDeck HUD's settings as one "key=value,…" string (DroidDeckHudView.applyConfig), stored in SessionPrefs. */
internal object DroidDeckHudConfig {
/**
* Bannerlator's Fusion defaults (DeckOverlaySettings), with the FPS graph from the old DroidDeck HUD. The HUD starts
* Bannerlator's defaults (DeckOverlaySettings), with the FPS graph from the old DroidDeck HUD. The HUD starts
* locked, so like the old HUD it lets touches through until it is unlocked to move it.
*/
val DEFAULTS: Map<String, String> = linkedMapOf(
"hudSize" to "minimal", "hudLocked" to "1", "hudScale" to "100", "hudOpacity" to "80", "hudColor" to "mid",
"hudSize" to "minimal", "hudLocked" to "1", "hudScale" to "100", "hudDock" to "none", "hudOpacity" to "80", "hudColor" to "mid",
"hudOutline" to "40", "hudOutlineAccent" to "1",
"showFPS" to "1", "showFPSGraph" to "1", "showCPUUsage" to "1", "showCPULoad" to "1", "showGPULoad" to "1",
"showVram" to "1", "showRAM" to "1", "showPower" to "1", "showTemp" to "1", "showBatteryTemp" to "1",
@@ -25,7 +25,7 @@ internal object FusionHudConfig {
fun load(context: Context): MutableMap<String, String> {
val values = LinkedHashMap(DEFAULTS)
val stored = SessionPrefs.fusionHudConfig(context)
val stored = SessionPrefs.droidDeckHudConfig(context)
if (stored == null) {
values["showFPS"] = flag(SessionPrefs.hudShowFps(context))
values["showFPSGraph"] = flag(SessionPrefs.hudShowGraph(context))
@@ -43,12 +43,12 @@ internal object FusionHudConfig {
if (key !in DEFAULTS) return values
values[key] = value
TWINS[key]?.let { values[it] = value }
SessionPrefs.setFusionHudConfig(context, encode(values))
SessionPrefs.setDroidDeckHudConfig(context, encode(values))
return values
}
fun reset(context: Context): Map<String, String> {
SessionPrefs.setFusionHudConfig(context, encode(DEFAULTS))
SessionPrefs.setDroidDeckHudConfig(context, encode(DEFAULTS))
return DEFAULTS
}
@@ -6,26 +6,28 @@ import android.os.Handler
import android.os.Looper
import android.view.Choreographer
import android.view.View
import android.view.animation.PathInterpolator
import android.view.ViewGroup
import android.widget.FrameLayout
import com.droiddeck.launcher.gpu.FrameGen
import com.droiddeck.launcher.gpu.GpuInfo
import com.droiddeck.launcher.runtime.LinuxRuntime
import com.droiddeck.launcher.session.SessionPrefs
import com.droiddeck.launcher.ui.Motion
import com.droiddeck.launcher.wayland.WaylandCompositor
import java.io.File
import kotlin.math.roundToInt
/**
* FusionHUD on the session screen, in place of the old text HUD: the view, the frame feed from gamescope
* DroidDeck HUD on the session screen, in place of the old text HUD: the view, the frame feed from gamescope
* (MangoHud's frame times) and MangoHud's readings, started with the session's first frame.
*/
class FusionHudHost(context: Context) {
class DroidDeckHudHost(context: Context) {
private val context = context.applicationContext
private val handler = Handler(Looper.getMainLooper())
private val feed = GameFrameFeed(File(LinuxRuntime.rootDir(this.context), HudFrames.PATH))
private val readings = MangoReadings(File(this.context.filesDir, "session"), LinuxRuntime.rootDir(this.context))
private var view: FusionHudView? = null
private var view: DroidDeckHudView? = null
private var parent: ViewGroup? = null
private var running = false
private var hidden = false
@@ -49,7 +51,7 @@ class FusionHudHost(context: Context) {
private val listener = object : WaylandCompositor.GameListener {
override fun onGameSurface(window: String?, gpuName: String?) {
if (!gpuName.isNullOrBlank()) handler.post { this@FusionHudHost.gpuName = cleanGpuName(gpuName) }
if (!gpuName.isNullOrBlank()) handler.post { this@DroidDeckHudHost.gpuName = cleanGpuName(gpuName) }
if (window != null && window != lastWindow) {
lastWindow = window
handler.post { onPresentingWindowChanged?.invoke() }
@@ -76,20 +78,26 @@ class FusionHudHost(context: Context) {
/** Adds the HUD to [root] at [index] (above the game surface, under the session overlay). */
fun attach(root: FrameLayout, index: Int) {
if (view != null) return
val hud = FusionHudView(root.context)
val hud = DroidDeckHudView(root.context)
hud.setFrameStats(feed.stats)
hud.setMangoReadings(readings)
hud.setGpuModel(cleanGpuName(GpuInfo.detect().displayName(context)))
hud.onRefresh = Runnable { refreshLabels(hud) }
hud.setOnMovedListener { x, y ->
wantX = x; wantY = y
dockEdgeFor(hud)?.let { edge -> setDock(hud, edge); return@setOnMovedListener }
keepOnScreen(hud)
wantX = hud.x; wantY = hud.y
SessionPrefs.setFusionHudPosition(context, hud.x, hud.y)
SessionPrefs.setDroidDeckHudPosition(context, hud.x, hud.y)
}
hud.setOnSizeCycledListener { size -> DroidDeckHudConfig.set(context, "hudSize", size); onConfigChanged?.invoke() }
hud.setOnDockChangedListener { token -> setDock(hud, DroidDeckHudDock.from(token)) }
hud.setOnScaledListener { percent ->
DroidDeckHudConfig.set(context, "hudScale", percent.toString())
onConfigChanged?.invoke()
}
hud.setOnSizeCycledListener { size -> FusionHudConfig.set(context, "hudSize", size); onConfigChanged?.invoke() }
hud.setOnLockChangedListener { locked ->
FusionHudConfig.set(context, "hudLocked", if (locked) "1" else "0")
DroidDeckHudConfig.set(context, "hudLocked", if (locked) "1" else "0")
onConfigChanged?.invoke()
}
hud.addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ -> if (!hud.isDragging) keepOnScreen(hud) }
@@ -100,14 +108,14 @@ class FusionHudHost(context: Context) {
leftMargin = margin
topMargin = margin
})
SessionPrefs.fusionHudPosition(context)?.let { (x, y) -> wantX = x; wantY = y; hud.post { keepOnScreen(hud) } }
SessionPrefs.droidDeckHudPosition(context)?.let { (x, y) -> wantX = x; wantY = y; hud.post { keepOnScreen(hud) } }
view = hud
parent = root
applyConfig()
}
fun applyConfig() {
view?.applyConfig(FusionHudConfig.encode(FusionHudConfig.load(context)))
view?.applyConfig(DroidDeckHudConfig.encode(DroidDeckHudConfig.load(context)))
}
fun refresh() {
@@ -157,7 +165,7 @@ class FusionHudHost(context: Context) {
}
}
/** A sensor report (FusionHUD's diagnostics) in Downloads/DroidDeck; null when it can't be written. */
/** A sensor report (DroidDeck HUD's diagnostics) in Downloads/DroidDeck; null when it can't be written. */
fun exportDiagnostics(): File? = runCatching {
val dir = File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), "DroidDeck")
dir.mkdirs()
@@ -180,7 +188,7 @@ class FusionHudHost(context: Context) {
file
}.getOrNull()
private fun refreshLabels(hud: FusionHudView) {
private fun refreshLabels(hud: DroidDeckHudView) {
if (feed.engine.isNotBlank() && !feed.steamFocused) engine = feed.engine
hud.setEngineLabel(engine)
if (gpuName.isNotBlank()) hud.setGpuModel(gpuName)
@@ -203,6 +211,105 @@ class FusionHudHost(context: Context) {
return if (stats.size > 3 && stats[3] > 1f) stats[3] else 0f
}
/** The edge the HUD was dropped over, once a good part of it hangs past that edge; null when it stays. */
private fun dockEdgeFor(v: View): DroidDeckHudDock? {
val p = v.parent as? View ?: return null
if (p.width <= 0 || p.height <= 0 || v.width <= 0 || v.height <= 0) return null
val over = mapOf(
DroidDeckHudDock.LEFT to -v.x / v.width,
DroidDeckHudDock.RIGHT to (v.x + v.width - p.width) / v.width,
DroidDeckHudDock.TOP to -v.y / v.height,
DroidDeckHudDock.BOTTOM to (v.y + v.height - p.height) / v.height,
).maxByOrNull { it.value } ?: return null
return over.key.takeIf { over.value >= DOCK_OVERHANG }
}
/** Tucks the HUD against [edge] as its FPS tab, or with [DroidDeckHudDock.NONE] brings it back out from where it was docked. */
private fun setDock(hud: DroidDeckHudView, edge: DroidDeckHudDock) {
if (edge == hud.dock) return
animateDock(hud, edge) { commitDock(hud, edge) }
}
private fun commitDock(hud: DroidDeckHudView, edge: DroidDeckHudDock) {
if (edge == DroidDeckHudDock.NONE) {
when (hud.dock) {
DroidDeckHudDock.LEFT -> wantX = 0f
DroidDeckHudDock.RIGHT -> wantX = Float.MAX_VALUE
DroidDeckHudDock.TOP -> wantY = 0f
DroidDeckHudDock.BOTTOM -> wantY = Float.MAX_VALUE
DroidDeckHudDock.NONE -> {}
}
} else {
val p = hud.parent as? View
if (p != null) {
wantX = wantX.coerceIn(0f, p.width.toFloat())
wantY = wantY.coerceIn(0f, p.height.toFloat())
}
SessionPrefs.setDroidDeckHudPosition(context, wantX, wantY)
}
DroidDeckHudConfig.set(context, "hudDock", edge.token)
applyConfig()
hud.post { keepOnScreen(hud) }
onConfigChanged?.invoke()
}
/**
* One shape contracts into the tab, and the tab expands back out to the HUD: the view is scaled onto the
* tab's exact rectangle, and the layouts swap at that same size and place. Timing and curve are the
* launcher's own ([Motion]), and off when animations are off.
*/
private fun animateDock(hud: DroidDeckHudView, edge: DroidDeckHudDock, commit: () -> Unit) {
hud.animate().cancel()
hud.scaleX = 1f; hud.scaleY = 1f; hud.alpha = 1f
val p = hud.parent as? View
if (Motion.scale == 0f || p == null || !hud.isLaidOut || hud.width <= 0) { commit(); return }
if (edge != DroidDeckHudDock.NONE) {
val (tabW, tabH) = hud.dockTabSize()
val (tabX, tabY) = settled(p, edge, tabW, tabH)
val sx = tabW / hud.width; val sy = tabH / hud.height
hud.pivotX = pivotFor(hud.x, tabX, sx) - hud.x
hud.pivotY = pivotFor(hud.y, tabY, sy) - hud.y
hud.animate().scaleX(sx).scaleY(sy).setDuration(Motion.ms(300).toLong()).setInterpolator(EASE)
.withEndAction {
commit()
hud.scaleX = 1f; hud.scaleY = 1f
hud.x = tabX; hud.y = tabY
hud.alpha = 0.5f
hud.animate().alpha(1f).setDuration(Motion.ms(120).toLong()).start()
}.start()
} else {
val tabX = hud.x; val tabY = hud.y
val tabW = hud.width.toFloat(); val tabH = hud.height.toFloat()
commit()
val w = hud.contentWidth; val h = hud.contentHeight
val (x, y) = settled(p, DroidDeckHudDock.NONE, w, h)
hud.x = x; hud.y = y
val sx = tabW / w; val sy = tabH / h
hud.pivotX = pivotFor(x, tabX, sx) - x
hud.pivotY = pivotFor(y, tabY, sy) - y
hud.scaleX = sx; hud.scaleY = sy
hud.animate().scaleX(1f).scaleY(1f).setDuration(Motion.ms(360).toLong()).setInterpolator(EASE).start()
}
}
/** The pivot, in parent coordinates, that scaling by [scale] takes a span starting at [from] onto one starting at [to]. */
private fun pivotFor(from: Float, to: Float, scale: Float): Float =
if (scale > 0.999f) from else (to - from * scale) / (1f - scale)
/** Where a [w] x [h] HUD or tab sits once [keepOnScreen] has settled it against [dock]. */
private fun settled(p: View, dock: DroidDeckHudDock, w: Float, h: Float): Pair<Float, Float> {
val maxX = (p.width - w).coerceAtLeast(0f); val maxY = (p.height - h).coerceAtLeast(0f)
var x = wantX.coerceIn(0f, maxX); var y = wantY.coerceIn(0f, maxY)
when (dock) {
DroidDeckHudDock.LEFT -> x = 0f
DroidDeckHudDock.RIGHT -> x = maxX
DroidDeckHudDock.TOP -> y = 0f
DroidDeckHudDock.BOTTOM -> y = maxY
DroidDeckHudDock.NONE -> {}
}
return Pair(x, y)
}
// The HUD is clamped from where the user left it (wantX/wantY, set on a drop or restore), not from where
// it is drawn: a window that shrinks and grows back (picture-in-picture, a fold) must not leave it in the
// corner the small window pushed it to.
@@ -212,13 +319,24 @@ class FusionHudHost(context: Context) {
if (wantX.isNaN()) { wantX = v.x; wantY = v.y }
val maxX = (p.width - v.width).toFloat().coerceAtLeast(0f)
val maxY = (p.height - v.height).toFloat().coerceAtLeast(0f)
val x = wantX.coerceIn(0f, maxX)
val y = wantY.coerceIn(0f, maxY)
var x = wantX.coerceIn(0f, maxX)
var y = wantY.coerceIn(0f, maxY)
when (v.let { it as? DroidDeckHudView }?.dock) {
DroidDeckHudDock.LEFT -> x = 0f
DroidDeckHudDock.RIGHT -> x = maxX
DroidDeckHudDock.TOP -> y = 0f
DroidDeckHudDock.BOTTOM -> y = maxY
else -> {}
}
if (v.x != x) v.x = x
if (v.y != y) v.y = y
}
companion object {
/** How much of the HUD, as a share of its own size, must hang past a screen edge for it to dock there. */
private const val DOCK_OVERHANG = 0.4f
private val EASE = PathInterpolator(0.2f, 0.8f, 0.2f, 1f)
/** True while the HUD is on screen; DroidDeck keeps sampling VRAM for it (GpuMemComponent). */
@Volatile @JvmStatic var showing = false
private set
@@ -14,11 +14,11 @@
package com.droiddeck.launcher.hud
/**
* Size modes for the Fusion HUD (the 4th selectable in-game overlay style). One shared color-coded
* Size modes for the DroidDeck HUD (the 4th selectable in-game overlay style). One shared color-coded
* visual language, four amounts of detail — see the approved mockup. The config value is the lower-case
* token stored under the `hudSize` key; the label is the user-facing string.
*/
enum class FusionSize(val token: String, val label: String) {
enum class DroidDeckHudSize(val token: String, val label: String) {
FULL("full", "Full"),
TILES("tiles", "Tiles"),
PILL("pill", "Pill"),
@@ -26,7 +26,7 @@ enum class FusionSize(val token: String, val label: String) {
MEGA("mega", "Mega");
/** Next size in the tap-cycle: Full → Tiles → Pill → Minimal → Mega → Full. */
fun next(): FusionSize {
fun next(): DroidDeckHudSize {
val all = values()
return all[(ordinal + 1) % all.size]
}
@@ -45,7 +45,7 @@ enum class FusionSize(val token: String, val label: String) {
}
companion object {
fun from(token: String?): FusionSize =
fun from(token: String?): DroidDeckHudSize =
values().firstOrNull { it.token.equals(token, ignoreCase = true) } ?: FULL
// Chip-label ids (must match the labels the config UIs build). "Clock" is a small subtle
@@ -66,12 +66,21 @@ enum class FusionSize(val token: String, val label: String) {
}
}
/** The screen edge the HUD is tucked against, where only its FPS tab shows ([NONE] = floating free). */
enum class DroidDeckHudDock(val token: String) {
NONE("none"), LEFT("left"), RIGHT("right"), TOP("top"), BOTTOM("bottom");
companion object {
fun from(token: String?): DroidDeckHudDock = values().firstOrNull { it.token == token } ?: NONE
}
}
/**
* The Wayland HDR state the Fusion HUD shows on its own line, directly under the latency · display-server
* line (the host sets it with [FusionHudView.setHdrState]). [NONE] = no line at all: every session whose
* The Wayland HDR state the DroidDeck HUD shows on its own line, directly under the latency · display-server
* line (the host sets it with [DroidDeckHudView.setHdrState]). [NONE] = no line at all: every session whose
* HDR gate is closed (X11, SDR screens, HDR off) keeps the HUD exactly as it was.
*/
object FusionHdr {
object DroidDeckHudHdr {
const val NONE = 0
const val ON = 1 // HDR frames on screen with HDR headroom
const val NO_HEADROOM = 2 // HDR frames on screen, but the display gives them no headroom (5 s+)
@@ -23,6 +23,7 @@ import android.graphics.Path
import android.graphics.RectF
import android.graphics.Typeface
import android.text.format.DateFormat
import android.view.GestureDetector
import android.view.MotionEvent
import android.view.View
import androidx.annotation.VisibleForTesting
@@ -32,6 +33,7 @@ import java.util.Date
import java.util.Locale
import java.util.function.BiConsumer
import java.util.function.Consumer
import java.util.function.IntConsumer
import kotlin.math.max
import kotlin.math.min
import kotlin.math.roundToInt
@@ -47,7 +49,7 @@ import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeoutOrNull
/**
* Fusion HUD — the 4th selectable in-game overlay. One color-coded visual language rendered at four
* DroidDeck HUD — the 4th selectable in-game overlay. One color-coded visual language rendered at four
* SIZE modes (Full / Tiles / Pill / Minimal / Mega), all driven by [FrameStats] (gamescope's frame times
* read by MangoHud's rules) + a single cached [HudMetrics.Snapshot]. Pure Canvas drawing.
*
@@ -60,7 +62,7 @@ import kotlinx.coroutines.withTimeoutOrNull
* drag are frozen while locked. A locked HUD lets a touch through where an on-screen control under it
* takes it ([passesTouchAt]); everywhere else it keeps the touch, so a long press there unlocks it.
*/
class FusionHudView(context: Context) : View(context) {
class DroidDeckHudView(context: Context) : View(context) {
private var frames: FrameStats? = null
internal fun setFrameStats(stats: FrameStats?) { frames = stats }
@@ -78,7 +80,7 @@ class FusionHudView(context: Context) : View(context) {
private val density = resources.displayMetrics.density
// ---- Config -----------------------------------------------------------
private var size = FusionSize.FULL
private var size = DroidDeckHudSize.FULL
private var scale = 1f
private var bgOpacity = 0.8f
private var outlineIntensity = 0.4f
@@ -114,7 +116,7 @@ class FusionHudView(context: Context) : View(context) {
private var engineLabel = ""
private var displayServer = "" // "X11" / "Wayland": which display server the game runs on
private var hdrState = FusionHdr.NONE // Wayland HDR, on its own line under latency · display server
private var hdrState = DroidDeckHudHdr.NONE // Wayland HDR, on its own line under latency · display server
private var gpuModel = ""
// The GPU name a Wayland session reports to games instead of the real adapter ("" = none). It has
// to travel separately from gpuModel: Wayland hands the spoof to DXVK and leaves the Vulkan device
@@ -146,7 +148,13 @@ class FusionHudView(context: Context) : View(context) {
private var headerMark: RectF? = null
private var chipRect: RectF? = null
// Every size sits in the DroidDeck mark's D: a straight left side split by the orb, round on the
// Pushed past a screen edge, the HUD shrinks to a tab with the FPS that stays at that edge.
var dock = DroidDeckHudDock.NONE
private set
private var tabRect: RectF? = null
private val tabPath = Path()
// Every size sits in the DroidDeck mark's D: a straight left side, round on the
// right. Its fixed layers (fill, header band, watermark, glowing outline) go into a bitmap, because
// Android before 9 skips glow on shapes drawn with hardware acceleration.
private var dPanel: RectF? = null
@@ -213,11 +221,41 @@ class FusionHudView(context: Context) : View(context) {
fun setOnMovedListener(l: BiConsumer<Float, Float>?) { onMovedListener = l }
fun setOnSizeCycledListener(l: Consumer<String>?) { onSizeCycledListener = l }
fun setOnLockChangedListener(l: Consumer<Boolean>?) { onLockChangedListener = l }
private var onDockChangedListener: Consumer<String>? = null
private var onScaledListener: IntConsumer? = null
fun setOnDockChangedListener(l: Consumer<String>?) { onDockChangedListener = l }
/** A pinch settled on this size, in percent. */
fun setOnScaledListener(l: IntConsumer?) { onScaledListener = l }
private val lockController = HudLockController(context, this, object : HudLockController.Callbacks {
override fun onTap() { cycleSize() }
override fun onMoved(x: Float, y: Float) { onMovedListener?.accept(x, y) }
override fun onLockChanged(locked: Boolean) { onLockChangedListener?.accept(locked) }
override fun onPinch(factor: Float) {
val next = (scale * factor).coerceIn(MIN_SCALE, MAX_SCALE)
if (next == scale) return
scale = next
rebuildAndInvalidate()
}
override fun onPinchEnd() { onScaledListener?.accept((scale * 100f).roundToInt()) }
})
// A docked tab always takes touches, locked or not: a tap or a pull away from the edge brings the HUD back.
private val dockDetector = GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
override fun onDown(e: MotionEvent): Boolean = true
override fun onSingleTapUp(e: MotionEvent): Boolean { onDockChangedListener?.accept(DroidDeckHudDock.NONE.token); return true }
override fun onScroll(e1: MotionEvent?, e2: MotionEvent, distanceX: Float, distanceY: Float): Boolean {
if (e1 == null) return false
val inward = when (dock) {
DroidDeckHudDock.LEFT -> e2.rawX - e1.rawX
DroidDeckHudDock.RIGHT -> e1.rawX - e2.rawX
DroidDeckHudDock.TOP -> e2.rawY - e1.rawY
DroidDeckHudDock.BOTTOM -> e1.rawY - e2.rawY
DroidDeckHudDock.NONE -> 0f
}
if (inward > 12f * density) onDockChangedListener?.accept(DroidDeckHudDock.NONE.token)
return true
}
})
// ---- Public surface (symmetric with the other overlays) ---------------
@@ -227,9 +265,9 @@ class FusionHudView(context: Context) : View(context) {
* in place of the real model, marked so it can't be read as the chip that is really rendering. */
fun setGpuSpoofName(s: String?) { gpuSpoofName = s ?: ""; post { rebuildAndInvalidate() } }
fun setDisplayServer(s: String?) { displayServer = s ?: ""; post { rebuildAndInvalidate() } }
/** [FusionHdr] code; [FusionHdr.NONE] (the default) draws no HDR line anywhere. Any thread. */
/** [DroidDeckHudHdr] code; [DroidDeckHudHdr.NONE] (the default) draws no HDR line anywhere. Any thread. */
fun setHdrState(state: Int) {
val v = if (state in FusionHdr.ON..FusionHdr.NOT_ON_THIS_SCREEN) state else FusionHdr.NONE
val v = if (state in DroidDeckHudHdr.ON..DroidDeckHudHdr.NOT_ON_THIS_SCREEN) state else DroidDeckHudHdr.NONE
post { if (v != hdrState) { hdrState = v; rebuildAndInvalidate() } }
}
fun setWineVersion(s: String?) { if ((s ?: "") != wineVersion) { wineVersion = s ?: ""; post { rebuildAndInvalidate() } } }
@@ -255,7 +293,7 @@ class FusionHudView(context: Context) : View(context) {
if (graphRect != null) invalidate()
}
/** Fusion has no orientation (tap cycles size instead); kept for a symmetric host surface. */
/** The HUD has no orientation (tap cycles size instead); kept for a symmetric host surface. */
fun setVertical(vertical: Boolean) { /* no-op */ }
fun isVertical(): Boolean = false
@@ -269,7 +307,7 @@ class FusionHudView(context: Context) : View(context) {
if (configString.isNullOrEmpty()) return
val cfg = KeyValueSet(configString)
size = FusionSize.from(cfg.get("hudSize", "minimal"))
size = DroidDeckHudSize.from(cfg.get("hudSize", "minimal"))
showFPS = cfg.get("showFPS", "1") == "1"
showEngine = cfg.get("showEngine", "1") == "1"
showGpuModel = cfg.get("showGpuModel", "1") == "1"
@@ -285,7 +323,7 @@ class FusionHudView(context: Context) : View(context) {
showGraph = cfg.get("showFPSGraph", "0") == "1"
showLow001 = cfg.get("showLow001", "1") == "1"
fpsDecimal = cfg.get("fpsDecimal", "1") == "1"
showClockTime = cfg.get("showClock", "1") == "1" // Fusion clock defaults ON
showClockTime = cfg.get("showClock", "1") == "1" // the clock defaults ON
showPerCore = cfg.get("showPerCore", "1") == "1"
showSwap = cfg.get("showSwap", "1") == "1"
showNet = cfg.get("showNet", "1") == "1"
@@ -296,6 +334,7 @@ class FusionHudView(context: Context) : View(context) {
showSession = cfg.get("showSession", "1") == "1"
tempDisplay = HudMetrics.TempDisplay.from(cfg)
lockController.setLocked(cfg.get("hudLocked", "1") == "1")
dock = DroidDeckHudDock.from(cfg.get("hudDock", "none"))
colorIntensity = when (cfg.get("hudColor", "vivid")) {
"soft" -> 0.72f; "mid" -> 0.88f; else -> 1.0f
@@ -453,27 +492,27 @@ class FusionHudView(context: Context) : View(context) {
private fun glowing(spans: List<Span>): List<Span> =
spans.mapIndexed { i, s -> if (i == 0) Span(s.text, s.color, s.sizePx, glow = true) else s }
// ---- Wayland HDR state (one line of its own; nothing at all for FusionHdr.NONE) ----
// ---- Wayland HDR state (one line of its own; nothing at all for DroidDeckHudHdr.NONE) ----
/** The state as a full line: "HDR", "HDR (no headroom)", "HDR off", "HDR ready", "HDR tone-mapped",
* "HDR not on this screen". */
private fun hdrLine(px: Float): List<Span> = when (hdrState) {
FusionHdr.ON -> listOf(Span("HDR", colHdr, px))
FusionHdr.NO_HEADROOM -> listOf(Span("HDR", colHdr, px), Span(" (no headroom)", colBat, px))
FusionHdr.OFF -> listOf(Span("HDR off", colDim, px))
FusionHdr.READY -> listOf(Span("HDR ready", colDim, px))
FusionHdr.TONEMAPPED -> listOf(Span("HDR", colDim, px), Span(" tone-mapped", colBat, px))
FusionHdr.NOT_ON_THIS_SCREEN -> listOf(Span("HDR", colDim, px), Span(" not on this screen", colBat, px))
DroidDeckHudHdr.ON -> listOf(Span("HDR", colHdr, px))
DroidDeckHudHdr.NO_HEADROOM -> listOf(Span("HDR", colHdr, px), Span(" (no headroom)", colBat, px))
DroidDeckHudHdr.OFF -> listOf(Span("HDR off", colDim, px))
DroidDeckHudHdr.READY -> listOf(Span("HDR ready", colDim, px))
DroidDeckHudHdr.TONEMAPPED -> listOf(Span("HDR", colDim, px), Span(" tone-mapped", colBat, px))
DroidDeckHudHdr.NOT_ON_THIS_SCREEN -> listOf(Span("HDR", colDim, px), Span(" not on this screen", colBat, px))
else -> emptyList()
}
/** The value after an "HDR" label (Full / Mega): "on", "no headroom", "off", "ready", "tone-mapped",
* "not on this screen". */
private fun hdrValue(px: Float): List<Span> = when (hdrState) {
FusionHdr.ON -> listOf(Span("on", colHdr, px))
FusionHdr.NO_HEADROOM -> listOf(Span("no headroom", colBat, px))
FusionHdr.OFF -> listOf(Span("off", colDim, px))
FusionHdr.READY -> listOf(Span("ready", colDim, px))
FusionHdr.TONEMAPPED -> listOf(Span("tone-mapped", colBat, px))
FusionHdr.NOT_ON_THIS_SCREEN -> listOf(Span("not on this screen", colBat, px))
DroidDeckHudHdr.ON -> listOf(Span("on", colHdr, px))
DroidDeckHudHdr.NO_HEADROOM -> listOf(Span("no headroom", colBat, px))
DroidDeckHudHdr.OFF -> listOf(Span("off", colDim, px))
DroidDeckHudHdr.READY -> listOf(Span("ready", colDim, px))
DroidDeckHudHdr.TONEMAPPED -> listOf(Span("tone-mapped", colBat, px))
DroidDeckHudHdr.NOT_ON_THIS_SCREEN -> listOf(Span("not on this screen", colBat, px))
else -> emptyList()
}
private fun hdrText(): String = hdrLine(1f).joinToString("") { it.text }
@@ -495,26 +534,65 @@ class FusionHudView(context: Context) : View(context) {
// ---- Layout builders --------------------------------------------------
private fun rebuild() {
glyphs.clear(); tileRects.clear(); graphRect = null
headerMark = null; chipRect = null; dPanel = null; dDividerTop = -1f
headerMark = null; chipRect = null; dPanel = null; dDividerTop = -1f; tabRect = null
val s = snap
if (s == null) { contentW = 0f; contentH = 0f; return }
if (dock != DroidDeckHudDock.NONE) { buildDockTab(); return }
when (size) {
FusionSize.FULL -> { buildFull(s); intoPanel(sp(10f), header = true) }
FusionSize.TILES -> { buildTiles(s); intoPanel(sp(9f), header = true) }
FusionSize.PILL -> { buildPill(s); intoPanel(sp(10f), header = false) }
FusionSize.MINIMAL -> buildMinimal(s)
FusionSize.MEGA -> { buildMega(s); intoPanel(sp(10f), header = true) }
DroidDeckHudSize.FULL -> { buildFull(s); intoPanel(sp(10f), header = true) }
DroidDeckHudSize.TILES -> { buildTiles(s); intoPanel(sp(9f), header = true) }
DroidDeckHudSize.PILL -> { buildPill(s); intoPanel(sp(10f), header = false) }
DroidDeckHudSize.MINIMAL -> buildMinimal(s)
DroidDeckHudSize.MEGA -> { buildMega(s); intoPanel(sp(10f), header = true) }
}
}
/** The docked tab: the FPS alone, in a box square on the edge it sits against. */
private fun buildDockTab() {
val numPx = sp(20f)
val spans = tabSpans()
val padX = sp(9f); val padY = sp(7f)
placeRun(padX, padY + capHeight(numPx), spans)
val (w, h) = dockTabSize()
contentW = w; contentH = h
tabRect = RectF(0f, 0f, contentW, contentH)
}
private fun tabSpans() = listOf(Span(one(fpsNow), colValue, sp(20f)), Span("fps", colDim, sp(8.5f)))
/** The size the docked tab has, so the HUD can contract to exactly that shape before the tab replaces it. */
internal fun dockTabSize(): Pair<Float, Float> =
Pair(runWidth(tabSpans()) + 2f * sp(9f), capHeight(sp(20f)) + 2f * sp(7f))
private fun drawTab(canvas: Canvas, rect: RectF) {
val r = sp(8f); val stroke = max(outlineWidth(), sp(1.5f)); val h = stroke / 2f
val round = floatArrayOf(r, r, r, r, r, r, r, r)
val edge = when (dock) {
DroidDeckHudDock.LEFT -> intArrayOf(0, 3)
DroidDeckHudDock.RIGHT -> intArrayOf(1, 2)
DroidDeckHudDock.TOP -> intArrayOf(0, 1)
DroidDeckHudDock.BOTTOM -> intArrayOf(2, 3)
DroidDeckHudDock.NONE -> intArrayOf()
}
for (corner in edge) { round[corner * 2] = 0f; round[corner * 2 + 1] = 0f }
tabPath.rewind()
tabPath.addRoundRect(rect.left + h, rect.top + h, rect.right - h, rect.bottom - h, round, Path.Direction.CW)
headerPaint.shader = null
headerPaint.color = withAlpha(panelColor(), max(Color.alpha(panelColor()), 200))
canvas.drawPath(tabPath, headerPaint)
strokePaint.strokeWidth = stroke
strokePaint.color = outlineColor()
canvas.drawPath(tabPath, strokePaint)
}
// ---- DroidDeck panel, header and chip -----------------------------------
/** The clock sits in the header on every size but the Pill, which keeps it under the FPS. */
private fun footerClock(): Boolean = showClockTime && size == FusionSize.PILL
private fun footerClock(): Boolean = showClockTime && size == DroidDeckHudSize.PILL
private fun measureSans(text: String, sizePx: Float): Float { wordmarkPaint.textSize = sizePx; return wordmarkPaint.measureText(text) }
private fun panelInset() = sp(8f) // room for the glow around the panel
private fun panelLeft() = sp(13f) // the orb and its glow stick out of the left side
private fun panelLeft() = sp(13f) // the outline's glow sticks out of the left side
private fun contentLeft() = panelLeft() + sp(16f)
/** The DroidDeck mark, "DroidDeck" and the clock across the top, starting on [left], with the same
@@ -672,7 +750,7 @@ class FusionHudView(context: Context) : View(context) {
rows.add(HudRow(Span("GPU", colGpu, rowPx), gpuModelSpans(rowPx, colValue)))
if (displayServer.isNotBlank())
rows.add(HudRow(Span("DISP", colDisp, rowPx), listOf(Span(displayServer, colValue, rowPx))))
if (hdrState != FusionHdr.NONE)
if (hdrState != DroidDeckHudHdr.NONE)
rows.add(HudRow(Span("HDR", colHdr, rowPx), hdrValue(rowPx)))
if (showGPU) {
val v = ArrayList<Span>()
@@ -784,7 +862,7 @@ class FusionHudView(context: Context) : View(context) {
dxVersion().ifBlank { null }, false))
if (displayServer.isNotBlank())
tiles.add(Tile("DISPLAY", colDisp, listOf(Span(displayServer, colValue, valPx)),
if (hdrState != FusionHdr.NONE) hdrText() else null, false))
if (hdrState != DroidDeckHudHdr.NONE) hdrText() else null, false))
if (showGpuModel && gpuNameText().isNotBlank())
tiles.add(Tile("GPU", colGpu, gpuModelSpans(valPx, colValue), null, true))
if (showBattery || showPower || showBatteryTemp) {
@@ -893,7 +971,7 @@ class FusionHudView(context: Context) : View(context) {
}
// Wayland HDR state on its OWN line directly under the latency · display-server line (it ran off
// the capsule's right edge as "40.3ms · Wayland · HDR (no headroom)"). Only in HDR sessions.
if (hdrState != FusionHdr.NONE) stack.add(hdrLine(stkPx))
if (hdrState != DroidDeckHudHdr.NONE) stack.add(hdrLine(stkPx))
var statsW = 0f
for (l in stack) statsW = max(statsW, runWidth(l))
@@ -963,7 +1041,7 @@ class FusionHudView(context: Context) : View(context) {
}
val footerLabel = listOf(if (showEngine) engineLabel else "", displayServer)
.filter { it.isNotBlank() }.joinToString(" · ")
val hdr = if (hdrState != FusionHdr.NONE) hdrLine(footPx) else emptyList()
val hdr = if (hdrState != DroidDeckHudHdr.NONE) hdrLine(footPx) else emptyList()
val (headerBottom, headerRight) = addPanelHeader(left, inner)
val x = headerRight
@@ -1143,7 +1221,7 @@ class FusionHudView(context: Context) : View(context) {
val band = ArrayList<List<Span>>()
if (showResolution) band.add(listOf(Span("RES ", colDim, bandPx), Span(resolutionString(), colValue, bandPx)))
if (displayServer.isNotBlank()) band.add(listOf(Span("DISP ", colDim, bandPx), Span(displayServer, colDisp, bandPx)))
if (hdrState != FusionHdr.NONE) band.add(listOf(Span("HDR ", colDim, bandPx)) + hdrValue(bandPx))
if (hdrState != DroidDeckHudHdr.NONE) band.add(listOf(Span("HDR ", colDim, bandPx)) + hdrValue(bandPx))
if (showProton && wineVersion.isNotBlank()) band.add(listOf(Span(wineVersion, colVram, bandPx)))
if (showSession) band.add(listOf(Span("elapsed ", colDim, bandPx), Span(elapsedString(), colValue, bandPx)))
if (band.isNotEmpty()) {
@@ -1204,6 +1282,7 @@ class FusionHudView(context: Context) : View(context) {
}
chipRect?.let { drawChip(canvas, it) }
tabRect?.let { drawTab(canvas, it) }
// Text
for (g in glyphs) {
@@ -1253,19 +1332,17 @@ class FusionHudView(context: Context) : View(context) {
Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color))
/** The D: straight left side with small corners, round on the right with radius [rad] (a half circle
* when it is half the height). [split] > 0 leaves that much open above and below the middle of the
* left side, where the orb sits. */
private fun dShape(l: Float, t: Float, r: Float, b: Float, rad: Float, corner: Float, split: Float): Path {
val cy = (t + b) / 2f
* when it is half the height). */
private fun dShape(l: Float, t: Float, r: Float, b: Float, rad: Float, corner: Float): Path {
return Path().apply {
if (split > 0f) moveTo(l, cy + split) else moveTo(l, t + corner)
moveTo(l, t + corner)
lineTo(l, b - corner); quadTo(l, b, l + corner, b)
lineTo(r - rad, b)
arcTo(r - 2f * rad, b - 2f * rad, r, b, 90f, -90f, false)
lineTo(r, t + rad)
arcTo(r - 2f * rad, t, r, t + 2f * rad, 0f, -90f, false)
lineTo(l + corner, t); quadTo(l, t, l, t + corner)
if (split > 0f) lineTo(l, cy - split) else close()
close()
}
}
@@ -1285,7 +1362,7 @@ class FusionHudView(context: Context) : View(context) {
val bmp = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
val c = Canvas(bmp)
val corner = sp(6f)
val body = dShape(panel.left, panel.top, panel.right, panel.bottom, dRadius, corner, 0f)
val body = dShape(panel.left, panel.top, panel.right, panel.bottom, dRadius, corner)
bgPaint.color = panelColor()
c.drawPath(body, bgPaint)
c.save()
@@ -1307,7 +1384,7 @@ class FusionHudView(context: Context) : View(context) {
c.restore()
if (stroke > 0f) {
val h = stroke / 2f
val outline = dShape(panel.left + h, panel.top + h, panel.right - h, panel.bottom - h, dRadius - h, corner, sp(9f))
val outline = dShape(panel.left + h, panel.top + h, panel.right - h, panel.bottom - h, dRadius - h, corner)
val blur = BlurMaskFilter((sp(3.2f) - 0.5f).coerceAtLeast(0.5f) / 0.57735f, BlurMaskFilter.Blur.NORMAL)
glowPaint.strokeWidth = stroke
// Two blurred passes under the sharp one, as the 4-in-1 preview's neon.
@@ -1315,8 +1392,6 @@ class FusionHudView(context: Context) : View(context) {
glowPaint.maskFilter = if (pass < 2) blur else null
glowPaint.style = Paint.Style.STROKE; glowPaint.color = outlineColor()
c.drawPath(outline, glowPaint)
glowPaint.style = Paint.Style.FILL; glowPaint.color = accent
c.drawCircle(panel.left + h, panel.centerY(), sp(5.5f), glowPaint)
}
glowPaint.maskFilter = null
}
@@ -1358,15 +1433,21 @@ class FusionHudView(context: Context) : View(context) {
// Declining the down event hands the whole gesture to the views under the HUD.
override fun onTouchEvent(event: MotionEvent): Boolean {
if (dock != DroidDeckHudDock.NONE) return dockDetector.onTouchEvent(event)
if (event.actionMasked == MotionEvent.ACTION_DOWN && lockController.isLocked() &&
passesTouchAt?.invoke(event.rawX, event.rawY) == true) return false
return lockController.onTouchEvent(event)
}
internal val contentWidth: Float get() = contentW
internal val contentHeight: Float get() = contentH
internal val isDragging: Boolean get() = lockController.isDragging()
private companion object {
const val REFRESH_MS = 500L
const val MIN_SCALE = 0.5f
const val MAX_SCALE = 2f
const val GRAPH_CLIP_MS = 49.9f
fun parseIntOr(s: String?, d: Int): Int = try { s?.trim()?.toInt() ?: d } catch (e: Exception) { d }
@@ -8,7 +8,7 @@ import kotlin.math.roundToInt
* overlay.cpp update_hud_info_with_frametime and hud_elements.cpp fps() / frame_timing(). The FPS is the
* frames counted over a sampling period of at least 500 ms, the frame time next to it is 1000 / FPS, and
* the graph holds the last 200 frame times (zeros until filled) on a fixed 0-50 ms scale, min and max
* taken over those 200. Average and lows are FusionHUD's own readouts.
* taken over those 200. Average and lows are DroidDeck HUD's own readouts.
*/
internal class FrameStats {
private val graph = FloatArray(GRAPH_FRAMES)
@@ -22,6 +22,7 @@ import android.graphics.RectF;
import android.os.SystemClock;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.View;
import java.util.function.BiConsumer;
@@ -29,17 +30,17 @@ import java.util.function.Consumer;
/**
* Shared touch + lock behaviour for every in-game performance HUD (classic FrameRating(+Horizontal),
* GameHub PerfHudView, GameNative PerformanceHudView, and the Fusion HUD). One place so the four
* GameHub PerfHudView, GameNative PerformanceHudView, and the DroidDeck HUD). One place so the four
* overlays can't drift:
*
* <ul>
* <li><b>tap</b> → {@link Callbacks#onTap()} (orientation-toggle for the first three; size-cycle for
* Fusion) — a no-op that only re-flashes the lock badge while locked.</li>
* the DroidDeck HUD) — a no-op that only re-flashes the lock badge while locked.</li>
* <li><b>drag</b> → moves the host view and, on release, {@link Callbacks#onMoved} to persist the
* position — disabled (frozen) while locked.</li>
* <li><b>long-press</b> → toggles {@code hudLocked}, persisted via {@link Callbacks#onLockChanged}
* and kept in sync with the "Lock in place" menu chip. Works locked or unlocked (so a long-press
* always unlocks); a locked {@code FusionHudView} passes touches on only over on-screen controls.</li>
* always unlocks); a locked {@code DroidDeckHudView} passes touches on only over on-screen controls.</li>
* </ul>
*
* <p>On every lock/unlock (and on a blocked gesture while locked) a small padlock badge fades in →
@@ -52,12 +53,16 @@ import java.util.function.Consumer;
public class HudLockController {
public interface Callbacks {
/** Unlocked single tap: orientation-toggle (classic/gamehub/gamenative) or size-cycle (fusion). */
/** Unlocked single tap: orientation-toggle (classic/gamehub/gamenative) or size-cycle (DroidDeck HUD). */
void onTap();
/** Drag released (unlocked): persist the new (x, y). */
void onMoved(float x, float y);
/** Lock toggled by long-press: persist {@code hudLocked} + sync the menu chip. */
void onLockChanged(boolean locked);
/** Two-finger pinch (unlocked): the change since the previous event, above 1 when the fingers spread. */
default void onPinch(float factor) {}
/** The fingers came off a pinch: persist the new size. */
default void onPinchEnd() {}
}
// Fade timing (ms): in → hold → out. Lock/unlock hold ~1.5 s; a blocked-gesture re-flash is shorter.
@@ -70,12 +75,15 @@ public class HudLockController {
private final View view;
private final Callbacks cb;
private final GestureDetector detector;
private final ScaleGestureDetector scaleDetector;
private boolean locked = false;
// Drag state
private float downRawX, downRawY, startX, startY;
private boolean dragging = false;
// A pinch ends the gesture's drag and tap: the finger left down after it must not move the HUD.
private boolean pinched = false;
// Fade state
private long fadeStart = 0;
@@ -90,6 +98,8 @@ public class HudLockController {
this.cb = cb;
this.detector = new GestureDetector(context, new Listener());
this.detector.setIsLongpressEnabled(true);
this.scaleDetector = new ScaleGestureDetector(context, new PinchListener());
this.scaleDetector.setQuickScaleEnabled(false);
iconFill.setStyle(Paint.Style.FILL);
iconStroke.setStyle(Paint.Style.STROKE);
iconStroke.setStrokeCap(Paint.Cap.ROUND);
@@ -105,6 +115,7 @@ public class HudLockController {
/** Feed from the host view's onTouchEvent. Always consumes (mirrors the legacy manual handlers). */
public boolean onTouchEvent(MotionEvent event) {
scaleDetector.onTouchEvent(event);
detector.onTouchEvent(event);
int action = event.getActionMasked();
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
@@ -122,6 +133,7 @@ public class HudLockController {
startX = view.getX();
startY = view.getY();
dragging = false;
pinched = false;
return true;
}
@@ -135,6 +147,7 @@ public class HudLockController {
@Override
public boolean onSingleTapUp(MotionEvent e) {
if (pinched) return true;
if (locked) {
flash(true, HOLD_REFLASH_MS); // intentionally locked — remind the user
} else {
@@ -145,6 +158,7 @@ public class HudLockController {
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (pinched) return true;
if (locked) {
if (!dragging) flash(true, HOLD_REFLASH_MS);
dragging = true; // mark so the blocked drag doesn't fall through to a tap
@@ -157,6 +171,27 @@ public class HudLockController {
}
}
private final class PinchListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
@Override
public boolean onScaleBegin(ScaleGestureDetector d) {
if (locked) return false;
pinched = true;
dragging = false;
return true;
}
@Override
public boolean onScale(ScaleGestureDetector d) {
cb.onPinch(d.getScaleFactor());
return true;
}
@Override
public void onScaleEnd(ScaleGestureDetector d) {
cb.onPinchEnd();
}
}
// ---- Fade badge -------------------------------------------------------
private void flash(boolean showLocked, long hold) {
fadeShowLocked = showLocked;
@@ -1006,7 +1006,7 @@ public class HudMetrics {
// =======================================================================
/**
* Immutable point-in-time reading of every metric the Fusion HUD draws. Collected in one pass by
* Immutable point-in-time reading of every metric the DroidDeck HUD draws. Collected in one pass by
* {@link #snapshot()} so the view never touches sysfs / BatteryManager during draw (the user's
* explicit ask: one collection pass, cached, so gameplay isn't strained). All numeric fields are
* raw (nullable when unreadable); the view formats + colours them.
@@ -1268,7 +1268,7 @@ public class HudMetrics {
Snapshot s = snapshot();
StringBuilder sb = new StringBuilder();
sb.append("DroidDeck FusionHUD diagnostics\n");
sb.append("DroidDeck HUD diagnostics\n");
sb.append("Generated: ")
.append(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US).format(new Date())).append('\n');
sb.append("Device: ").append(Build.MANUFACTURER).append(' ').append(Build.MODEL).append('\n');
@@ -21,7 +21,7 @@ class GpuMemComponent(private val file: File, private val root: File) : SessionP
thread = Thread({
while (running) {
try { Thread.sleep(PERIOD_MS) } catch (e: InterruptedException) { break }
if (running && (OverlayShown.check(root) || com.droiddeck.launcher.hud.FusionHudHost.showing)) sample()?.let { write(it) }
if (running && (OverlayShown.check(root) || com.droiddeck.launcher.hud.DroidDeckHudHost.showing)) sample()?.let { write(it) }
}
}, "gpu-mem").apply { isDaemon = true; start() }
}
@@ -286,18 +286,18 @@ object SessionPrefs {
prefs(context).edit().putInt("hudOpacity", percent.coerceIn(HUD_OPACITY_RANGE)).apply()
}
fun fusionHudConfig(context: Context): String? = prefs(context).getString("fusionHud", null)
fun droidDeckHudConfig(context: Context): String? = prefs(context).getString("__KEEP_droidDeckHud__", null)
fun setFusionHudConfig(context: Context, config: String) {
prefs(context).edit().putString("fusionHud", config).apply()
fun setDroidDeckHudConfig(context: Context, config: String) {
prefs(context).edit().putString("__KEEP_droidDeckHud__", config).apply()
}
fun fusionHudPosition(context: Context): Pair<Float, Float>? =
prefs(context).getString("fusionHudPos", null)?.split(',')?.mapNotNull { it.toFloatOrNull() }
fun droidDeckHudPosition(context: Context): Pair<Float, Float>? =
prefs(context).getString("__KEEP_droidDeckHudPos__", null)?.split(',')?.mapNotNull { it.toFloatOrNull() }
?.takeIf { it.size == 2 }?.let { it[0] to it[1] }
fun setFusionHudPosition(context: Context, x: Float, y: Float) {
prefs(context).edit().putString("fusionHudPos", "$x,$y").apply()
fun setDroidDeckHudPosition(context: Context, x: Float, y: Float) {
prefs(context).edit().putString("__KEEP_droidDeckHudPos__", "$x,$y").apply()
}
const val HUD_COLOR_MINT = "mint"
@@ -15,7 +15,7 @@ object SettingsReset {
"dualScreenMode", "dualScreenLauncher", "dualScreenSessionControls",
"gameStoresEnabled", "gameStoresSpeedTier", "gameStoresParallel", "storesOpenTab", "storesShowMature",
"storesInstallLanguage",
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "fusionHud", "fusionHudPos", "backActionsInverted", "backDoubleTapMs", "touch", "osc", "shape", "steamController",
"hud", "hudDeck", "hudFps", "hudBattery", "hudGraph", "hudColor", "hudOpacity", "__KEEP_droidDeckHud__", "__KEEP_droidDeckHudPos__", "backActionsInverted", "backDoubleTapMs", "touch", "osc", "shape", "steamController",
"gamepadLeft", "gamepadRight", "pipAutoEnter", "unfoldedControls", "unfoldedControlsWithController",
"stretch16x9", "picturePosition", "railLabels",
"gpuDriverMode", "androidDriver", "linuxDriver", "linuxDriver.steam", "linuxDriver.desktop",
@@ -4,11 +4,11 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import com.droiddeck.launcher.R
import com.droiddeck.launcher.hud.FusionSize
import com.droiddeck.launcher.hud.DroidDeckHudSize
/** Bannerlator's Fusion HUD settings (DeckOverlaySettings): one row per key of the HUD's config string. */
/** Bannerlator's DroidDeck HUD settings (DeckOverlaySettings): one row per key of the HUD's config string. */
@Composable
internal fun FusionHudSettings(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
internal fun DroidDeckHudSettings(host: MenuHost, a: DrawerActions, track: (String) -> Modifier) {
val cfg = a.hudConfig
fun on(key: String) = cfg[key] == "1"
fun int(key: String, fallback: Int) = cfg[key]?.toIntOrNull() ?: fallback
@@ -16,14 +16,14 @@ internal fun FusionHudSettings(host: MenuHost, a: DrawerActions, track: (String)
SettingsGroup(stringResource(R.string.drawer_hud)) {
ToggleRow(host, "hud", stringResource(R.string.drawer_hud), null, a.hudOn, chipModifier = track("hud"), onChange = a.onHud)
if (!a.hudOn) return@SettingsGroup
val size = FusionSize.from(cfg["hudSize"])
val size = DroidDeckHudSize.from(cfg["hudSize"])
ChoiceRow(host, "hud-size", stringResource(R.string.hud_size), stringResource(R.string.hud_size_hint),
listOf(
FusionSize.FULL to stringResource(R.string.hud_size_full),
FusionSize.TILES to stringResource(R.string.hud_size_tiles),
FusionSize.PILL to stringResource(R.string.hud_size_pill),
FusionSize.MINIMAL to stringResource(R.string.hud_size_minimal),
FusionSize.MEGA to stringResource(R.string.hud_size_mega),
DroidDeckHudSize.FULL to stringResource(R.string.hud_size_full),
DroidDeckHudSize.TILES to stringResource(R.string.hud_size_tiles),
DroidDeckHudSize.PILL to stringResource(R.string.hud_size_pill),
DroidDeckHudSize.MINIMAL to stringResource(R.string.hud_size_minimal),
DroidDeckHudSize.MEGA to stringResource(R.string.hud_size_mega),
),
size, chipModifier = track("hud-size")) { a.onHudSetting("hudSize", it.token) }
ToggleRow(host, "hud-locked", stringResource(R.string.hud_locked), stringResource(R.string.hud_locked_hint), on("hudLocked"),
@@ -47,7 +47,7 @@ internal fun FusionHudSettings(host: MenuHost, a: DrawerActions, track: (String)
if (cfg["hudOutlineAccent"] == "0") "0" else "1", chipModifier = track("hud-outline-color")) { a.onHudSetting("hudOutlineAccent", it) }
}
val size = FusionSize.from(cfg["hudSize"])
val size = DroidDeckHudSize.from(cfg["hudSize"])
val chips = size.supportedChips() + EXTRA[size].orEmpty()
SettingsGroup(stringResource(R.string.hud_group_metrics)) {
for (metric in METRICS) {
@@ -84,7 +84,7 @@ internal fun FusionHudSettings(host: MenuHost, a: DrawerActions, track: (String)
}
}
SettingsGroup(stringResource(R.string.hud_group_more), detail = stringResource(R.string.hud_credit)) {
SettingsGroup(stringResource(R.string.hud_group_more)) {
ActionRow(stringResource(R.string.hud_export), stringResource(R.string.hud_export_hint),
stringResource(R.string.hud_export_button), onClick = a.onHudExport, modifier = track("hud-export"))
ActionRow(stringResource(R.string.hud_reset), null, stringResource(R.string.hud_reset_button),
@@ -95,11 +95,11 @@ internal fun FusionHudSettings(host: MenuHost, a: DrawerActions, track: (String)
private fun flag(on: Boolean) = if (on) "1" else "0"
// The Pill also draws the battery temperature and watts.
private val EXTRA = mapOf(FusionSize.PILL to setOf("Temp", "Power"))
private val EXTRA = mapOf(DroidDeckHudSize.PILL to setOf("Temp", "Power"))
private class HudMetric(val chip: String, val key: String, val label: Int)
// FusionSize.supportedChips() names; Wrapper and DX version have nothing to show in DroidDeck.
// DroidDeckHudSize.supportedChips() names; Wrapper and DX version have nothing to show in DroidDeck.
private val METRICS = listOf(
HudMetric("FPS", "showFPS", R.string.drawer_hud_fps),
HudMetric("FPS graph", "showFPSGraph", R.string.hud_metric_graph),
@@ -124,10 +124,10 @@ private val METRICS = listOf(
HudMetric("Clock", "showClock", R.string.hud_metric_clock),
)
// Switches a size lists but never draws (FusionHudView): the Pill and Minimal always show the FPS, the
// Switches a size lists but never draws (DroidDeckHudView): the Pill and Minimal always show the FPS, the
// Pill has no graph, Tiles has no graph and no 0.01% low.
private val HIDDEN = mapOf(
FusionSize.PILL to setOf("FPS", "FPS graph"),
FusionSize.MINIMAL to setOf("FPS"),
FusionSize.TILES to setOf("FPS graph", "0.01% low"),
DroidDeckHudSize.PILL to setOf("FPS", "FPS graph"),
DroidDeckHudSize.MINIMAL to setOf("FPS"),
DroidDeckHudSize.TILES to setOf("FPS graph", "0.01% low"),
)
@@ -533,7 +533,7 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
modifier = Modifier.weight(1f).fillMaxWidth().verticalScroll(pageScroll.getValue(page)),
) { CompositionLocalProvider(LocalChipMinWidth provides 96.dp, LocalCompactSettings provides true) {
when (page) {
SessionDrawerPage.HUD -> FusionHudSettings(host, a) { key -> focus.track(page, key) }
SessionDrawerPage.HUD -> DroidDeckHudSettings(host, a) { key -> focus.track(page, key) }
SessionDrawerPage.DISPLAY -> {
SettingsGroup(stringResource(R.string.drawer_page_display)) {
val fgOpen = host.open == "fg"