summaryrefslogtreecommitdiff
path: root/src/systems/input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems/input.rs')
-rw-r--r--src/systems/input.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/systems/input.rs b/src/systems/input.rs
new file mode 100644
index 0000000..96ac3b8
--- /dev/null
+++ b/src/systems/input.rs
@@ -0,0 +1,41 @@
+use sdl2::event::{Event, WindowEvent};
+use sdl2::{EventPump, Sdl};
+use specs::prelude::*;
+
+pub struct SysInput
+{
+ event_pump: EventPump,
+}
+
+impl SysInput
+{
+ pub fn new(sdl: &Sdl) -> Self
+ {
+ Self {
+ event_pump: sdl.event_pump().unwrap(),
+ }
+ }
+}
+
+impl<'a> System<'a> for SysInput
+{
+ type SystemData = ();
+
+ fn run(&mut self, (): Self::SystemData)
+ {
+ for event in self.event_pump.poll_iter() {
+ match event {
+ Event::Quit { .. } => {
+ panic!("Quitting due to exit signal");
+ },
+ Event::Window {
+ win_event: WindowEvent::Resized(x, y),
+ ..
+ } => {
+ println!("Window resized to {}x{}", x, y);
+ },
+ _ => {},
+ }
+ }
+ }
+}