Skip to main content

PadKind

Enum PadKind 

Source
pub enum PadKind {
    Xbox,
    PlayStation,
    PlayStation4,
    Nintendo,
    Playdate,
    Generic,
}
Expand description

Who made a pad, which decides the Confirm / Cancel swap here and the button names shown on screen (ticket 0220).

Variants§

§

Xbox

A Microsoft pad.

§

PlayStation

A Sony pad other than a PS4 one (a PS5 pad).

§

PlayStation4

A Sony PS4 pad: named as a PlayStation pad, except its left centre button is Share.

§

Nintendo

A Nintendo pad (Switch Pro controller, Joy-Cons).

§

Playdate

The Playdate’s own buttons (game ADR-0070): the D-pad, A and B. Its backend reports A at the binding position East and B at West (targets/playdate.ron, ADR-0008 §1), with no swap, so a game binds them in its keymap’s targets."playdate" table.

§

Generic

Anything else, or a pad that doesn’t say. Treated like an Xbox pad.

Implementations§

Source§

impl PadKind

Source

pub const ALL: [PadKind; 6]

Every kind.

Source

pub fn from_ids(vendor: u16, product: u16) -> Self

The kind of a pad from its USB vendor and product ids; unknown vendors (and 0, “not reported”) are Generic. The product only matters for Sony, to tell a PS4 pad apart.

Source

pub fn position(self, button: Button) -> Button

The position bindings use for the button physically at button on this kind of pad: on a Nintendo pad the bottom and right face buttons swap (so its right button, labelled A, is South and confirms by default); every other button, and every other pad, is unchanged.

Source

pub fn button_name(self, button: Button) -> &'static str

What help text calls the button at binding position button on this kind of pad (docs/design/controls.md, Button names on screen): Xbox letters (also on generic pads), Sony’s shapes, or Nintendo’s letters (a PS4 pad says Share where later Sony pads say Create). The Playdate’s A is East and its B is West, as printed on it; every other name is the Xbox one, its D-pad’s and its crank’s among them, but South’s, which is the X that leaves free: A would name a button its A doesn’t press. It has none of the other buttons (their actions move to chords and menus in tickets 1034 and 1035). The only place buttons get their names.

Source

pub fn chord_name(self, chord: ButtonChord, join: &str) -> String

What help text calls chord on this kind of pad: its button’s name, or a button chord’s two names with join between them (A+B, B+← with +), in the chord’s order.

Trait Implementations§

Source§

impl Clone for PadKind

Source§

fn clone(&self) -> PadKind

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 PadKind

Source§

impl Debug for PadKind

Source§

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

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

impl Default for PadKind

Source§

fn default() -> PadKind

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for PadKind

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl Eq for PadKind

Source§

impl Hash for PadKind

Source§

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

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 PadKind

Source§

fn cmp(&self, other: &PadKind) -> 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 PadKind

Source§

fn eq(&self, other: &PadKind) -> 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 PadKind

Source§

fn partial_cmp(&self, other: &PadKind) -> 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 PadKind

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

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

impl StructuralPartialEq for PadKind

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, 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.