Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3222)

Unified Diff: device/hid/hid_service_win.cc

Issue 502573002: Find HID report IDs in output and feature reports on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use unsigned types and move INITGUID to back to .cc. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/hid/hid_service_win.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_service_win.cc
diff --git a/device/hid/hid_service_win.cc b/device/hid/hid_service_win.cc
index 23afa4f40affe0da4e6d4d9d0a8038e5e498ecfe..3060b2b3766ecb2ac2a0e271266d001c9447baec 100644
--- a/device/hid/hid_service_win.cc
+++ b/device/hid/hid_service_win.cc
@@ -17,16 +17,6 @@
#define INITGUID
-#include <windows.h>
-#include <hidclass.h>
-
-extern "C" {
-
-#include <hidsdi.h>
-#include <hidpi.h>
-
-}
-
#include <setupapi.h>
#include <winioctl.h>
#include "base/win/scoped_handle.h"
@@ -159,6 +149,49 @@ void HidServiceWin::Enumerate() {
}
}
+void HidServiceWin::CollectInfoFromButtonCaps(
+ PHIDP_PREPARSED_DATA preparsed_data,
+ HIDP_REPORT_TYPE report_type,
+ USHORT button_caps_length,
+ HidCollectionInfo* collection_info) {
+ if (button_caps_length > 0) {
+ scoped_ptr<HIDP_BUTTON_CAPS[]> button_caps(
+ new HIDP_BUTTON_CAPS[button_caps_length]);
+ if (HidP_GetButtonCaps(report_type,
+ &button_caps[0],
+ &button_caps_length,
+ preparsed_data) == HIDP_STATUS_SUCCESS) {
+ for (size_t 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);
+ }
+ }
+ }
+ }
+}
+
+void HidServiceWin::CollectInfoFromValueCaps(
+ PHIDP_PREPARSED_DATA preparsed_data,
+ HIDP_REPORT_TYPE report_type,
+ USHORT value_caps_length,
+ HidCollectionInfo* collection_info) {
+ if (value_caps_length > 0) {
+ scoped_ptr<HIDP_VALUE_CAPS[]> value_caps(
+ new HIDP_VALUE_CAPS[value_caps_length]);
+ if (HidP_GetValueCaps(
+ report_type, &value_caps[0], &value_caps_length, preparsed_data) ==
+ HIDP_STATUS_SUCCESS) {
+ for (size_t 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);
+ }
+ }
+ }
+ }
+}
+
void HidServiceWin::PlatformAddDevice(const std::string& device_path) {
HidDeviceInfo device_info;
device_info.device_id = device_path;
@@ -215,39 +248,32 @@ void HidServiceWin::PlatformAddDevice(const std::string& device_path) {
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.has_report_id = true;
- }
- }
- }
- }
- 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);
- device_info.has_report_id = true;
- }
- }
- }
+ CollectInfoFromButtonCaps(preparsed_data,
+ HidP_Input,
+ capabilities.NumberInputButtonCaps,
+ &collection_info);
+ CollectInfoFromButtonCaps(preparsed_data,
+ HidP_Output,
+ capabilities.NumberOutputButtonCaps,
+ &collection_info);
+ CollectInfoFromButtonCaps(preparsed_data,
+ HidP_Feature,
+ capabilities.NumberFeatureButtonCaps,
+ &collection_info);
+ CollectInfoFromValueCaps(preparsed_data,
+ HidP_Input,
+ capabilities.NumberInputValueCaps,
+ &collection_info);
+ CollectInfoFromValueCaps(preparsed_data,
+ HidP_Output,
+ capabilities.NumberOutputValueCaps,
+ &collection_info);
+ CollectInfoFromValueCaps(preparsed_data,
+ HidP_Feature,
+ capabilities.NumberFeatureValueCaps,
+ &collection_info);
+ if (!collection_info.report_ids.empty()) {
+ device_info.has_report_id = true;
}
device_info.collections.push_back(collection_info);
}
« no previous file with comments | « device/hid/hid_service_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698