mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-06 04:55:44 +00:00
fix(input): send files with older Winlator key names through the converter
This commit is contained in:
1 parent
f94d5179c3
commit
2f192fddee
3 files changed
+20
-2
No files matched your search
@@ -93,6 +93,21 @@ class WinlatorLayoutsTest {
|
||||
{"type":"D_PAD","shape":"CIRCLE","bindings":["KEY_W","KEY_D","KEY_S","KEY_A"],"scale":1,"x":0.2,"y":0.5}]}"""
|
||||
assertFalse(WinlatorLayouts.needsConversion(keysOnly))
|
||||
assertTrue(WinlatorLayouts.needsConversion("""{"cursorSpeed":1,"elements":[{"type":"TRACKPAD","bindings":["MOUSE_MOVE_UP"]}]}"""))
|
||||
val aliases = """{"cursorSpeed":1,"elements":[{"type":"BUTTON","shape":"CIRCLE","bindings":["KEY_SHIFT","NONE"],"scale":1,"x":0.5,"y":0.5}]}"""
|
||||
assertTrue(WinlatorLayouts.needsConversion(aliases))
|
||||
val (layout, bindings) = WinlatorLayouts.import(aliases, "x", InputLayoutScreen.MAIN, 1920, 1080)!!
|
||||
assertEquals(InputAction.Keys(listOf(42)), bindings.elements[layout.elements.single().id])
|
||||
}
|
||||
|
||||
@Test fun droidDecksOwnExportStaysOnItsOwnImporter() {
|
||||
val element = InputSurfaceElement(InputControl.A, .4f, .4f, .1f, .1f, "jump", InputElementKind.BUTTON, "Jump", buttonShape = InputButtonShape.CIRCLE)
|
||||
val layout = SavedInputLayout("l", "Mine", listOf(element), screen = InputLayoutScreen.MAIN, aspect = 1000f / 600f)
|
||||
val preset = SavedInputBindings("b", "Mine", false, "l", elements = mapOf("jump" to InputAction.Keys(listOf(57))))
|
||||
val exported = InputLayoutFile.export(layout, preset, 1000, 600)!!
|
||||
assertFalse(WinlatorLayouts.needsConversion(exported))
|
||||
val (back, actions) = InputLayoutFile.import(context, exported, "Mine", InputLayoutScreen.MAIN, InputSurfaceStyle(), 1000, 600, 1f)!!
|
||||
val imported = back.elements.single()
|
||||
assertEquals(InputAction.Keys(listOf(57)), actions.elements[imported.id])
|
||||
}
|
||||
|
||||
@Test fun rejectsAFileWithNothingToPlace() {
|
||||
|
||||
Reference in new issue
Block a user