SDL_GamepadButton

Struct SDL_GamepadButton 

Source
#[repr(transparent)]
pub struct SDL_GamepadButton(pub c_int);
Expand description

The list of buttons available on a gamepad

For controllers that use a diamond pattern for the face buttons, the south/east/west/north buttons below correspond to the locations in the diamond pattern. For Xbox controllers, this would be A/B/X/Y, for Nintendo Switch controllers, this would be B/A/Y/X, for GameCube controllers this would be A/X/B/Y, for PlayStation controllers this would be Cross/Circle/Square/Triangle.

For controllers that don’t use a diamond pattern for the face buttons, the south/east/west/north buttons indicate the buttons labeled A, B, C, D, or 1, 2, 3, 4, or for controllers that aren’t labeled, they are the primary, secondary, etc. buttons.

The activate action is often the south button and the cancel action is often the east button, but in some regions this is reversed, so your game should allow remapping actions based on user preferences.

You can query the labels for the face buttons using SDL_GetGamepadButtonLabel()

§Availability

This enum is available since SDL 3.2.0.

§Known values (sdl3-sys)

Associated constantGlobal constantDescription
INVALIDSDL_GAMEPAD_BUTTON_INVALID
SOUTHSDL_GAMEPAD_BUTTON_SOUTHBottom face button (e.g. Xbox A button)
EASTSDL_GAMEPAD_BUTTON_EASTRight face button (e.g. Xbox B button)
WESTSDL_GAMEPAD_BUTTON_WESTLeft face button (e.g. Xbox X button)
NORTHSDL_GAMEPAD_BUTTON_NORTHTop face button (e.g. Xbox Y button)
BACKSDL_GAMEPAD_BUTTON_BACK
GUIDESDL_GAMEPAD_BUTTON_GUIDE
STARTSDL_GAMEPAD_BUTTON_START
LEFT_STICKSDL_GAMEPAD_BUTTON_LEFT_STICK
RIGHT_STICKSDL_GAMEPAD_BUTTON_RIGHT_STICK
LEFT_SHOULDERSDL_GAMEPAD_BUTTON_LEFT_SHOULDER
RIGHT_SHOULDERSDL_GAMEPAD_BUTTON_RIGHT_SHOULDER
DPAD_UPSDL_GAMEPAD_BUTTON_DPAD_UP
DPAD_DOWNSDL_GAMEPAD_BUTTON_DPAD_DOWN
DPAD_LEFTSDL_GAMEPAD_BUTTON_DPAD_LEFT
DPAD_RIGHTSDL_GAMEPAD_BUTTON_DPAD_RIGHT
MISC1SDL_GAMEPAD_BUTTON_MISC1Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button)
RIGHT_PADDLE1SDL_GAMEPAD_BUTTON_RIGHT_PADDLE1Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button)
LEFT_PADDLE1SDL_GAMEPAD_BUTTON_LEFT_PADDLE1Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button)
RIGHT_PADDLE2SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button)
LEFT_PADDLE2SDL_GAMEPAD_BUTTON_LEFT_PADDLE2Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button)
TOUCHPADSDL_GAMEPAD_BUTTON_TOUCHPADPS4/PS5 touchpad button
MISC2SDL_GAMEPAD_BUTTON_MISC2Additional button
MISC3SDL_GAMEPAD_BUTTON_MISC3Additional button (e.g. Nintendo GameCube left trigger click)
MISC4SDL_GAMEPAD_BUTTON_MISC4Additional button (e.g. Nintendo GameCube right trigger click)
MISC5SDL_GAMEPAD_BUTTON_MISC5Additional button
MISC6SDL_GAMEPAD_BUTTON_MISC6Additional button
COUNTSDL_GAMEPAD_BUTTON_COUNT

Tuple Fields§

§0: c_int

Implementations§

Source§

impl SDL_GamepadButton

Source

pub const INVALID: Self

Source

pub const SOUTH: Self

Bottom face button (e.g. Xbox A button)

Source

pub const EAST: Self

Right face button (e.g. Xbox B button)

Source

pub const WEST: Self

Left face button (e.g. Xbox X button)

Source

pub const NORTH: Self

Top face button (e.g. Xbox Y button)

Source

pub const BACK: Self

Source

pub const GUIDE: Self

Source

pub const START: Self

Source

pub const LEFT_STICK: Self

Source

pub const RIGHT_STICK: Self

Source

pub const LEFT_SHOULDER: Self

Source

pub const RIGHT_SHOULDER: Self

Source

pub const DPAD_UP: Self

Source

pub const DPAD_DOWN: Self

Source

pub const DPAD_LEFT: Self

Source

pub const DPAD_RIGHT: Self

Source

pub const MISC1: Self

Additional button (e.g. Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button, Google Stadia capture button)

Source

pub const RIGHT_PADDLE1: Self

Upper or primary paddle, under your right hand (e.g. Xbox Elite paddle P1, DualSense Edge RB button, Right Joy-Con SR button)

Source

pub const LEFT_PADDLE1: Self

Upper or primary paddle, under your left hand (e.g. Xbox Elite paddle P3, DualSense Edge LB button, Left Joy-Con SL button)

Source

pub const RIGHT_PADDLE2: Self

Lower or secondary paddle, under your right hand (e.g. Xbox Elite paddle P2, DualSense Edge right Fn button, Right Joy-Con SL button)

Source

pub const LEFT_PADDLE2: Self

Lower or secondary paddle, under your left hand (e.g. Xbox Elite paddle P4, DualSense Edge left Fn button, Left Joy-Con SR button)

Source

pub const TOUCHPAD: Self

PS4/PS5 touchpad button

Source

pub const MISC2: Self

Additional button

Source

pub const MISC3: Self

Additional button (e.g. Nintendo GameCube left trigger click)

Source

pub const MISC4: Self

Additional button (e.g. Nintendo GameCube right trigger click)

Source

pub const MISC5: Self

Additional button

Source

pub const MISC6: Self

Additional button

Source

pub const COUNT: Self

Trait Implementations§

Source§

impl Clone for SDL_GamepadButton

Source§

fn clone(&self) -> SDL_GamepadButton

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SDL_GamepadButton

Available on crate feature debug-impls only.
Source§

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

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

impl Default for SDL_GamepadButton

Source§

fn default() -> SDL_GamepadButton

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

impl From<SDL_GamepadButton> for c_int

Source§

fn from(value: SDL_GamepadButton) -> Self

Converts to this type from the input type.
Source§

impl GroupMetadata for SDL_GamepadButton

Available on crate feature metadata only.
Source§

const GROUP_METADATA: &'static Group

Metadata for this group
Source§

impl Hash for SDL_GamepadButton

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 SDL_GamepadButton

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

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

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

impl PartialEq<SDL_GamepadButton> for c_int

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<i32> for SDL_GamepadButton

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for SDL_GamepadButton

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for SDL_GamepadButton

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 Copy for SDL_GamepadButton

Source§

impl Eq for SDL_GamepadButton

Source§

impl StructuralPartialEq for SDL_GamepadButton

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