Skip to content

Commit

Permalink
style: Cargo fmt.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecelis committed Dec 1, 2024
1 parent 9861067 commit cf89e1b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 27 deletions.
4 changes: 3 additions & 1 deletion src/chord.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use bevy::{
input::keyboard::KeyCode, prelude::{Deref, DerefMut, Resource}, reflect::{Enum, Reflect}
input::keyboard::KeyCode,
prelude::{Deref, DerefMut, Resource},
reflect::{Enum, Reflect},
};

use std::{collections::VecDeque, fmt};
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod plugin;
mod time_limit;

pub use chord::{KeyChord, KeyChordQueue};
pub use plugin::{InputSequencePlugin};
pub use plugin::InputSequencePlugin;
pub use time_limit::TimeLimit;

pub use keyseq::{
Expand All @@ -22,9 +22,9 @@ pub use keyseq::{

/// Convenient glob import
pub mod prelude {
pub use super::cond_system::IntoCondSystem;
pub use super::input_sequence::{ButtonSequence, InputSequence, KeySequence};
pub use super::{action, keyseq, InputSequencePlugin, Modifiers, TimeLimit};
pub use super::{KeyChordQueue, KeyChord};
pub use super::cond_system::IntoCondSystem;
pub use super::{KeyChord, KeyChordQueue};
pub use std::time::Duration;
}
22 changes: 12 additions & 10 deletions src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use std::collections::{HashMap, VecDeque};

use crate::{
cache::InputSequenceCache,
chord::{KeyChordQueue, is_modifier},
chord::{is_modifier, KeyChordQueue},
frame_time::FrameTime,
input_sequence::{ButtonSequence, InputSequence, KeySequence},
KeyChord, Modifiers,
Expand Down Expand Up @@ -242,15 +242,17 @@ fn key_sequence_matcher(
time: time.elapsed_seconds(),
};
let maybe_start = last_times.front().cloned();
let mut input = keychord_queue.drain(..).chain(
keys
.get_just_pressed()
.filter(|k| !is_modifier(**k))
.map(|k| {
let chord = KeyChord(mods, *k);
last_times.push_back(now.clone());
chord
}))
let mut input = keychord_queue
.drain(..)
.chain(
keys.get_just_pressed()
.filter(|k| !is_modifier(**k))
.map(|k| {
let chord = KeyChord(mods, *k);
last_times.push_back(now.clone());
chord
}),
)
.peekable();
if input.peek().is_none() {
return;
Expand Down
20 changes: 7 additions & 13 deletions tests/simulated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ mod simulate_app {
keyboard::KeyCode,
Axis, ButtonInput as Input,
},
prelude::{Resource, Commands, ResMut},
prelude::{Commands, ResMut, Resource},
MinimalPlugins,
};
use bevy_input_sequence::prelude::*;
Expand Down Expand Up @@ -261,18 +261,12 @@ mod simulate_app {
fn match_a_and_c() {
let mut app = new_app();

app.world_mut().add(KeySequence::new(
set(1),
[KeyCode::KeyA],
));
app.world_mut().add(KeySequence::new(
set(2),
[KeyCode::KeyA, KeyCode::KeyB],
));
app.world_mut().add(KeySequence::new(
set(3),
[KeyCode::KeyC],
));
app.world_mut()
.add(KeySequence::new(set(1), [KeyCode::KeyA]));
app.world_mut()
.add(KeySequence::new(set(2), [KeyCode::KeyA, KeyCode::KeyB]));
app.world_mut()
.add(KeySequence::new(set(3), [KeyCode::KeyC]));
assert_eq!(get(app.world()), 0);
press_key(&mut app, KeyCode::KeyA);
app.update();
Expand Down

0 comments on commit cf89e1b

Please sign in to comment.