Skip to content
Open
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
9 changes: 6 additions & 3 deletions src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,14 @@ impl Device {
/// Get the system name of the device.
///
/// To get the descriptive device name, use `name`.
pub fn sysname(&self) -> &str {
///
/// The sysname is the name of the device in the `/sys` filesystem.
/// If the sysname is not valid UTF-8, the invalid bytes are replaced
/// with `U+FFFD REPLACEMENT CHARACTER`.
pub fn sysname(&self) -> Cow<'_, str> {
unsafe {
CStr::from_ptr(ffi::libinput_device_get_sysname(self.as_raw_mut()))
.to_str()
.expect("Device sysname is no valid utf8")
.to_string_lossy()
}
}

Expand Down