Skip to content

Commit

Permalink
doc: Bump to 0.6.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecelis committed Nov 24, 2024
1 parent fbb12c6 commit 2ca3f55
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 17 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

All notable changes to this project will be documented in this file.

## [0.4.0] - 2024-04-23
## [0.5.0] - 2024-04-23

### Features
- Optimize look ups to incrementally search using O(log n) instead of O(m^2 log n). See [PR #7](https://github.com/not-elm/bevy-input-sequence/pull/7) for more details.

## [0.4.0] - 2024-04-23

Expand Down
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy-input-sequence"
description = "Recognizes input sequences and send events"
version = "0.5.0"
description = "Recognizes and acts on input sequences"
version = "0.6.0"
edition = "2021"
authors = ["elm", "Shane Celis <[email protected]>"]
keywords = [
Expand All @@ -18,22 +18,18 @@ readme = "README.md"
license = "MIT OR Apache-2.0"
repository = "https://github.com/elm-register/bevy-input-sequence"


[[example]]
name = "keycode"
path = "examples/keycode.rs"


[[example]]
name = "gamepad_button"
path = "examples/gamepad_button.rs"


[[example]]
name = "multiple_input"
path = "examples/multiple_input.rs"


[dependencies]
bevy = { version = "0.14", default-features = false, features = [] }
trie-rs = { version = "0.4" }
Expand All @@ -43,3 +39,6 @@ keyseq = { version = "0.4.0", features = [ "bevy" ] }
bevy = "0.14"
trybuild = "1.0"
version-sync = "0.9"

[patch.crates-io]
keyseq = { path = "../keyseq" }
54 changes: 45 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# bevy-input-sequence

Detect input sequences from the keyboard or a gamepad.
Recognizes and acts on input sequences from the keyboard or a gamepad.

# Use Cases

Expand Down Expand Up @@ -42,6 +42,7 @@ fn main() {
}

fn setup(mut commands: Commands) {
// Add key sequence.
commands.add(
KeySequence::new(say_hello,
keyseq! { H I })
Expand All @@ -63,11 +64,11 @@ with `action::send_event()`.
use bevy::prelude::*;
use bevy_input_sequence::prelude::*;

// Define an event
/// Define an event.
#[derive(Event, Clone, Debug)]
struct MyEvent;

// Add event as an key sequence
/// Add event as an key sequence.
fn main() {
App::new()
.add_plugins(MinimalPlugins)
Expand Down Expand Up @@ -101,11 +102,11 @@ take an input of `Gamepad`.
use bevy::prelude::*;
use bevy_input_sequence::prelude::*;

// Define an event
/// Define an event.
#[derive(Event, Clone, Debug)]
struct MyEvent(Gamepad);

// Add event as an key sequence
/// Add event as an key sequence.
fn main() {
App::new()
.add_plugins(MinimalPlugins)
Expand All @@ -132,6 +133,41 @@ fn check_events(mut events: EventReader<MyEvent>) {
}
```

## Trigger an Event on Key Sequence

You can also trigger an event with `action::trigger()` or `action::trigger_targets()`.

```rust
use bevy::prelude::*;
use bevy_input_sequence::prelude::*;

/// Define an event.
#[derive(Event, Clone, Debug)]
struct MyEvent;

/// Add event as an key sequence.
fn main() {
App::new()
.add_plugins(MinimalPlugins)
.add_plugins(InputSequencePlugin::default())
.add_event::<MyEvent>()
.add_systems(Startup, setup)
.observe(check_trigger)
.update(); // Normally you'd run it here.
}

fn setup(mut commands: Commands) {
commands.add(
KeySequence::new(action::trigger(MyEvent),
keyseq! { Ctrl-E L M })
);
}

fn check_trigger(mut trigger: Trigger<MyEvent>) {
info!("got event {:?}", trigger.event());
}
```

## KeySequence Creation Patterns

`KeySequence::new` now returns `KeySequenceBuilder`, which implements `Command`.
Expand All @@ -152,8 +188,8 @@ fn create_key_sequence(mut commands: Commands) {
}

fn create_key_sequence_and_add_it_to_an_entity(mut commands: Commands) {
let parent = commands.spawn_empty().id();
commands.entity(parent).add(KeySequence::new(
let id = commands.spawn_empty().id();
commands.entity(id).add(KeySequence::new(
action::send_event(MyEvent),
keyseq! { Ctrl-E L M }
));
Expand Down Expand Up @@ -254,8 +290,8 @@ cargo run --example run_if

| bevy-input-sequence | bevy |
|---------------------|------|
| 0.5 | 0.14 |
| 0.3 ~ 0.4.0 | 0.13 |
| 0.5 ~ 0.6 | 0.14 |
| 0.3 ~ 0.4 | 0.13 |
| 0.2 | 0.12 |
| 0.1 | 0.11 |

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![doc(html_root_url = "https://docs.rs/bevy-input-sequence/0.5.0")]
#![doc(html_root_url = "https://docs.rs/bevy-input-sequence/0.6.0")]
#![doc = include_str!("../README.md")]
#![forbid(missing_docs)]

Expand Down

0 comments on commit 2ca3f55

Please sign in to comment.