20 uint16_t (*
onGetReport)(uint8_t report_id, uint8_t report_type,
21 uint8_t* buffer, uint16_t reqlen) =
nullptr;
23 uint8_t
const* buffer, uint16_t bufsize) =
nullptr;
29 const char*
name =
nullptr;
56 const char*
getName()
const override {
return "UsbManager"; }
59 bool start()
override;
75 bool hidSlotsFull()
const {
return activeHidCount() >= MAX_ACTIVE_HID; }
86 return !wasNeededBefore && needsReplug_;
90 struct InterfaceEntry {
92 const char* owner =
nullptr;
96 uint8_t activeHidCount()
const;
98 static constexpr uint8_t MAX_ACTIVE_HID = 2;
101 uint8_t activeMask_ = 0;
102 bool needsReplug_ =
false;
103 InterfaceEntry entries_[3] = {};
bool init() override
Initializes USB manager service state.
bool registerInterface(UsbHidInterface type, const char *moduleName, const UsbInterfaceSpec &def)
Registers a HID interface request from a module.
const char * getName() const override
bool hidSlotsFull() const
Reports whether the HID interface budget is exhausted.
ServiceState getState() const override
bool newlyRequiresReplug(bool wasNeededBefore) const
Tests whether a toggle newly introduced a replug requirement.
bool start() override
Starts USB manager service state.
static UsbManager & instance()
Returns singleton USB manager instance.
void unregisterInterface(UsbHidInterface type, const char *moduleName)
Unregisters a previously registered HID interface.
void stop() override
Stops USB manager service state.
uint8_t activeInterfaceMask() const
bool applyConfiguration()
Applies current interface set to USB HID stack.
void(* onReportComplete)(uint8_t const *report, uint16_t len)
void(* onSetReport)(uint8_t report_id, uint8_t report_type, uint8_t const *buffer, uint16_t bufsize)
uint16_t(* onGetReport)(uint8_t report_id, uint8_t report_type, uint8_t *buffer, uint16_t reqlen)
const uint8_t * reportDesc
UsbHidCallbacks callbacks