mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 21:15:43 +00:00
fix(input): ignore touchpad taps while an on-screen mouse button is shown
This commit is contained in:
1 parent
b1a410ccd2
commit
0d06d3d1d6
5 files changed
+91
-1
No files matched your search
@@ -4069,6 +4069,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||
touchpad.desktop = SessionState.mode == SessionService.MODE_DESKTOP
|
||||
touchpad.tapClicks = !onScreenMouseButtonShown()
|
||||
placeTouchpadAtGuest(rect)
|
||||
}
|
||||
touchpad.onTouch(event)
|
||||
@@ -4079,6 +4080,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
|
||||
private fun onScreenMouseButtonShown(): Boolean {
|
||||
val layout = primaryInputLayout ?: return false
|
||||
return onScreenButtonsVisible && !steamTouchInUse && onScreenControls?.isButtonsOnly != true &&
|
||||
inputProfile.hasMouseButton(InputRole.PRIMARY, layout.style.shown(layout.elements))
|
||||
}
|
||||
|
||||
private val directTouchSink = object : DirectTouchHold.Touch {
|
||||
override fun down(pointerId: Int, x: Float, y: Float) = sendDirectTouch(0, pointerId, x, y)
|
||||
override fun move(pointerId: Int, x: Float, y: Float) = sendDirectTouch(1, pointerId, x, y)
|
||||
|
||||
@@ -50,6 +50,10 @@ 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 elementClickAction(role: InputRole, element: InputSurfaceElement): InputAction = clicks[role]?.get(element.id)
|
||||
?: defaultElementClick(element, elementAction(role, element.id, element.control)) { action(role, it) }
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ class TouchpadGestures(
|
||||
var bounds: android.graphics.RectF = android.graphics.RectF(0f, 0f, 1f, 1f)
|
||||
var sensitivity = 1.15f
|
||||
var desktop = false
|
||||
var tapClicks = true
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private var lastX = 0f
|
||||
@@ -55,6 +56,7 @@ class TouchpadGestures(
|
||||
private val clickUp = Runnable { releaseClick() }
|
||||
|
||||
private fun click(button: Int) {
|
||||
if (!tapClicks) return
|
||||
releaseClick()
|
||||
listener.onButton(button, true, x, y)
|
||||
clicked = button
|
||||
@@ -262,7 +264,7 @@ class TouchpadGestures(
|
||||
}
|
||||
!cancelled && travelled <= slopPx && event.eventTime - downAt < TouchTiming.TAP_MS -> {
|
||||
click(PointerGestures.BTN_LEFT)
|
||||
lastTapAt = event.eventTime
|
||||
if (tapClicks) lastTapAt = event.eventTime
|
||||
}
|
||||
}
|
||||
dragging = false; held = false; twoFingers = false
|
||||
|
||||
Reference in new issue
Block a user