mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 07:46:01 +00:00
feat(steam): optional Steam integration setup (#1637)
* feat(steam): add optional device integration setup * feat(steam): show integration setup as inline settings rows * fix(steam): offer App info when shortcuts stay blocked
This commit is contained in:
1 parent
73daaf7adc
commit
f13916ee25
20 files changed
+813
-94
No files matched your search
@@ -0,0 +1,62 @@
|
||||
package com.droiddeck.launcher.input
|
||||
|
||||
import android.app.Application
|
||||
import android.view.KeyEvent
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28, 33], manifest = Config.NONE, application = Application::class)
|
||||
class HomeGuideInputTest {
|
||||
private val states = mutableListOf<Boolean>()
|
||||
private var cancellations = 0
|
||||
private val input = HomeGuideInput({ states.add(it) }, { cancellations++ })
|
||||
|
||||
private fun home(action: Int, device: Int = 10, repeat: Int = 0, down: Long = 10) =
|
||||
KeyEvent(down, down + 100, action, KeyEvent.KEYCODE_HOME, repeat, 0, device, 102)
|
||||
|
||||
@Test fun guideIsHeldImmediatelyAndReleaseDoesNotDependOnAndroidDownTime() {
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true))
|
||||
assertEquals(listOf(true), states)
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_DOWN, repeat = 1), true))
|
||||
assertFalse(input.onKeyEvent(KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BUTTON_X), true))
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_UP, down = 77), true))
|
||||
assertEquals(listOf(true, false), states)
|
||||
}
|
||||
|
||||
@Test fun anUnownedHomePressKeepsAndroidBehaviorEvenIfSessionBecomesEligibleBeforeRelease() {
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_DOWN), false))
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_UP), true))
|
||||
assertTrue(states.isEmpty())
|
||||
}
|
||||
|
||||
@Test fun focusLossReleasesGuideAndConsumesTheOwnedReleaseWithoutAnotherTap() {
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true)
|
||||
input.cancel()
|
||||
assertEquals(1, cancellations)
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_DOWN, repeat = 2), false))
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_UP), false))
|
||||
assertEquals(listOf(true, false), states)
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_UP), false))
|
||||
}
|
||||
|
||||
@Test fun disablingDuringAHoldReleasesItAndDoesNotStealTheNextAndroidHomePress() {
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true)
|
||||
assertTrue(input.onKeyEvent(home(KeyEvent.ACTION_UP), false))
|
||||
assertEquals(listOf(true, false), states)
|
||||
assertFalse(input.onKeyEvent(home(KeyEvent.ACTION_DOWN), false))
|
||||
}
|
||||
|
||||
@Test fun guideStaysHeldUntilAllOwnersReleaseAndDisconnectCancelsTheLastOwner() {
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN), true)
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_DOWN, device = 11), true)
|
||||
input.onKeyEvent(home(KeyEvent.ACTION_UP), true)
|
||||
assertEquals(listOf(true), states)
|
||||
input.onDeviceRemoved(11)
|
||||
assertEquals(listOf(true, false), states)
|
||||
assertEquals(1, cancellations)
|
||||
}
|
||||
}
|
||||
@@ -328,6 +328,53 @@ class PadBridgeQamTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun homeGuidePrecedesEarlyPartnerInputAndDoesNotGenerateABareButton() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
assertTrue(pad().isDown(PadState.GUIDE))
|
||||
bridge.applyExternal({ it.press(PadState.X, true) }, true)
|
||||
assertFalse(pad().isDown(PadState.X))
|
||||
advance(80)
|
||||
assertTrue(pad().isDown(PadState.GUIDE))
|
||||
assertTrue(pad().isDown(PadState.X))
|
||||
bridge.applyExternal({ it.press(PadState.X, false) }, true)
|
||||
bridge.setHomeGuidePressed(false)
|
||||
advance(1000)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
assertFalse(pad().isDown(PadState.X))
|
||||
}
|
||||
|
||||
@Test fun cancellingHomeDiscardsQueuedPartnersAndReleasesGuideImmediately() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
bridge.applyExternal({ it.press(PadState.LB, true); it.leftY = -1f }, true)
|
||||
bridge.cancelHomeGuide()
|
||||
advance(1000)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
assertFalse(pad().isDown(PadState.LB))
|
||||
assertEquals(0f, pad().leftY)
|
||||
}
|
||||
|
||||
@Test fun homeAndTouchGuideHaveIndependentReleases() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
bridge.setSystemButtons(true, false)
|
||||
bridge.setHomeGuidePressed(false)
|
||||
advance(1000)
|
||||
assertTrue(pad().isDown(PadState.GUIDE))
|
||||
bridge.setSystemButtons(false, false)
|
||||
advance(1000)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
}
|
||||
|
||||
@Test fun releasingHomeStopsHeldAxesFromBecomingNavigation() {
|
||||
bridge.setHomeGuidePressed(true)
|
||||
bridge.applyExternal({ it.leftY = -1f }, true)
|
||||
advance(80)
|
||||
assertEquals(-1f, pad().leftY)
|
||||
bridge.setHomeGuidePressed(false)
|
||||
advance(1000)
|
||||
assertEquals(0f, pad().leftY)
|
||||
assertFalse(pad().isDown(PadState.GUIDE))
|
||||
}
|
||||
|
||||
private fun key(device: InputDevice, code: Int, action: Int = KeyEvent.ACTION_DOWN, repeat: Int = 0, scan: Int = 0) =
|
||||
KeyEvent(0L, 0L, action, code, repeat, 0, device.id, scan, 0, InputDevice.SOURCE_GAMEPAD)
|
||||
|
||||
|
||||
Reference in new issue
Block a user