1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use std::time::Duration;

use bevy::app::{App, Startup, Update};
use bevy::DefaultPlugins;
use bevy::prelude::{Commands, Event, EventReader, GamepadButtonType, KeyCode};

use bevy_input_sequence::AddInputSequenceEvent;
use bevy_input_sequence::prelude::{Act, InputSequence, Timeout};


#[derive(Event, Clone, Debug)]
struct MyEvent;


fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_input_sequence_event::<MyEvent>()
        .add_systems(Startup, setup)
        .add_systems(Update, input_sequence_event_system)
        .run();
}


fn setup(mut commands: Commands) {
    commands.spawn(InputSequence::new(
        MyEvent,
        Timeout::from_duration(Duration::from_secs(5)),
        &[
            Act::Key(KeyCode::W) | Act::PadButton(GamepadButtonType::North),
            Act::Key(KeyCode::D) | Act::PadButton(GamepadButtonType::East),
            Act::Key(KeyCode::S) | Act::PadButton(GamepadButtonType::South),
            Act::Key(KeyCode::A) | Act::PadButton(GamepadButtonType::West)
        ],
    ));
}


fn input_sequence_event_system(
    mut er: EventReader<MyEvent>
) {
    for e in er.iter() {
        println!("{e:?} Coming ");
    }
}