Skip to content

Commit

Permalink
fix(config): Skip virtual devices.
Browse files Browse the repository at this point in the history
  • Loading branch information
pastaq committed Mar 3, 2024
1 parent e94d77b commit 4910177
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 22 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ impl CompositeDeviceConfig {
};
let evdev_configs = self.get_evdev_configs();

Ok(evdev_configs.len() == evdev_devices.len())
Ok(evdev_configs.len() >= 1)
}

/// Returns an array of all defined hidraw source devices
Expand Down Expand Up @@ -244,6 +244,15 @@ impl CompositeDeviceConfig {
// an evdev definition in the config.
let devices = procfs::device::get_all()?;
for device in devices {
// Ignore virtual devices.
// TODO: Maybe in the future we will support virtual devices if we figure something
// out.

if is_virtual(&device) {
log::debug!("{} is virtual, skipping.", device.name);
continue;
}

for evdev_config in evdev_configs.clone() {
let evdev_config = evdev_config.clone();
let mut has_matches = false;
Expand Down Expand Up @@ -376,3 +385,15 @@ impl CompositeDeviceConfig {
Some(matches)
}
}

/// Determines if a procfs device is virtual or real.
fn is_virtual(device: &procfs::device::Device) -> bool {
if device.phys_path != "" {
return false;
}

if device.sysfs_path.contains("/devices/virtual") {
return true;
}
return false;
}
2 changes: 1 addition & 1 deletion src/input/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl Manager {
continue;
}

// Skip configs where the required source devices don't exist.
// Skip configs where the required source devices aren't physically present.
if !config.sources_exist()? {
continue;
}
Expand Down

0 comments on commit 4910177

Please sign in to comment.