mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 04:46:08 +00:00
Rumble: don't restart the vibrator on every force-feedback packet (#514)
fix: stop restarting the vibrator on every force-feedback packet
This commit is contained in:
1 parent
7570ce7e18
commit
e8821f4efc
2 files changed
+36
-2
No files matched your search
@@ -78,6 +78,24 @@ class RumbleComponentTest {
|
||||
assertFalse("the phone buzzed as well", shadowOf(vibrator).isVibrating)
|
||||
}
|
||||
|
||||
@Test fun repeatedAndRapidEffectsDoNotRestartTheMotors() {
|
||||
val pad = FakeMotors()
|
||||
rumble.controllerMotors = { pad }
|
||||
activeController(PAD_ID)
|
||||
repeat(5) { effect(strong = 40000, weak = 1000) }
|
||||
effect(strong = 20000, weak = 1000)
|
||||
assertEquals("a stream of packets restarted the motor each time", 1, pad.played.size)
|
||||
shadowOf(Looper.getMainLooper()).idleFor(java.time.Duration.ofMillis(RumbleComponent.MIN_GAP_MS))
|
||||
effect(strong = 40000, weak = 1000)
|
||||
assertEquals("the same strength, still playing, was started again", 1, pad.played.size)
|
||||
effect(strong = 20000, weak = 1000)
|
||||
assertEquals(Triple(20000, 1000, 5000L), pad.played.last())
|
||||
effect(strong = 0, weak = 0)
|
||||
assertFalse(pad.vibrating)
|
||||
effect(strong = 20000, weak = 1000)
|
||||
assertTrue("an effect right after a stop was dropped", pad.vibrating)
|
||||
}
|
||||
|
||||
@Test fun aControllerWithoutMotorsFallsBackToThePhone() {
|
||||
rumble.controllerMotors = { null }
|
||||
activeController(PAD_ID)
|
||||
|
||||
Reference in new issue
Block a user