Skip to content

Commit

Permalink
Add system api (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
boozook authored Sep 15, 2023
1 parent ff44928 commit 1da2ad4
Show file tree
Hide file tree
Showing 7 changed files with 498 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ jobs:
cargo test -p=playdate-display --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-display --lib --no-default-features --features=$FEATURES_2 -- --nocapture
cargo test -p=playdate-system --lib --no-default-features --features=$FEATURES_1 -- --nocapture
cargo test -p=playdate-system --lib --no-default-features --features=$FEATURES_2 -- --nocapture
- name: Examples
run: |
FEATURES=bindgen-runtime,bindings-derive-debug
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

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

40 changes: 40 additions & 0 deletions api/system/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "playdate-system"
version = "0.1.0"
edition = "2021"

readme = "README.md"
license = "MIT OR Apache-2.0"
authors = ["Alex Koz <[email protected]>"]
description = "High-level System API built on-top of Playdate API"
homepage = "https://github.com/boozook/playdate"
repository = "https://github.com/boozook/playdate.git"


[features]
default = ["sys/default"]
# sys- features:
lang-items = ["sys/lang-items"]
allocator = ["sys/allocator"]
panic-handler = ["sys/panic-handler"]
eh-personality = ["sys/eh-personality"]
error-ctx = ["sys/error-ctx"]
bindgen-runtime = ["sys/bindgen-runtime"]
bindgen-static = ["sys/bindgen-static"]
bindings-derive-default = ["sys/bindings-derive-default"]
bindings-derive-eq = ["sys/bindings-derive-eq"]
bindings-derive-copy = ["sys/bindings-derive-copy"]
bindings-derive-debug = ["sys/bindings-derive-debug"]
bindings-derive-hash = ["sys/bindings-derive-hash"]
bindings-derive-ord = ["sys/bindings-derive-ord"]
bindings-derive-partialeq = ["sys/bindings-derive-partialeq"]
bindings-derive-partialord = ["sys/bindings-derive-partialord"]
bindings-derive-constparamty = ["sys/bindings-derive-constparamty"]
bindings-documentation = ["sys/bindings-documentation"]


[dependencies.sys]
version = "0.1"
path = "../sys"
package = "playdate-sys"
default-features = false
29 changes: 29 additions & 0 deletions api/system/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# System API for PlayDate

High-level system API built on-top of [playdate-sys][].


## Usage

```rust
use playdate_system::*;
use playdate_sys::println;

let system = System::new();

match system.language() {
PDLanguage::English => println!("Hello"),
PDLanguage::Japanese => println!("こんにちは"),
PDLanguage::Unknown => println!("Привет"),
}
system.draw_fps(20, 20);
```


[playdate-sys]: https://crates.io/crates/playdate-sys



- - -

This software is not sponsored or supported by Panic.
11 changes: 11 additions & 0 deletions api/system/src/lang.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pub use sys::ffi::PDLanguage;

pub trait PDLanguageExt {
#![allow(non_upper_case_globals)]
const English: PDLanguage = PDLanguage::kPDLanguageEnglish;
const Japanese: PDLanguage = PDLanguage::kPDLanguageJapanese;
const Unknown: PDLanguage = PDLanguage::kPDLanguageUnknown;
}


impl PDLanguageExt for PDLanguage {}
Loading

0 comments on commit 1da2ad4

Please sign in to comment.