mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
fix: preserve shared input ownership and reset profile settings
This commit is contained in:
1 parent
3dd6aeef46
commit
6530faaf78
9 files changed
+80
-12
No files matched your search
@@ -16,6 +16,36 @@ class InputSourceOwnershipTest {
|
||||
private fun state() = JoyConPadTest.RecordingWriter.pads[0]!!
|
||||
@After fun close() { bridge.stop(); DeckControls.releaseAll(); DeckControls.setRouter(null) }
|
||||
|
||||
@Test fun removingLastTouchSurfaceReleasesLegacyMouseRoute() {
|
||||
val routed = PadState()
|
||||
bridge.setTouchRoute(object : PadBridge.TouchRoute {
|
||||
override fun active() = true
|
||||
override fun accept(state: PadState) { routed.copyFrom(state) }
|
||||
})
|
||||
val first = Any(); val second = Any()
|
||||
bridge.applyTouch(first, InputRole.PRIMARY) { it.press(PadState.A, true) }
|
||||
bridge.applyTouch(second, InputRole.SECONDARY) { it.press(PadState.A, true) }
|
||||
bridge.releaseTouch(first)
|
||||
assertTrue(routed.isDown(PadState.A))
|
||||
bridge.releaseTouch(second)
|
||||
assertFalse(routed.isDown(PadState.A))
|
||||
}
|
||||
|
||||
@Test fun nativeTrackpadKeepsItsOwnerUntilThatContactEnds() {
|
||||
val first = DeckControls.source(InputRole.PRIMARY)
|
||||
val second = DeckControls.source(InputRole.SECONDARY)
|
||||
try {
|
||||
first.setPad(false, true, .25f, .5f)
|
||||
val firstPosition = JoyConPadTest.RecordingWriter.deckPads.copyOf()
|
||||
second.setPad(false, true, -.75f, -.5f)
|
||||
assertArrayEquals(firstPosition, JoyConPadTest.RecordingWriter.deckPads)
|
||||
first.setPad(false, false)
|
||||
assertTrue(JoyConPadTest.RecordingWriter.deckPads[0] < 0)
|
||||
second.close()
|
||||
assertEquals(0, JoyConPadTest.RecordingWriter.grips and 16)
|
||||
} finally { first.close(); second.close() }
|
||||
}
|
||||
|
||||
@Test fun closingOneSurfaceDoesNotReleaseAnotherSurfaceOrPhysicalPad() {
|
||||
val a = Any(); val b = Any()
|
||||
bridge.applyExternal({ it.press(PadState.A, true) }, true)
|
||||
|
||||
@@ -203,11 +203,15 @@ class JoyConPadTest {
|
||||
companion object {
|
||||
val pads = HashMap<Int, PadState>()
|
||||
var grips = 0
|
||||
var deckPads = ShortArray(4)
|
||||
|
||||
@JvmStatic @Implementation fun __staticInitializer__() = Unit
|
||||
|
||||
@JvmStatic @Implementation
|
||||
fun writeDeckControls(slot: Int, controls: Int, pads: ShortArray, pressure: ShortArray) { grips = controls }
|
||||
fun writeDeckControls(slot: Int, controls: Int, pads: ShortArray, pressure: ShortArray) {
|
||||
grips = controls
|
||||
deckPads = pads.copyOf()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,12 @@ import android.content.Context
|
||||
import com.droiddeck.launcher.core.AppUiPrefs
|
||||
import com.droiddeck.launcher.gpu.FrameGen
|
||||
import com.droiddeck.launcher.input.ControllerPrefs
|
||||
import com.droiddeck.launcher.input.InputAction
|
||||
import com.droiddeck.launcher.input.InputControl
|
||||
import com.droiddeck.launcher.input.InputProfile
|
||||
import com.droiddeck.launcher.input.InputProfiles
|
||||
import com.droiddeck.launcher.input.InputRole
|
||||
import com.droiddeck.launcher.input.InputSurfaceLayout
|
||||
import org.junit.Assert.*
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
@@ -20,7 +26,7 @@ class SettingsResetTest {
|
||||
private val session get() = prefs("session")
|
||||
|
||||
@Before fun clear() {
|
||||
listOf("session", "controller", "app-ui", "frame_gen", "steam_touch", "agent").forEach {
|
||||
listOf("session", "controller", "input-profiles", "input-surfaces", "app-ui", "frame_gen", "steam_touch", "agent").forEach {
|
||||
prefs(it).edit().clear().commit()
|
||||
}
|
||||
}
|
||||
@@ -92,6 +98,21 @@ class SettingsResetTest {
|
||||
assertEquals("a:1,2", prefs("steam_touch").getString("copiedLayout", null))
|
||||
}
|
||||
|
||||
@Test fun inputProfilesAndSurfacesResetWithoutRestoringLegacyMappings() {
|
||||
ControllerPrefs.setTarget(app, "a", "b")
|
||||
InputProfiles.select(app, InputProfile.DESKTOP)
|
||||
InputProfiles.save(app, InputProfile.defaults(InputProfile.GAME)
|
||||
.withBinding(InputRole.PHYSICAL, InputControl.A, InputAction.Disabled))
|
||||
InputSurfaceLayout.save(app, InputProfile.DESKTOP, emptyList())
|
||||
|
||||
assertTrue(SettingsReset.resetAll(app, gameProfiles = false))
|
||||
|
||||
assertEquals(InputProfiles.AUTO, InputProfiles.selection(app))
|
||||
assertEquals(InputProfile.defaults(InputProfile.GAME), InputProfiles.read(app, InputProfile.GAME))
|
||||
assertEquals(InputProfile.defaults(InputProfile.DESKTOP), InputProfiles.read(app, InputProfile.DESKTOP))
|
||||
assertEquals(InputSurfaceLayout.defaults(), InputSurfaceLayout.read(app, InputProfile.DESKTOP))
|
||||
}
|
||||
|
||||
@Test fun gameTextureFilteringIsKeptUnlessGameProfilesAreReset() {
|
||||
session.edit().putString("gameTextureFiltering", """{"440":{"anisotropy":16}}""").commit()
|
||||
SettingsReset.resetAll(app, gameProfiles = false)
|
||||
|
||||
Reference in new issue
Block a user