#![no_std] #![forbid(unsafe_code)] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Key { Up, Down, Left, Right, Enter, Escape, Space, Backspace, Tab, Char(u8), } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum GamepadButton { South, East, North, West, DpadUp, DpadDown, DpadLeft, DpadRight, Start, Select, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum Axis { LeftX, LeftY, RightX, RightY, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum InputEvent { KeyDown(Key), KeyUp(Key), PointerDown { id: u8, x: u16, y: u16 }, PointerMove { id: u8, x: u16, y: u16 }, PointerUp { id: u8, x: u16, y: u16 }, Scroll { dx: i16, dy: i16 }, GamepadButton { button: GamepadButton, pressed: bool }, GamepadAxis { axis: Axis, value: i16 }, } pub trait InputDevice { fn poll(&mut self) -> Option; fn has_event(&self) -> bool; /// Clears the device's own interrupt condition after an IRQ, before /// the line is re-armed. Devices that clear it by being read need not. fn acknowledge(&mut self) {} }