rockot@chromium.org | 26958d1 | 2014-02-27 17:29:10 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
rockot@chromium.org | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef DEVICE_HID_HID_DEVICE_INFO_H_ |
| 6 | #define DEVICE_HID_HID_DEVICE_INFO_H_ |
| 7 | |
| 8 | #include <string> |
rockot@chromium.org | fe7b300 | 2014-04-25 00:16:40 | [diff] [blame] | 9 | #include <vector> |
rockot@chromium.org | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 10 | |
reillyg | fbff124c | 2015-01-09 03:03:37 | [diff] [blame] | 11 | #include "base/memory/ref_counted.h" |
rockot@chromium.org | 26958d1 | 2014-02-27 17:29:10 | [diff] [blame] | 12 | #include "build/build_config.h" |
csharp@chromium.org | 104de62a | 2014-07-03 18:20:04 | [diff] [blame] | 13 | #include "device/hid/hid_collection_info.h" |
rockot@chromium.org | 26958d1 | 2014-02-27 17:29:10 | [diff] [blame] | 14 | |
rockot@chromium.org | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 15 | namespace device { |
| 16 | |
| 17 | enum HidBusType { |
| 18 | kHIDBusTypeUSB = 0, |
| 19 | kHIDBusTypeBluetooth = 1, |
| 20 | }; |
| 21 | |
reillyg | fab70f55 | 2015-03-23 23:21:14 | [diff] [blame] | 22 | #if defined(OS_MACOSX) |
| 23 | typedef uint64_t HidDeviceId; |
| 24 | const uint64_t kInvalidHidDeviceId = -1; |
| 25 | #else |
rockot@chromium.org | 26958d1 | 2014-02-27 17:29:10 | [diff] [blame] | 26 | typedef std::string HidDeviceId; |
| 27 | extern const char kInvalidHidDeviceId[]; |
reillyg | fab70f55 | 2015-03-23 23:21:14 | [diff] [blame] | 28 | #endif |
rockot@chromium.org | 26958d1 | 2014-02-27 17:29:10 | [diff] [blame] | 29 | |
reillyg | fbff124c | 2015-01-09 03:03:37 | [diff] [blame] | 30 | class HidDeviceInfo : public base::RefCountedThreadSafe<HidDeviceInfo> { |
| 31 | public: |
reillyg | 37cde995 | 2015-01-13 03:07:11 | [diff] [blame] | 32 | HidDeviceInfo(const HidDeviceId& device_id, |
| 33 | uint16_t vendor_id, |
| 34 | uint16_t product_id, |
| 35 | const std::string& product_name, |
| 36 | const std::string& serial_number, |
| 37 | HidBusType bus_type, |
| 38 | const std::vector<uint8> report_descriptor); |
| 39 | |
| 40 | HidDeviceInfo(const HidDeviceId& device_id, |
| 41 | uint16_t vendor_id, |
| 42 | uint16_t product_id, |
| 43 | const std::string& product_name, |
| 44 | const std::string& serial_number, |
| 45 | HidBusType bus_type, |
| 46 | const HidCollectionInfo& collection, |
| 47 | size_t max_input_report_size, |
| 48 | size_t max_output_report_size, |
| 49 | size_t max_feature_report_size); |
reillyg | fbff124c | 2015-01-09 03:03:37 | [diff] [blame] | 50 | |
| 51 | // Device identification. |
| 52 | const HidDeviceId& device_id() const { return device_id_; } |
| 53 | uint16_t vendor_id() const { return vendor_id_; } |
| 54 | uint16_t product_id() const { return product_id_; } |
| 55 | const std::string& product_name() const { return product_name_; } |
| 56 | const std::string& serial_number() const { return serial_number_; } |
| 57 | HidBusType bus_type() const { return bus_type_; } |
| 58 | |
| 59 | // Top-Level Collections information. |
| 60 | const std::vector<HidCollectionInfo>& collections() const { |
| 61 | return collections_; |
| 62 | } |
| 63 | bool has_report_id() const { return has_report_id_; }; |
| 64 | 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_; } |
| 66 | size_t max_feature_report_size() const { return max_feature_report_size_; } |
| 67 | |
reillyg | 37cde995 | 2015-01-13 03:07:11 | [diff] [blame] | 68 | // The raw HID report descriptor is not available on Windows. |
| 69 | const std::vector<uint8>& report_descriptor() const { |
| 70 | return report_descriptor_; |
| 71 | } |
| 72 | |
| 73 | protected: |
| 74 | virtual ~HidDeviceInfo(); |
reillyg | fbff124c | 2015-01-09 03:03:37 | [diff] [blame] | 75 | |
| 76 | private: |
| 77 | friend class base::RefCountedThreadSafe<HidDeviceInfo>; |
rockot@chromium.org | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 78 | |
csharp@chromium.org | 104de62a | 2014-07-03 18:20:04 | [diff] [blame] | 79 | // Device identification. |
reillyg | fbff124c | 2015-01-09 03:03:37 | [diff] [blame] | 80 | HidDeviceId device_id_; |
| 81 | uint16_t vendor_id_; |
| 82 | uint16_t product_id_; |
| 83 | std::string product_name_; |
| 84 | std::string serial_number_; |
| 85 | HidBusType bus_type_; |
reillyg | 37cde995 | 2015-01-13 03:07:11 | [diff] [blame] | 86 | std::vector<uint8> report_descriptor_; |
csharp@chromium.org | 104de62a | 2014-07-03 18:20:04 | [diff] [blame] | 87 | |
| 88 | // Top-Level Collections information. |
reillyg | fbff124c | 2015-01-09 03:03:37 | [diff] [blame] | 89 | std::vector<HidCollectionInfo> collections_; |
| 90 | bool has_report_id_; |
| 91 | size_t max_input_report_size_; |
| 92 | size_t max_output_report_size_; |
| 93 | size_t max_feature_report_size_; |
reillyg | fbff124c | 2015-01-09 03:03:37 | [diff] [blame] | 94 | |
| 95 | DISALLOW_COPY_AND_ASSIGN(HidDeviceInfo); |
rockot@chromium.org | 125724f | 2014-01-31 20:13:23 | [diff] [blame] | 96 | }; |
| 97 | |
| 98 | } // namespace device |
| 99 | |
| 100 | #endif // DEVICE_HID_HID_DEVICE_INFO_H_ |