Skip to content

Commit

Permalink
RawDevice: introduce system_path() method
Browse files Browse the repository at this point in the history
  • Loading branch information
waynr committed Jan 16, 2022
1 parent 099b6e9 commit 3a42534
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/raw_stream.rs
Expand Up @@ -2,7 +2,7 @@ use std::fs::{File, OpenOptions};
use std::io::Write;
use std::mem::MaybeUninit;
use std::os::unix::io::{AsRawFd, RawFd};
use std::path::Path;
use std::path::{Path, PathBuf};
use std::{io, mem};

use crate::constants::*;
Expand Down Expand Up @@ -68,6 +68,7 @@ pub struct RawDevice {
supported_snd: Option<AttributeSet<SoundType>>,
pub(crate) event_buf: Vec<libc::input_event>,
grabbed: bool,
system_path: PathBuf,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -225,6 +226,7 @@ impl RawDevice {
auto_repeat,
event_buf: Vec::new(),
grabbed: false,
system_path: path.to_path_buf(),
})
}

Expand Down Expand Up @@ -383,6 +385,11 @@ impl RawDevice {
self.supported_snd.as_deref()
}

/// Returns the system path used to open the device.
pub fn system_path(&self) -> &Path {
self.system_path.as_ref()
}

/// Read a maximum of `num` events into the internal buffer. If the underlying fd is not
/// O_NONBLOCK, this will block.
///
Expand Down

0 comments on commit 3a42534

Please sign in to comment.