use smithay::backend::input::{ Device, DeviceCapability, Event, InputBackend, InputTime, KeyState, KeyboardKeyEvent, Keycode, UnusedEvent, }; use smithay::output::Output; use crate::input::backend_ext::NiriInputDevice; pub struct TestInputBackend; #[derive(PartialEq, Eq, Hash)] pub struct TestInputDevice; pub struct TestKeyboardKeyEvent { pub time: InputTime, pub code: Keycode, pub state: KeyState, pub count: u32, } impl InputBackend for TestInputBackend { type Device = TestInputDevice; type KeyboardKeyEvent = TestKeyboardKeyEvent; type PointerAxisEvent = UnusedEvent; type PointerButtonEvent = UnusedEvent; type PointerMotionEvent = UnusedEvent; type PointerMotionAbsoluteEvent = UnusedEvent; type GestureSwipeBeginEvent = UnusedEvent; type GestureSwipeUpdateEvent = UnusedEvent; type GestureSwipeEndEvent = UnusedEvent; type GesturePinchBeginEvent = UnusedEvent; type GesturePinchUpdateEvent = UnusedEvent; type GesturePinchEndEvent = UnusedEvent; type GestureHoldBeginEvent = UnusedEvent; type GestureHoldEndEvent = UnusedEvent; type TouchDownEvent = UnusedEvent; type TouchUpEvent = UnusedEvent; type TouchMotionEvent = UnusedEvent; type TouchCancelEvent = UnusedEvent; type TouchFrameEvent = UnusedEvent; type TabletToolAxisEvent = UnusedEvent; type TabletToolProximityEvent = UnusedEvent; type TabletToolTipEvent = UnusedEvent; type TabletToolButtonEvent = UnusedEvent; type SwitchToggleEvent = UnusedEvent; type SpecialEvent = UnusedEvent; } impl Device for TestInputDevice { fn id(&self) -> String { String::from("test") } fn name(&self) -> String { String::from("test input device") } fn has_capability(&self, capability: DeviceCapability) -> bool { matches!(capability, DeviceCapability::Keyboard) } fn usb_id(&self) -> Option<(u32, u32)> { None } fn syspath(&self) -> Option { None } } impl NiriInputDevice for TestInputDevice { fn output(&self, _state: &crate::niri::State) -> Option { None } } impl Event for TestKeyboardKeyEvent { fn time(&self) -> InputTime { self.time } fn device(&self) -> ::Device { TestInputDevice } } impl KeyboardKeyEvent for TestKeyboardKeyEvent { fn key_code(&self) -> Keycode { self.code } fn state(&self) -> KeyState { self.state } fn count(&self) -> u32 { self.count } }