basic_game_events/
input.rs

1use crate::commands::Commands;
2use crate::topic_ids::TopicIds;
3use pubsub_bus::*;
4
5#[allow(dead_code)] // allow dead code for illustrative purposes
6pub struct Input {
7    device: String, // E.g. "keyboard", "mouse", "gamepad"
8    emitter: EventEmitter<Commands, TopicIds>,
9}
10
11impl Input {
12    pub fn new() -> Self {
13        Self {
14            device: "keyboard".to_string(),
15            emitter: EventEmitter::new(),
16        }
17    }
18}
19
20impl Publisher<Commands, TopicIds> for Input {
21    fn get_mut_emitter(&mut self) -> &mut EventEmitter<Commands, TopicIds> {
22        &mut self.emitter
23    }
24}