OLD | NEW |
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 Loading... |
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 HidUsageAndPage usage_and_page; |
| 182 usage_and_page.usage = capabilities.Usage; |
| 183 usage_and_page.usage_page = capabilities.UsagePage; |
| 184 device_info.usages.push_back(usage_and_page); |
183 } | 185 } |
184 // Detect if the device supports report ids. | 186 // Detect if the device supports report ids. |
185 if (capabilities.NumberInputValueCaps > 0) { | 187 if (capabilities.NumberInputValueCaps > 0) { |
186 scoped_ptr<HIDP_VALUE_CAPS[]> value_caps( | 188 scoped_ptr<HIDP_VALUE_CAPS[]> value_caps( |
187 new HIDP_VALUE_CAPS[capabilities.NumberInputValueCaps]); | 189 new HIDP_VALUE_CAPS[capabilities.NumberInputValueCaps]); |
188 USHORT value_caps_length = capabilities.NumberInputValueCaps; | 190 USHORT value_caps_length = capabilities.NumberInputValueCaps; |
189 if (HidP_GetValueCaps(HidP_Input, &value_caps[0], &value_caps_length, | 191 if (HidP_GetValueCaps(HidP_Input, &value_caps[0], &value_caps_length, |
190 preparsed_data) == HIDP_STATUS_SUCCESS) { | 192 preparsed_data) == HIDP_STATUS_SUCCESS) { |
191 device_info.has_report_id = (value_caps[0].ReportID != 0); | 193 device_info.has_report_id = (value_caps[0].ReportID != 0); |
192 } | 194 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 return NULL; | 252 return NULL; |
251 scoped_refptr<HidConnectionWin> connection(new HidConnectionWin(device_info)); | 253 scoped_refptr<HidConnectionWin> connection(new HidConnectionWin(device_info)); |
252 if (!connection->available()) { | 254 if (!connection->available()) { |
253 LOG_GETLASTERROR(ERROR) << "Failed to open device."; | 255 LOG_GETLASTERROR(ERROR) << "Failed to open device."; |
254 return NULL; | 256 return NULL; |
255 } | 257 } |
256 return connection; | 258 return connection; |
257 } | 259 } |
258 | 260 |
259 } // namespace device | 261 } // namespace device |
OLD | NEW |