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

Fix hidapi on Windows 10 #214

Closed
nitsch opened this issue Feb 22, 2016 · 8 comments · Fixed by #319
Closed

Fix hidapi on Windows 10 #214

nitsch opened this issue Feb 22, 2016 · 8 comments · Fixed by #319

Comments

@nitsch
Copy link
Collaborator

nitsch commented Feb 22, 2016

hidapi needs to be adapted for Windows 10. See #187 (comment). Will the suggested dowgrade work on other platforms (including older versions of Windows) as well or are we losing something else in the process? Should Windows 10 simply user a different version of hidapi while everybody else sticks to the current one?

@cboulay
Copy link
Contributor

cboulay commented Feb 22, 2016

I forked a more recent hidapi and made some changes to it such that it now works in multiple Windows versions and OS X.

I also made a change to the number of bytes hidapi returns in Windows to reverse a problematic commit made about 8 months after the hidapi commit pointed to currently by thp/psmoveapi/external/hidapi. Obviously this commit was made for a reason, but it causes the number of bytes returned to be different in Windows and OSX. I don't know if this is specific to Win10 only.

@thp
Copy link
Owner

thp commented Dec 1, 2016

@cboulay Did you try to submit your changes to https://github.com/signal11/hidapi via pull request?

@cboulay
Copy link
Contributor

cboulay commented Dec 1, 2016

No. The most important change was done by someone else, committed on March 3.

The problem with hid_get_feature_report returning different numbers of bytes in Mac and Windows still exists in their repo. According to their API docs, they want it to behave the Windows way where res = number of bytes in the feature report + 1. This is not what happens in Mac. I suppose I should make an issue about this.

Until this is fixed, I think the best course of action would be to have the submodule point to the signal11/hidapi repo, but then change all the res == X checks to res == X || res == X+1. I've even seen some hidapi using code that checks if res >= X. I don't know if this has the potential to be harmful, probably not.

@cboulay
Copy link
Contributor

cboulay commented Dec 1, 2016

There's already a pull request for it. signal11/hidapi#219

@rafaellago
Copy link
Contributor

Will this issue be adressed in the 4.0.0??

@thp
Copy link
Owner

thp commented Dec 26, 2016

It's probably not yet fixed in 4.0.0, but hopefully a point release after that (now that we have proper CI and build/release infrastructure in place, it should be easy to do more regular releases, since the cost of doing a release is basically just doing a Git tag).

@cboulay If I understand you correctly, if we replace the result checks with something like this, it should work, right? (the +1 only happens on Windows?)

#if defined(_WIN32)
#define PSMOVE_CHECK_HIDAPI_RESULT(value, expected) ((value) == ((expected) + 1))
#else
#define PSMOVE_CHECK_HIDAPI_RESULT(value, expected) ((value == (expected))
#endif

@cboulay
Copy link
Contributor

cboulay commented Dec 26, 2016

I know hidapi in MacOS returns one less byte than hidapi in Windows. According to the hidapi API docs, returning (report-size + 1) bytes is expected, so it almost makes more sense to have ((expected)-1) for Mac, but that's just semantics.

This is a problem that should be addressed in hidapi itself, and I hope it will be soon, but your solution above should work until then.

I haven't tested in Linux.

@rafaellago
Copy link
Contributor

I recompiled the project using @cboulay hidapi, it seemed to work fine, at least now the binaries recognize the controller. But I'm having a real hard time to pair it to bluetooth. Don't actually know if it is another problem regarding W10.

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 a pull request may close this issue.

4 participants