fix(input): screen taps move the pointer without clicking while an on-screen mouse button is shown (#2465)

* fix(input): screen taps move the pointer without clicking while an on-screen mouse button is shown

* fix(input): keep tap-to-click with the stock Desktop on-screen gamepad

Only mouse buttons the user bound, not the profile base's stock bindings, make screen taps pointer-only.

* fix(input): count mouse buttons on the second-screen and foldable panels

* fix(input): keep tap clicks off on the swapped panel, copied stock panels and the scroll layer

* fix(input): move the pointer before the desktop gesture buffer when an on-screen mouse button clicks

* fix(input): the on-screen button gate leaves uninitialized gestures alone

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
MaxsTechReviewandKurt Himebauch authored and GitHub committed 2026-11-17 11:21:32 -05:00
1 parent 0794f361ad
commit 7852098e63
12 files changed
+292 -10

No files matched your search

@@ -97,6 +97,16 @@ data class InputLibrary(
fun compileActive(isDesktop: Boolean, panel: String? = null): InputProfile = compileParts(activeId(isDesktop), InputRole.entries.associateWith {
preset(if (it == InputRole.SECONDARY) panelPart(isDesktop, panel).bindings else activePart(isDesktop, it).bindings)
})
fun compileStock(isDesktop: Boolean, panel: String? = null): InputProfile {
val defaults = InputProfile.defaults(profile(activeId(isDesktop)).base)
val stock = InputStockLayouts.presets(InputStockLayouts.layouts())
return compileParts(defaults.id, InputRole.entries.associateWith { role ->
val part = if (role == InputRole.SECONDARY) panelPart(isDesktop, panel) else activePart(isDesktop, role)
val origin = layouts.firstOrNull { it.id == part.layout }?.origin ?: part.layout
stock.firstOrNull { it.id == part.bindings || (origin != null && it.layoutId == origin) }
?: SavedInputBindings(part.bindings, "", role == InputRole.PHYSICAL, part.layout, defaults.bindings[role].orEmpty())
})
}
fun saveSelection(isDesktop: Boolean, name: String, id: String = newInputId()): InputLibrary {
val current = profile(activeId(isDesktop))
@@ -53,6 +53,16 @@ data class InputProfile(
fun elementClickAction(role: InputRole, element: InputSurfaceElement): InputAction = clicks[role]?.get(element.id)
?: defaultElementClick(element, elementAction(role, element.id, element.control)) { action(role, it) }
fun showsMouseButton(role: InputRole, shown: List<InputSurfaceElement>, stock: InputProfile): Boolean = shown.any { element ->
val action = elementAction(role, element.id, element.control).takeIf {
elements[role]?.get(element.id) != stock.elements[role]?.get(element.id) || it != stock.elementAction(role, element.id, element.control)
}
val click = elementClickAction(role, element).takeIf {
clicks[role]?.get(element.id) != stock.clicks[role]?.get(element.id) || it != stock.elementClickAction(role, element)
}
listOfNotNull(action, click).any { it is InputAction.MouseButton && it.validFor(element.control) }
}
companion object {
const val GAME = "game"
const val DESKTOP = "desktop"
@@ -32,6 +32,7 @@ class OnScreenControls(context: Context, pad: PadBridge?, val dock: OnScreenLayo
var isPinnedOnly = false
private set
val hasPinned get() = layout?.elements?.any { it.alwaysShown } == true
val inputSurface: com.droiddeck.launcher.ui.InputSurfaceView get() = surface
var onTouchMiss: ((MotionEvent) -> Unit)?
get() = surface.onTouchMiss
set(value) { surface.onTouchMiss = value }
@@ -42,6 +42,7 @@ class ScrollTouchGestures(
private var flingY = 0f
private var flingAt = 0L
private var flinging = false
var clicks = true
private val longPress = Runnable {
held = true
@@ -86,7 +87,7 @@ class ScrollTouchGestures(
lastY = startY
tracker = VelocityTracker.obtain().also { it.addMovement(event) }
listener.onMove(startX, startY)
handler.postDelayed(longPress, TouchTiming.HOLD_MS)
if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS)
}
MotionEvent.ACTION_MOVE -> {
val index = event.findPointerIndex(pointerId).takeIf { it >= 0 } ?: return true
@@ -153,6 +154,7 @@ class ScrollTouchGestures(
private fun click(button: Int) {
releaseClick()
if (!clicks) return
listener.onButton(button, true)
clicked = button
handler.postDelayed(clickUp, TouchTiming.CLICK_MS)
@@ -17,6 +17,11 @@ class TouchpadGestures(
var bounds: android.graphics.RectF = android.graphics.RectF(0f, 0f, 1f, 1f)
var sensitivity = 1.15f
var desktop = false
var clicks = true
set(value) {
if (field != value) lastTapAt = 0L
field = value
}
private val handler = Handler(Looper.getMainLooper())
private var lastX = 0f
@@ -50,12 +55,17 @@ class TouchpadGestures(
held = true
dragging = true
listener.onLongPress()
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
press(PointerGestures.BTN_LEFT)
}
private val clickUp = Runnable { releaseClick() }
private fun press(button: Int) {
if (clicks) listener.onButton(button, true, x, y)
}
private fun click(button: Int) {
releaseClick()
if (!clicks) return
listener.onButton(button, true, x, y)
clicked = button
handler.postDelayed(clickUp, TouchTiming.CLICK_MS)
@@ -108,12 +118,12 @@ class TouchpadGestures(
travelled = 0f; held = false; twoFingers = false; scrolled = false; secondWasTap = false
fingers = 1; pinching = false
anchorId = event.getPointerId(0); moverId = -1; holdDrag = false; scrollLocked = false
if (event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) {
if (clicks && event.eventTime - lastTapAt < TouchTiming.DOUBLE_TAP_MS) {
dragging = true
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
press(PointerGestures.BTN_LEFT)
} else {
dragging = false
handler.postDelayed(longPress, TouchTiming.HOLD_MS)
if (clicks) handler.postDelayed(longPress, TouchTiming.HOLD_MS)
}
return true
}
@@ -153,7 +163,7 @@ class TouchpadGestures(
secondWasTap = false
if (!dragging) {
dragging = true
listener.onButton(PointerGestures.BTN_LEFT, true, x, y)
press(PointerGestures.BTN_LEFT)
}
}
}