diff options
author | csharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 17:14:13 +0000 |
---|---|---|
committer | csharp@chromium.org <csharp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-07-03 17:14:13 +0000 |
commit | 0eac598eeed59ebebdeb0d44e93677fbb9cb9d5a (patch) | |
tree | 6c5033490339860687bd80a6f6a663784eddd654 /device/hid/hid_service_win.cc | |
parent | c9ab4198a25ff667f69acc6c9c8dad10c81bbe64 (diff) | |
download | chromium_src-0eac598eeed59ebebdeb0d44e93677fbb9cb9d5a.zip chromium_src-0eac598eeed59ebebdeb0d44e93677fbb9cb9d5a.tar.gz chromium_src-0eac598eeed59ebebdeb0d44e93677fbb9cb9d5a.tar.bz2 |
Revert 281133 "chrome.hid: enrich model with report IDs"
Speculative revert to try and fix Win browser tests.
> chrome.hid: enrich model with report IDs
>
> - add report IDs and max report size
> - don't expose sensitive usages
>
> BUG=364423
> R=rockot@chromium.org
> TESTS=run device_unittests (HidReportDescriptorTest)
>
> Review URL: https://codereview.chromium.org/317783010
TBR=jracle@logitech.com
Review URL: https://codereview.chromium.org/369923002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281282 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_service_win.cc')
-rw-r--r-- | device/hid/hid_service_win.cc | 68 |
1 files changed, 28 insertions, 40 deletions
diff --git a/device/hid/hid_service_win.cc b/device/hid/hid_service_win.cc index 9f27cff..82477a5 100644 --- a/device/hid/hid_service_win.cc +++ b/device/hid/hid_service_win.cc @@ -187,50 +187,38 @@ void HidServiceWin::PlatformAddDevice(const std::string& device_path) { PHIDP_PREPARSED_DATA preparsed_data; if (HidD_GetPreparsedData(device_handle.Get(), &preparsed_data) && preparsed_data) { - HIDP_CAPS capabilities = {0}; + HIDP_CAPS capabilities; if (HidP_GetCaps(preparsed_data, &capabilities) == HIDP_STATUS_SUCCESS) { - device_info.max_input_report_size = capabilities.InputReportByteLength; - device_info.max_output_report_size = capabilities.OutputReportByteLength; - device_info.max_feature_report_size = - capabilities.FeatureReportByteLength; - HidCollectionInfo collection_info; - collection_info.usage = HidUsageAndPage( - capabilities.Usage, - static_cast<HidUsageAndPage::Page>(capabilities.UsagePage)); - USHORT button_caps_length = capabilities.NumberInputButtonCaps; - if (button_caps_length > 0) { - scoped_ptr<HIDP_BUTTON_CAPS[]> button_caps( - new HIDP_BUTTON_CAPS[button_caps_length]); - if (HidP_GetButtonCaps(HidP_Input, - &button_caps[0], - &button_caps_length, - preparsed_data) == HIDP_STATUS_SUCCESS) { - for (int i = 0; i < button_caps_length; i++) { - int report_id = button_caps[i].ReportID; - if (report_id != 0) { - collection_info.report_ids.insert(report_id); - } - } - } - } + device_info.input_report_size = capabilities.InputReportByteLength; + device_info.output_report_size = capabilities.OutputReportByteLength; + device_info.feature_report_size = capabilities.FeatureReportByteLength; + device_info.usages.push_back(HidUsageAndPage( + capabilities.Usage, + static_cast<HidUsageAndPage::Page>(capabilities.UsagePage))); + } + // Detect if the device supports report ids. + if (capabilities.NumberInputValueCaps > 0) { + scoped_ptr<HIDP_VALUE_CAPS[]> value_caps( + new HIDP_VALUE_CAPS[capabilities.NumberInputValueCaps]); USHORT value_caps_length = capabilities.NumberInputValueCaps; - if (value_caps_length > 0) { - scoped_ptr<HIDP_VALUE_CAPS[]> value_caps( - new HIDP_VALUE_CAPS[value_caps_length]); - if (HidP_GetValueCaps(HidP_Input, - &value_caps[0], - &value_caps_length, - preparsed_data) == HIDP_STATUS_SUCCESS) { - for (int i = 0; i < value_caps_length; i++) { - int report_id = value_caps[i].ReportID; - if (report_id != 0) { - collection_info.report_ids.insert(report_id); - } - } - } + if (HidP_GetValueCaps(HidP_Input, &value_caps[0], &value_caps_length, + preparsed_data) == HIDP_STATUS_SUCCESS) { + device_info.has_report_id = (value_caps[0].ReportID != 0); } - device_info.collections.push_back(collection_info); } + if (!device_info.has_report_id && capabilities.NumberInputButtonCaps > 0) + { + scoped_ptr<HIDP_BUTTON_CAPS[]> button_caps( + new HIDP_BUTTON_CAPS[capabilities.NumberInputButtonCaps]); + USHORT button_caps_length = capabilities.NumberInputButtonCaps; + if (HidP_GetButtonCaps(HidP_Input, + &button_caps[0], + &button_caps_length, + preparsed_data) == HIDP_STATUS_SUCCESS) { + device_info.has_report_id = (button_caps[0].ReportID != 0); + } + } + HidD_FreePreparsedData(preparsed_data); } |