Skip to main content

Button

Enum Button 

Source
pub enum Button {
Show 34 variants South, East, West, North, LeftShoulder, RightShoulder, LeftTrigger, RightTrigger, Select, Start, LeftStickPress, RightStickPress, DpadUp, DpadDown, DpadLeft, DpadRight, LeftStickUp, LeftStickDown, LeftStickLeft, LeftStickRight, RightStickUp, RightStickDown, RightStickLeft, RightStickRight, CrankBack, CrankForward, SystemMenu0, SystemMenu1, SystemMenu2, SystemMenu3, SystemMenu4, SystemMenu5, SystemMenu6, SystemMenu7,
}
Expand description

A controller button, named by its position on an Xbox-shaped pad, whatever is printed on it (game ADR-0034). Each stick’s four directions count as buttons too, and so does a crank wound one notch either way (the Playdate’s, ticket 1035: pressed and let go once per notch), and so does an item of the game’s own in the system’s menu (pressed and let go when the player picks it, ADR-0008 §3). app translates what the platform reports to these; anything else on a pad is ignored, and so are the system’s own buttons (the Playdate’s Menu and Lock, the Deck’s Steam and Quick Access), which no keymap can name.

The first 16 are in the order of the browser Gamepad API’s “standard” mapping.

Variants§

§

South

The bottom face button (Xbox A).

§

East

The right face button (Xbox B).

§

West

The left face button (Xbox X).

§

North

The top face button (Xbox Y).

§

LeftShoulder

The left shoulder button (Xbox LB).

§

RightShoulder

The right shoulder button (Xbox RB).

§

LeftTrigger

The left trigger (Xbox LT), pulled far enough to count as pressed.

§

RightTrigger

The right trigger (Xbox RT), pulled far enough to count as pressed.

§

Select

The left centre button (Xbox Back).

§

Start

The right centre button (Xbox Start).

§

LeftStickPress

Pressing the left stick in.

§

RightStickPress

Pressing the right stick in.

§

DpadUp

D-pad up.

§

DpadDown

D-pad down.

§

DpadLeft

D-pad left.

§

DpadRight

D-pad right.

§

LeftStickUp

The left stick pushed up.

§

LeftStickDown

The left stick pushed down.

§

LeftStickLeft

The left stick pushed left.

§

LeftStickRight

The left stick pushed right.

§

RightStickUp

The right stick pushed up.

§

RightStickDown

The right stick pushed down.

§

RightStickLeft

The right stick pushed left.

§

RightStickRight

The right stick pushed right.

§

CrankBack

The crank wound one notch backwards (counterclockwise).

§

CrankForward

The crank wound one notch forwards (clockwise).

§

SystemMenu0

The first item of the game’s own in the system’s menu.

§

SystemMenu1

The second item of the game’s own in the system’s menu.

§

SystemMenu2

The third item of the game’s own in the system’s menu.

§

SystemMenu3

The fourth item of the game’s own in the system’s menu.

§

SystemMenu4

The fifth item of the game’s own in the system’s menu.

§

SystemMenu5

The sixth item of the game’s own in the system’s menu.

§

SystemMenu6

The seventh item of the game’s own in the system’s menu.

§

SystemMenu7

The eighth item of the game’s own in the system’s menu.

Implementations§

Source§

impl Button

Source

pub const ALL: &'static [Button]

Every button, in declaration order.

Source

pub fn name(self) -> &'static str

The name used in keymap files (the variant name).

Source§

impl Button

Source

pub fn system_menu(slot: u8) -> Option<Button>

The system menu’s item slot (from 0), if a keymap can name it (below SYSTEM_MENU_ITEMS).

Source

pub fn system_menu_slot(self) -> Option<u8>

Which item of the system’s menu this is (from 0), if it is one.

Source

pub fn from_name(name: &str) -> Option<Button>

Looks a button up by its name (exact match).

Source

pub fn parse(s: &str) -> Result<Button, String>

Parses a keymap-file button name: "South", "DpadUp", "LeftStickLeft", …

Trait Implementations§

Source§

impl Clone for Button

Source§

fn clone(&self) -> Button

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Button

Source§

impl Debug for Button

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Button

Source§

fn deserialize<D>( deserializer: D, ) -> Result<Button, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Button

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Eq for Button

Source§

impl From<Button> for ButtonChord

Source§

fn from(button: Button) -> ButtonChord

Converts to this type from the input type.
Source§

impl FromIterator<Button> for ButtonSet

Source§

fn from_iter<I: IntoIterator<Item = Button>>(buttons: I) -> Self

Creates a value from an iterator. Read more
Source§

impl FromStr for Button

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Button, <Button as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for Button

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Button

Source§

fn cmp(&self, other: &Button) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Button

Source§

fn eq(&self, other: &Button) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialEq<Button> for ButtonChord

A binding is a button when it is that button on its own.

Source§

fn eq(&self, button: &Button) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Button

Source§

fn partial_cmp(&self, other: &Button) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for Button

A button in a data file (a target’s inputs, shuyi_assets::target) and in a baked keymap (pack) is its name.

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Button

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.