This commit is contained in:
Thomas Forgione 2022-08-02 14:17:11 +02:00
parent bc48d72c90
commit fe1a0537b5
2 changed files with 17 additions and 6 deletions

View File

@ -199,12 +199,12 @@ impl Updatable for Character {
/// An event was asked to the character.
fn manage_event(&mut self, event: Event) {
match event {
Event::ButtonPressed(Button::Button1) => {
Event::ButtonPressed(Button::Button0) => {
self.jump();
self.can_jump = false;
}
Event::ButtonReleased(Button::Button1) => {
Event::ButtonReleased(Button::Button0) => {
self.can_jump = true;
}

View File

@ -35,20 +35,23 @@ pub enum Button {
Down,
/// The main action or validatation button.
Button1,
Button0,
/// The user asks to do the secondary action.
Button2,
Button1,
/// The user asks to do the tertiary action.
Button3,
Button2,
/// The user asks to do the 4th action or cancel.
Button4,
Button3,
}
/// This structure holds what button are pressed or released, and stores the events.
pub struct InputManager {
/// All the connected gamepads.
gamepads: Vec<Gamepad>,
/// The events that have occur.
events: VecDeque<Event>,
}
@ -57,7 +60,15 @@ impl InputManager {
/// Creates a new input manager.
pub fn new() -> InputManager {
InputManager {
gamepads: vec![],
events: VecDeque::new(),
}
}
}
/// Holds the gamepad information.
#[derive(Clone)]
pub struct Gamepad {
/// The inner gamepad.
inner: web_sys::Gamepad,
}