mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
fix(input): keep stock Desktop tap-to-click and cover direct and scroll touch routes
Only mouse buttons that differ from the shipped bindings count as user-picked. Direct touch moves the pointer instead of tapping and the scroll layer stops clicking while such a button is shown.
This commit is contained in:
1 parent
8c3d6cfaad
commit
f6e109ef61
6 files changed
+78
-10
No files matched your search
@@ -4046,7 +4046,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) gesturePointerReady = false
|
||||
touchscreenGestures.onTouch(event)
|
||||
}
|
||||
com.droiddeck.launcher.input.TouchRouter.Route.SCROLL -> scrollTouch.onTouch(event)
|
||||
com.droiddeck.launcher.input.TouchRouter.Route.SCROLL -> {
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) scrollTouch.tapClicks = !onScreenMouseButtonShown()
|
||||
scrollTouch.onTouch(event)
|
||||
}
|
||||
else -> {
|
||||
if (com.droiddeck.launcher.input.TouchRouter.steamKeyboardZone(snapshot)) {
|
||||
val wasActive = threeFingerTap.active && event.actionMasked != MotionEvent.ACTION_DOWN
|
||||
@@ -4104,6 +4107,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
showCursor(cx, cy)
|
||||
}
|
||||
|
||||
private var directTouchMovesOnly = false
|
||||
|
||||
private fun dispatchDirectTouch(event: MotionEvent): Boolean {
|
||||
val rect = drawnRect() ?: return false
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN)
|
||||
@@ -4116,6 +4121,18 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) ignoreGameTouch = false
|
||||
return true
|
||||
}
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||
directTouchMovesOnly = !programLocksPointer() && onScreenMouseButtonShown()
|
||||
if (directTouchMovesOnly) {
|
||||
directTouchHold.cancel()
|
||||
WaylandCompositor.nativeSendTouch(3, -1, 0, 0)
|
||||
}
|
||||
}
|
||||
if (directTouchMovesOnly) {
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) directTouchMovesOnly = false
|
||||
else movePointer(event.x, event.y)
|
||||
return true
|
||||
}
|
||||
if (SessionState.mode == SessionService.MODE_DESKTOP && twoFingerGestures.onTouch(event)) return true
|
||||
return forwardTouch(event, rect)
|
||||
}
|
||||
|
||||
@@ -50,8 +50,13 @@ data class InputProfile(
|
||||
fun elementAction(role: InputRole, id: String, control: InputControl): InputAction =
|
||||
elements[role]?.get(id) ?: if (id == "legacy:${control.id}") action(role, control) else InputAction.Disabled
|
||||
|
||||
fun hasMouseButton(role: InputRole, elements: List<InputSurfaceElement>) = elements.any {
|
||||
(it.kind == InputElementKind.BUTTON || it.kind == InputElementKind.TRIGGER) && elementAction(role, it.id, it.control) is InputAction.MouseButton
|
||||
fun hasMouseButton(role: InputRole, elements: List<InputSurfaceElement>): Boolean {
|
||||
val stock = defaults(id)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
fun elementClickAction(role: InputRole, element: InputSurfaceElement): InputAction = clicks[role]?.get(element.id)
|
||||
|
||||
@@ -34,6 +34,7 @@ class ScrollTouchGestures(
|
||||
private var movedAt = 0L
|
||||
private var scrolling = false
|
||||
private var vertical = true
|
||||
var tapClicks = true
|
||||
private var held = false
|
||||
private var dragging = false
|
||||
private var stoppedFling = false
|
||||
@@ -129,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) {
|
||||
if (held && tapClicks) {
|
||||
dragging = true
|
||||
listener.onButton(PointerGestures.BTN_LEFT, true)
|
||||
} else {
|
||||
@@ -152,6 +153,7 @@ class ScrollTouchGestures(
|
||||
}
|
||||
|
||||
private fun click(button: Int) {
|
||||
if (!tapClicks) return
|
||||
releaseClick()
|
||||
listener.onButton(button, true)
|
||||
clicked = button
|
||||
|
||||
Reference in new issue
Block a user