From 67923962e91b7b115e38ed9c9871ca7d793f26fe Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Tue, 22 May 2018 17:47:09 -0400 Subject: [PATCH] Reorder driverIds, re-enable Bridge --- src/app/MidiWidget.cpp | 7 +++++++ src/midi.cpp | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/app/MidiWidget.cpp b/src/app/MidiWidget.cpp index 39736c40..e374d5ed 100644 --- a/src/app/MidiWidget.cpp +++ b/src/app/MidiWidget.cpp @@ -29,6 +29,13 @@ struct MidiDriverChoice : LedDisplayChoice { } void step() override { text = midiWidget->midiIO->getDriverName(midiWidget->midiIO->driverId); + if (text.empty()) { + text = "(No driver)"; + color.a = 0.5f; + } + else { + color.a = 1.f; + } } }; diff --git a/src/midi.cpp b/src/midi.cpp index ed4332e9..91fc235d 100644 --- a/src/midi.cpp +++ b/src/midi.cpp @@ -8,6 +8,7 @@ namespace rack { +static std::vector driverIds; static std::map drivers; @@ -47,10 +48,6 @@ MidiIO::~MidiIO() { } std::vector MidiIO::getDriverIds() { - std::vector driverIds; - for (auto pair : drivers) { - driverIds.push_back(pair.first); - } return driverIds; } @@ -195,13 +192,19 @@ void MidiOutput::setDeviceId(int deviceId) { // midi //////////////////// +static void midiAddDriver(int driverId, MidiDriver *driver) { + assert(driver); + driverIds.push_back(driverId); + drivers[driverId] = driver; +} + void midiInit() { for (int driverId : rtmidiGetDrivers()) { - drivers[driverId] = rtmidiCreateDriver(driverId); + midiAddDriver(driverId, rtmidiCreateDriver(driverId)); } - // drivers[BRIDGE_DRIVER] = bridgeCreateDriver(); - drivers[GAMEPAD_DRIVER] = gamepadGetDriver(); - drivers[KEYBOARD_DRIVER] = keyboardGetDriver(); + midiAddDriver(BRIDGE_DRIVER, bridgeGetMidiDriver()); + midiAddDriver(KEYBOARD_DRIVER, keyboardGetDriver()); + midiAddDriver(GAMEPAD_DRIVER, gamepadGetDriver()); }