From 3edbfc89abaeef15671dff623a451cc53e0fa0ad Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Tue, 16 Apr 2024 11:56:29 -0700 Subject: [PATCH] has_capability --- src/backend/libei/mod.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/backend/libei/mod.rs b/src/backend/libei/mod.rs index 48dfae4e6266..26231e736001 100644 --- a/src/backend/libei/mod.rs +++ b/src/backend/libei/mod.rs @@ -147,7 +147,11 @@ impl input::Device for request::Device { } fn has_capability(&self, capability: input::DeviceCapability) -> bool { - todo!() + if let Ok(capability) = DeviceCapability::try_from(capability) { + self.has_capability(capability) + } else { + false + } } fn usb_id(&self) -> Option<(u32, u32)> { @@ -420,3 +424,19 @@ fn convert_request(request: EisRequest) -> Option> { _ => None, } } + +// XXX not a direct match? +impl TryFrom for DeviceCapability { + type Error = (); + fn try_from(other: input::DeviceCapability) -> Result { + match other { + input::DeviceCapability::Gesture => Err(()), + input::DeviceCapability::Keyboard => Ok(DeviceCapability::Keyboard), + input::DeviceCapability::Pointer => Ok(DeviceCapability::Pointer), + input::DeviceCapability::Switch => Err(()), + input::DeviceCapability::TabletPad => Err(()), + input::DeviceCapability::TabletTool => Err(()), + input::DeviceCapability::Touch => Ok(DeviceCapability::Touch), + } + } +}