[][src]Struct gba_hal::data::KeyInput

#[repr(transparent)]
pub struct KeyInput(pub u16);

This is the GBA's native key reading value.

The term "native" here means "low-active". In other words, false == "pressed", and true is "released".

You probably actually want to have "normal" style key data, where false == "released" and true == "pressed". To get this you must XOR the lower 10 bits of the inner value:

let high_active_keys_value = key_input.0 ^ 0b11_1111_1111;

That's not provided by this crate because this crate sticks to minimal declarations. You can of course use the gba crate for this and other helpful higher level abstractions.

The bits are as follows:

  • 0: a
  • 1: b
  • 2: select
  • 3: start
  • 4: right
  • 5: left
  • 6: up
  • 7: down
  • 8: r
  • 9: l

Methods

impl KeyInput[src]

pub const fn new() -> Self[src]

A const "zero value" constructor

impl KeyInput[src]

pub const A_RELEASED_BIT: u16[src]

pub const fn a_released(self) -> bool[src]

pub const fn with_a_released(self, bit: bool) -> Self[src]

pub const B_RELEASED_BIT: u16[src]

pub const fn b_released(self) -> bool[src]

pub const fn with_b_released(self, bit: bool) -> Self[src]

pub const SELECT_RELEASED_BIT: u16[src]

pub const fn select_released(self) -> bool[src]

pub const fn with_select_released(self, bit: bool) -> Self[src]

pub const START_RELEASED_BIT: u16[src]

pub const fn start_released(self) -> bool[src]

pub const fn with_start_released(self, bit: bool) -> Self[src]

pub const RIGHT_RELEASED_BIT: u16[src]

pub const fn right_released(self) -> bool[src]

pub const fn with_right_released(self, bit: bool) -> Self[src]

pub const LEFT_RELEASED_BIT: u16[src]

pub const fn left_released(self) -> bool[src]

pub const fn with_left_released(self, bit: bool) -> Self[src]

pub const UP_RELEASED_BIT: u16[src]

pub const fn up_released(self) -> bool[src]

pub const fn with_up_released(self, bit: bool) -> Self[src]

pub const DOWN_RELEASED_BIT: u16[src]

pub const fn down_released(self) -> bool[src]

pub const fn with_down_released(self, bit: bool) -> Self[src]

pub const R_RELEASED_BIT: u16[src]

pub const fn r_released(self) -> bool[src]

pub const fn with_r_released(self, bit: bool) -> Self[src]

pub const L_RELEASED_BIT: u16[src]

pub const fn l_released(self) -> bool[src]

pub const fn with_l_released(self, bit: bool) -> Self[src]

Trait Implementations

impl PartialEq<KeyInput> for KeyInput[src]

impl Eq for KeyInput[src]

impl Copy for KeyInput[src]

impl Debug for KeyInput[src]

impl Clone for KeyInput[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Default for KeyInput[src]

Auto Trait Implementations

impl Send for KeyInput

impl Sync for KeyInput

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]