pub struct InputSystem { /* private fields */ }Expand description
Named key-action registry with context dispatch.
Donor: oa::InputSystem.
Implementations§
Source§impl InputSystem
impl InputSystem
pub fn new() -> Self
Sourcepub fn register_action(&mut self, action: KeyAction)
pub fn register_action(&mut self, action: KeyAction)
Register action, replacing any existing action with the same name.
Sourcepub fn unregister_action(&mut self, name: &str)
pub fn unregister_action(&mut self, name: &str)
Remove the action named name, if present.
Sourcepub fn set_callback(&mut self, name: &str, callback: impl FnMut() + 'static)
pub fn set_callback(&mut self, name: &str, callback: impl FnMut() + 'static)
Attach or replace the callback of the action named name.
Sourcepub fn rebind(&mut self, name: &str, binding: KeyBinding)
pub fn rebind(&mut self, name: &str, binding: KeyBinding)
Replace the trigger of the action named name.
Sourcepub fn set_context(&mut self, context: InputContext)
pub fn set_context(&mut self, context: InputContext)
Set the active focus context.
Sourcepub const fn context(&self) -> InputContext
pub const fn context(&self) -> InputContext
Return the active focus context.
Sourcepub fn action_count(&self) -> usize
pub fn action_count(&self) -> usize
Return the number of registered actions.
Sourcepub fn dispatch(&mut self, event: &InputEvent) -> bool
pub fn dispatch(&mut self, event: &InputEvent) -> bool
Dispatch event to the first matching action in context.
Returns true when an action’s binding matched — including the case
where a repeated key event is consumed without firing because
allow_repeat is false.
Sourcepub fn register_defaults(&mut self)
pub fn register_defaults(&mut self)
Register the reusable Realm tool bindings.
Installs named callback-free actions; the application attaches each
behavior through Self::set_callback:
| action | binding | context |
|---|---|---|
screenshot | F12 | Global |
record | Ctrl+R | Global |
toggle_camera | Space | Global |
undo | Ctrl+Z | NodeCanvas |
redo | Ctrl+Y | NodeCanvas |
save | Ctrl+S | Global |
fit_view | F | NodeCanvas |
Sourcepub fn load_bindings_yaml(&mut self, path: &str) -> Result<()>
pub fn load_bindings_yaml(&mut self, path: &str) -> Result<()>
Load bindings from a versioned YAML document.
Loading is transactional: a syntax or schema error leaves registered actions untouched. Persisted rebinds preserve existing callbacks; new actions arrive callback-free.
§Errors
Returns ErrorKind::InvalidArgument for an empty path, and
ErrorKind::MissingCapability while no YAML backend is linked — the
donor’s documented behavior without yaml-cpp.
Sourcepub fn save_bindings_yaml(&self, path: &str) -> Result<()>
pub fn save_bindings_yaml(&self, path: &str) -> Result<()>
Save bindings to a versioned YAML document.
§Errors
Returns ErrorKind::InvalidArgument for an empty path, and
ErrorKind::MissingCapability while no YAML backend is linked.