use crossbeam::channel::Sender;
use winit::{
    event::{Event, WindowEvent},
    event_loop::{ActiveEventLoop, ControlFlow, EventLoop},
    window::{Window, WindowId},
    application::ApplicationHandler,
};
use crate::system::Query;

pub struct Handler {
    pub channel:Sender<Query>,
}

impl Handler {
    pub fn new(channel:Sender<Query>) -> Self
    {
        Self { channel }
    }
}

impl ApplicationHandler for Handler {
    fn resumed(&mut self, _event_loop: &winit::event_loop::ActiveEventLoop)
    {
        
    }

    fn window_event(
        &mut self,
        _event_loop:&ActiveEventLoop,
        _window_id:WindowId,
        _event: WindowEvent,
    ) {
        
    }

    fn device_event(
        &mut self,
        _event_loop: &ActiveEventLoop,
        _device_id: winit::event::DeviceId,
        event: winit::event::DeviceEvent,
    ) {
        use winit::event::DeviceEvent;

        match event {
            DeviceEvent::Added => { println!(" - added"); }
            DeviceEvent::Removed => { println!(" - removed"); }
            _ => { }
        }
    }
}
