ControllerState

Struct ControllerState 

Source
pub struct ControllerState {
    pub up: Input<'static>,
    pub down: Input<'static>,
    pub left: Input<'static>,
    pub right: Input<'static>,
    pub a: Input<'static>,
    pub b: Input<'static>,
    pub c: Input<'static>,
    pub d: Input<'static>,
    pub select: Input<'static>,
    pub start: Input<'static>,
}
Expand description

State of all physical input buttons on the Lilka game console.

Each field is an esp-hal [Input] pin configured with an internal pull-up resistor. The logic is active-low:

  • is_low() → button is pressed.
  • is_high() → button is released.

§Layout

                [UP  GPIO38]
[LEFT GPIO39]  [DOWN GPIO41]  [RIGHT GPIO40]

[A GPIO5]  [B GPIO6]  [C GPIO10]  [D GPIO9]

     [SELECT GPIO0]   [START GPIO4]

§Example — D-pad and buttons in a game loop

use lilkaoxide::prelude::*;

loop {
    if lilka.controller.up.is_low() {
        // move player up
    }
    if lilka.controller.a.is_low() {
        // action A
    }
    if lilka.controller.start.is_low() {
        // pause menu
    }
}

Fields§

§up: Input<'static>

D-pad up — GPIO38, active-low.

§down: Input<'static>

D-pad down — GPIO41, active-low.

§left: Input<'static>

D-pad left — GPIO39, active-low.

§right: Input<'static>

D-pad right — GPIO40, active-low.

§a: Input<'static>

Action button A — GPIO5, active-low.

§b: Input<'static>

Action button B — GPIO6, active-low.

§c: Input<'static>

Action button C — GPIO10, active-low.

§d: Input<'static>

Action button D — GPIO9, active-low.

§select: Input<'static>

Select button — GPIO0, active-low.

§start: Input<'static>

Start button — GPIO4, active-low.

Implementations§

Source§

impl ControllerState

Source

pub fn init_controller( gpio5: GPIO5<'static>, gpio6: GPIO6<'static>, gpio10: GPIO10<'static>, gpio9: GPIO9<'static>, gpio38: GPIO38<'static>, gpio41: GPIO41<'static>, gpio39: GPIO39<'static>, gpio40: GPIO40<'static>, gpio0: GPIO0<'static>, gpio4: GPIO4<'static>, ) -> Self

Initialises all controller GPIO pins as pull-up inputs.

This function is called internally by crate::Lilka::init — you should not need to call it directly. It moves the concrete GPIO peripheral tokens into [Input] handles with Pull::Up so that pressing a button drives the pin to ground (active-low).

§Pin assignment

Auto Trait Implementations§

§

impl Freeze for ControllerState

§

impl RefUnwindSafe for ControllerState

§

impl Send for ControllerState

§

impl Sync for ControllerState

§

impl Unpin for ControllerState

§

impl !UnwindSafe for ControllerState

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.