Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ device = { version = "0.2", path = "support/device", package = "playdate-device"
simulator = { version = "0.1", path = "support/sim-ctrl", package = "playdate-simulator-utils", default-features = false }
bindgen = { version = "0.2", path = "support/bindgen", package = "playdate-bindgen", default-features = false }
bindgen-cfg = { version = "0.2", path = "support/bindgen-cfg", package = "playdate-bindgen-cfg", default-features = false }
gen-api-shorthands = { version = "0.1", path = "support/gen-api-shorthands", package = "playdate-gen-api-shorthands" }

# Deps that used multiple times,
# This is to prevent various versions in the deps-tree for faster compilation time
Expand All @@ -52,6 +53,10 @@ thiserror = "2.0"
tokio = { version = "1.43", default-features = false }
async-std = { version = "1.13", default-features = false }

proc-macro2 = { version = "1.0" }
quote = { version = "1.0" }
syn = { version = "2.0", features = ["extra-traits", "full", "parsing"] }


[workspace.metadata.playdate.options.assets]
dependencies = true
Expand Down
3 changes: 2 additions & 1 deletion api/ctrl/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-controls"
version = "0.3.8"
version = "0.3.9"
readme = "README.md"
description = "High-level controls API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand All @@ -23,6 +23,7 @@ bindings-derive-debug = ["sys/bindings-derive-debug"]


[dependencies]
gen-api-shorthands.workspace = true
sys = { workspace = true, default-features = false }
system = { workspace = true, default-features = false }

Expand Down
1 change: 1 addition & 0 deletions api/ctrl/src/buttons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use core::fmt::Display;
use core::ops::BitAnd;
use sys::ffi::PDButtons;

pub use crate::peripherals::buttons_shorthands::*;

pub trait PDButtonsExt: Sized + BitAnd<Self> {
#![allow(non_snake_case)]
Expand Down
8 changes: 8 additions & 0 deletions api/ctrl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,11 @@ extern crate sys;
pub mod api;
pub mod buttons;
pub mod peripherals;

pub mod accelerometer {
pub use crate::peripherals::accelerometer_shorthands::*;
}

pub mod crank {
pub use crate::peripherals::crank_shorthands::*;
}
4 changes: 4 additions & 0 deletions api/ctrl/src/peripherals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl<Api: api::Api> Peripherals<Api> where Api: Copy {
pub const fn crank(&self) -> Crank<Api> { Crank(self.0) }
}

#[gen_api_shorthands::gen_shorthands]
impl<Api: api::Api> Peripherals<Api> {
/// Enables specified peripheral.
///
Expand Down Expand Up @@ -134,6 +135,7 @@ impl<Api: api::Api> Accelerometer<Api> {
pub const fn new_with(api: Api) -> Self { Self(api) }
}

#[gen_api_shorthands::gen_shorthands(pub(crate) mod accelerometer_shorthands)]
impl<Api: api::Api> Accelerometer<Api> {
/// Enables accelerometer only.
///
Expand Down Expand Up @@ -218,6 +220,7 @@ impl<Api: api::Api> Buttons<Api> {
pub const fn new_with(api: Api) -> Self { Self(api) }
}

#[gen_api_shorthands::gen_shorthands(pub(crate) mod buttons_shorthands)]
impl<Api: api::Api> Buttons<Api> {
/// Returns the current buttons [`State`].
///
Expand Down Expand Up @@ -363,6 +366,7 @@ impl<Api: api::Api> Crank<Api> {
pub const fn new_with(api: Api) -> Self { Self(api) }
}

#[gen_api_shorthands::gen_shorthands(pub(crate) mod crank_shorthands)]
impl<Api: api::Api> Crank<Api> {
/// Returns boolean indicating whether or not the crank is folded into the unit.
///
Expand Down
10 changes: 4 additions & 6 deletions api/display/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-display"
version = "0.3.8"
version = "0.3.9"
readme = "README.md"
description = "High-level Display API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand All @@ -21,11 +21,9 @@ bindgen-runtime = ["sys/bindgen-runtime"]
bindgen-static = ["sys/bindgen-static"]
bindings-derive-debug = ["sys/bindings-derive-debug"]


[dependencies.sys]
workspace = true
default-features = false

[dependencies]
gen-api-shorthands.workspace = true
sys = { workspace = true, default-features = false }

[package.metadata.docs.rs]
all-features = false
Expand Down
3 changes: 1 addition & 2 deletions api/display/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use core::ffi::c_float;
use core::ffi::c_int;
use core::ffi::c_uint;


#[derive(Debug, Clone, Copy)]
pub struct Display<Api = api::Default>(Api);

Expand Down Expand Up @@ -48,7 +47,7 @@ impl Display<api::Default> {
bottom: Self::ROWS as _ };
}


#[gen_api_shorthands::gen_shorthands]
impl<Api: api::Api> Display<Api> {
/// Returns the width of the display, taking the current scale into account;
///
Expand Down
3 changes: 2 additions & 1 deletion api/gfx/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "playdate-graphics"
version = "0.6.0"
version = "0.6.1"
readme = "README.md"
description = "High-level graphics API built on-top of Playdate API"
keywords = ["playdate", "sdk", "api", "gamedev"]
Expand All @@ -24,6 +24,7 @@ bindings-derive-debug = ["sys/bindings-derive-debug", "color/bindings-derive-deb


[dependencies]
gen-api-shorthands.workspace = true
sys = { workspace = true, default-features = false }
fs = { workspace = true, default-features = false }
color = { workspace = true, default-features = false }
Expand Down
125 changes: 2 additions & 123 deletions api/gfx/src/bitmap/bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,130 +601,9 @@ impl core::fmt::Debug for BitmapData<'_> {
}
}

pub use frame_buffer_bitmap as copy_frame_buffer_bitmap;

//
// Global Bitmap-related methods
//

/// Only valid in the Simulator,
/// returns the debug framebuffer as a bitmap.
///
/// Returns error on device.
///
/// This function is shorthand for [`Graphics::debug_bitmap`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::getDebugBitmap`].
#[doc(alias = "sys::ffi::playdate_graphics::getDebugBitmap")]
#[inline(always)]
pub fn debug_bitmap() -> Result<Bitmap<api::Default, false>, ApiError> { Graphics::Default().debug_bitmap() }

/// Returns a bitmap containing the contents of the display buffer.
///
/// __The system owns this bitmap—​do not free it.__
///
/// This function is shorthand for [`Graphics::display_buffer_bitmap`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::getDisplayBufferBitmap`].
#[doc(alias = "sys::ffi::playdate_graphics::getDisplayBufferBitmap")]
#[inline(always)]
pub fn display_buffer_bitmap() -> Result<Bitmap<api::Default, false>, Error> {
Graphics::Default().display_buffer_bitmap()
}

/// Returns a copy the contents of the working frame buffer as a bitmap.
///
/// The caller is responsible for freeing the returned bitmap, it will automatically on drop.
///
/// This function is shorthand for [`Graphics::frame_buffer_bitmap`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::copyFrameBufferBitmap`].
#[doc(alias = "sys::ffi::playdate_graphics::copyFrameBufferBitmap")]
#[inline(always)]
pub fn copy_frame_buffer_bitmap() -> Result<Bitmap<api::Default, true>, Error> {
Graphics::Default().frame_buffer_bitmap()
}


/// Sets the stencil used for drawing.
///
/// If the `tile` is `true` the stencil image will be tiled.
///
/// Tiled stencils must have width equal to a multiple of 32 pixels.
///
/// This function is shorthand for [`Graphics::set_stencil_tiled`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::setStencilImage`].
#[doc(alias = "sys::ffi::playdate_graphics::setStencilImage")]
#[inline(always)]
pub fn set_stencil_tiled(image: &impl AnyBitmap, tile: bool) {
Graphics::Default().set_stencil_tiled(image, tile)
}

/// Sets the stencil used for drawing.
/// For a tiled stencil, use [`set_stencil_tiled`] instead.
///
/// NOTE: Officially deprecated in favor of [`set_stencil_tiled`], which adds a `tile` flag
///
/// This function is shorthand for [`Graphics::set_stencil`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::setStencil`].
#[doc(alias = "sys::ffi::playdate_graphics::setStencil")]
#[inline(always)]
pub fn set_stencil(image: &impl AnyBitmap) { Graphics::Default().set_stencil(image) }

/// Sets the mode used for drawing bitmaps.
///
/// Note that text drawing uses bitmaps, so this affects how fonts are displayed as well.
///
/// This function is shorthand for [`Graphics::set_draw_mode`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::setDrawMode`].
#[doc(alias = "sys::ffi::playdate_graphics::setDrawMode")]
#[inline(always)]
pub fn set_draw_mode(mode: BitmapDrawMode) -> BitmapDrawMode { Graphics::Default().set_draw_mode(mode) }

/// Push a new drawing context for drawing into the given bitmap.
///
/// If `target` is [`BitmapRef::null()`], the drawing functions will use the display framebuffer.
///
/// To push framebuffer to context use [`push_framebuffer_to_context`].
///
/// This function is shorthand for [`Graphics::push_context`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::pushContext`].
#[doc(alias = "sys::ffi::playdate_graphics::pushContext")]
#[inline(always)]
pub fn push_context(target: &impl AnyBitmap) { Graphics::Default().push_context(target) }

/// Push a new drawing context for drawing into the display framebuffer.
///
/// This function is shorthand for [`Graphics::push_framebuffer_to_context`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::pushContext`].
#[doc(alias = "sys::ffi::playdate_graphics::pushContext")]
#[inline(always)]
pub fn push_framebuffer_to_context() { Graphics::Default().push_framebuffer_to_context() }

/// Pops a context off the stack (if any are left),
/// restoring the drawing settings from before the context was pushed.
///
/// This function is shorthand for [`Graphics::pop_context`],
/// using default ZST end-point.
///
/// Equivalent to [`sys::ffi::playdate_graphics::popContext`].
#[doc(alias = "sys::ffi::playdate_graphics::popContext")]
#[inline(always)]
pub fn pop_context() { Graphics::Default().pop_context() }


#[gen_api_shorthands::gen_shorthands]
impl<Api: crate::api::Api> Graphics<Api> {
/// Only valid in the Simulator,
/// returns the debug framebuffer as a bitmap.
Expand Down
Loading
Loading