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

Unified Diff: device/hid/hid_service_mac.cc

Issue 225513005: chrome.hid : enrich device info with Top-Level collections usages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: HidUsageAndPage::Page 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/hid/hid_service_linux.cc ('k') | device/hid/hid_service_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_service_mac.cc
diff --git a/device/hid/hid_service_mac.cc b/device/hid/hid_service_mac.cc
index 3df7e592333e6b8ec9620d8f924456b951202572..ed85ec2d5cc922c51397f5e09a6dba3168ebdd5a 100644
--- a/device/hid/hid_service_mac.cc
+++ b/device/hid/hid_service_mac.cc
@@ -143,16 +143,30 @@ void HidServiceMac::PlatformAddDevice(IOHIDDeviceRef hid_device) {
GetHidIntProperty(hid_device, CFSTR(kIOHIDVendorIDKey));
device_info.product_id =
GetHidIntProperty(hid_device, CFSTR(kIOHIDProductIDKey));
- device_info.usage =
- GetHidIntProperty(hid_device, CFSTR(kIOHIDPrimaryUsageKey));
- device_info.usage_page =
- GetHidIntProperty(hid_device, CFSTR(kIOHIDPrimaryUsagePageKey));
device_info.input_report_size =
GetHidIntProperty(hid_device, CFSTR(kIOHIDMaxInputReportSizeKey));
device_info.output_report_size =
GetHidIntProperty(hid_device, CFSTR(kIOHIDMaxOutputReportSizeKey));
device_info.feature_report_size =
GetHidIntProperty(hid_device, CFSTR(kIOHIDMaxFeatureReportSizeKey));
+ CFTypeRef deviceUsagePairsRaw =
+ IOHIDDeviceGetProperty(hid_device, CFSTR(kIOHIDDeviceUsagePairsKey));
+ CFArrayRef deviceUsagePairs =
+ base::mac::CFCast<CFArrayRef>(deviceUsagePairsRaw);
+ CFIndex deviceUsagePairsCount = CFArrayGetCount(deviceUsagePairs);
+ for (CFIndex i = 0; i < deviceUsagePairsCount; i++) {
+ CFDictionaryRef deviceUsagePair = base::mac::CFCast<CFDictionaryRef>(
+ CFArrayGetValueAtIndex(deviceUsagePairs, i));
+ CFNumberRef usage_raw = base::mac::CFCast<CFNumberRef>(
+ CFDictionaryGetValue(deviceUsagePair, CFSTR(kIOHIDDeviceUsageKey)));
+ uint16_t usage;
+ CFNumberGetValue(usage_raw, kCFNumberSInt32Type, &usage);
+ CFNumberRef page_raw = base::mac::CFCast<CFNumberRef>(
+ CFDictionaryGetValue(deviceUsagePair, CFSTR(kIOHIDDeviceUsagePageKey)));
+ HidUsageAndPage::Page page;
+ CFNumberGetValue(page_raw, kCFNumberSInt32Type, &page);
+ device_info.usages.push_back(HidUsageAndPage(usage, page));
+ }
device_info.product_name =
GetHidStringProperty(hid_device, CFSTR(kIOHIDProductKey));
device_info.serial_number =
« no previous file with comments | « device/hid/hid_service_linux.cc ('k') | device/hid/hid_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698