Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement get_sys_path() and dev node iterator for virtual devices #72

Merged
merged 8 commits into from
Aug 3, 2022

Conversation

StephanvanSchaik
Copy link
Contributor

This addresses issue #70 by:

  • Implementing the ui_get_sysname ioctl.
  • Using the aforementioned ioctl to implement VirtualDevice::get_syspath() function, which returns the syspath of the form /sys/devices/virtual/input/inputX for the virtual device.
  • Adding both a synchronous and asynchronous version of VirtualDevice::enumerate_dev_nodes() depending on the tokio feature flag that essentially yields an iterator over the devices nodes of the form /dev/input/eventX that correspond to the virtual device.

jtroo added a commit to jtroo/kanata that referenced this pull request Aug 1, 2022
This commit switches the underlying evdev library from evdev-rs to evdev
again. Using the evdev-rs library for uinput devices caused a regression
in mouse button functionality. Git bisect shows that the mouse
functionality broke in commit 6b4a7e5.

In addition, it looks like a PR is currently open for getting the dev
node info in the evdev crate, so hopefully there will be feature parity
to support the symlink code soon:
emberian/evdev#72
src/uinput.rs Outdated Show resolved Hide resolved
src/uinput.rs Outdated Show resolved Hide resolved
@StephanvanSchaik
Copy link
Contributor Author

@jeff-hiner This is ready for review.

jtroo added a commit to jtroo/kanata that referenced this pull request Aug 1, 2022
This commit switches the underlying evdev library from evdev-rs to evdev
again. Using the evdev-rs library for uinput devices caused a regression
in mouse button functionality. Git bisect shows that the mouse
functionality broke in commit 6b4a7e5.

In addition, it looks like a PR is currently open for getting the dev
node info in the evdev crate, so hopefully there will be feature parity
to support the symlink code soon:
emberian/evdev#72
src/uinput.rs Outdated

/// This struct is returned from the [VirtualDevice::enumerate_dev_nodes] function and will yield
/// the syspaths corresponding to the virtual device. These are of the form `/dev/input123`.
#[cfg(not(feature = "tokio"))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bit of a further nit, but can we either ungate this or gate this behind a blocking feature? In a single binary if one crate user were to define tokio and another does not it'll really confuse cargo. I'd like to make sure that if someone really wants to they could build and use both simultaneously.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, it makes sense to not even have the feature gate there if we are differentiating them anyway.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to somehow disambiguate the two DevNodes structs as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. I had a much better look now and fixed a few other things too:

  • Added fs feature flag to the tokio dependency, so cargo b --features tokio actually works.
  • Because of the .await?, the async version of the iterator is dealing with just Option<T> which simplifies the code.
  • Renamed the DevNodes variant for the sync version to DevNodesBlocking so they can co-exist.

With the tokio feature flag, one should have access to both the sync and async versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants