Filter Surface Pro 2017 non-gamepad HID devices
The Surface Pro 2017 is a hybrid laptop/tablet device with a detachable keyboard. The keyboard is a composite device that includes several HID devices, some of which are incorrectly recognized as gamepads. This CL modifies the RawInput data fetcher on Windows to filter out devices that match the IDs for the Surface Pro 2017 keyboard. It also adds a check to exclude any PCI HID devices since there are no known PCI gamepads. The problematic devices intended to be filtered by this CL are: \\?\HID#VEN_8086&DEV_9D3E&SUBSYS_00000000&REV_21&Col02#4&f87ce30&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030} \\?\HID#VEN_8086&DEV_9D3E&SUBSYS_00000000&REV_21&Col05#4&f87ce30&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030} \\?\HID#VID_045E&PID_0922&Col06#7&36425755&0&0005#{4d1e55b2-f16f-11cf-88cb-001111000030} \\?\HID#VID_045E&PID_0922&Col09#7&36425755&0&0008#{4d1e55b2-f16f-11cf-88cb-001111000030} BUG=881156 Change-Id: I04687ffc94c92c284928eaec28c1edc85d05bf33 Reviewed-on: https://chromium-review.googlesource.com/1211978 Commit-Queue: Matt Reynolds <mattreynolds@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Cr-Commit-Position: refs/heads/master@{#594095}
This commit is contained in:

committed by
Commit Bot

parent
45fbc04e34
commit
e2dfd3b0d5
@ -31,9 +31,24 @@ const uint32_t kSearchUsageNumber = 0x0221;
|
||||
const uint32_t kHomeUsageNumber = 0x0223;
|
||||
const uint32_t kBackUsageNumber = 0x0224;
|
||||
|
||||
// Blacklisted vendor IDs.
|
||||
// Vendor IDs.
|
||||
const uint32_t kVendorOculus = 0x2833;
|
||||
const uint32_t kVendorBlue = 0xb58e;
|
||||
const uint32_t kVendorMicrosoft = 0x045e;
|
||||
|
||||
// Product IDs.
|
||||
const uint32_t kProductSurfacePro2017Keyboard = 0x0922;
|
||||
|
||||
struct VendorProductPair {
|
||||
const uint16_t vendor;
|
||||
const uint16_t product;
|
||||
} kFilteredDevices[] = {
|
||||
// The Surface Pro 2017's detachable keyboard is a composite device with
|
||||
// several HID sub-devices. Filter out the keyboard's device ID to avoid
|
||||
// treating these sub-devices as gamepads.
|
||||
{kVendorMicrosoft, kProductSurfacePro2017Keyboard},
|
||||
};
|
||||
const size_t kFilteredDevicesLen = base::size(kFilteredDevices);
|
||||
|
||||
// The fetcher will collect all HID usages from the Button usage page and any
|
||||
// additional usages listed below.
|
||||
@ -216,10 +231,26 @@ bool RawInputGamepadDeviceWin::QueryDeviceInfo() {
|
||||
if (vendor_id_ == kVendorOculus || vendor_id_ == kVendorBlue)
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < kFilteredDevicesLen; ++i) {
|
||||
const auto& filter = kFilteredDevices[i];
|
||||
if (vendor_id_ == filter.vendor && product_id_ == filter.product)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Fetch the device's |name_| (RIDI_DEVICENAME).
|
||||
if (!QueryDeviceName())
|
||||
return false;
|
||||
|
||||
// From the name we can guess at the bus type. PCI HID devices have "VEN" and
|
||||
// "DEV" instead of "VID" and "PID". PCI HID devices are typically not
|
||||
// gamepads and are ignored.
|
||||
// Example PCI device name: \\?\HID#VEN_1234&DEV_ABCD
|
||||
// TODO(crbug/881539): Potentially allow PCI HID devices to be enumerated, but
|
||||
// prefer known gamepads when there is contention.
|
||||
std::wstring pci_prefix = L"\\\\?\\HID#VEN_";
|
||||
if (!name_.compare(0, pci_prefix.size(), pci_prefix))
|
||||
return false;
|
||||
|
||||
// Fetch the human-friendly |product_string_|, if available.
|
||||
if (!QueryProductString())
|
||||
product_string_ = L"Unknown Gamepad";
|
||||
|
Reference in New Issue
Block a user