mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-23 06:46:02 +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 (device in held && (fromMouse || injected)) {
|
||||||
if (event.action == KeyEvent.ACTION_UP) {
|
if (event.action == KeyEvent.ACTION_UP) {
|
||||||
held.remove(device)
|
held.remove(device)
|
||||||
sendRight(false)
|
if (held.isEmpty()) sendRight(false)
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
if (event.action != KeyEvent.ACTION_DOWN || event.repeatCount > 0 || !toGuest) return false
|
if (event.action != KeyEvent.ACTION_DOWN || event.repeatCount > 0 || !toGuest) return false
|
||||||
if (!fromMouse && !(injected && mouseAttached())) return false
|
if (!fromMouse && !(injected && mouseAttached())) return false
|
||||||
|
if (held.isEmpty()) sendRight(true)
|
||||||
held.add(device)
|
held.add(device)
|
||||||
sendRight(true)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,15 @@ class MouseBackInputTest {
|
|||||||
assertEquals(listOf(true, false), presses)
|
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() {
|
@Test fun cancelReleasesAHeldPressOnce() {
|
||||||
input.onKeyEvent(injected(KeyEvent.ACTION_DOWN), toGuest = true)
|
input.onKeyEvent(injected(KeyEvent.ACTION_DOWN), toGuest = true)
|
||||||
input.cancel()
|
input.cancel()
|
||||||
|
|||||||
Reference in new issue
Block a user