mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
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:
1 parent
0794f361ad
commit
7852098e63
12 files changed
+292
-10
No files matched your search
@@ -191,6 +191,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var unfoldedPanel by mutableStateOf<OnScreenControls?>(null)
|
||||
private var unfoldedColumn: android.widget.LinearLayout? = null
|
||||
private var unfoldedDeckSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null
|
||||
private var swappedInputSurface: com.droiddeck.launcher.ui.InputSurfaceView? = null
|
||||
private var unfoldedDeckPanel by mutableStateOf<com.droiddeck.launcher.input.DeckPanel?>(null)
|
||||
private var deckPanelLayouts: Map<com.droiddeck.launcher.input.DeckPanel, com.droiddeck.launcher.input.SavedInputLayout?> = emptyMap()
|
||||
private lateinit var sessionRoot: FrameLayout
|
||||
@@ -200,6 +201,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
@Volatile private var inputUsesLocalActions = false
|
||||
private var inputUsesPointer = false
|
||||
private var inputProfile = InputProfile.defaults(InputProfile.GAME)
|
||||
private var stockInputProfile = InputProfile.defaults(InputProfile.GAME)
|
||||
private val inputMotion = InputMotion { inputRouter }
|
||||
private val heldKeys = HeldInput { code, down -> WaylandCompositor.nativeSendKey(code, if (down) 1 else 0) }
|
||||
private val heldButtons = HeldInput(::sendSceneButton)
|
||||
@@ -893,6 +895,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
drawnRect()?.let { forwardTouch(event, it) }
|
||||
}
|
||||
override fun rightClick(x: Float, y: Float) {
|
||||
if (!screenTapsClick) return
|
||||
pointerListener.onLongPress()
|
||||
pointerListener.onButton(PointerGestures.BTN_RIGHT, true, x, y)
|
||||
surfaceView.postDelayed({ pointerListener.onButton(PointerGestures.BTN_RIGHT, false, x, y) }, 50L)
|
||||
@@ -4278,6 +4281,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
val library = com.droiddeck.launcher.input.InputLibraries.read(this)
|
||||
val desktop = loadingMode() == SessionService.MODE_DESKTOP
|
||||
inputProfile = library.compileActive(desktop, secondScreenMode.panel(this))
|
||||
stockInputProfile = library.compileStock(desktop, secondScreenMode.panel(this))
|
||||
primaryInputLayout = library.activeLayout(desktop, InputRole.PRIMARY)
|
||||
adaptiveSticks = primaryInputLayout?.adaptiveSticks
|
||||
quickButtons = primaryInputLayout?.takeIf { it.editable }?.let { l -> l.quickButtons.associateWith { it !in l.style.hidden } }.orEmpty()
|
||||
@@ -4735,6 +4739,12 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
private var lockedSwipeY = 0f
|
||||
private var dismissTouch = false
|
||||
private var sessionTouchDown = false
|
||||
private var screenTapsClick = true
|
||||
|
||||
private fun onScreenMouseButtonShown(): Boolean = listOfNotNull(
|
||||
onScreenControls?.inputSurface, bottomInputControls?.inputSurface, unfoldedPanel?.inputSurface, unfoldedDeckSurface,
|
||||
secondScreenPresentation?.controlsView, swappedInputSurface,
|
||||
).any { it.isShown && inputProfile.showsMouseButton(it.inputRole, it.shownElements, stockInputProfile) }
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
val pen = PenStream.penIndex(event)
|
||||
@@ -4767,6 +4777,11 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
val snapshot = fingerTouchSnapshot(uiBlocking)
|
||||
val route = com.droiddeck.launcher.input.TouchRouter.decide(snapshot)
|
||||
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
|
||||
screenTapsClick = !onScreenMouseButtonShown()
|
||||
if (::touchpad.isInitialized) touchpad.clicks = screenTapsClick
|
||||
if (::scrollTouch.isInitialized) scrollTouch.clicks = screenTapsClick
|
||||
}
|
||||
if (route != touchRoute) {
|
||||
Log.i(TAG, "touch route $touchRoute -> $route (mode=$routedTouchMode steamUi=${SessionState.steamUi} scrollLayer=$scrollTouchGesture)")
|
||||
touchRoute = route
|
||||
@@ -4916,6 +4931,10 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
if (event.actionMasked == MotionEvent.ACTION_UP || event.actionMasked == MotionEvent.ACTION_CANCEL) ignoreGameTouch = false
|
||||
return true
|
||||
}
|
||||
// With an on-screen mouse button the press comes from the button, so the pointer has to be there before
|
||||
// the two-finger gesture buffer holds the touch-down.
|
||||
if (SessionState.mode == SessionService.MODE_DESKTOP && !screenTapsClick && !pointerLocked &&
|
||||
event.actionMasked == MotionEvent.ACTION_DOWN) movePointer(event.x, event.y)
|
||||
if (SessionState.mode == SessionService.MODE_DESKTOP && twoFingerGestures.onTouch(event)) return true
|
||||
return forwardTouch(event, rect)
|
||||
}
|
||||
@@ -4950,7 +4969,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
}
|
||||
}
|
||||
}
|
||||
directTouchHold.onTouch(event)
|
||||
if (screenTapsClick) directTouchHold.onTouch(event)
|
||||
else if (!pointerLocked && (event.actionMasked == MotionEvent.ACTION_DOWN || event.actionMasked == MotionEvent.ACTION_MOVE))
|
||||
movePointer(event.x, event.y)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -6045,8 +6066,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
|
||||
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 { swappedInputSurface = it } },
|
||||
modifier = Modifier.fillMaxWidth().weight(1f),
|
||||
onRelease = { if (swappedInputSurface === it) swappedInputSurface = null },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user