playdate-controls

Crates.ioplaydate-controls
lib.rsplaydate-controls
version0.3.6
sourcesrc
created_at2023-09-08 13:01:36.37918
updated_at2024-07-13 08:12:39.769753
descriptionHigh-level controls API built on-top of Playdate API
homepagehttps://github.com/boozook/playdate
repositoryhttps://github.com/boozook/playdate.git
max_upload_size
id967089
size57,550
Alexander Koz. (boozook)

documentation

README

Controls API for PlayDate

High-level controls API built on-top of playdate-sys.

Covered components: buttons, accelerometer and crank.

Prerequisites

  1. Rust nightly toolchain (rustup is optional)
  2. Playdate SDK
  3. Follow the official documentation
  4. Follow the instructions for playdate-sys

Usage

Buttons:

extern crate playdate_controls as controls;

// Get buttons state
let buttons = controls::peripherals::Buttons::get();

if buttons.current.a() { println("button A currently is DOWN") }
if buttons.pushed.b() { println("button B was pushed") }
if buttons.released.b() { println("button B was released") }

Accelerometer:

extern crate playdate_controls as controls;

// Turn on the accelerometer
controls::peripherals::Accelerometer::enable();

// Get accelerometer data
let (x, y, z) = controls::peripherals::Accelerometer::get();
println!("[{x:.2},{y:.2},{z:.2}]");

See more in examples.


This software is not sponsored or supported by Panic.

Commit count: 476

cargo fmt