-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathhid_interface.h
40 lines (30 loc) · 1.39 KB
/
hid_interface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright 2017 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef U2FD_HID_INTERFACE_H_
#define U2FD_HID_INTERFACE_H_
#include <string>
#include <base/callback.h>
namespace u2f {
// Interface to create and manage a HID device.
// It passes output HID reports sent by the client connected to the HID device,
// and can send back input HID reports to the client.
class HidInterface {
public:
virtual ~HidInterface() = default;
// Sets up the HID device. Must be called before any other method.
// |hid_version| sets the HID interface version number as returned to clients.
// |report_desc| contains the raw HID report descriptor.
// Returns true on success.
virtual bool Init(uint32_t hid_version, const std::string& report_desc) = 0;
// Sends the HID report stored in |report| to the device client.
// Returns true on success, false if it failed to send it.
virtual bool SendReport(const std::string& report) = 0;
// Callback invoked when the HID device client sends an output report.
// The raw report prefixed by the report ID is passed in |report|.
using OutputReportCallback = base::Callback<void(const std::string& report)>;
virtual void SetOutputReportHandler(
const OutputReportCallback& on_output_report) = 0;
};
} // namespace u2f
#endif // U2FD_HID_INTERFACE_H_