class Opal::Input::Core::InputRemapModel

Overview

Tier-1 Core Engine Model managing a complete profile of input actions, categories, multi-slot bindings, conflict resolution, Lapis/Godot export, and KeyMap synchronization.

Defined in:

opal/input/core/remap_model.cr

Constructors

Instance Method Summary

Constructor Detail

def self.default_profile(profile_name : String = "Default Controls") : InputRemapModel #

Creates a standard game + TUI default profile if needed.


[View source]
def self.from_content(content : String, format : RemapFormat | Nil = nil) : InputRemapModel #

[View source]
def self.from_file(path : String) : InputRemapModel #

[View source]
def self.from_json_string(content : String) : InputRemapModel #

[View source]
def self.from_yaml_string(content : String) : InputRemapModel #

[View source]
def self.new(profile_name : String = "Default Controls", max_slots : Int32 = 2, conflict_policy : ConflictPolicy = ConflictPolicy::Allow, gamepad_style : GamepadStyle = GamepadStyle::DualShock, allow_clear : Bool = true, allow_reset : Bool = true, actions : Array(InputAction) | Nil = nil) #

[View source]

Instance Method Detail

def action_at(index : Int32) : InputAction | Nil #

[View source]
def action_pressed?(action_id : String | Symbol, event : Terminal::KeyEvent | Terminal::MouseEvent) : Bool #

Checks whether a live event triggers the given action ID.


[View source]
def actions : Array(InputAction) #

[View source]
def add(action : InputAction) : InputAction #

[View source]
def add_action(id : String | Symbol, label : String | Nil = nil, category : String = "General", description : String = "", primary : InputBinding | String | Nil = nil, secondary : InputBinding | String | Nil = nil, deadzone : Float32 = 0.2_f32, locked : Bool = false) : InputAction #

Registers or updates an InputAction in the profile.


[View source]
def allow_clear=(allow_clear : Bool) #

[View source]
def allow_clear? : Bool #

[View source]
def allow_reset=(allow_reset : Bool) #

[View source]
def allow_reset? : Bool #

[View source]
def assign_binding(action_id : String | Symbol, slot : Int32, binding : InputBinding | String, policy : ConflictPolicy | Nil = nil) : Bool #

Assigns a binding to an action's slot while applying the configured ConflictPolicy. Returns true if assignment succeeded, false if blocked or invalid.


[View source]
def assign_binding_at(action_index : Int32, slot : Int32, binding : InputBinding | String, policy : ConflictPolicy | Nil = nil) : Bool #

Assigns a binding by action index.


[View source]
def categories : Array(String) #

Distinct action categories in registration order.


[View source]
def clear_slot(action_id : String | Symbol, slot : Int32) : Bool #

[View source]
def conflict_policy : ConflictPolicy #

[View source]
def conflict_policy=(conflict_policy : ConflictPolicy) #

[View source]
def conflicts : Array(BindingConflict) #

Computes all active duplicate binding conflicts across actions that share scope.


[View source]
def conflicts_for(action_id : String | Symbol) : Array(BindingConflict) #

[View source]
def empty? : Bool #

[View source]
def export(format : RemapFormat | Symbol | String = RemapFormat::JSON) : String #

[View source]
def find_action(id : String | Symbol) : InputAction | Nil #

[View source]
def gamepad_style : GamepadStyle #

[View source]
def gamepad_style=(gamepad_style : GamepadStyle) #

[View source]
def has_conflicts? : Bool #

[View source]
def index_of(id : String | Symbol) : Int32 | Nil #

[View source]
def max_slots : Int32 #

[View source]
def max_slots=(max_slots : Int32) #

[View source]
def profile_name : String #

[View source]
def profile_name=(profile_name : String) #

[View source]
def reset_action(action_id : String | Symbol) : Bool #

[View source]
def reset_all! : Bool #

[View source]
def size : Int32 #

[View source]
def slot_conflicted?(action_id : String | Symbol, slot : Int32) : Bool #

[View source]
def to_footer_bindings(category : String | Nil = nil, limit : Int32 = 6) : Array(NamedTuple(key: String, desc: String)) #

Builds a Footer binding badge array (Array(NamedTuple(key: String, desc: String))) from the primary bindings of the actions in this model.


[View source]
def to_json_string(pretty : Bool = true) : String #

[View source]
def to_key_map(&on_trigger : String, Terminal::KeyEvent -> Nil) : KeyMap #

Builds an Opal::Input::KeyMap wired to the current bindings in this model.


[View source]
def to_lapis_config : String #

Exports bindings in Godot 4.8 / Lapis InputMap configuration format ([input]).


[View source]
def to_yaml_string : String #

[View source]
def triggered_actions(event : Terminal::KeyEvent | Terminal::MouseEvent) : Array(String) #

Returns all action IDs triggered by the given input event.


[View source]