Skip to main content

Buttons

Struct Buttons 

Source
pub struct Buttons(/* private fields */);
Expand description

The eight buttons, set where held.

The d-pad occupies the low nibble and the action buttons the high one, which is the layout GBDK’s J_ constants use.

Implementations§

Source§

impl Buttons

Source

pub const fn new() -> Self

Creates a new default initialized bitfield.

Source

pub const fn from_bits(bits: u8) -> Self

Convert from bits.

Source

pub const fn into_bits(self) -> u8

Convert into bits.

Source

pub const fn right(&self) -> bool

Right on the d-pad.

Bits: 0..1

Source

pub const fn with_right_checked(self, value: bool) -> Result<Self, ()>

Right on the d-pad.

Bits: 0..1

Source

pub const fn with_right(self, value: bool) -> Self

Right on the d-pad.

Bits: 0..1

Source

pub const fn set_right(&mut self, value: bool)

Right on the d-pad.

Bits: 0..1

Source

pub const fn set_right_checked(&mut self, value: bool) -> Result<(), ()>

Right on the d-pad.

Bits: 0..1

Source

pub const fn left(&self) -> bool

Left on the d-pad.

Bits: 1..2

Source

pub const fn with_left_checked(self, value: bool) -> Result<Self, ()>

Left on the d-pad.

Bits: 1..2

Source

pub const fn with_left(self, value: bool) -> Self

Left on the d-pad.

Bits: 1..2

Source

pub const fn set_left(&mut self, value: bool)

Left on the d-pad.

Bits: 1..2

Source

pub const fn set_left_checked(&mut self, value: bool) -> Result<(), ()>

Left on the d-pad.

Bits: 1..2

Source

pub const fn up(&self) -> bool

Up on the d-pad.

Bits: 2..3

Source

pub const fn with_up_checked(self, value: bool) -> Result<Self, ()>

Up on the d-pad.

Bits: 2..3

Source

pub const fn with_up(self, value: bool) -> Self

Up on the d-pad.

Bits: 2..3

Source

pub const fn set_up(&mut self, value: bool)

Up on the d-pad.

Bits: 2..3

Source

pub const fn set_up_checked(&mut self, value: bool) -> Result<(), ()>

Up on the d-pad.

Bits: 2..3

Source

pub const fn down(&self) -> bool

Down on the d-pad.

Bits: 3..4

Source

pub const fn with_down_checked(self, value: bool) -> Result<Self, ()>

Down on the d-pad.

Bits: 3..4

Source

pub const fn with_down(self, value: bool) -> Self

Down on the d-pad.

Bits: 3..4

Source

pub const fn set_down(&mut self, value: bool)

Down on the d-pad.

Bits: 3..4

Source

pub const fn set_down_checked(&mut self, value: bool) -> Result<(), ()>

Down on the d-pad.

Bits: 3..4

Source

pub const fn a(&self) -> bool

The A button.

Bits: 4..5

Source

pub const fn with_a_checked(self, value: bool) -> Result<Self, ()>

The A button.

Bits: 4..5

Source

pub const fn with_a(self, value: bool) -> Self

The A button.

Bits: 4..5

Source

pub const fn set_a(&mut self, value: bool)

The A button.

Bits: 4..5

Source

pub const fn set_a_checked(&mut self, value: bool) -> Result<(), ()>

The A button.

Bits: 4..5

Source

pub const fn b(&self) -> bool

The B button.

Bits: 5..6

Source

pub const fn with_b_checked(self, value: bool) -> Result<Self, ()>

The B button.

Bits: 5..6

Source

pub const fn with_b(self, value: bool) -> Self

The B button.

Bits: 5..6

Source

pub const fn set_b(&mut self, value: bool)

The B button.

Bits: 5..6

Source

pub const fn set_b_checked(&mut self, value: bool) -> Result<(), ()>

The B button.

Bits: 5..6

Source

pub const fn select(&self) -> bool

The Select button.

Bits: 6..7

Source

pub const fn with_select_checked(self, value: bool) -> Result<Self, ()>

The Select button.

Bits: 6..7

Source

pub const fn with_select(self, value: bool) -> Self

The Select button.

Bits: 6..7

Source

pub const fn set_select(&mut self, value: bool)

The Select button.

Bits: 6..7

Source

pub const fn set_select_checked(&mut self, value: bool) -> Result<(), ()>

The Select button.

Bits: 6..7

Source

pub const fn start(&self) -> bool

The Start button.

Bits: 7..8

Source

pub const fn with_start_checked(self, value: bool) -> Result<Self, ()>

The Start button.

Bits: 7..8

Source

pub const fn with_start(self, value: bool) -> Self

The Start button.

Bits: 7..8

Source

pub const fn set_start(&mut self, value: bool)

The Start button.

Bits: 7..8

Source

pub const fn set_start_checked(&mut self, value: bool) -> Result<(), ()>

The Start button.

Bits: 7..8

Source§

impl Buttons

Source

pub const fn x(self) -> DPadX

Where the d-pad points left or right.

Source

pub const fn y(self) -> DPadY

Where the d-pad points up or down.

Trait Implementations§

Source§

impl Clone for Buttons

Source§

fn clone(&self) -> Buttons

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 Buttons

Source§

impl Debug for Buttons

Source§

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

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

impl Default for Buttons

Source§

fn default() -> Self

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

impl Eq for Buttons

Source§

impl From<Buttons> for u8

Source§

fn from(v: Buttons) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Buttons

Source§

fn from(v: u8) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Buttons

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Buttons

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CellValue for T
where T: Copy + BankSafe,

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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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.