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

RFC: add filter function based enumeration #584

Open
Youw opened this issue May 31, 2023 · 2 comments
Open

RFC: add filter function based enumeration #584

Youw opened this issue May 31, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@Youw
Copy link
Member

Youw commented May 31, 2023

          We could do both: allow SDL filter out devices like this, _and_ avoid patching HIDAPI sources if we would introduce something like:
typedef int (*HID_API_CALL hidapi_ven_dev_filter_func)(unsigned short vendor_id, unsigned short product_id);
struct hid_device_info HID_API_EXPORT * HID_API_CALL hid_enumerate_ven_dev_filter(hidapi_ven_dev_filter_func);

But that is a different effort, and would definitely need an implementation on all platforms.

Originally posted by @Youw in #575 (comment)

@mcuee mcuee added the enhancement New feature or request label Jun 2, 2023
@JoergAtGithub
Copy link
Contributor

We filter devices in the postprocessing after enumeration. But it would make sense to define blacklist entries before enumeration. This makes als sense when we think about hot-plugging.
We currently use the following criteria:

  • VID/PID to filter a few problematic devices
  • Usage-Table/Usage to filter out whole device categories like mouses, joysticks and gamepads
  • Bus-Type to filter out all embedded (SPI/I2C) laptop devices
  • There is also one case where we use the interface number, but it seems this is only, because at that time Usage-Table/Usage detection wasn't reliable.

@Youw
Copy link
Member Author

Youw commented Jun 4, 2023

I agree all of those are valid points.

Knowing the codebase, I must say that to implement (early) filtering for each criteria will be challenging, e.g.: it is impossible to get the usage_pages/usages of the device with libusb backend w/o opening the device, which is so much for "early" filtering.

I believe on all (not sure about macOS - that one is a bit different) platforms, having an early filter for vid/pid only is simple-enough and probably should be our first step towards that direction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: To do
Development

No branches or pull requests

3 participants