mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-08 08:04:47 -10:00
fix(input): delay held QAM to 700 ms
This commit is contained in:
1 parent
fa5506df35
commit
749ade4a45
4 files changed
+20
-14
No files matched your search
@@ -37,7 +37,7 @@ class BackQamInput(private val setPressed: (Boolean) -> Unit, private val onTap:
|
||||
if (!alreadyHeld) setPressed(true)
|
||||
}
|
||||
presses[device] = Press(hold, used = presses.values.any { it.held })
|
||||
handler.postDelayed(hold, 500)
|
||||
handler.postDelayed(hold, 700)
|
||||
true
|
||||
}
|
||||
KeyEvent.ACTION_UP -> {
|
||||
|
||||
@@ -607,9 +607,6 @@ internal fun SessionDrawer(open: Boolean, requestedPage: SessionDrawerPage, cont
|
||||
if (a.steam) ChoiceRow(host, "back-actions", stringResource(R.string.mode_back), null,
|
||||
listOf(false to stringResource(SessionPrefs.BACK_MENU_THEN_QAM), true to stringResource(SessionPrefs.BACK_QAM_THEN_MENU)),
|
||||
a.backActionsInverted, chipModifier = focus.track(page, "back-actions"), onPick = a.onBackActionsInverted)
|
||||
if (a.steam && a.padType in listOf(SessionPrefs.CONTROLLER_DECK, SessionPrefs.CONTROLLER_STEAM)) {
|
||||
Note(stringResource(R.string.back_native_qam_hint))
|
||||
}
|
||||
if (a.steam && a.unfoldedControls != null) ToggleRow(host, "unfolded-controls", stringResource(R.string.unfolded_controls),
|
||||
stringResource(R.string.unfolded_controls_hint), a.unfoldedControls,
|
||||
chipModifier = focus.track(page, "unfolded-controls"), onChange = a.onUnfoldedControls)
|
||||
|
||||
@@ -306,7 +306,7 @@
|
||||
<string name="mode_controller_x360">Xbox 360 controller</string>
|
||||
<string name="mode_controller_note">Deck: Quick Access button and gyro. Steam Controller: the same, with grip sense on the back buttons. DualShock 4 and DualSense: gyro, and the trackpads as their touchpad. Xbox 360: open Quick Access with Guide+A.</string>
|
||||
<string name="mode_back">Back</string>
|
||||
<string name="back_native_qam_hint">Hold Back for 500 ms, then press another button for Steam shortcuts. Single and double taps keep the selected actions.</string>
|
||||
<string name="back_native_qam_hint">Hold Back for 700 ms, then press another button for Steam shortcuts. Single and double taps keep the selected actions.</string>
|
||||
<string name="brightness_permission_title">Allow brightness control</string>
|
||||
<string name="brightness_permission_text">Tap to allow Steam to change Android screen brightness.</string>
|
||||
<string name="back_menu_then_qam">Menu → QAM</string>
|
||||
|
||||
@@ -40,9 +40,9 @@ class BackQamInputTest {
|
||||
assertTrue(changes.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun aHoldStartsAt500msAndNeverProducesATap() {
|
||||
@Test fun aHoldStartsAt700msAndNeverProducesATap() {
|
||||
assertTrue(send(KeyEvent.ACTION_DOWN))
|
||||
advance(499)
|
||||
advance(699)
|
||||
assertTrue(changes.isEmpty())
|
||||
advance(1)
|
||||
for (repeat in 1..10) assertTrue(send(KeyEvent.ACTION_DOWN, repeat = repeat))
|
||||
@@ -54,12 +54,21 @@ class BackQamInputTest {
|
||||
assertTrue(taps.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun releasingBetween500And700msStillProducesASingleTap() {
|
||||
send(KeyEvent.ACTION_DOWN)
|
||||
advance(600)
|
||||
send(KeyEvent.ACTION_UP)
|
||||
advance(500)
|
||||
assertEquals(listOf(false), taps)
|
||||
assertTrue(changes.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun holdingTheSecondPressCancelsTheFirstTap() {
|
||||
send(KeyEvent.ACTION_DOWN)
|
||||
send(KeyEvent.ACTION_UP)
|
||||
advance(400)
|
||||
send(KeyEvent.ACTION_DOWN)
|
||||
advance(499)
|
||||
advance(699)
|
||||
assertTrue(taps.isEmpty())
|
||||
advance(1)
|
||||
assertEquals(listOf(true), changes)
|
||||
@@ -70,7 +79,7 @@ class BackQamInputTest {
|
||||
|
||||
@Test fun otherButtonsAndSelectPassThroughWhileBackIsHeld() {
|
||||
send(KeyEvent.ACTION_DOWN)
|
||||
advance(500)
|
||||
advance(700)
|
||||
for (code in listOf(KeyEvent.KEYCODE_BUTTON_X, KeyEvent.KEYCODE_BUTTON_SELECT)) {
|
||||
for (action in listOf(KeyEvent.ACTION_DOWN, KeyEvent.ACTION_UP)) {
|
||||
assertFalse(input.onKeyEvent(KeyEvent(action, code), true))
|
||||
@@ -90,7 +99,7 @@ class BackQamInputTest {
|
||||
|
||||
@Test fun losingFocusReleasesQamAndConsumesTheLateRelease() {
|
||||
send(KeyEvent.ACTION_DOWN)
|
||||
advance(500)
|
||||
advance(700)
|
||||
input.cancel()
|
||||
input.cancel()
|
||||
assertTrue(send(KeyEvent.ACTION_DOWN, repeat = 1, enabled = false))
|
||||
@@ -120,7 +129,7 @@ class BackQamInputTest {
|
||||
|
||||
@Test fun openingAnOverlayReleasesQamBeforeRoutingItsNextKey() {
|
||||
send(KeyEvent.ACTION_DOWN)
|
||||
advance(500)
|
||||
advance(700)
|
||||
assertFalse(input.onKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_B), false))
|
||||
assertTrue(send(KeyEvent.ACTION_UP, enabled = false))
|
||||
assertEquals(listOf(true, false), changes)
|
||||
@@ -128,13 +137,13 @@ class BackQamInputTest {
|
||||
|
||||
@Test fun repeatsAfterCancellationCannotReassertQam() {
|
||||
send(KeyEvent.ACTION_DOWN)
|
||||
advance(500)
|
||||
advance(700)
|
||||
input.cancel()
|
||||
assertTrue(send(KeyEvent.ACTION_DOWN, repeat = 1))
|
||||
advance(1000)
|
||||
assertEquals(listOf(true, false), changes)
|
||||
assertTrue(send(KeyEvent.ACTION_DOWN))
|
||||
advance(500)
|
||||
advance(700)
|
||||
assertTrue(send(KeyEvent.ACTION_UP))
|
||||
assertEquals(listOf(true, false, true, false), changes)
|
||||
}
|
||||
@@ -151,7 +160,7 @@ class BackQamInputTest {
|
||||
@Test fun removingOneDeviceDoesNotReleaseAnotherDevicesHold() {
|
||||
send(KeyEvent.ACTION_DOWN, device = 4)
|
||||
send(KeyEvent.ACTION_DOWN, device = 5)
|
||||
advance(500)
|
||||
advance(700)
|
||||
input.onDeviceRemoved(4)
|
||||
assertEquals(listOf(true), changes)
|
||||
send(KeyEvent.ACTION_UP, device = 5)
|
||||
|
||||
Reference in new issue
Block a user