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), + } + } +}