Struct System

Source
pub struct System { /* private fields */ }
Expand description

Contains the setup for a particular application.

Implementations§

Source§

impl System

Source

pub fn new() -> Self

Source

pub fn add_users(&mut self, count: usize) -> &mut Self

Adds an amount of users to the system, connecting any unassigned devices to the new users as available.

Source

pub fn add_action(&mut self, name: Id, action: Action) -> &mut Self

Adds an action to the list of actions the system supports.

Source

pub fn add_layout(&mut self, layout: LayoutId) -> &mut Self

Adds a layout to the list of layouts the system supports.

Source

pub fn add_action_set(&mut self, id: ActionSetId, set: ActionSet) -> &mut Self

Associates an action set with an id.

Source

pub fn set_user_layout( &mut self, user_id: UserId, layout: LayoutId, ) -> &mut Self

Sets the layout of a user. If not called, all user’s start with a None layout (default layout).

Source

pub fn mark_action_set_enabled( &mut self, user_id: UserId, set_id: ActionSetId, enabled: bool, ) -> &mut Self

Enables and disables a provided action set for a given user. When enabled, a user will receive input events for the actions in the action set, until the set is disabled (or until System::update stops being called).

Source

pub fn enable_action_set_for_all(&mut self, id: ActionSetId) -> &mut Self

Enables an action set for all existing users. See System::mark_action_set_enabled for further details.

Source

pub fn send_event(&mut self, source: Source, event: Event)

Sends an input event to the system. Use with caution! Gamepad events are already handled/built-in, but Mouse and Keyboard events should come from the relevant feature/extension (like winit).

Source

pub fn update(&mut self)

Collects gamepad input and updates relevant actions.

Source

pub fn get_user_ids(&self) -> Vec<UserId>

Returns a list of active user ids.

Source

pub fn get_user_action(&self, user_id: UserId, action_id: Id) -> Option<&State>

Returns the state for an action on a given user. If the action is invalid or is not enabled for the user’s layout or list of enabled action sets, None will be returned.

Auto Trait Implementations§

§

impl Freeze for System

§

impl RefUnwindSafe for System

§

impl !Send for System

§

impl !Sync for System

§

impl Unpin for System

§

impl UnwindSafe for System

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.