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

Usage page is invalid in Linux #24

Closed
jleni opened this issue Aug 5, 2018 · 18 comments
Closed

Usage page is invalid in Linux #24

jleni opened this issue Aug 5, 2018 · 18 comments

Comments

@jleni
Copy link
Contributor

jleni commented Aug 5, 2018

When enumerating devices, I have noticed that usage_page is always zero. However, this is not the case when using other libraries.

@jleni
Copy link
Contributor Author

jleni commented Aug 5, 2018

It seems this is a known issue in signal11 hidapi
signal11/hidapi#385

@ruabmbua
Copy link
Owner

ruabmbua commented Aug 5, 2018

Would you mind telling me what platform you are using?

@jleni
Copy link
Contributor Author

jleni commented Aug 5, 2018

Linux. I guess I need to enable a different feature in my cargo.toml

linux-static-hidraw = []

@ruabmbua
Copy link
Owner

ruabmbua commented Aug 5, 2018

Because hidapi explicitly does not support usage page querying for some backends. However I am not sure which backends are affected (can`t remember)

@jleni
Copy link
Contributor Author

jleni commented Aug 5, 2018

How do I change the backend? I am doing the following:

[dependencies.hidapi]
version = "0.5"
features = ["linux-static-hidraw"]

but I get the following:

   Compiling hidapi v0.5.0
error: failed to run custom build command for `hidapi v0.5.0`
process didn't exit successfully: `/home/user/test/target/debug/build/hidapi-1db141914f340e4a/build-script-build` (exit code: 101)
--- stderr
thread 'main' panicked at 'Exactly one linux hidapi backend must be selected.', /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/hidapi-0.5.0/build.rs:92:9

@ruabmbua
Copy link
Owner

ruabmbua commented Aug 5, 2018

You have to disable default features. Look it up in the Cargo docs

@jleni
Copy link
Contributor Author

jleni commented Aug 5, 2018

Thanks!

@jleni jleni closed this as completed Aug 5, 2018
@jleni
Copy link
Contributor Author

jleni commented Aug 5, 2018

I include the solution in case someone has the same issue.
Adding the following to my Cargo.toml solved the problem with usage_page

[dependencies.hidapi]
version = "0.5"
default-features = false
features=["linux-static-hidraw"]

@ruabmbua
Copy link
Owner

ruabmbua commented Aug 5, 2018

I am considering switching the default Backend on linux, when more people have the same issue.

@jleni jleni changed the title Usage page is always zero Usage page is invalid in LInux Aug 9, 2018
@jleni jleni reopened this Aug 9, 2018
@jleni
Copy link
Contributor Author

jleni commented Aug 9, 2018

Hi @ruabmbua

I am reopening the issue as usage_page seems to be invalid in Linux. While switching to hidraw returns something, the value is not valid.

I've done a bit of research and it seems that signal11 is not even filling the values. There is an old PR that has been left behind, etc.
signal11/hidapi#385

The whole signal11 project has been unmaintained for several years. That makes me a bit uncomfortable. :(

@jleni jleni changed the title Usage page is invalid in LInux Usage page is invalid in Linux Aug 9, 2018
@jleni
Copy link
Contributor Author

jleni commented Aug 9, 2018

What do you think of progressively moving to a full native implementation? It would be possible to start with Linux only and recreate the ioctl calls.

@ruabmbua
Copy link
Owner

ruabmbua commented Aug 9, 2018

I already thought about the option before moving to 0.5

Would be an interesting project in my opinion, but t I don`t really have much time on hand right now, so I won't start the effort anytime soon.

Maybe I will think about it again next month.

Btw. for what reason do you need the usage page? You could use feature reports to query the device yourself. A rust library for hid record parsing would be great. Maybe I will work on that soon (I am currently experimenting with stm32f0 based USB microcontroller)

@jleni
Copy link
Contributor Author

jleni commented Aug 9, 2018

I need to solve this in the following days. Forking or creating another crate does not make sense to me.
I will probably submit you a PR once I have something. I will probably start with a simple record parsing but I like the idea of removing all dependencies from signal11 over time.
Do you think you will have time to review a small PR?

@ruabmbua
Copy link
Owner

ruabmbua commented Aug 9, 2018

Of course. I will be available the day after tomorrow. Currently I am in the mountains with a very suboptimal Internet Connection (Loadding GitHub takes several minutes)

@ruabmbua
Copy link
Owner

The more I think of it, removing the dependency to signal11 hidapi is probably the way to go. I have to dig into its internals, to understand all the platform details. Starting with linux however should be a no brainer.

I will create a branch, for work on a rust based hidraw backend. You are welcome to submit a PR against it.

@jleni
Copy link
Contributor Author

jleni commented Aug 11, 2018

Yes, signal11 is not well maintained and a native crate would be ideal. I can help with that, however, in the meantime I will need to provide a faster workaround just to get the usage_page.

@ruabmbua
Copy link
Owner

http://www.usb.org/developers/hidpage/ should be of help.

@ruabmbua
Copy link
Owner

Closed in favor of #26.

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

No branches or pull requests

2 participants