mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-12 03:21:08 +00:00
fix(input): keep the right button down until every overlapping mouse Back is released
This commit is contained in:
1 parent
db8c66b107
commit
aad60fef5b
2 files changed
+11
-2
No files matched your search
@@ -20,14 +20,14 @@ class MouseBackInput(private val sendRight: (Boolean) -> Unit, private val mouse
|
||||
if (device in held && (fromMouse || injected)) {
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
held.remove(device)
|
||||
sendRight(false)
|
||||
if (held.isEmpty()) sendRight(false)
|
||||
}
|
||||
return true
|
||||
}
|
||||
if (event.action != KeyEvent.ACTION_DOWN || event.repeatCount > 0 || !toGuest) return false
|
||||
if (!fromMouse && !(injected && mouseAttached())) return false
|
||||
if (held.isEmpty()) sendRight(true)
|
||||
held.add(device)
|
||||
sendRight(true)
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -76,6 +76,15 @@ class MouseBackInputTest {
|
||||
assertEquals(listOf(true, false), presses)
|
||||
}
|
||||
|
||||
@Test fun overlappingPressesHoldTheButtonUntilTheLastRelease() {
|
||||
input.onKeyEvent(key(KeyEvent.ACTION_DOWN), toGuest = true)
|
||||
input.onKeyEvent(injected(KeyEvent.ACTION_DOWN), toGuest = true)
|
||||
input.onKeyEvent(key(KeyEvent.ACTION_UP), toGuest = true)
|
||||
assertEquals(listOf(true), presses)
|
||||
input.onKeyEvent(injected(KeyEvent.ACTION_UP), toGuest = true)
|
||||
assertEquals(listOf(true, false), presses)
|
||||
}
|
||||
|
||||
@Test fun cancelReleasesAHeldPressOnce() {
|
||||
input.onKeyEvent(injected(KeyEvent.ACTION_DOWN), toGuest = true)
|
||||
input.cancel()
|
||||
|
||||
Reference in new issue
Block a user