[go: nahoru, domu]

blob: bc89832229c24827c3abac05ff5783f645fd32f2 [file] [log] [blame]
rockot@chromium.org26958d12014-02-27 17:29:101// Copyright 2014 The Chromium Authors. All rights reserved.
rockot@chromium.org125724f2014-01-31 20:13:232// 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.orgfe7b3002014-04-25 00:16:409#include <vector>
rockot@chromium.org125724f2014-01-31 20:13:2310
reillygfbff124c2015-01-09 03:03:3711#include "base/memory/ref_counted.h"
rockot@chromium.org26958d12014-02-27 17:29:1012#include "build/build_config.h"
csharp@chromium.org104de62a2014-07-03 18:20:0413#include "device/hid/hid_collection_info.h"
rockot@chromium.org26958d12014-02-27 17:29:1014
rockot@chromium.org125724f2014-01-31 20:13:2315namespace device {
16
17enum HidBusType {
18 kHIDBusTypeUSB = 0,
19 kHIDBusTypeBluetooth = 1,
20};
21
reillygfab70f552015-03-23 23:21:1422#if defined(OS_MACOSX)
23typedef uint64_t HidDeviceId;
24const uint64_t kInvalidHidDeviceId = -1;
25#else
rockot@chromium.org26958d12014-02-27 17:29:1026typedef std::string HidDeviceId;
27extern const char kInvalidHidDeviceId[];
reillygfab70f552015-03-23 23:21:1428#endif
rockot@chromium.org26958d12014-02-27 17:29:1029
reillygfbff124c2015-01-09 03:03:3730class HidDeviceInfo : public base::RefCountedThreadSafe<HidDeviceInfo> {
31 public:
reillyg37cde9952015-01-13 03:07:1132 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);
reillygfbff124c2015-01-09 03:03:3750
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
reillyg37cde9952015-01-13 03:07:1168 // 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();
reillygfbff124c2015-01-09 03:03:3775
76 private:
77 friend class base::RefCountedThreadSafe<HidDeviceInfo>;
rockot@chromium.org125724f2014-01-31 20:13:2378
csharp@chromium.org104de62a2014-07-03 18:20:0479 // Device identification.
reillygfbff124c2015-01-09 03:03:3780 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_;
reillyg37cde9952015-01-13 03:07:1186 std::vector<uint8> report_descriptor_;
csharp@chromium.org104de62a2014-07-03 18:20:0487
88 // Top-Level Collections information.
reillygfbff124c2015-01-09 03:03:3789 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_;
reillygfbff124c2015-01-09 03:03:3794
95 DISALLOW_COPY_AND_ASSIGN(HidDeviceInfo);
rockot@chromium.org125724f2014-01-31 20:13:2396};
97
98} // namespace device
99
100#endif // DEVICE_HID_HID_DEVICE_INFO_H_