2021-10-22 04:55:27 +00:00
|
|
|
|
|
|
|
use std::sync::{Arc, Mutex};
|
|
|
|
|
|
|
|
use crate::error::Error;
|
|
|
|
|
2021-10-31 18:00:14 +00:00
|
|
|
#[derive(Copy, Clone, Debug, PartialEq)]
|
|
|
|
pub enum JoystickDevice {
|
|
|
|
A,
|
|
|
|
B,
|
|
|
|
C,
|
|
|
|
D,
|
|
|
|
}
|
2021-10-22 04:55:27 +00:00
|
|
|
|
|
|
|
pub trait Host {
|
2021-10-23 02:36:05 +00:00
|
|
|
//fn create_pty(&self) -> Result<Box<dyn Tty>, Error>;
|
2021-10-22 04:55:27 +00:00
|
|
|
fn add_window(&self, updater: Box<dyn WindowUpdater>) -> Result<(), Error>;
|
2021-10-31 18:00:14 +00:00
|
|
|
fn register_joystick(&self, device: JoystickDevice, input: Box<dyn JoystickUpdater>) -> Result<(), Error> { Err(Error::new("Not supported")) }
|
2021-10-22 04:55:27 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 02:36:05 +00:00
|
|
|
pub trait Tty {
|
|
|
|
fn device_name(&self) -> String;
|
|
|
|
fn read(&mut self) -> Option<u8>;
|
|
|
|
fn write(&mut self, output: u8) -> bool;
|
2021-10-22 04:55:27 +00:00
|
|
|
}
|
|
|
|
|
2021-10-23 02:36:05 +00:00
|
|
|
pub trait WindowUpdater: Send {
|
|
|
|
fn update_frame(&mut self, width: u32, height: u32, bitmap: &mut [u32]);
|
2021-10-22 04:55:27 +00:00
|
|
|
}
|
|
|
|
|
2021-10-31 18:00:14 +00:00
|
|
|
pub trait JoystickUpdater: Send {
|
|
|
|
fn update_joystick(&mut self, modifiers: u16);
|
|
|
|
}
|
|
|
|
|
2021-10-28 04:01:18 +00:00
|
|
|
pub trait BlitableSurface {
|
|
|
|
fn set_size(&mut self, width: u32, height: u32);
|
|
|
|
fn blit<B: Iterator<Item=u32>>(&mut self, pos_x: u32, pos_y: u32, bitmap: B, width: u32, height: u32);
|
|
|
|
}
|
|
|
|
|
2021-10-31 18:00:14 +00:00
|
|
|
|