-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1d5a38
commit 64f3b87
Showing
16 changed files
with
1,151 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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" | ||
|
||
|
@@ -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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "../../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "../../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "../../" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}); | ||
} |
Oops, something went wrong.