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 #ifndef DEVICE_HID_HID_DEVICE_INFO_H_ | 5 #ifndef DEVICE_HID_HID_DEVICE_INFO_H_ |
6 #define DEVICE_HID_HID_DEVICE_INFO_H_ | 6 #define DEVICE_HID_HID_DEVICE_INFO_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <string> | 11 #include <string> |
9 #include <vector> | 12 #include <vector> |
10 | 13 |
| 14 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
12 #include "build/build_config.h" | 16 #include "build/build_config.h" |
13 #include "device/hid/hid_collection_info.h" | 17 #include "device/hid/hid_collection_info.h" |
14 | 18 |
15 namespace device { | 19 namespace device { |
16 | 20 |
17 enum HidBusType { | 21 enum HidBusType { |
18 kHIDBusTypeUSB = 0, | 22 kHIDBusTypeUSB = 0, |
19 kHIDBusTypeBluetooth = 1, | 23 kHIDBusTypeBluetooth = 1, |
20 }; | 24 }; |
21 | 25 |
22 #if defined(OS_MACOSX) | 26 #if defined(OS_MACOSX) |
23 typedef uint64_t HidDeviceId; | 27 typedef uint64_t HidDeviceId; |
24 const uint64_t kInvalidHidDeviceId = -1; | 28 const uint64_t kInvalidHidDeviceId = -1; |
25 #else | 29 #else |
26 typedef std::string HidDeviceId; | 30 typedef std::string HidDeviceId; |
27 extern const char kInvalidHidDeviceId[]; | 31 extern const char kInvalidHidDeviceId[]; |
28 #endif | 32 #endif |
29 | 33 |
30 class HidDeviceInfo : public base::RefCountedThreadSafe<HidDeviceInfo> { | 34 class HidDeviceInfo : public base::RefCountedThreadSafe<HidDeviceInfo> { |
31 public: | 35 public: |
32 HidDeviceInfo(const HidDeviceId& device_id, | 36 HidDeviceInfo(const HidDeviceId& device_id, |
33 uint16_t vendor_id, | 37 uint16_t vendor_id, |
34 uint16_t product_id, | 38 uint16_t product_id, |
35 const std::string& product_name, | 39 const std::string& product_name, |
36 const std::string& serial_number, | 40 const std::string& serial_number, |
37 HidBusType bus_type, | 41 HidBusType bus_type, |
38 const std::vector<uint8> report_descriptor); | 42 const std::vector<uint8_t> report_descriptor); |
39 | 43 |
40 HidDeviceInfo(const HidDeviceId& device_id, | 44 HidDeviceInfo(const HidDeviceId& device_id, |
41 uint16_t vendor_id, | 45 uint16_t vendor_id, |
42 uint16_t product_id, | 46 uint16_t product_id, |
43 const std::string& product_name, | 47 const std::string& product_name, |
44 const std::string& serial_number, | 48 const std::string& serial_number, |
45 HidBusType bus_type, | 49 HidBusType bus_type, |
46 const HidCollectionInfo& collection, | 50 const HidCollectionInfo& collection, |
47 size_t max_input_report_size, | 51 size_t max_input_report_size, |
48 size_t max_output_report_size, | 52 size_t max_output_report_size, |
(...skipping 10 matching lines...) Expand all Loading... |
59 // Top-Level Collections information. | 63 // Top-Level Collections information. |
60 const std::vector<HidCollectionInfo>& collections() const { | 64 const std::vector<HidCollectionInfo>& collections() const { |
61 return collections_; | 65 return collections_; |
62 } | 66 } |
63 bool has_report_id() const { return has_report_id_; }; | 67 bool has_report_id() const { return has_report_id_; }; |
64 size_t max_input_report_size() const { return max_input_report_size_; } | 68 size_t max_input_report_size() const { return max_input_report_size_; } |
65 size_t max_output_report_size() const { return max_output_report_size_; } | 69 size_t max_output_report_size() const { return max_output_report_size_; } |
66 size_t max_feature_report_size() const { return max_feature_report_size_; } | 70 size_t max_feature_report_size() const { return max_feature_report_size_; } |
67 | 71 |
68 // The raw HID report descriptor is not available on Windows. | 72 // The raw HID report descriptor is not available on Windows. |
69 const std::vector<uint8>& report_descriptor() const { | 73 const std::vector<uint8_t>& report_descriptor() const { |
70 return report_descriptor_; | 74 return report_descriptor_; |
71 } | 75 } |
72 | 76 |
73 protected: | 77 protected: |
74 virtual ~HidDeviceInfo(); | 78 virtual ~HidDeviceInfo(); |
75 | 79 |
76 private: | 80 private: |
77 friend class base::RefCountedThreadSafe<HidDeviceInfo>; | 81 friend class base::RefCountedThreadSafe<HidDeviceInfo>; |
78 | 82 |
79 // Device identification. | 83 // Device identification. |
80 HidDeviceId device_id_; | 84 HidDeviceId device_id_; |
81 uint16_t vendor_id_; | 85 uint16_t vendor_id_; |
82 uint16_t product_id_; | 86 uint16_t product_id_; |
83 std::string product_name_; | 87 std::string product_name_; |
84 std::string serial_number_; | 88 std::string serial_number_; |
85 HidBusType bus_type_; | 89 HidBusType bus_type_; |
86 std::vector<uint8> report_descriptor_; | 90 std::vector<uint8_t> report_descriptor_; |
87 | 91 |
88 // Top-Level Collections information. | 92 // Top-Level Collections information. |
89 std::vector<HidCollectionInfo> collections_; | 93 std::vector<HidCollectionInfo> collections_; |
90 bool has_report_id_; | 94 bool has_report_id_; |
91 size_t max_input_report_size_; | 95 size_t max_input_report_size_; |
92 size_t max_output_report_size_; | 96 size_t max_output_report_size_; |
93 size_t max_feature_report_size_; | 97 size_t max_feature_report_size_; |
94 | 98 |
95 DISALLOW_COPY_AND_ASSIGN(HidDeviceInfo); | 99 DISALLOW_COPY_AND_ASSIGN(HidDeviceInfo); |
96 }; | 100 }; |
97 | 101 |
98 } // namespace device | 102 } // namespace device |
99 | 103 |
100 #endif // DEVICE_HID_HID_DEVICE_INFO_H_ | 104 #endif // DEVICE_HID_HID_DEVICE_INFO_H_ |
OLD | NEW |