[Windows] Fix crash when a HID device has no input reports #205
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Some devices, like the XD002 keyboard with the factory firmware, have HID report descriptors which do not declare any input reports. If such HID descriptor additionally had the vendor-defined page and usage codes which correspond to the HID console, QMK Toolbox tried to use that HID interface as a HID console, and an attempt to read the nonexistent input report caused a crash inside HidLibrary; this made using QMK Toolbox impossible when a device with such HID report descriptor is connected.
Add a check for a non-zero input report size to
GetListableDevices()
to prevent the attempt to use a HID interface without any input repors as a HID console.The problematic HID report descriptor from the XD002 firmware is probably this one — it has only a single Output report defined. I did not actually have that device available for testing, so I made a device with a similar descriptor from a LUFA sample; with that device connected I reproduced a crash with the same backtrace as this one, which is fixed by the change from this PR.
Types of Changes
Issues Fixed or Closed by This PR