#control-api #playdate-sdk #sdk #playdate #gamedev

nightly no-std playdate-controls

High-level controls API built on-top of Playdate API

19 releases

new 0.3.9 Mar 19, 2025
0.3.7 Jan 31, 2025
0.3.6 Jul 13, 2024
0.3.2 Oct 27, 2023

#1810 in Game dev

Download history 3/week @ 2024-11-29 11/week @ 2024-12-06 10/week @ 2024-12-13 1/week @ 2024-12-20 8/week @ 2025-01-24 168/week @ 2025-01-31 17/week @ 2025-02-07 210/week @ 2025-02-14 66/week @ 2025-02-21 42/week @ 2025-02-28 16/week @ 2025-03-07 123/week @ 2025-03-14

254 downloads per month
Used in 2 crates

MIT/Apache

26MB
408K SLoC

Controls API for PlayDate

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

Covered components: buttons, accelerometer and crank.

⚠️ Prior to the version 1.0 API is unstable and can be changed without deprecation period.

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.

Dependencies