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

mac: Set a valid interface number on hid_device_info for USB HID dev… #2

Merged
merged 1 commit into from
Jun 9, 2019

Conversation

z3ntu
Copy link
Collaborator

@z3ntu z3ntu commented Jun 5, 2019

…ices

Previously the interface would never be set on Mac.

This presents a big pain because retrieving interface numbers can be the
only way to distinguish between the interfaces returned by HIDAPI.

This change makes it possible to retrieve interface number from an
hid_device_info on Mac for USB HID devices only.

It is unclear if the Mac OS IOKit library returns valid interface numbers for non-HID USB devices. Because of this, I have opted to simply skip that case - leave it initialised to -1.

In the future, we can easily relax this restriction if it turns out IOKit correctly returns interface number with non-HID USB devices. For now, this PR brings 90% of the value at 5% of the risk.

Re-open of signal11/hidapi#380

@Qbicz Qbicz requested review from todbot and Youw June 5, 2019 07:40
Copy link
Member

@Youw Youw left a comment

Choose a reason for hiding this comment

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

I don't have my mac available right now, so I cannot try and verify the update.
Otherwise - the change looks good.

mac/hid.c Outdated Show resolved Hide resolved
Previously the interface would never be set on Mac.

This presents a big pain because retrieving interface numbers can be the
only way to distinguish between the interfaces returned by HIDAPI.

This change makes it possible to retrieve interface number from an
hid_device_info on Mac for USB HID devices only.

It is unclear if the macOS IOKit library returns valid interface numbers
for non-HID USB devices. Because of this, I have opted to simply skip
that case - leave it initialised to `-1`.

In the future, we can easily relax this restriction if it turns out
IOKit correctly returns interface number with non-HID USB devices. For
now, this commit brings 90% of the value at 5% of the risk.
@z3ntu z3ntu changed the title [Mac] Set a valid interface number on hid_device_info for USB HID dev… mac: Set a valid interface number on hid_device_info for USB HID dev… Jun 6, 2019
Copy link
Contributor

@todbot todbot left a comment

Choose a reason for hiding this comment

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

I did a few quick tests on MacOS 10.14.5 on a few HID Raw devices and nothing seems amiss. Thanks!

@todbot todbot merged commit 121567d into libusb:master Jun 9, 2019
@Qbicz
Copy link
Member

Qbicz commented Jun 9, 2019

Thanks @todbot for merging this. However, can we use "rebase & merge" strategy to keep linear history? There are many advantages, the most important for me is possibility to git bisect and git revert or git cherry-pick any commit. Actually I think we can only support "rebase & merge" in settings of repo, I will change that.

@todbot
Copy link
Contributor

todbot commented Jun 9, 2019

Hi @Qbicz, I've never used those techniques before. I'll have to read up on them (my git workflow is pretty simplistic I fear). However I'm happy to do whatever works best. I assume this doc is a place to start learning about "rebase & merge"?

@Youw
Copy link
Member

Youw commented Jun 10, 2019

I assume this doc

A good start. Try also:
https://www.git-tower.com/learn/git/ebook/en/command-line/advanced-topics/rebase

@Qbicz I suggest also allowing squash-merge, so force-push is not mandatory for PRs.

@Qbicz
Copy link
Member

Qbicz commented Jun 10, 2019

@todbot yes, it's a good place. Basically, you apply your commits on top of the existing history and resolve any conflicts in your commit that introduces the change.

I have changed settings to allow squash-merge and rebase-merge.

@z3ntu z3ntu deleted the pr_380 branch June 20, 2019 17:14
@mcuee mcuee added the macOS Related to macOS backend label Jul 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS Related to macOS backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants