Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ ioctl_write_int!(ui_set_mscbit, UINPUT_IOCTL_BASE, 104);
ioctl_write_int!(ui_set_ledbit, UINPUT_IOCTL_BASE, 105);
ioctl_write_int!(ui_set_sndbit, UINPUT_IOCTL_BASE, 106);
ioctl_write_int!(ui_set_ffbit, UINPUT_IOCTL_BASE, 107);
ioctl_write_buf!(ui_set_phys, UINPUT_IOCTL_BASE, 108, u8);
ioctl_write_ptr!(ui_set_phys, UINPUT_IOCTL_BASE, 108, usize);
ioctl_write_int!(ui_set_swbit, UINPUT_IOCTL_BASE, 109);
ioctl_write_int!(ui_set_propbit, UINPUT_IOCTL_BASE, 110);

Expand Down
9 changes: 9 additions & 0 deletions src/uinput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
sys, AttributeSetRef, Error, FFEffectCode, InputEvent, KeyCode, MiscCode, PropType,
RelativeAxisCode, SwitchCode, SynchronizationEvent, UInputCode, UInputEvent, UinputAbsSetup,
};
use std::ffi::CString;
use std::os::fd::{AsFd, AsRawFd, BorrowedFd, OwnedFd, RawFd};
use std::path::PathBuf;
use std::{fs, io};
Expand Down Expand Up @@ -52,6 +53,14 @@ impl<'a> VirtualDeviceBuilder<'a> {
self
}

pub fn with_phys(self, path: &str) -> io::Result<Self> {
let c_str = CString::new(path)?;
unsafe {
sys::ui_set_phys(self.fd.as_raw_fd(), c_str.as_ptr() as *const usize)?;
}
Ok(self)
}

pub fn with_keys(self, keys: &AttributeSetRef<KeyCode>) -> io::Result<Self> {
// Run ioctls for setting capability bits
unsafe {
Expand Down