Set the key codes that can be emitted by this device.
(self, keys: &AttributeSetRef<KeyCode>)
| 73 | |
| 74 | /// Set the key codes that can be emitted by this device. |
| 75 | pub fn with_keys(self, keys: &AttributeSetRef<KeyCode>) -> io::Result<Self> { |
| 76 | // Run ioctls for setting capability bits |
| 77 | unsafe { |
| 78 | sys::ui_set_evbit( |
| 79 | self.fd.as_raw_fd(), |
| 80 | crate::EventType::KEY.0 as nix::sys::ioctl::ioctl_param_type, |
| 81 | )?; |
| 82 | } |
| 83 | |
| 84 | for bit in keys.iter() { |
| 85 | unsafe { |
| 86 | sys::ui_set_keybit( |
| 87 | self.fd.as_raw_fd(), |
| 88 | bit.0 as nix::sys::ioctl::ioctl_param_type, |
| 89 | )?; |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | Ok(self) |
| 94 | } |
| 95 | |
| 96 | /// Set the absolute axes of this device. |
| 97 | pub fn with_absolute_axis(self, axis: &UinputAbsSetup) -> io::Result<Self> { |