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

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

Issue 492963007: Store HID report sizes as uint16_t. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « device/hid/hid_report_descriptor.h ('k') | device/hid/hid_report_descriptor_unittest.cc » ('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_report_descriptor.h" 5 #include "device/hid/hid_report_descriptor.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 8
9 namespace device { 9 namespace device {
10 10
(...skipping 11 matching lines...) Expand all
22 items_.push_back(linked_ptr<HidReportDescriptorItem>(item)); 22 items_.push_back(linked_ptr<HidReportDescriptorItem>(item));
23 header_index += item->GetSize(); 23 header_index += item->GetSize();
24 } 24 }
25 } 25 }
26 26
27 HidReportDescriptor::~HidReportDescriptor() {} 27 HidReportDescriptor::~HidReportDescriptor() {}
28 28
29 void HidReportDescriptor::GetDetails( 29 void HidReportDescriptor::GetDetails(
30 std::vector<HidCollectionInfo>* top_level_collections, 30 std::vector<HidCollectionInfo>* top_level_collections,
31 bool* has_report_id, 31 bool* has_report_id,
32 int* max_input_report_size, 32 uint16_t* max_input_report_size,
33 int* max_output_report_size, 33 uint16_t* max_output_report_size,
34 int* max_feature_report_size) { 34 uint16_t* max_feature_report_size) {
35 DCHECK(top_level_collections); 35 DCHECK(top_level_collections);
36 DCHECK(max_input_report_size); 36 DCHECK(max_input_report_size);
37 DCHECK(max_output_report_size); 37 DCHECK(max_output_report_size);
38 DCHECK(max_feature_report_size); 38 DCHECK(max_feature_report_size);
39 STLClearObject(top_level_collections); 39 STLClearObject(top_level_collections);
40 40
41 *has_report_id = false; 41 *has_report_id = false;
42 *max_input_report_size = 0; 42 *max_input_report_size = 0;
43 *max_output_report_size = 0; 43 *max_output_report_size = 0;
44 *max_feature_report_size = 0; 44 *max_feature_report_size = 0;
45 45
46 // Global tags data: 46 // Global tags data:
47 HidUsageAndPage::Page current_usage_page = HidUsageAndPage::kPageUndefined; 47 HidUsageAndPage::Page current_usage_page = HidUsageAndPage::kPageUndefined;
48 int current_report_count = 0; 48 uint16_t current_report_count = 0;
49 int cached_report_count = 0; 49 uint16_t cached_report_count = 0;
50 int current_report_size = 0; 50 uint16_t current_report_size = 0;
51 int cached_report_size = 0; 51 uint16_t cached_report_size = 0;
52 int current_input_report_size = 0; 52 uint16_t current_input_report_size = 0;
53 int current_output_report_size = 0; 53 uint16_t current_output_report_size = 0;
54 int current_feature_report_size = 0; 54 uint16_t current_feature_report_size = 0;
55 55
56 // Local tags data: 56 // Local tags data:
57 uint16_t current_usage = 0; 57 uint16_t current_usage = 0;
58 58
59 for (std::vector<linked_ptr<HidReportDescriptorItem> >::const_iterator 59 for (std::vector<linked_ptr<HidReportDescriptorItem> >::const_iterator
60 items_iter = items().begin(); 60 items_iter = items().begin();
61 items_iter != items().end(); 61 items_iter != items().end();
62 ++items_iter) { 62 ++items_iter) {
63 linked_ptr<HidReportDescriptorItem> current_item = *items_iter; 63 linked_ptr<HidReportDescriptorItem> current_item = *items_iter;
64 64
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 *max_feature_report_size = 148 *max_feature_report_size =
149 std::max(*max_feature_report_size, current_feature_report_size); 149 std::max(*max_feature_report_size, current_feature_report_size);
150 150
151 // Convert bits into bytes 151 // Convert bits into bytes
152 *max_input_report_size /= kBitsPerByte; 152 *max_input_report_size /= kBitsPerByte;
153 *max_output_report_size /= kBitsPerByte; 153 *max_output_report_size /= kBitsPerByte;
154 *max_feature_report_size /= kBitsPerByte; 154 *max_feature_report_size /= kBitsPerByte;
155 } 155 }
156 156
157 } // namespace device 157 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_report_descriptor.h ('k') | device/hid/hid_report_descriptor_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698