Deluge Firmware 1.3.0
Build date: 2025.06.05
Loading...
Searching...
No Matches
usb_hosted.h
1/*
2 * Copyright © 2024 Synthstrom Audible Limited
3 *
4 * This file is part of The Synthstrom Audible Deluge Firmware.
5 *
6 * The Synthstrom Audible Deluge Firmware is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software Foundation,
8 * either version 3 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * See the GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along with this program.
15 * If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#pragma once
19
20#include "io/midi/cable_types/usb_hosted.h"
21#include "io/midi/midi_root_complex.h"
22#include "util/container/vector/named_thing_vector.h"
23#include <array>
24
25class MIDIRootComplexUSBHosted : public MIDIRootComplex {
26private:
27#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Winvalid-offsetof"
29 NamedThingVector hostedMIDIDevices_{__builtin_offsetof(MIDICableUSBHosted, name)};
30#pragma GCC diagnostic pop
31
32public:
33 MIDIRootComplexUSBHosted(const MIDIRootComplexUSBHosted&) = delete;
34 MIDIRootComplexUSBHosted(MIDIRootComplexUSBHosted&&) = delete;
35 MIDIRootComplexUSBHosted& operator=(const MIDIRootComplexUSBHosted&) = delete;
36 MIDIRootComplexUSBHosted& operator=(MIDIRootComplexUSBHosted&&) = delete;
37
38 MIDIRootComplexUSBHosted();
39 ~MIDIRootComplexUSBHosted() override;
40
41 [[nodiscard]] RootComplexType getType() const override { return RootComplexType::RC_USB_HOST; }
42
43 [[nodiscard]] size_t getNumCables() const override { return hostedMIDIDevices_.getNumElements(); }
44 [[nodiscard]] MIDICable* getCable(size_t index) override;
45
46 [[nodiscard]] NamedThingVector& getHostedMIDIDevices() { return hostedMIDIDevices_; }
47 [[nodiscard]] NamedThingVector const& getHostedMIDIDevices() const { return hostedMIDIDevices_; }
48
49 void flush() override;
50 [[nodiscard]] Error poll() override;
51};
52
53extern "C" {
54void usbSendCompleteAsHost(int32_t ip);
55}
Definition usb_hosted.h:22
A MIDI cable connection. Stores all state specific to a given cable and its contained ports and chann...
Definition midi_device.h:94
Error poll() override
Poll the root complex, calling back in to the MIDI engine for any new messages.
Definition usb_hosted.cpp:233
void flush() override
Flush as much data as possible from any internal buffers to hardware queues.
Definition usb_hosted.cpp:148
Definition named_thing_vector.h:35