mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
fix(input): keep hold-drag, drop pointer-locked taps and count click actions and second-screen buttons for tap suppression
This commit is contained in:
1 parent
a2a7adc83d
commit
5c971344d1
8 files changed
+101
-21
No files matched your search
@@ -804,7 +804,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
scrollRestY = 0f
|
||||
}
|
||||
override fun replay(event: MotionEvent) {
|
||||
if (directTouchMovesOnly) moveDirectPointer(event.x, event.y)
|
||||
if (directTouchTapsOff && !programLocksPointer()) moveDirectPointer(event.x, event.y)
|
||||
else drawnRect()?.let { forwardTouch(event, it) }
|
||||
}
|
||||
override fun rightClick(x: Float, y: Float) {
|
||||
@@ -4086,10 +4086,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
|
||||
private fun onScreenMouseButtonShown(): Boolean {
|
||||
if (steamTouchControls?.visibility == View.VISIBLE) return false
|
||||
val controls = listOfNotNull(unfoldedPanel, bottomInputControls, onScreenControls)
|
||||
.filter { it.visibility == View.VISIBLE && !it.isButtonsOnly }.map { it.shownElements() }
|
||||
val deck = listOfNotNull(unfoldedDeckSurface?.takeIf { it.visibility == View.VISIBLE }?.shownElements())
|
||||
return (controls + deck).any { inputProfile.hasMouseButton(InputRole.PRIMARY, it) }
|
||||
val primary = listOfNotNull(unfoldedPanel, bottomInputControls, onScreenControls)
|
||||
.filter { it.visibility == View.VISIBLE }.map { it.shownElements() } +
|
||||
listOfNotNull(unfoldedDeckSurface?.takeIf { it.visibility == View.VISIBLE }?.shownElements())
|
||||
val secondary = secondScreenPresentation?.shownControlElements().orEmpty()
|
||||
return primary.any { inputProfile.hasMouseButton(InputRole.PRIMARY, it) } ||
|
||||
inputProfile.hasMouseButton(InputRole.SECONDARY, secondary)
|
||||
}
|
||||
|
||||
private val directTouchSink = object : DirectTouchHold.Touch {
|
||||
@@ -4108,7 +4110,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
showCursor(cx, cy)
|
||||
}
|
||||
|
||||
private var directTouchMovesOnly = false
|
||||
private var directTouchTapsOff = false
|
||||
|
||||
private fun moveDirectPointer(x: Float, y: Float) {
|
||||
if (pointerLocked) gestureOutput.moveTo(x, y) else movePointer(x, y)
|
||||
@@ -4127,22 +4129,24 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
return true
|
||||
}
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||
directTouchMovesOnly = !programLocksPointer() && onScreenMouseButtonShown()
|
||||
if (directTouchMovesOnly) {
|
||||
directTouchTapsOff = onScreenMouseButtonShown()
|
||||
if (directTouchTapsOff && !programLocksPointer()) {
|
||||
gesturePointerReady = false
|
||||
directTouchHold.cancel()
|
||||
WaylandCompositor.nativeSendTouch(3, -1, 0, 0)
|
||||
}
|
||||
}
|
||||
if (directTouchMovesOnly) {
|
||||
if (directTouchTapsOff && !programLocksPointer()) {
|
||||
val handled = SessionState.mode == SessionService.MODE_DESKTOP && twoFingerGestures.onTouch(event)
|
||||
if (!handled && event.actionMasked != MotionEvent.ACTION_UP && event.actionMasked != MotionEvent.ACTION_CANCEL)
|
||||
moveDirectPointer(event.x, event.y)
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) directTouchMovesOnly = false
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) directTouchTapsOff = false
|
||||
return true
|
||||
}
|
||||
if (SessionState.mode == SessionService.MODE_DESKTOP && twoFingerGestures.onTouch(event)) return true
|
||||
return forwardTouch(event, rect)
|
||||
val forwarded = forwardTouch(event, rect)
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) directTouchTapsOff = false
|
||||
return forwarded
|
||||
}
|
||||
|
||||
private fun forwardTouch(event: MotionEvent, rect: android.graphics.RectF): Boolean {
|
||||
@@ -4175,7 +4179,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
}
|
||||
directTouchHold.onTouch(event)
|
||||
if (!directTouchTapsOff) directTouchHold.onTouch(event)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -53,10 +53,11 @@ data class InputProfile(
|
||||
|
||||
fun hasMouseButton(role: InputRole, elements: List<InputSurfaceElement>): Boolean {
|
||||
val stock = defaults(base)
|
||||
fun chosen(action: InputAction, shipped: InputAction) = action is InputAction.MouseButton && action != shipped
|
||||
return elements.any {
|
||||
val action = elementAction(role, it.id, it.control)
|
||||
(it.kind == InputElementKind.BUTTON || it.kind == InputElementKind.TRIGGER) && action is InputAction.MouseButton &&
|
||||
action != stock.elementAction(role, it.id, it.control)
|
||||
val pressable = it.kind == InputElementKind.BUTTON || it.kind == InputElementKind.TRIGGER
|
||||
pressable && chosen(elementAction(role, it.id, it.control), stock.elementAction(role, it.id, it.control)) ||
|
||||
it.hasClick && chosen(elementClickAction(role, it), stock.elementClickAction(role, it))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class ScrollTouchGestures(
|
||||
private fun sample(x: Float, y: Float, t: Long) {
|
||||
if (!scrolling && !dragging && hypot(x - startX, y - startY) > slopPx) {
|
||||
handler.removeCallbacks(longPress)
|
||||
if (held && tapClicks) {
|
||||
if (held) {
|
||||
dragging = true
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true)
|
||||
} else {
|
||||
|
||||
@@ -239,6 +239,8 @@ class SecondScreenPresentation(
|
||||
return super.dispatchGenericMotionEvent(event)
|
||||
}
|
||||
|
||||
fun shownControlElements() = controlsView?.takeIf { it.visibility == View.VISIBLE }?.shownElements().orEmpty()
|
||||
|
||||
fun refreshControls() {
|
||||
if (!created || !currentMode.controls) return
|
||||
val controls = controlsView ?: return
|
||||
|
||||
Reference in new issue
Block a user