diff --git a/clients/android/app/src/main/kotlin/io/unom/punktfunk/MainActivity.kt b/clients/android/app/src/main/kotlin/io/unom/punktfunk/MainActivity.kt index 99a5845a..0c029a15 100644 --- a/clients/android/app/src/main/kotlin/io/unom/punktfunk/MainActivity.kt +++ b/clients/android/app/src/main/kotlin/io/unom/punktfunk/MainActivity.kt @@ -244,6 +244,13 @@ class MainActivity : ComponentActivity() { lastPadIsGamepad = true lastPadStyle = Gamepad.PadStyle.XBOX // Valve pads carry A/B/X/Y in Xbox positions val action = if (down) KeyEvent.ACTION_DOWN else KeyEvent.ACTION_UP + // The console UI navigates through padKeyProbe (GamepadNavEffect's held-state + repeat + // machinery — A/X/Y/D-pad/Select), NOT the focus system: synthesized events must be + // offered there first, exactly like real ones in dispatchKeyEvent (tester-diagnosed: + // routing everything via super.dispatchKeyEvent bypassed the probe, so only B — which + // never rides key events — did anything). The probes gate on keycode only, so a + // synthetic KeyEvent satisfies them. + padKeyProbe?.let { if (it(KeyEvent(action, keyCode))) return } when (keyCode) { // B → back, on release (same edge the real-pad path uses). KeyEvent.KEYCODE_BUTTON_B -> if (!down) onBackPressedDispatcher.onBackPressed() diff --git a/clients/android/kit/src/main/kotlin/io/unom/punktfunk/kit/Sc2Capture.kt b/clients/android/kit/src/main/kotlin/io/unom/punktfunk/kit/Sc2Capture.kt index e666da6b..5722f118 100644 --- a/clients/android/kit/src/main/kotlin/io/unom/punktfunk/kit/Sc2Capture.kt +++ b/clients/android/kit/src/main/kotlin/io/unom/punktfunk/kit/Sc2Capture.kt @@ -214,7 +214,10 @@ class Sc2Capture( for (key in held) if (key !in uiHeld) sink(key, true) for (key in uiHeld) if (key !in held) sink(key, false) uiHeld = held - // Left stick → one focus step per push (device convention: +y = up). + // Left stick → a HELD D-pad direction (device convention: +y = up): pressed while + // deflected, released on centre/direction change. The console UI's probe machinery + // turns a held direction into its own auto-repeat, exactly like a physical D-pad; the + // focus-hook path moves once per press edge either way. val dir = when { state.lsX <= -STICK_NAV -> android.view.KeyEvent.KEYCODE_DPAD_LEFT state.lsX >= STICK_NAV -> android.view.KeyEvent.KEYCODE_DPAD_RIGHT @@ -223,18 +226,21 @@ class Sc2Capture( else -> 0 } if (dir != uiStickDir) { + // The D-pad bits share these keycodes; don't release a direction the physical + // D-pad itself still holds (uiHeld tracks the button-sourced state). + if (uiStickDir != 0 && uiStickDir !in uiHeld) sink(uiStickDir, false) + if (dir != 0 && dir !in uiHeld) sink(dir, true) uiStickDir = dir - if (dir != 0) { - sink(dir, true) - sink(dir, false) - } } } /** Release every held UI-mode key (link drop / stop) so nothing sticks in the focus system. */ private fun releaseUiKeys() { val sink = onUiKey - if (sink != null) for (key in uiHeld) sink(key, false) + if (sink != null) { + for (key in uiHeld) sink(key, false) + if (uiStickDir != 0 && uiStickDir !in uiHeld) sink(uiStickDir, false) + } uiHeld = HashSet() uiStickDir = 0 }