diff --git a/src/sys.rs b/src/sys.rs index 17c4f0d..086b120 100644 --- a/src/sys.rs +++ b/src/sys.rs @@ -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); diff --git a/src/uinput.rs b/src/uinput.rs index 847571c..02506bb 100644 --- a/src/uinput.rs +++ b/src/uinput.rs @@ -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}; @@ -52,6 +53,14 @@ impl<'a> VirtualDeviceBuilder<'a> { self } + pub fn with_phys(self, path: &str) -> io::Result { + 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) -> io::Result { // Run ioctls for setting capability bits unsafe {