pub struct Input { /* private fields */ }
Expand description

Manages player input bindings and allows reading key/button presses and axes

Implementations

Creates a new input action with the given name.

Adds an input binding to the given action. If the action doesn’t exist, it will be created. See the module-level documentation for a list of key names.

Removes all the bindings from the given action.

Gets the deadzone for the given composite axis. See the module-level documentation for a list of composite axis names.

Sets the deadzone for the given composite axis. See the module-level documentation for a list of composite axis names.

Returns true if the given action was pressed this frame

Returns true if the given action was released this frame

Returns true if the given action is currently being held

Returns the number of frames that the given action was held for, or 0 if it is not held.

Returns the number of frames that the given action was released for, or 0 if it is not released.

Returns the current value between 0.0 and 1.0 for the axis associated with the given action. This will only return the value of an individual positive/negative component. If you want a combined positive/negative range, see Input::paired_axis().

Returns the current value between -1.0 and 1.0 for the negative and positive part associated with the negative and positive actions, respectively.

Returns the current values between -1.0 and 1.0 for the 2D axis given four actions representing each cardinal direction. The distance is capped at a Euclidean distance value of 1.0 to avoid overly large diagonal values for sticks with square gates.

Returns the current angle and distance for the 2D axis given four actions representing each cardinal direction. The distance is capped at a Euclidean distance value of 1.0 to avoid overly large diagonal values for sticks with square gates.

Returns the currently pressed four-way direction given four actions representing each cardinal direction. If no direction is held, or the 2D axis is too close to a diagonal, returns None.

Returns the currently pressed eight-way direction given four actions representing each cardinal direction. If no direction is held, returns None.

Returns the current mouse cursor position in game screen coordinates. These are not raw window coordinates. For example, if you have a game at 320x224 and the window is scaled to 640x448, then placing your cursor in the bottom right of the window’s client area will return a position close to (320, 224).

Returns the amount that the mouse moved this logic frame. This is not guaranteed to match 1-to-1 with the values returned from Input::cursor_position(). With the cursor unlocked, the motion may not match with the reported position if the window is a different size from the game’s base size. With the cursor locked, the motion is taken from raw mouse input if available, so it most likely will not match with the reported position even if the values are scaled up or down.

Returns true if the mouse cursor is displayed when it is over the game window.

Sets whether the mouse cursor is displayed when it is over the game window.

Returns true if the mouse cursor is currently locked.

Sets whether the mouse cursor is locked. When locked, the cursor will be trapped inside the window, and Input::cursor_motion() will report raw mouse motion if available.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.