use std::error::Error;
use async_trait::async_trait;
/*
Functions the input subsystem needs to perform:
- init
- register and unregister event handlers for:
- mouse movement
- keydown, keyup, keypress
- clicks
*/
#[async_trait]
pub trait InputSubsystem {
async fn init() -> Result<Self, Box<dyn Error>> where Self: Sized;
async fn register_on_mouse_move(&mut self, id: &str, callback: dyn FnMut(OnMouseMoveEvent)) -> Result<(), Box<dyn Error>>;
async fn unregister_on_mouse_move(&mut self, id: &str) -> Result<(), Box<dyn Error>>;
async fn register_on_key_down(&mut self, id: &str, callback: dyn FnMut(OnKeyDownEvent)) -> Result<(), Box<dyn Error>>;
async fn unregister_on_key_down(&mut self, id: &str) -> Result<(), Box<dyn Error>>;
async fn register_on_key_up(&mut self, id: &str, callback: dyn FnMut(OnKeyUpEvent)) -> Result<(), Box<dyn Error>>;
async fn unregister_on_key_up(&mut self, id: &str) -> Result<(), Box<dyn Error>>;
async fn register_on_keypress(&mut self, id: &str, callback: dyn FnMut(OnKeypressEvent)) -> Result<(), Box<dyn Error>>;
async fn unregister_on_keypress(&mut self, id: &str) -> Result<(), Box<dyn Error>>;
async fn register_on_click(&mut self, id: &str, callback: dyn FnMut(OnClickEvent)) -> Result<(), Box<dyn Error>>;
async fn unregister_on_click(&mut self, id: &str) -> Result<(), Box<dyn Error>>;
}
pub struct OnMouseMoveEvent {}
pub struct OnKeyDownEvent {}
pub struct OnKeyUpEvent {}
pub struct OnKeypressEvent {}
pub struct OnClickEvent {}