}
pub struct App {
- pub canvas: Canvas<Window>,
- pub event_pump: EventPump,
- pub sprites: SpriteManager,
- pub state: Box<dyn AppState>,
- pub ctrl_man: ControllerManager,
+ canvas: Canvas<Window>,
+ event_pump: EventPump,
+ sprites: SpriteManager,
+ state: Box<dyn AppState>,
+ ctrl_man: ControllerManager,
}
impl App {
pub fn handle_event(&mut self, event: &Event) {
match event {
- Event::ControllerDeviceAdded { which: id, .. } => { self.add_device(*id) }
- Event::ControllerDeviceRemoved { which: id, .. } => { self.remove_device(*id) }
- Event::ControllerDeviceRemapped { which: id, .. } => { println!("device remapped ({})!", *id) }
- Event::ControllerButtonDown { button: btn, .. } => { println!("button {} down!", btn.string()) }
- Event::ControllerButtonUp { button: btn, .. } => { println!("button {} up!", btn.string()) }
- Event::ControllerAxisMotion { axis: ax, .. } => { println!("axis motion {}!", ax.string()) }
+ Event::ControllerDeviceAdded { which, .. } => { self.add_device(*which) }
+ Event::ControllerDeviceRemoved { which, .. } => { self.remove_device(*which) }
+ Event::ControllerDeviceRemapped { which, .. } => { println!("device remapped ({})!", *which) }
+ Event::ControllerButtonDown { button, .. } => { println!("button {} down!", button.string()) }
+ Event::ControllerButtonUp { button, .. } => { println!("button {} up!", button.string()) }
+ Event::ControllerAxisMotion { axis, .. } => { println!("axis motion {}!", axis.string()) }
_ => {}
}
}