Skip to content

Commit

Permalink
has_capability
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Apr 16, 2024
1 parent 2a25bd4 commit 3edbfc8
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/backend/libei/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)> {
Expand Down Expand Up @@ -420,3 +424,19 @@ fn convert_request(request: EisRequest) -> Option<InputEvent<EiInput>> {
_ => None,
}
}

// XXX not a direct match?
impl TryFrom<input::DeviceCapability> for DeviceCapability {
type Error = ();
fn try_from(other: input::DeviceCapability) -> Result<DeviceCapability, ()> {
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),
}
}
}

0 comments on commit 3edbfc8

Please sign in to comment.