summaryrefslogtreecommitdiffstats
path: root/device/hid/hid_connection_mac.cc
diff options
context:
space:
mode:
authorreillyg@chromium.org <reillyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 22:01:26 +0000
committerreillyg@chromium.org <reillyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-28 22:01:26 +0000
commit054293034c1e79f6ee7ff5b11e6a35673d7f38a3 (patch)
tree8f1a63690fbcdb0396c25c57d9de79d04a3853f8 /device/hid/hid_connection_mac.cc
parent3e65977489925662657d91d334d6e9d1b520c60a (diff)
downloadchromium_src-054293034c1e79f6ee7ff5b11e6a35673d7f38a3.zip
chromium_src-054293034c1e79f6ee7ff5b11e6a35673d7f38a3.tar.gz
chromium_src-054293034c1e79f6ee7ff5b11e6a35673d7f38a3.tar.bz2
hid: Remove size from receive APIs and return report ID separately.
The size parameter is unnecessary when calling chrome.hid.receive and chrome.hid.receiveFeatureReport because, since the caller does not know which report ID will be returned, it should always be set to the maximum input or feature report size provided by the device. The size of the report ID is now not included in the maximum report sizes for the device since it no longer effects buffer size. In addition increase consistency by always providing the report ID to the chrome.hid.receive callback instead of including it as the first byte of the data buffer only if it is non-zero. BUG= Review URL: https://codereview.chromium.org/413913003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285989 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_connection_mac.cc')
-rw-r--r--device/hid/hid_connection_mac.cc14
1 files changed, 9 insertions, 5 deletions
diff --git a/device/hid/hid_connection_mac.cc b/device/hid/hid_connection_mac.cc
index 521f287..d497ac0 100644
--- a/device/hid/hid_connection_mac.cc
+++ b/device/hid/hid_connection_mac.cc
@@ -17,10 +17,14 @@ HidConnectionMac::HidConnectionMac(HidDeviceInfo device_info)
message_loop_ = base::MessageLoopProxy::current();
DCHECK(device_.get());
- inbound_buffer_.reset((uint8_t*)malloc(device_info.max_input_report_size));
+ size_t expected_report_size = device_info.max_input_report_size;
+ if (device_info.has_report_id) {
+ expected_report_size++;
+ }
+ inbound_buffer_.reset((uint8_t*)malloc(expected_report_size));
IOHIDDeviceRegisterInputReportCallback(device_.get(),
inbound_buffer_.get(),
- device_info.max_input_report_size,
+ expected_report_size,
&HidConnectionMac::InputReportCallback,
this);
IOHIDDeviceOpen(device_, kIOHIDOptionsTypeNone);
@@ -62,14 +66,14 @@ void HidConnectionMac::PlatformGetFeatureReport(
}
uint8_t* feature_report_buffer = reinterpret_cast<uint8_t*>(buffer->data());
- CFIndex max_feature_report_size = device_info().max_feature_report_size;
+ CFIndex report_size = buffer->size();
IOReturn result = IOHIDDeviceGetReport(device_,
kIOHIDReportTypeFeature,
report_id,
feature_report_buffer,
- &max_feature_report_size);
+ &report_size);
if (result == kIOReturnSuccess)
- callback.Run(true, max_feature_report_size);
+ callback.Run(true, report_size);
else
callback.Run(false, 0);
}