mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Sync latest upstream touch handling
This commit is contained in:
4 files changed
+30
-4
No files matched your search
@@ -2394,6 +2394,7 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
||||
gestureConfig = com.droiddeck.launcher.input.GesturePrefs.read(this, gestureGame)
|
||||
gestureTouchStreamGate.reset()
|
||||
if (::touchscreenGestures.isInitialized) touchscreenGestures.configure(gestureConfig)
|
||||
if (::directTouchHold.isInitialized) directTouchHold.configure(gestureConfig)
|
||||
gesturePointerReady = false
|
||||
recognizedGesture = null
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class DirectTouchHold(
|
||||
private var y = 0f
|
||||
private var consumed = false
|
||||
private var pressed = false
|
||||
private var delayMs = 0L
|
||||
private val release = Runnable {
|
||||
if (pressed) listener.onButton(PointerGestures.BTN_RIGHT, false, x, y)
|
||||
pressed = false
|
||||
@@ -28,6 +29,11 @@ class DirectTouchHold(
|
||||
handler.postDelayed(release, 50L)
|
||||
}
|
||||
|
||||
fun configure(config: TouchGestureConfig) {
|
||||
cancel()
|
||||
delayMs = if (config.longPressEnabled) config.longPressDelay.toLong().coerceAtLeast(1L) else 0L
|
||||
}
|
||||
|
||||
fun cancel() {
|
||||
handler.removeCallbacks(hold)
|
||||
handler.removeCallbacks(release)
|
||||
@@ -40,7 +46,7 @@ class DirectTouchHold(
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
cancel()
|
||||
x = event.x; y = event.y
|
||||
handler.postDelayed(hold, 500L)
|
||||
if (delayMs > 0L) handler.postDelayed(hold, delayMs)
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> if (event.pointerCount > 1 ||
|
||||
abs(event.x - x) > slopPx || abs(event.y - y) > slopPx) handler.removeCallbacks(hold)
|
||||
|
||||
Reference in new issue
Block a user