mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-24 23:36:04 +00:00
fix: Steam touch controls appear once the session makes the device; tidier default layout
This commit is contained in:
1 parent
270dfbdcc3
commit
ac8455925e
3 files changed
+19
-9
No files matched your search
@@ -148,6 +148,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
private var steamTouchControls: com.droiddeck.launcher.input.SteamTouchControls? = null
|
private var steamTouchControls: com.droiddeck.launcher.input.SteamTouchControls? = null
|
||||||
private var oscStyle by mutableStateOf(SessionPrefs.OSC_STYLE_DROIDDECK)
|
private var oscStyle by mutableStateOf(SessionPrefs.OSC_STYLE_DROIDDECK)
|
||||||
private var steamTouchAvailable by mutableStateOf(false)
|
private var steamTouchAvailable by mutableStateOf(false)
|
||||||
|
private var steamTouchRetries = 0
|
||||||
|
private val steamTouchRetry = Runnable { updateOnScreenControls() }
|
||||||
private var keyboard: KeyboardHost? = null
|
private var keyboard: KeyboardHost? = null
|
||||||
private var controllerSettings by mutableStateOf<ControllerPrefs.Settings?>(null)
|
private var controllerSettings by mutableStateOf<ControllerPrefs.Settings?>(null)
|
||||||
private val sessionClipboard by lazy {
|
private val sessionClipboard by lazy {
|
||||||
@@ -1853,8 +1855,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
val buttonsOnly = forced == SessionPrefs.OSC_STEAM_QAM
|
val buttonsOnly = forced == SessionPrefs.OSC_STEAM_QAM
|
||||||
// Steam's touch controller stands in for the app's pad, and is plugged into the client only
|
// Steam's touch controller stands in for the app's pad, and is plugged into the client only
|
||||||
// while it is shown - as Steam Link withdraws its controls when a physical pad is in use.
|
// while it is shown - as Steam Link withdraws its controls when a physical pad is in use.
|
||||||
val steam = if (!buttonsOnly && SessionState.mode == SessionService.MODE_STEAM &&
|
val wantsSteam = !buttonsOnly && SessionState.mode == SessionService.MODE_STEAM &&
|
||||||
SessionPrefs.oscStyle(this) == SessionPrefs.OSC_STYLE_STEAM) steamTouch() else null
|
SessionPrefs.oscStyle(this) == SessionPrefs.OSC_STYLE_STEAM
|
||||||
|
val steam = if (wantsSteam) steamTouch() else null
|
||||||
|
// The service makes the device while the session starts, after this activity: the app's
|
||||||
|
// own pad until then, and another look in a moment.
|
||||||
|
if (wantsSteam && steam == null && steamTouchRetries++ < 120) {
|
||||||
|
uiHandler.removeCallbacks(steamTouchRetry)
|
||||||
|
uiHandler.postDelayed(steamTouchRetry, 1000)
|
||||||
|
}
|
||||||
if (steam == null) {
|
if (steam == null) {
|
||||||
steamTouchControls?.let { it.releaseAll(); it.visibility = View.GONE }
|
steamTouchControls?.let { it.releaseAll(); it.visibility = View.GONE }
|
||||||
com.droiddeck.launcher.input.SteamTouchDevice.current?.plugged = false
|
com.droiddeck.launcher.input.SteamTouchDevice.current?.plugged = false
|
||||||
|
|||||||
@@ -226,14 +226,14 @@ object SteamTouchConfig {
|
|||||||
fun defaultElement(type: Int, available: Set<Int>): Element? {
|
fun defaultElement(type: Int, available: Set<Int>): Element? {
|
||||||
val leftStick = JOYSTICK_LEFT in available
|
val leftStick = JOYSTICK_LEFT in available
|
||||||
val rightStick = JOYSTICK_RIGHT in available
|
val rightStick = JOYSTICK_RIGHT in available
|
||||||
val faceY = if (rightStick) -0.33f else 0f
|
val faceY = if (rightStick) -0.30f else 0f
|
||||||
val p: Pair<Float, Float> = when (type) {
|
val p: Pair<Float, Float> = when (type) {
|
||||||
THUMB -> 75f / 1280 to 75f / 720
|
THUMB -> 75f / 1280 to 75f / 720
|
||||||
STEAM -> 636f / 1280 to 75f / 720
|
STEAM -> 636f / 1280 to 75f / 720
|
||||||
SELECT -> 516f / 1280 to 75f / 720
|
SELECT -> 516f / 1280 to 75f / 720
|
||||||
START -> 756f / 1280 to 75f / 720
|
START -> 756f / 1280 to 75f / 720
|
||||||
KEYBOARD -> 1205f / 1280 to 75f / 720
|
KEYBOARD -> 1205f / 1280 to 75f / 720
|
||||||
DPAD -> if (leftStick) 0.147f to 0.43f else 200f / 1280 to 525f / 720
|
DPAD -> if (leftStick) 0.147f to 0.47f else 200f / 1280 to 525f / 720
|
||||||
A -> 1083f / 1280 to 607f / 720 + faceY
|
A -> 1083f / 1280 to 607f / 720 + faceY
|
||||||
B -> 1163f / 1280 to 527f / 720 + faceY
|
B -> 1163f / 1280 to 527f / 720 + faceY
|
||||||
X -> 1003f / 1280 to 527f / 720 + faceY
|
X -> 1003f / 1280 to 527f / 720 + faceY
|
||||||
@@ -242,10 +242,10 @@ object SteamTouchConfig {
|
|||||||
JOYSTICK_RIGHT -> 0.85f to 0.76f
|
JOYSTICK_RIGHT -> 0.85f to 0.76f
|
||||||
JOYSTICK_LEFT_BUTTON -> 0.29f to 0.88f
|
JOYSTICK_LEFT_BUTTON -> 0.29f to 0.88f
|
||||||
JOYSTICK_RIGHT_BUTTON -> 0.71f to 0.88f
|
JOYSTICK_RIGHT_BUTTON -> 0.71f to 0.88f
|
||||||
BUMPER_LEFT -> 0.06f to 0.25f
|
BUMPER_LEFT -> 0.06f to 0.205f
|
||||||
TRIGGER_LEFT -> 0.16f to 0.25f
|
TRIGGER_LEFT -> 0.16f to 0.205f
|
||||||
BUMPER_RIGHT -> 0.94f to 0.25f
|
BUMPER_RIGHT -> 0.94f to 0.205f
|
||||||
TRIGGER_RIGHT -> 0.84f to 0.25f
|
TRIGGER_RIGHT -> 0.84f to 0.205f
|
||||||
TRACKPAD_LEFT -> 0.3f to 0.55f
|
TRACKPAD_LEFT -> 0.3f to 0.55f
|
||||||
TRACKPAD_CENTER -> 0.5f to 0.55f
|
TRACKPAD_CENTER -> 0.5f to 0.55f
|
||||||
TRACKPAD_RIGHT -> 0.7f to 0.55f
|
TRACKPAD_RIGHT -> 0.7f to 0.55f
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ class SteamTouchControls(
|
|||||||
canvas.drawCircle(x, y, r, fill)
|
canvas.drawCircle(x, y, r, fill)
|
||||||
canvas.drawCircle(x, y, r, stroke)
|
canvas.drawCircle(x, y, r, stroke)
|
||||||
val label = label(e.type)
|
val label = label(e.type)
|
||||||
|
if (label.length > 3) text.textSize = r * 0.36f
|
||||||
LABEL_COLORS[e.type]?.let { text.color = it }
|
LABEL_COLORS[e.type]?.let { text.color = it }
|
||||||
canvas.drawText(label, x, y - (text.descent() + text.ascent()) / 2, text)
|
canvas.drawText(label, x, y - (text.descent() + text.ascent()) / 2, text)
|
||||||
}
|
}
|
||||||
@@ -259,7 +260,7 @@ class SteamTouchControls(
|
|||||||
SteamTouchConfig.MACRO_2_FINGER -> "2F"
|
SteamTouchConfig.MACRO_2_FINGER -> "2F"
|
||||||
in SteamTouchConfig.MACRO_0..SteamTouchConfig.MACRO_0 + 7 -> "M${type - SteamTouchConfig.MACRO_0 + 1}"
|
in SteamTouchConfig.MACRO_0..SteamTouchConfig.MACRO_0 + 7 -> "M${type - SteamTouchConfig.MACRO_0 + 1}"
|
||||||
else -> "?"
|
else -> "?"
|
||||||
}.let { if (it == "STEAM") "S" else it }
|
}
|
||||||
|
|
||||||
// ---- The report ----
|
// ---- The report ----
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user