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

Side by Side Diff: device/hid/hid_service_win.cc

Issue 256673002: HID: Support top-level collection usages in device info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/hid/hid_service_mac.cc ('k') | device/hid/hid_usage_and_page.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/hid/hid_service_win.h" 5 #include "device/hid/hid_service_win.h"
6 6
7 #include <cstdlib> 7 #include <cstdlib>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 for (ULONG i = 32; 168 for (ULONG i = 32;
169 HidD_SetNumInputBuffers(device_handle.Get(), i); 169 HidD_SetNumInputBuffers(device_handle.Get(), i);
170 i <<= 1); 170 i <<= 1);
171 171
172 // Get usage and usage page (optional). 172 // Get usage and usage page (optional).
173 PHIDP_PREPARSED_DATA preparsed_data; 173 PHIDP_PREPARSED_DATA preparsed_data;
174 if (HidD_GetPreparsedData(device_handle.Get(), &preparsed_data) && 174 if (HidD_GetPreparsedData(device_handle.Get(), &preparsed_data) &&
175 preparsed_data) { 175 preparsed_data) {
176 HIDP_CAPS capabilities; 176 HIDP_CAPS capabilities;
177 if (HidP_GetCaps(preparsed_data, &capabilities) == HIDP_STATUS_SUCCESS) { 177 if (HidP_GetCaps(preparsed_data, &capabilities) == HIDP_STATUS_SUCCESS) {
178 device_info.usage = capabilities.Usage;
179 device_info.usage_page = capabilities.UsagePage;
180 device_info.input_report_size = capabilities.InputReportByteLength; 178 device_info.input_report_size = capabilities.InputReportByteLength;
181 device_info.output_report_size = capabilities.OutputReportByteLength; 179 device_info.output_report_size = capabilities.OutputReportByteLength;
182 device_info.feature_report_size = capabilities.FeatureReportByteLength; 180 device_info.feature_report_size = capabilities.FeatureReportByteLength;
181 device_info.usages.push_back(HidUsageAndPage(
182 capabilities.Usage,
183 static_cast<HidUsageAndPage::Page>(capabilities.UsagePage)));
183 } 184 }
184 // Detect if the device supports report ids. 185 // Detect if the device supports report ids.
185 if (capabilities.NumberInputValueCaps > 0) { 186 if (capabilities.NumberInputValueCaps > 0) {
186 scoped_ptr<HIDP_VALUE_CAPS[]> value_caps( 187 scoped_ptr<HIDP_VALUE_CAPS[]> value_caps(
187 new HIDP_VALUE_CAPS[capabilities.NumberInputValueCaps]); 188 new HIDP_VALUE_CAPS[capabilities.NumberInputValueCaps]);
188 USHORT value_caps_length = capabilities.NumberInputValueCaps; 189 USHORT value_caps_length = capabilities.NumberInputValueCaps;
189 if (HidP_GetValueCaps(HidP_Input, &value_caps[0], &value_caps_length, 190 if (HidP_GetValueCaps(HidP_Input, &value_caps[0], &value_caps_length,
190 preparsed_data) == HIDP_STATUS_SUCCESS) { 191 preparsed_data) == HIDP_STATUS_SUCCESS) {
191 device_info.has_report_id = (value_caps[0].ReportID != 0); 192 device_info.has_report_id = (value_caps[0].ReportID != 0);
192 } 193 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 return NULL; 251 return NULL;
251 scoped_refptr<HidConnectionWin> connection(new HidConnectionWin(device_info)); 252 scoped_refptr<HidConnectionWin> connection(new HidConnectionWin(device_info));
252 if (!connection->available()) { 253 if (!connection->available()) {
253 LOG_GETLASTERROR(ERROR) << "Failed to open device."; 254 LOG_GETLASTERROR(ERROR) << "Failed to open device.";
254 return NULL; 255 return NULL;
255 } 256 }
256 return connection; 257 return connection;
257 } 258 }
258 259
259 } // namespace device 260 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_service_mac.cc ('k') | device/hid/hid_usage_and_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698