| 1 | use smithay::backend::input::{ |
| 2 | Device, DeviceCapability, Event, InputBackend, InputTime, KeyState, KeyboardKeyEvent, Keycode, |
| 3 | UnusedEvent, |
| 4 | }; |
| 5 | use smithay::output::Output; |
| 6 | |
| 7 | use crate::input::backend_ext::NiriInputDevice; |
| 8 | |
| 9 | pub struct TestInputBackend; |
| 10 | |
| 11 | #[derive(PartialEq, Eq, Hash)] |
| 12 | pub struct TestInputDevice; |
| 13 | |
| 14 | pub struct TestKeyboardKeyEvent { |
| 15 | pub time: InputTime, |
| 16 | pub code: Keycode, |
| 17 | pub state: KeyState, |
| 18 | pub count: u32, |
| 19 | } |
| 20 | |
| 21 | impl InputBackend for TestInputBackend { |
| 22 | type Device = TestInputDevice; |
| 23 | |
| 24 | type KeyboardKeyEvent = TestKeyboardKeyEvent; |
| 25 | type PointerAxisEvent = UnusedEvent; |
| 26 | type PointerButtonEvent = UnusedEvent; |
| 27 | type PointerMotionEvent = UnusedEvent; |
| 28 | type PointerMotionAbsoluteEvent = UnusedEvent; |
| 29 | |
| 30 | type GestureSwipeBeginEvent = UnusedEvent; |
| 31 | type GestureSwipeUpdateEvent = UnusedEvent; |
| 32 | type GestureSwipeEndEvent = UnusedEvent; |
| 33 | type GesturePinchBeginEvent = UnusedEvent; |
| 34 | type GesturePinchUpdateEvent = UnusedEvent; |
| 35 | type GesturePinchEndEvent = UnusedEvent; |
| 36 | type GestureHoldBeginEvent = UnusedEvent; |
| 37 | type GestureHoldEndEvent = UnusedEvent; |
| 38 | |
| 39 | type TouchDownEvent = UnusedEvent; |
| 40 | type TouchUpEvent = UnusedEvent; |
| 41 | type TouchMotionEvent = UnusedEvent; |
| 42 | type TouchCancelEvent = UnusedEvent; |
| 43 | type TouchFrameEvent = UnusedEvent; |
| 44 | type TabletToolAxisEvent = UnusedEvent; |
| 45 | type TabletToolProximityEvent = UnusedEvent; |
| 46 | type TabletToolTipEvent = UnusedEvent; |
| 47 | type TabletToolButtonEvent = UnusedEvent; |
| 48 | |
| 49 | type SwitchToggleEvent = UnusedEvent; |
| 50 | |
| 51 | type SpecialEvent = UnusedEvent; |
| 52 | } |
| 53 | |
| 54 | impl Device for TestInputDevice { |
| 55 | fn id(&self) -> String { |
| 56 | String::from("test") |
| 57 | } |
| 58 | |
| 59 | fn name(&self) -> String { |
| 60 | String::from("test input device") |
| 61 | } |
| 62 | |
| 63 | fn has_capability(&self, capability: DeviceCapability) -> bool { |
| 64 | matches!(capability, DeviceCapability::Keyboard) |
| 65 | } |
| 66 | |
| 67 | fn usb_id(&self) -> Option<(u32, u32)> { |
| 68 | None |
| 69 | } |
| 70 | |
| 71 | fn syspath(&self) -> Option<std::path::PathBuf> { |
| 72 | None |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | impl NiriInputDevice for TestInputDevice { |
| 77 | fn output(&self, _state: &crate::niri::State) -> Option<Output> { |
| 78 | None |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | impl Event<TestInputBackend> for TestKeyboardKeyEvent { |
| 83 | fn time(&self) -> InputTime { |
| 84 | self.time |
| 85 | } |
| 86 | |
| 87 | fn device(&self) -> <TestInputBackend as InputBackend>::Device { |
| 88 | TestInputDevice |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | impl KeyboardKeyEvent<TestInputBackend> for TestKeyboardKeyEvent { |
| 93 | fn key_code(&self) -> Keycode { |
| 94 | self.code |
| 95 | } |
| 96 | |
| 97 | fn state(&self) -> KeyState { |
| 98 | self.state |
| 99 | } |
| 100 | |
| 101 | fn count(&self) -> u32 { |
| 102 | self.count |
| 103 | } |
| 104 | } |