// SPDX-FileCopyrightText: 2026 Reactorcoremeltdown
// SPDX-License-Identifier: GPL-3.0-or-later

package space.rcmd.android.sizzle.input

/**
 * The single source of truth mapping a stable action-id string to the neutral
 * [InputAction] it produces. Both [GamepadInput] and [KeyboardInput] resolve
 * their (user-rebindable) binding maps through here, and the Settings screen uses
 * the same ids as binding keys — so an action id means exactly one thing across
 * inputs and there is no per-source duplication of the vocabulary.
 *
 * A few ids are deliberately NOT here because they mutate input-local state
 * rather than emitting an action (e.g. the keyboard's "octaveUp"/"octaveDown",
 * which nudge [KeyboardInput.baseOctave]); those handlers special-case them.
 */
object InputActions {
    fun fromId(id: String): InputAction? = when (id) {
        "playPause" -> InputAction.PlayPause
        "stop" -> InputAction.Stop
        "loop" -> InputAction.ToggleLoop
        "up" -> InputAction.NavUp
        "down" -> InputAction.NavDown
        "left" -> InputAction.NavLeft
        "right" -> InputAction.NavRight
        "increment" -> InputAction.Increment(1)
        "decrement" -> InputAction.Decrement(1)
        "clear" -> InputAction.ClearCell
        "noteOff" -> InputAction.NoteOffCell
        "nextColumn" -> InputAction.NextColumn
        "prevColumn" -> InputAction.PrevColumn
        "nextTab" -> InputAction.NextTab
        "prevTab" -> InputAction.PrevTab
        else -> null
    }
}
