Skip to content

Commit b7b61c3

Browse files
authored
feat(midi): add midi dev name from macro
1 parent 2f4667a commit b7b61c3

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

cores/esp32/Arduino.h

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -222,28 +222,14 @@ size_t getArduinoLoopTaskStackSize(void);
222222
return sz; \
223223
}
224224

225-
#if CONFIG_TINYUSB_MIDI_ENABLE
226-
// Forward declaration of USBMIDI class for the SET_USB_MIDI_DEVICE_NAME macro
227-
#include "USB/USBMIDI.h"
228-
#define SET_USB_MIDI_DEVICE_NAME(name) \
229-
namespace { \
230-
static const char* _usb_midi_default_name = name; \
231-
static struct _USBMIDINameSetter { \
232-
_USBMIDINameSetter() { \
233-
USBMIDI::setDefaultName(_usb_midi_default_name); \
234-
} \
235-
} _usb_midi_name_setter; \
236-
}
237-
#else
238-
#define SET_USB_MIDI_DEVICE_NAME(name) \
239-
namespace { \
240-
static struct _USBMIDINameSetter { \
241-
_USBMIDINameSetter() { \
242-
log_e("USB MIDI is not enabled. Enable it in menuconfig under Component Config -> TinyUSB -> CDC Enable"); \
243-
} \
244-
} _usb_midi_name_setter; \
245-
}
246-
#endif
225+
#define ESP32_USB_MIDI_DEFAULT_NAME "TinyUSB MIDI"
226+
#define SET_USB_MIDI_DEVICE_NAME(name) \
227+
const char* getUSBMIDIDefaultDeviceName() { \
228+
if (strlen(name) == 0) { \
229+
return ESP32_USB_MIDI_DEFAULT_NAME; \
230+
} \
231+
return name; \
232+
}
247233

248234
bool shouldPrintChipDebugReport(void);
249235
#define ENABLE_CHIP_DEBUG_REPORT \

0 commit comments

Comments
 (0)