pub enum Button {
Show 17 variants
ActionDown,
ActionRight,
ActionLeft,
ActionUp,
FrontLeftUpper,
FrontRightUpper,
FrontLeftLower,
FrontRightLower,
LeftCenterCluster,
RightCenterCluster,
LeftStick,
RightStick,
DPadUp,
DPadDown,
DPadLeft,
DPadRight,
Mode,
}
Expand description
A button on a gamepad.
Check for the current state of button presses on a gamepad using one of:
- Gamepad::all_currently_pressed()
- Gamepad::all_just_pressed()
- Gamepad::is_currently_pressed()
- Gamepad::is_just_pressed()
Different platforms call the buttons different things, see the below pictures for an overview, as well as the individual button documentations for a comparison.
Playstation
Switch
Xbox
W3C Gamepad API standard gamepad layout:
Variants§
ActionDown
Lowermost button in right cluster
- Playstation:
X
/Cross
button - Switch:
B
button - Xbox:
A
button - Gamepad API:
buttons[0]
/Bottom button in right cluster
ActionRight
Rightmost button in right cluster
- Gamepad API:
buttons[1]
/Right button in right cluster
- Playstation:
O
/Circle
button - Switch:
A
- Xbox:
B
ActionLeft
Leftmost button in right cluster
- Gamepad API:
buttons[2]
/Left button in right cluster
- Playstation:
□
/Square
- Switch:
Y
- Xbox:
X
ActionUp
Topmost button in right cluster
- Gamepad API:
buttons[3]
/Top button in right cluster
- Playstation:
△
/Triangle
- Switch:
X
- Xbox:
Y
FrontLeftUpper
Top left front button
- Gamepad API:
buttons[4]
/Top left front button
- Playstation:
L1
- Switch:
L
- Xbox:
LB
(Left Bumper
)
FrontRightUpper
Top right front button
- Gamepad API:
buttons[5]
/Top right front button
- Playstation:
R1
- Switch:
R
- Xbox:
RB
(Right Bumper
)
FrontLeftLower
Bottom left front button
- Gamepad API:
buttons[6]
/Bottom left front button
- Playstation:
L2
- Switch:
ZL
- Xbox:
LT
(Left Trigger
)
FrontRightLower
Bottom right front button
- Gamepad API:
buttons[7]
/Bottom right front button
- Playstation:
R2
- Switch:
ZR
- Xbox:
RT
(Right Trigger
)
LeftCenterCluster
Left button in center cluster - select/back
- Gamepad API:
buttons[8]
/Left button in center cluster
- Playstation:
SELECT
- Switch:
Capture
- Xbox:
RT
(Right Trigger
)
RightCenterCluster
Right button in center cluster - start/forward.
- Gamepad API:
buttons[9]
/Right button in center cluster
- Playstation:
Start
- Switch:
Home
- Xbox:
Start
LeftStick
Left stick pressed button.
RightStick
Right stick pressed button.
DPadUp
D-pad up button.
DPadDown
D-pad down button.
DPadLeft
D-pad left button.
DPadRight
D-pad right button.
Mode
Mode button.
- Gamepad API:
buttons[16]
/Center button in center cluster
Implementations§
Trait Implementations§
source§impl Ord for Button
impl Ord for Button
source§impl PartialEq<Button> for Button
impl PartialEq<Button> for Button
source§impl PartialOrd<Button> for Button
impl PartialOrd<Button> for Button
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for Button
impl Eq for Button
impl StructuralEq for Button
impl StructuralPartialEq for Button
Auto Trait Implementations§
impl RefUnwindSafe for Button
impl Send for Button
impl Sync for Button
impl Unpin for Button
impl UnwindSafe for Button
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more