feat(input): describe on-screen layout choices, scope per-game layouts and delete unused ones (#2939)

* feat(input): describe on-screen layout choices, scope per-game layouts and delete unused ones

- The layout menu says what each choice is: "DroidDeck controls" work in
  every game and are edited here; "Steam touch controls" are each game's
  controls from Steam, for Steam games only.
- Layouts made with "+ New for <game>" (or "Just this game") are listed
  only for that game, marked "Just for <game>". Older ones are recognised
  by carrying the name of the game that draws them.
- Saved layouts nothing uses get a delete button in the menu. Deleting one
  also removes a profile that still uses it but can no longer be chosen,
  such as copies made by the old profile screen.
- A game set to Steam touch controls that runs without Steam shows a note
  under Layout instead of silently using the default.

* fix(input): a layout the built-in profile still lists can be deleted once another is chosen

Applying a layout used to write it into the Game profile; choosing another
now goes on top, so the profile's part is no longer drawn. Only parts a mode
actually draws count as in use, and deleting points the built-in profile
back at the stock layout.
This commit is contained in:
Kurt Himebauch authored and GitHub committed 2026-11-20 11:54:59 -05:00
1 parent 83dc5f37e9
commit d5c83eae15
9 files changed
+304 -26

No files matched your search

@@ -646,8 +646,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private var oscRearButtons by mutableStateOf(false)
private var oscTrackpads by mutableStateOf(false)
private var onScreenButtonsVisible by mutableStateOf(false)
private var layoutOptions by mutableStateOf<List<Pair<String, String>>>(emptyList())
private var layoutOptions by mutableStateOf<List<com.droiddeck.launcher.input.ControlsChoice.Option>>(emptyList())
private var layoutChoice by mutableStateOf("")
private var layoutHint by mutableStateOf<String?>(null)
private var layoutEditor by mutableStateOf<Triple<String, String, String>?>(null)
private var layoutEditorScope: String? = null
private var layoutEditorSplit: com.droiddeck.launcher.ui.InputEditorSplit? = null
@@ -1746,7 +1747,9 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
layoutGame = controlsGameName(),
layoutOptions = layoutOptions,
layoutChoice = layoutChoice,
layoutHint = layoutHint,
onLayout = ::chooseLayout,
onDeleteLayout = ::deleteLayout,
oscRearButtons = oscRearButtons.takeIf {
unfoldedPanel == null && !usesSteamTouchLayout() && com.droiddeck.launcher.input.PadKit.current(this).steam &&
primaryInputLayout?.let(com.droiddeck.launcher.input.OnScreenLayout::hasBuiltInKit) == true
@@ -4432,8 +4435,15 @@ class SessionActivity : ComponentActivity(), SurfaceHolder.Callback, com.droidde
private fun refreshLayoutOptions() {
val steam = SessionState.mode == SessionService.MODE_STEAM
val game = controlsGameId()
layoutOptions = com.droiddeck.launcher.input.ControlsChoice.options(this, game, steam, controlsGameName())
layoutChoice = com.droiddeck.launcher.input.ControlsChoice.current(this, game, steam, loadingMode() == SessionService.MODE_DESKTOP)
val desktop = loadingMode() == SessionService.MODE_DESKTOP
layoutOptions = com.droiddeck.launcher.input.ControlsChoice.options(this, game, steam, controlsGameName(), desktop)
layoutChoice = com.droiddeck.launcher.input.ControlsChoice.current(this, game, steam, desktop)
layoutHint = if (com.droiddeck.launcher.input.ControlsChoice.steamUnavailable(this, game, steam)) getString(R.string.osc_layout_steam_unavailable) else null
}
private fun deleteLayout(id: String) {
runCatching { com.droiddeck.launcher.input.ControlsChoice.delete(this, id) }.onFailure { Log.w(TAG, "could not delete layout $id", it) }
refreshLayoutOptions()
}
private fun chooseLayout(id: String) {