mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
Preserve second-screen choices across partial selections and migration retries
Track explicit whole-profile choices, including Auto, separately from inherited profiles so physical and main-screen overrides do not suppress legacy panel migration. Persist this distinction in library version 8 and read older selection records compatibly. Keep saved Deck panels during unavailable-controller fallbacks and retain legacy preferences when migration fails. Add regressions for all three review findings, explicit Auto selection and older saved libraries. Validation: all 992 input/UI tests passed.
This commit is contained in:
1 parent
281c2aea1b
commit
aff9738748
5 files changed
+110
-13
No files matched your search
@@ -9,7 +9,7 @@ import org.json.JSONObject
|
||||
import java.util.UUID
|
||||
|
||||
object InputLibraries {
|
||||
private const val VERSION = 7
|
||||
private const val VERSION = 8
|
||||
private const val KEY = "library"
|
||||
private const val RECOVERY = "library-recovery."
|
||||
const val OVERLAY = "builtin.overlay"
|
||||
@@ -231,7 +231,7 @@ object InputLibraries {
|
||||
for ((mode, selection) in library.selections) {
|
||||
val parts = JSONObject()
|
||||
selection.parts.forEach { (role, id) -> parts.put(role.name, id) }
|
||||
selections.put(mode, JSONObject().put("profile", selection.profile).put("parts", parts))
|
||||
selections.put(mode, JSONObject().put("profile", selection.profile).put("parts", parts).put("profileSelected", selection.profileSelected))
|
||||
}
|
||||
return JSONObject().put("selections", selections).put("version", VERSION).put("selected", library.selected).put("steam", library.steam).put("desktop", library.desktop)
|
||||
.put("profiles", profiles).put("layouts", layouts).put("bindings", bindings).toString()
|
||||
@@ -272,7 +272,9 @@ object InputLibraries {
|
||||
val value = saved.getJSONObject(mode)
|
||||
val parts = value.getJSONObject("parts")
|
||||
require(parts.length() <= InputRole.entries.size)
|
||||
InputSelection(value.getString("profile"), parts.keys().asSequence().associate { role -> InputRole.valueOf(role) to parts.getString(role) })
|
||||
val profile = value.getString("profile")
|
||||
InputSelection(profile, parts.keys().asSequence().associate { role -> InputRole.valueOf(role) to parts.getString(role) },
|
||||
value.optBoolean("profileSelected", profile != InputProfiles.AUTO || parts.length() == 0))
|
||||
}
|
||||
}.orEmpty()
|
||||
InputLibrary(profiles, layouts, bindings, doc.getString("selected"), doc.getString("steam"), doc.getString("desktop"), selections).validate()
|
||||
|
||||
@@ -44,7 +44,9 @@ data class SavedInputBindings(
|
||||
?: defaultElementClick(element, action(element)) { controls[it] ?: InputAction.Native() }
|
||||
}
|
||||
|
||||
data class InputSelection(val profile: String = InputProfiles.AUTO, val parts: Map<InputRole, String> = emptyMap())
|
||||
data class InputSelection(
|
||||
val profile: String = InputProfiles.AUTO, val parts: Map<InputRole, String> = emptyMap(), val profileSelected: Boolean = false,
|
||||
)
|
||||
|
||||
data class InputPart(val bindings: String, val layout: String? = null)
|
||||
|
||||
@@ -68,7 +70,7 @@ data class InputLibrary(
|
||||
val id = selection(isDesktop).profile
|
||||
return if (id == InputProfiles.AUTO) { if (isDesktop) desktop else steam } else id
|
||||
}
|
||||
fun selectProfile(isDesktop: Boolean, id: String) = copy(selections = selections + (mode(isDesktop) to InputSelection(id)))
|
||||
fun selectProfile(isDesktop: Boolean, id: String) = copy(selections = selections + (mode(isDesktop) to InputSelection(id, profileSelected = true)))
|
||||
fun selectPart(isDesktop: Boolean, role: InputRole, bindingsId: String): InputLibrary {
|
||||
val previous = selection(isDesktop)
|
||||
return copy(selections = selections + (mode(isDesktop) to previous.copy(parts = previous.parts + (role to bindingsId))))
|
||||
|
||||
Reference in new issue
Block a user