mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
fix(input): suppress two-finger tap clicks, count swapped-screen controls and re-anchor locked swipes
This commit is contained in:
1 parent
5c971344d1
commit
ba50192bfe
5 files changed
+59
-4
No files matched your search
@@ -4089,7 +4089,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
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()
|
||||
val secondary = secondScreenPresentation?.shownControlElements().orEmpty() +
|
||||
swappedControls?.takeIf { it.isShown }?.shownElements().orEmpty()
|
||||
return primary.any { inputProfile.hasMouseButton(InputRole.PRIMARY, it) } ||
|
||||
inputProfile.hasMouseButton(InputRole.SECONDARY, secondary)
|
||||
}
|
||||
@@ -4111,6 +4112,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
|
||||
private var directTouchTapsOff = false
|
||||
private var swappedControls: com.droiddeck.launcher.ui.InputSurfaceView? = null
|
||||
|
||||
private fun moveDirectPointer(x: Float, y: Float) {
|
||||
if (pointerLocked) gestureOutput.moveTo(x, y) else movePointer(x, y)
|
||||
@@ -4130,6 +4132,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||
directTouchTapsOff = onScreenMouseButtonShown()
|
||||
if (::twoFingerGestures.isInitialized) twoFingerGestures.tapClicks = !directTouchTapsOff
|
||||
if (directTouchTapsOff && !programLocksPointer()) {
|
||||
gesturePointerReady = false
|
||||
directTouchHold.cancel()
|
||||
@@ -4137,6 +4140,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
}
|
||||
}
|
||||
if (directTouchTapsOff && !programLocksPointer()) {
|
||||
lockedSwipeX = event.x
|
||||
lockedSwipeY = event.y
|
||||
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)
|
||||
@@ -5217,7 +5222,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
androidx.compose.runtime.key(profileLayout) {
|
||||
androidx.compose.ui.viewinterop.AndroidView(
|
||||
factory = { context -> com.droiddeck.launcher.ui.InputSurfaceView(context, padBridge, profileLayout?.elements.orEmpty(),
|
||||
surfaceStyle = profileLayout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle()) },
|
||||
surfaceStyle = profileLayout?.style ?: com.droiddeck.launcher.input.InputSurfaceStyle())
|
||||
.also { swappedControls = it } },
|
||||
onRelease = { if (swappedControls === it) swappedControls = null },
|
||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
|
||||
|
||||
private enum class State { IDLE, PENDING, CANDIDATE, TAPPED, HELD, SCROLLING, PASSING }
|
||||
|
||||
var tapClicks = true
|
||||
|
||||
private val handler = Handler(Looper.getMainLooper())
|
||||
private var state = State.IDLE
|
||||
private var x = 0f
|
||||
@@ -151,7 +153,7 @@ class TwoFingerGestures(private val slopPx: Float, private val listener: Listene
|
||||
when (was) {
|
||||
State.TAPPED -> {
|
||||
listener.cancelTouch()
|
||||
listener.rightClick(x, y)
|
||||
if (tapClicks) listener.rightClick(x, y)
|
||||
return true
|
||||
}
|
||||
State.SCROLLING, State.HELD -> return true
|
||||
|
||||
@@ -239,7 +239,7 @@ class SecondScreenPresentation(
|
||||
return super.dispatchGenericMotionEvent(event)
|
||||
}
|
||||
|
||||
fun shownControlElements() = controlsView?.takeIf { it.visibility == View.VISIBLE }?.shownElements().orEmpty()
|
||||
fun shownControlElements() = controlsView?.takeIf { isShowing && it.isShown }?.shownElements().orEmpty()
|
||||
|
||||
fun refreshControls() {
|
||||
if (!created || !currentMode.controls) return
|
||||
|
||||
Reference in new issue
Block a user