pub struct ActionDescriptor<'a> {
pub handle: ActionHandle,
pub name: Option<&'a str>,
pub kind: ActionKind,
pub context: ContextId,
pub context_name: &'a str,
pub context_active: bool,
pub bindings: &'a [Binding],
}Expand description
Borrowed metadata for building hints from an action’s current bindings.
Obtain this view from ActionMap::action_descriptor or
ActionMap::action_descriptors. Names and bindings borrow the map without
allocating or consuming input. Reacquire the view after rebinding, applying
a config or changing contexts; the borrow prevents concurrent map mutation.
Keep the ActionHandle if a longer-lived identity is needed.
use ferravex_play::input::{ActionKind, ActionMap, Binding, ContextMode, InputCode};
let mut input = ActionMap::default();
let gameplay = input.create_context("gameplay")?;
let jump = input.named_action_handle(
"jump", ActionKind::Button, gameplay,
vec![Binding::digital(InputCode::Key(32))],
)?;
input.push_context(gameplay, ContextMode::Exclusive)?;
let hint = input.action_descriptor(jump)?;
assert_eq!(hint.handle, jump);
assert_eq!(hint.name, Some("jump"));
assert_eq!(hint.kind, ActionKind::Button);
assert_eq!(hint.context, gameplay);
assert_eq!(hint.context_name, "gameplay");
assert!(hint.context_active);
assert_eq!(hint.bindings[0].code, InputCode::Key(32));Fields§
§handle: ActionHandleIdentity owned by the map that produced this view, including for unnamed actions.
name: Option<&'a str>Registered name, or None for legacy unnamed actions.
kind: ActionKindHow the action interprets its bindings and consumes input.
context: ContextIdContext used to gate this action in its owning map.
context_name: &'a strRegistered context name; global actions use "global".
context_active: boolWhether the context stack enables this action. Global actions are always active. This does not indicate focus, held-button suppression, a connected device or whether the action has any bindings.
bindings: &'a [Binding]Current bindings, validated for this action’s kind on registration,
rebinding or config application. At most MAX_BINDINGS entries, in
authored order, including duplicates and zero scales. An empty slice
means unbound. Inspection does not filter by device availability.
Trait Implementations§
Source§impl<'a> Clone for ActionDescriptor<'a>
impl<'a> Clone for ActionDescriptor<'a>
Source§fn clone(&self) -> ActionDescriptor<'a>
fn clone(&self) -> ActionDescriptor<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more