cardinal_varvara/
controller_device.rs1use crate::{Event, Uxn};
2
3pub trait ControllerDevice: Send {
5 fn as_any(&mut self) -> &mut dyn std::any::Any;
7 fn char(&mut self, vm: &mut Uxn, c: u8) -> Event;
9 fn pressed(&mut self, vm: &mut Uxn, k: super::controller::Key, repeat: bool) -> Option<Event>;
11 fn released(&mut self, vm: &mut Uxn, k: super::controller::Key) -> Option<Event>;
13}
14
15impl ControllerDevice for super::controller::Controller {
16 fn as_any(&mut self) -> &mut dyn std::any::Any {
17 self
18 }
19 fn char(&mut self, vm: &mut Uxn, c: u8) -> Event {
20 self.char(vm, c)
21 }
22 fn pressed(&mut self, vm: &mut Uxn, k: super::controller::Key, repeat: bool) -> Option<Event> {
23 self.pressed(vm, k, repeat)
24 }
25 fn released(&mut self, vm: &mut Uxn, k: super::controller::Key) -> Option<Event> {
26 self.released(vm, k)
27 }
28}