Libraries/USB/src/USB/HID/Device.h
Go to the documentation of this file.
1 /****
2  * HID/Device.cpp
3  *
4  * Copyright 2023 mikee47 <mike@sillyhouse.net>
5  *
6  * This file is part of the Sming USB Library
7  *
8  * This library is free software: you can redistribute it and/or modify it under the terms of the
9  * GNU General Public License as published by the Free Software Foundation, version 3 or later.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along with this library.
16  * If not, see <https://www.gnu.org/licenses/>.
17  *
18  ****/
19 
20 #pragma once
21 
22 #include "../DeviceInterface.h"
23 
24 namespace USB::HID
25 {
26 class Device : public DeviceInterface
27 {
28 public:
29  using ReportComplete = Delegate<void()>;
30 
32 
33  bool sendReport(uint8_t report_id, void const* report, uint16_t len, ReportComplete callback);
34 
35 protected:
36  uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen);
37  void set_report(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize);
38  void report_complete();
39 
40 private:
41  ReportComplete reportCompleteCallback;
42 };
43 
44 } // namespace USB::HID
void set_report(uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize)
void report_complete()
DeviceInterface(uint8_t instance, const char *name)
Constructor.
Definition: DeviceInterface.h:71
Definition: Libraries/USB/src/USB/HID/Device.h:43
uint16_t get_report(uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen)
Delegate< void()> ReportComplete
Definition: Libraries/USB/src/USB/HID/Device.h:63
bool sendReport(uint8_t report_id, void const *report, uint16_t len, ReportComplete callback)
Base class to support a USB device interface implementation.
Definition: DeviceInterface.h:46
Definition: Delegate.h:20
Definition: Libraries/USB/src/USB/HID/Device.h:24