mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 15:56:01 +00:00
Revert "Improve accelerated drawer stick navigation"
This reverts commit 10f5506829.
This commit is contained in:
1 parent
9222f2e8e9
commit
582e467583
1 file changed
+3
-29
@@ -93,7 +93,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
private var drawerDirectionKey = KeyEvent.KEYCODE_UNKNOWN
|
private var drawerDirectionKey = KeyEvent.KEYCODE_UNKNOWN
|
||||||
private var drawerDirectionDownTime = 0L
|
private var drawerDirectionDownTime = 0L
|
||||||
private var drawerDirectionLastRepeat = 0L
|
private var drawerDirectionLastRepeat = 0L
|
||||||
private var drawerDirectionRepeatCount = 0
|
|
||||||
private var drawerDirectionDeviceId = -1
|
private var drawerDirectionDeviceId = -1
|
||||||
|
|
||||||
// Compose reads these; the activity writes them.
|
// Compose reads these; the activity writes them.
|
||||||
@@ -743,18 +742,8 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
val hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y)
|
val hatY = event.getAxisValue(MotionEvent.AXIS_HAT_Y)
|
||||||
val x = if (abs(hatX) > 0.4f) hatX else event.getAxisValue(MotionEvent.AXIS_X)
|
val x = if (abs(hatX) > 0.4f) hatX else event.getAxisValue(MotionEvent.AXIS_X)
|
||||||
val y = if (abs(hatY) > 0.4f) hatY else event.getAxisValue(MotionEvent.AXIS_Y)
|
val y = if (abs(hatY) > 0.4f) hatY else event.getAxisValue(MotionEvent.AXIS_Y)
|
||||||
val heldDirection = drawerDirectionKey.takeIf {
|
|
||||||
when (it) {
|
|
||||||
KeyEvent.KEYCODE_DPAD_LEFT -> -x >= DRAWER_DIRECTION_RELEASE_THRESHOLD
|
|
||||||
KeyEvent.KEYCODE_DPAD_RIGHT -> x >= DRAWER_DIRECTION_RELEASE_THRESHOLD
|
|
||||||
KeyEvent.KEYCODE_DPAD_UP -> -y >= DRAWER_DIRECTION_RELEASE_THRESHOLD
|
|
||||||
KeyEvent.KEYCODE_DPAD_DOWN -> y >= DRAWER_DIRECTION_RELEASE_THRESHOLD
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val keyCode = when {
|
val keyCode = when {
|
||||||
heldDirection != null -> heldDirection
|
maxOf(abs(x), abs(y)) < 0.45f -> KeyEvent.KEYCODE_UNKNOWN
|
||||||
maxOf(abs(x), abs(y)) < DRAWER_DIRECTION_ENGAGE_THRESHOLD -> KeyEvent.KEYCODE_UNKNOWN
|
|
||||||
abs(x) > abs(y) && x < 0f -> KeyEvent.KEYCODE_DPAD_LEFT
|
abs(x) > abs(y) && x < 0f -> KeyEvent.KEYCODE_DPAD_LEFT
|
||||||
abs(x) > abs(y) -> KeyEvent.KEYCODE_DPAD_RIGHT
|
abs(x) > abs(y) -> KeyEvent.KEYCODE_DPAD_RIGHT
|
||||||
y < 0f -> KeyEvent.KEYCODE_DPAD_UP
|
y < 0f -> KeyEvent.KEYCODE_DPAD_UP
|
||||||
@@ -768,29 +757,17 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
drawerDirectionDeviceId = event.deviceId
|
drawerDirectionDeviceId = event.deviceId
|
||||||
drawerDirectionDownTime = now
|
drawerDirectionDownTime = now
|
||||||
drawerDirectionLastRepeat = now
|
drawerDirectionLastRepeat = now
|
||||||
drawerDirectionRepeatCount = 0
|
|
||||||
dispatchDrawerKey(KeyEvent.ACTION_DOWN, 0, now)
|
dispatchDrawerKey(KeyEvent.ACTION_DOWN, 0, now)
|
||||||
} else if (keyCode != KeyEvent.KEYCODE_UNKNOWN &&
|
} else if (keyCode != KeyEvent.KEYCODE_UNKNOWN && now - drawerDirectionLastRepeat >= 240L) {
|
||||||
now - drawerDirectionLastRepeat >= drawerDirectionRepeatIntervalMs()) {
|
|
||||||
drawerDirectionLastRepeat = now
|
drawerDirectionLastRepeat = now
|
||||||
drawerDirectionRepeatCount++
|
dispatchDrawerKey(KeyEvent.ACTION_DOWN, 1, now)
|
||||||
dispatchDrawerKey(KeyEvent.ACTION_DOWN, drawerDirectionRepeatCount, now)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun drawerDirectionRepeatIntervalMs(): Long = when (drawerDirectionRepeatCount) {
|
|
||||||
0 -> DRAWER_DIRECTION_INITIAL_REPEAT_MS
|
|
||||||
1 -> 250L
|
|
||||||
2 -> 180L
|
|
||||||
3 -> 135L
|
|
||||||
else -> 105L
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun releaseDrawerDirection() {
|
private fun releaseDrawerDirection() {
|
||||||
if (drawerDirectionKey == KeyEvent.KEYCODE_UNKNOWN) return
|
if (drawerDirectionKey == KeyEvent.KEYCODE_UNKNOWN) return
|
||||||
dispatchDrawerKey(KeyEvent.ACTION_UP, 0, SystemClock.uptimeMillis())
|
dispatchDrawerKey(KeyEvent.ACTION_UP, 0, SystemClock.uptimeMillis())
|
||||||
drawerDirectionKey = KeyEvent.KEYCODE_UNKNOWN
|
drawerDirectionKey = KeyEvent.KEYCODE_UNKNOWN
|
||||||
drawerDirectionRepeatCount = 0
|
|
||||||
drawerDirectionDeviceId = -1
|
drawerDirectionDeviceId = -1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1125,9 +1102,6 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback {
|
|||||||
companion object {
|
companion object {
|
||||||
private const val TAG = "SessionActivity"
|
private const val TAG = "SessionActivity"
|
||||||
private const val BACK_DOUBLE_PRESS_TIMEOUT_MS = 500L
|
private const val BACK_DOUBLE_PRESS_TIMEOUT_MS = 500L
|
||||||
private const val DRAWER_DIRECTION_ENGAGE_THRESHOLD = 0.55f
|
|
||||||
private const val DRAWER_DIRECTION_RELEASE_THRESHOLD = 0.30f
|
|
||||||
private const val DRAWER_DIRECTION_INITIAL_REPEAT_MS = 420L
|
|
||||||
/** Compositor scale modes (Container.FULLSCREEN_* values): 1 = fit with bars, centred. */
|
/** Compositor scale modes (Container.FULLSCREEN_* values): 1 = fit with bars, centred. */
|
||||||
private const val SCALE_FIT = 1
|
private const val SCALE_FIT = 1
|
||||||
private const val ALIGN_CENTER = 0
|
private const val ALIGN_CENTER = 0
|
||||||
|
|||||||
Reference in new issue
Block a user