mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
fix(input): the layout editor shows the same placement as the session (#2783)
* fix(input): the layout editor shows the same placement as the session Editing a layout stored for one orientation while the editor is open in the other drew raw stored coordinates, so elements turned into flat, overlapping bars. Route the editor through OnScreenLayout like the on-screen controls: matched layouts are regenerated for the current screen, everything else follows the same fit, and the dirty check compares against what was shown when the editor opened. * fix(input): reset and scale in the editor frame the session saves The editor draft now carries the frame it was rebased to: the gamepad scaler is rebuilt with the editor surface's real dimensions when edits begin, so reset regenerates legacy controls for the display the user is editing instead of the primary display. Stock default positions keep their own frame aspect and are refitted into the draft frame before being applied, so reset on a differently shaped display lands where the editor shows and no longer marks an untouched layout as changed. * fix(input): refit only the default positions on reset and update the test callers --------- Co-authored-by: maxjivi05 <maxjividen@gmail.com>
This commit is contained in:
1 parent
cca84f7b6b
commit
fc5dd7f3c5
5 files changed
+29
-18
No files matched your search
@@ -50,7 +50,7 @@ class InputLayoutToolsTest {
|
||||
assertEquals(InputLibraries.DECK, independent.layout(InputProfile.GAME, InputRole.SECONDARY)!!.origin)
|
||||
val stock = InputStockLayouts.layouts().first { it.id == InputLibraries.DECK }.elements
|
||||
val dragged = mine.copy(elements = mine.elements.map { it.copy(x = 0f, y = 0f) })
|
||||
assertEquals(stock, InputLibraries.defaultPositions(context, copied, dragged))
|
||||
assertEquals(stock to InputStockLayouts.layouts().first { it.id == InputLibraries.DECK }.aspect, InputLibraries.defaultPositions(context, copied, dragged))
|
||||
assertEquals(mine.elements, dragged.elements.withPositionsOf(stock))
|
||||
assertEquals(copied, InputLibraries.decode(InputLibraries.encode(copied)))
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class InputLayoutToolsTest {
|
||||
@Test fun builtInGamepadDefaultsComeFromTheGamepadGenerator() {
|
||||
val library = InputLibraries.read(context)
|
||||
val gamepad = library.layouts.first { it.id == InputLibraries.OVERLAY }
|
||||
val defaults = InputLibraries.defaultPositions(context, library, gamepad)!!
|
||||
val defaults = InputLibraries.defaultPositions(context, library, gamepad)!!.first
|
||||
assertEquals(gamepad.elements.map { it.id }.toSet(), defaults.map { it.id }.toSet())
|
||||
assertNull(InputLibraries.defaultPositions(context, library, SavedInputLayout("new", "New")))
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ class InputSurfaceEditorViewTest {
|
||||
@Test fun editingStartsInTheDisplayedFrame() {
|
||||
val view = view()
|
||||
var started: Pair<List<InputSurfaceElement>, Float>? = null
|
||||
view.onBeginEdit = { elements, aspect -> started = elements to aspect }
|
||||
view.onBeginEdit = { elements, w, h -> started = elements to w.toFloat() / h }
|
||||
val (x, y) = center()
|
||||
view.touch(MotionEvent.ACTION_DOWN, x, y)
|
||||
view.touch(MotionEvent.ACTION_MOVE, x + 100f, y + 50f)
|
||||
|
||||
Reference in new issue
Block a user