Skip to content

Commit

Permalink
Merge pull request #38 from lukemcneil/bevy_0.13
Browse files Browse the repository at this point in the history
upgrade to bevy 0.13
  • Loading branch information
BlackPhlox authored May 9, 2024
2 parents a96f7c3 + 793ee17 commit 57be3ac
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ exclude = [
name = "bevy_midi"

[dependencies]
midir = "0.9"
midir = "0.10"
crossbeam-channel = "0.5.8"

[dev-dependencies]
bevy_egui = { version = "0.23", features = ["immutable_ctx"]}
strum = { version = "0.25", features = ["derive"] }
bevy_mod_picking = "0.17"
bevy_egui = { version = "0.27", features = ["immutable_ctx"]}
strum = { version = "0.26", features = ["derive"] }
bevy_mod_picking = "0.18"

[dependencies.bevy]
version = "0.12"
version = "0.13"
default-features = false
features = ["multi-threaded"]

[dev-dependencies.bevy]
version = "0.12"
version = "0.13"
features = ["bevy_core_pipeline","bevy_asset", "bevy_scene", "bevy_render", "bevy_winit", "bevy_gltf", "bevy_ui", "bevy_text", "zstd", "tonemapping_luts", "ktx2", "hdr"]
default-features = false

[target.'cfg(target_os = "linux")'.dev-dependencies.bevy]
version = "0.12"
version = "0.13"
features = ["x11", "wayland"]
default-features = false
29 changes: 15 additions & 14 deletions examples/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ use bevy::{
use bevy_midi::prelude::*;

const KEY_PORT_MAP: [(KeyCode, usize); 10] = [
(KeyCode::Key0, 0),
(KeyCode::Key1, 1),
(KeyCode::Key2, 2),
(KeyCode::Key3, 3),
(KeyCode::Key4, 4),
(KeyCode::Key5, 5),
(KeyCode::Key6, 6),
(KeyCode::Key7, 7),
(KeyCode::Key8, 8),
(KeyCode::Key9, 9),
(KeyCode::Digit0, 0),
(KeyCode::Digit1, 1),
(KeyCode::Digit2, 2),
(KeyCode::Digit3, 3),
(KeyCode::Digit4, 4),
(KeyCode::Digit5, 5),
(KeyCode::Digit6, 6),
(KeyCode::Digit7, 7),
(KeyCode::Digit8, 8),
(KeyCode::Digit9, 9),
];

fn main() {
Expand All @@ -27,6 +27,7 @@ fn main() {
.add_plugins(DefaultPlugins.set(LogPlugin {
level: Level::WARN,
filter: "bevy_midi=debug".to_string(),
update_subscriber: None,
}))
.add_plugins(MidiInputPlugin)
.add_systems(Startup, setup)
Expand All @@ -44,13 +45,13 @@ fn main() {
.run();
}

fn refresh_ports(keys: Res<Input<KeyCode>>, input: Res<MidiInput>) {
if keys.just_pressed(KeyCode::R) {
fn refresh_ports(keys: Res<ButtonInput<KeyCode>>, input: Res<MidiInput>) {
if keys.just_pressed(KeyCode::KeyR) {
input.refresh_ports();
}
}

fn connect(keys: Res<Input<KeyCode>>, input: Res<MidiInput>) {
fn connect(keys: Res<ButtonInput<KeyCode>>, input: Res<MidiInput>) {
for (keycode, index) in &KEY_PORT_MAP {
if keys.just_pressed(*keycode) {
if let Some((_, port)) = input.ports().get(*index) {
Expand All @@ -60,7 +61,7 @@ fn connect(keys: Res<Input<KeyCode>>, input: Res<MidiInput>) {
}
}

fn disconnect(keys: Res<Input<KeyCode>>, input: Res<MidiInput>) {
fn disconnect(keys: Res<ButtonInput<KeyCode>>, input: Res<MidiInput>) {
if keys.just_pressed(KeyCode::Escape) {
input.disconnect();
}
Expand Down
44 changes: 22 additions & 22 deletions examples/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ use bevy::prelude::*;
use bevy_midi::prelude::*;

const KEY_PORT_MAP: [(KeyCode, usize); 10] = [
(KeyCode::Key0, 0),
(KeyCode::Key1, 1),
(KeyCode::Key2, 2),
(KeyCode::Key3, 3),
(KeyCode::Key4, 4),
(KeyCode::Key5, 5),
(KeyCode::Key6, 6),
(KeyCode::Key7, 7),
(KeyCode::Key8, 8),
(KeyCode::Key9, 9),
(KeyCode::Digit0, 0),
(KeyCode::Digit1, 1),
(KeyCode::Digit2, 2),
(KeyCode::Digit3, 3),
(KeyCode::Digit4, 4),
(KeyCode::Digit5, 5),
(KeyCode::Digit6, 6),
(KeyCode::Digit7, 7),
(KeyCode::Digit8, 8),
(KeyCode::Digit9, 9),
];

const KEY_NOTE_MAP: [(KeyCode, u8); 7] = [
(KeyCode::A, 57),
(KeyCode::B, 59),
(KeyCode::C, 60),
(KeyCode::D, 62),
(KeyCode::E, 64),
(KeyCode::F, 65),
(KeyCode::G, 67),
(KeyCode::KeyA, 57),
(KeyCode::KeyB, 59),
(KeyCode::KeyC, 60),
(KeyCode::KeyD, 62),
(KeyCode::KeyE, 64),
(KeyCode::KeyF, 65),
(KeyCode::KeyG, 67),
];

fn main() {
Expand All @@ -46,13 +46,13 @@ fn main() {
.run();
}

fn refresh_ports(input: Res<Input<KeyCode>>, output: Res<MidiOutput>) {
if input.just_pressed(KeyCode::R) {
fn refresh_ports(input: Res<ButtonInput<KeyCode>>, output: Res<MidiOutput>) {
if input.just_pressed(KeyCode::KeyR) {
output.refresh_ports();
}
}

fn connect(input: Res<Input<KeyCode>>, output: Res<MidiOutput>) {
fn connect(input: Res<ButtonInput<KeyCode>>, output: Res<MidiOutput>) {
for (keycode, index) in &KEY_PORT_MAP {
if input.just_pressed(*keycode) {
if let Some((_, port)) = output.ports().get(*index) {
Expand All @@ -62,13 +62,13 @@ fn connect(input: Res<Input<KeyCode>>, output: Res<MidiOutput>) {
}
}

fn disconnect(input: Res<Input<KeyCode>>, output: Res<MidiOutput>) {
fn disconnect(input: Res<ButtonInput<KeyCode>>, output: Res<MidiOutput>) {
if input.just_pressed(KeyCode::Escape) {
output.disconnect();
}
}

fn play_notes(input: Res<Input<KeyCode>>, output: Res<MidiOutput>) {
fn play_notes(input: Res<ButtonInput<KeyCode>>, output: Res<MidiOutput>) {
for (keycode, note) in &KEY_NOTE_MAP {
if input.just_pressed(*keycode) {
output.send([0b1001_0000, *note, 127].into()); // Note on, channel 1, max velocity
Expand Down
5 changes: 3 additions & 2 deletions examples/piano.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ fn main() {
.add_plugins(DefaultPlugins.set(LogPlugin {
level: Level::WARN,
filter: "bevy_midi=debug".to_string(),
update_subscriber: None,
}))
.add_plugins(DefaultPickingPlugins)
.add_plugins(MidiInputPlugin)
Expand Down Expand Up @@ -73,8 +74,8 @@ fn setup(
let mut white_key_0: Handle<Mesh> = asset_server.load("models/white_key_0.gltf#Mesh0/Primitive0");
let mut white_key_1: Handle<Mesh> = asset_server.load("models/white_key_1.gltf#Mesh0/Primitive0");
let mut white_key_2: Handle<Mesh> = asset_server.load("models/white_key_2.gltf#Mesh0/Primitive0");
let b_mat = materials.add(Color::rgb(0.1, 0.1, 0.1).into());
let w_mat = materials.add(Color::rgb(1.0, 1.0, 1.0).into());
let b_mat = materials.add(Color::rgb(0.1, 0.1, 0.1));
let w_mat = materials.add(Color::rgb(1.0, 1.0, 1.0));

//Create keyboard layout
let pos_black = pos + Vec3::new(0., 0.06, 0.);
Expand Down

0 comments on commit 57be3ac

Please sign in to comment.