mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 13:26:02 +00:00
fix(input): Steam touch tint colors the D-pad and system buttons again
This commit is contained in:
1 parent
e67c185f13
commit
0364792111
2 files changed
+10
-7
No files matched your search
@@ -294,7 +294,7 @@ class SteamTouchControls(
|
||||
val held = (if (bits and DPAD_UP != 0L) 1 else 0) or (if (bits and DPAD_RIGHT != 0L) 2 else 0) or
|
||||
(if (bits and DPAD_DOWN != 0L) 4 else 0) or (if (bits and DPAD_LEFT != 0L) 8 else 0)
|
||||
canvas.save(); canvas.translate(x - r, y - r)
|
||||
art.dpad(canvas, 2 * r, 2 * r, PadKit.STEAM_DECK, held)
|
||||
art.dpad(canvas, 2 * r, 2 * r, PadKit.STEAM_DECK, held, ink = glyphInk())
|
||||
canvas.restore()
|
||||
}
|
||||
SteamTouchConfig.JOYSTICK_LEFT, SteamTouchConfig.JOYSTICK_RIGHT -> {
|
||||
@@ -333,10 +333,13 @@ class SteamTouchControls(
|
||||
private fun systemButton(canvas: Canvas, x: Float, y: Float, r: Float, shape: com.droiddeck.launcher.ui.PadArt.Shape,
|
||||
icon: com.droiddeck.launcher.ui.PadArt.Icon, pressed: Boolean) {
|
||||
canvas.save(); canvas.translate(x - r * 1.4f, y - r * 1.4f)
|
||||
art.system(canvas, r * 2.8f, r * 2.8f, shape, icon, pressed)
|
||||
art.system(canvas, r * 2.8f, r * 2.8f, shape, icon, pressed, glyphInk())
|
||||
canvas.restore()
|
||||
}
|
||||
|
||||
/** Glyphs follow the colour picked for Steam touch controls; white keeps the shared artwork's own ink. */
|
||||
private fun glyphInk() = if (tint != Color.WHITE) tint else com.droiddeck.launcher.ui.PadArt.INK
|
||||
|
||||
private fun isSquare(type: Int) = type in setOf(SteamTouchConfig.BUMPER_LEFT, SteamTouchConfig.BUMPER_RIGHT,
|
||||
SteamTouchConfig.TRIGGER_LEFT, SteamTouchConfig.TRIGGER_RIGHT, SteamTouchConfig.THUMB, SteamTouchConfig.KEYBOARD,
|
||||
SteamTouchConfig.PASTE, SteamTouchConfig.MACRO_1_FINGER, SteamTouchConfig.MACRO_2_FINGER) ||
|
||||
@@ -359,7 +362,7 @@ class SteamTouchControls(
|
||||
val icon = binding?.icon?.takeIf { it.isNotEmpty() }?.let(::iconOrLoad)
|
||||
val custom = binding != null && binding.background.isNotEmpty() && !binding.background.equals(SteamTouchBindings.DEFAULT_BACKGROUND, true)
|
||||
art.glass(canvas, shape, pressed && !custom, if (custom) parseColor(binding!!.background, SteamTouchBindings.DEFAULT_BACKGROUND) else 0x850E1014.toInt())
|
||||
val ink = if (pressed && !custom) com.droiddeck.launcher.ui.PadArt.ON_ACCENT else if (tint != Color.WHITE) tint else com.droiddeck.launcher.ui.PadArt.INK
|
||||
val ink = if (pressed && !custom) com.droiddeck.launcher.ui.PadArt.ON_ACCENT else glyphInk()
|
||||
if (icon != null) {
|
||||
val s = r * 0.62f
|
||||
if (custom) canvas.drawBitmap(tinted(binding!!.icon, icon, binding.foreground), null, RectF(x - s, y - s, x + s, y + s), Paint(Paint.ANTI_ALIAS_FLAG or Paint.FILTER_BITMAP_FLAG))
|
||||
|
||||
@@ -124,7 +124,7 @@ internal class PadArt(context: Context) {
|
||||
enum class Shape { ROUND, PILL, CHIP }
|
||||
enum class Icon { VIEW, MENU, QAM, KEYBOARD, BACK, START, CREATE, HOME, STEAM, SHARE, OPTIONS, MARK }
|
||||
|
||||
fun system(canvas: Canvas, w: Float, h: Float, shape: Shape, icon: Icon, pressed: Boolean) {
|
||||
fun system(canvas: Canvas, w: Float, h: Float, shape: Shape, icon: Icon, pressed: Boolean, ink: Int = INK) {
|
||||
val cx = w / 2f; val cy = h / 2f
|
||||
val size = when (shape) {
|
||||
Shape.ROUND -> { val r = min(w, h) / 2f * VISUAL; glass(canvas, circle(cx, cy, r), pressed); r * 1.2f }
|
||||
@@ -133,7 +133,7 @@ internal class PadArt(context: Context) {
|
||||
Shape.CHIP -> { val vh = min(h * VISUAL, w * VISUAL / 1.9f); val vw = vh * 1.9f
|
||||
glass(canvas, roundRect(cx - vw / 2, cy - vh / 2, cx + vw / 2, cy + vh / 2, vh * .32f), pressed); vh * 1.05f }
|
||||
}
|
||||
icon(canvas, cx, cy, size, icon, if (pressed) ON_ACCENT else INK)
|
||||
icon(canvas, cx, cy, size, icon, if (pressed) ON_ACCENT else ink)
|
||||
}
|
||||
|
||||
fun icon(canvas: Canvas, cx: Float, cy: Float, size: Float, icon: Icon, color: Int) {
|
||||
@@ -208,7 +208,7 @@ internal class PadArt(context: Context) {
|
||||
}
|
||||
|
||||
/** [held] bits: up 1, right 2, down 4, left 8. */
|
||||
fun dpad(canvas: Canvas, w: Float, h: Float, kit: PadKit, held: Int, chevrons: Boolean = true) {
|
||||
fun dpad(canvas: Canvas, w: Float, h: Float, kit: PadKit, held: Int, chevrons: Boolean = true, ink: Int = INK) {
|
||||
val cx = w / 2f; val cy = h / 2f
|
||||
val s = min(w, h) / 2f - dp(3f)
|
||||
val dirs = arrayOf(floatArrayOf(0f, -1f), floatArrayOf(1f, 0f), floatArrayOf(0f, 1f), floatArrayOf(-1f, 0f))
|
||||
@@ -235,7 +235,7 @@ internal class PadArt(context: Context) {
|
||||
canvas.drawRoundRect(rect, half * .4f, half * .4f, fill)
|
||||
}
|
||||
val m = (arms + half) / 2f
|
||||
if (chevrons) chevron(canvas, cx + dx * m, cy + dy * m, dx, dy, half * .32f, if (on) ON_ACCENT else INK, half * .17f)
|
||||
if (chevrons) chevron(canvas, cx + dx * m, cy + dy * m, dx, dy, half * .32f, if (on) ON_ACCENT else ink, half * .17f)
|
||||
}
|
||||
if (!disc) { fill.shader = null; fill.color = Color.argb(18, 255, 255, 255); canvas.drawCircle(cx, cy, half * .36f, fill) }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user