Skip to content

Commit

Permalink
v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AldaronLau committed Jul 30, 2019
1 parent b1d5a38 commit 64f3b87
Show file tree
Hide file tree
Showing 16 changed files with 1,151 additions and 25 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://free.plopgrizzly.com/semver/).

## [Unreleased]
### TODO
- Possibly redesign the controller API to be event based using a message queue.

## [0.3.0] - 2019-05-23
### Added
- `controllers()` which returns a `ControllerIter`.
- `Loop` and `loop_init!()`. Together they handle the program's control flow. It also makes it easier in the future to port to Android and other platforms that don't use `main()`. Besides that, it's a nice abstraction that works similarly to Android activities.
- Multi-threaded support. You should now be able to do IO calls from multiple threads.

### Removed
- `App` type.

### Changed
### Fixed
- Instead of `App` type everything is in a module, and must be enabled with a feature. This makes it so you don't have to compile the parts of the project you don't need.

## [0.2.1] - 2019-05-13
### Fixed
Expand Down
31 changes: 23 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
#
# Copyright © 2017-2019 Jeron Aldaron Lau.
# Dual-licensed under either the MIT License or the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_BSL.txt or copy at https://www.boost.org/LICENSE_1_0.txt, and
# accompanying file LICENSE_MIT.txt or copy at https://opensource.org/licenses/MIT)
# (See accompanying file LICENSE_BSL.txt or copy at https://www.boost.org/LICENSE_1_0.txt
# and accompanying file LICENSE_MIT.txt or copy at https://opensource.org/licenses/MIT)

[package]
name = "cala"
version = "0.2.1"
version = "0.3.0"
authors = ["Jeron Aldaron Lau <[email protected]>"]
edition = "2018"

Expand All @@ -21,8 +21,23 @@ keywords = ["device", "platform-agnostic", "cross-platform", "io", "gui"]
categories = ["game-engines", "hardware-support", "multimedia", "os"]

[dependencies]
whoami = "0.5" # user
wavy = "0.1" # audio
stronghold = "0.2" # file
serde = "1.0"
stick = "0.6" # joystick / controller
whoami = {version = "0.5", optional = true} # user
wavy = {version = "0.1", optional = true} # audio
stronghold = {version = "0.2", optional = true} # file
serde = {version = "1.0", optional = true}
stick = {version = "0.7", optional = true} # joystick / controller
# barg = {path = "../barg", optional = true}

[package.metadata.docs.rs]
features = ["all"]

[features]
default = []
all = ["user", "audio", "files", "controller",
#"gui"
]
user = ["whoami"]
audio = ["wavy"]
files = ["stronghold", "serde"]
controller = ["stick"]
# gui = ["barg"]
9 changes: 9 additions & 0 deletions examples/controller/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "controller"
version = "0.1.0"
authors = ["Jeron Aldaron Lau <[email protected]>"]
edition = "2018"

[dependencies.cala]
features = ["controller"]
path = "../../"
15 changes: 15 additions & 0 deletions examples/controller/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Set the home loop to `run()`.
cala::loop_init!(run, ());

// Function that runs while your app runs.
pub fn run(_: &mut ()) -> cala::Loop<()> {
let layout = cala::ControllerLayout::new().joy(false).lrt(false).abxy(false);

// Iterate through all of the controllers.
'a: for (id, state) in cala::controllers(&layout) {
println!("{}: {:?}", id, state.get());
}
std::thread::sleep(std::time::Duration::from_millis(16));
// Exit.
cala::Continue
}
9 changes: 9 additions & 0 deletions examples/monitoring/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "monitoring"
version = "0.1.0"
authors = ["Jeron Aldaron Lau <[email protected]>"]
edition = "2018"

[dependencies.cala]
features = ["audio"]
path = "../../"
30 changes: 30 additions & 0 deletions examples/monitoring/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use std::collections::VecDeque;

// The program data context.
struct Data {
buffer: VecDeque<(i16, i16)>,
}

// Set the home loop to `run()`.
cala::loop_init!(run, Data {
buffer: VecDeque::new(),
});

fn run(data: &mut Data) -> cala::Loop<Data> {
// Record some sound.
cala::record(&mut |_whichmic, l, r| {
data.buffer.push_back((l, r));
});

// Play that sound.
cala::play(&mut || {
if let Some((lsample, rsample)) = data.buffer.pop_front() {
cala::AudioSample::stereo(lsample, rsample)
} else {
// Play silence if not enough has been recorded yet.
cala::AudioSample::stereo(0, 0)
}
});

cala::Continue
}
9 changes: 9 additions & 0 deletions examples/user/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "user"
version = "0.1.0"
authors = ["Jeron Aldaron Lau <[email protected]>"]
edition = "2018"

[dependencies.cala]
features = ["user"]
path = "../../"
10 changes: 10 additions & 0 deletions examples/user/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Set the home loop to `run()`.
cala::loop_init!(run, ());

// Function that runs while your app runs.
pub fn run(_: &mut ()) -> cala::Loop<()> {
// Print out the user's information.
println!("{}", cala::user());
// Exit.
cala::Exit
}
24 changes: 24 additions & 0 deletions src/internal/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
static START: std::sync::Once = std::sync::ONCE_INIT;

// // // // // //

/// Initialize Cala.
pub fn init() {
START.call_once(|| {
#[cfg(feature = "user")]
{
// Initialize user data.
crate::user::initialize_user_io();
}
#[cfg(feature = "controller")]
{
// Initialize controller port data.
crate::controller::initialize_controller_io();
}
#[cfg(feature = "audio")]
{
// Intialize audio interface.
crate::audio::initialize_audio_io();
}
});
}
Loading

0 comments on commit 64f3b87

Please sign in to comment.