| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_connection_linux.h" | 5 #include "device/hid/hid_connection_linux.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <libudev.h> | 9 #include <libudev.h> |
| 10 #include <linux/hidraw.h> | 10 #include <linux/hidraw.h> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 104 } |
| 105 callback.Run(true); | 105 callback.Run(true); |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 void HidConnectionLinux::PlatformGetFeatureReport( | 109 void HidConnectionLinux::PlatformGetFeatureReport( |
| 110 uint8_t report_id, | 110 uint8_t report_id, |
| 111 const ReadCallback& callback) { | 111 const ReadCallback& callback) { |
| 112 // The first byte of the destination buffer is the report ID being requested | 112 // The first byte of the destination buffer is the report ID being requested |
| 113 // and is overwritten by the feature report. | 113 // and is overwritten by the feature report. |
| 114 DCHECK_GT(device_info().max_feature_report_size, 0); | 114 DCHECK_GT(device_info().max_feature_report_size, 0u); |
| 115 scoped_refptr<net::IOBufferWithSize> buffer( | 115 scoped_refptr<net::IOBufferWithSize> buffer( |
| 116 new net::IOBufferWithSize(device_info().max_feature_report_size + 1)); | 116 new net::IOBufferWithSize(device_info().max_feature_report_size + 1)); |
| 117 buffer->data()[0] = report_id; | 117 buffer->data()[0] = report_id; |
| 118 | 118 |
| 119 int result = ioctl(device_file_.GetPlatformFile(), | 119 int result = ioctl(device_file_.GetPlatformFile(), |
| 120 HIDIOCGFEATURE(buffer->size()), | 120 HIDIOCGFEATURE(buffer->size()), |
| 121 buffer->data()); | 121 buffer->data()); |
| 122 if (result < 0) { | 122 if (result < 0) { |
| 123 VPLOG(1) << "Failed to get feature report"; | 123 VPLOG(1) << "Failed to get feature report"; |
| 124 callback.Run(false, NULL, 0); | 124 callback.Run(false, NULL, 0); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 PendingHidReport report = pending_reports_.front(); | 219 PendingHidReport report = pending_reports_.front(); |
| 220 | 220 |
| 221 pending_reports_.pop(); | 221 pending_reports_.pop(); |
| 222 if (CompleteRead(report.buffer, report.size, read.callback)) { | 222 if (CompleteRead(report.buffer, report.size, read.callback)) { |
| 223 pending_reads_.pop(); | 223 pending_reads_.pop(); |
| 224 } | 224 } |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 } // namespace device | 228 } // namespace device |
| OLD | NEW |