diff --git a/src/mcu.cpp b/src/mcu.cpp index 50ca007b..71e76e07 100644 --- a/src/mcu.cpp +++ b/src/mcu.cpp @@ -1375,6 +1375,7 @@ int main(int argc, char *argv[]) int pageNum = 32; bool autodetect = true; ResetType resetType = ResetType::NONE; + bool listMidi = false; romset = ROM_SET_MK2; @@ -1453,6 +1454,10 @@ int main(int argc, char *argv[]) { resetType = ResetType::GM_RESET; } + else if (!strcmp(argv[i], "-pl")) + { + listMidi = true; + } else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "-help") || !strcmp(argv[i], "--help")) { // TODO: Might want to try to find a way to print out the executable's actual name (without any full paths). @@ -1474,6 +1479,8 @@ int main(int argc, char *argv[]) printf("\n"); printf(" -gs Reset system in GS mode.\n"); printf(" -gm Reset system in GM mode.\n"); + printf("\n"); + printf(" -pl List all MIDI ports.\n"); return 0; } else if (!strcmp(argv[i], "-sc155")) @@ -1749,7 +1756,7 @@ int main(int argc, char *argv[]) return 2; } - if(!MIDI_Init(port)) + if(!MIDI_Init(port, listMidi)) { fprintf(stderr, "ERROR: Failed to initialize the MIDI Input.\nWARNING: Continuing without MIDI Input...\n"); fflush(stderr); diff --git a/src/midi.h b/src/midi.h index 94366205..b61b525a 100644 --- a/src/midi.h +++ b/src/midi.h @@ -33,6 +33,6 @@ */ #pragma once -int MIDI_Init(int port); +int MIDI_Init(int port, bool listMidi); void MIDI_Quit(void); diff --git a/src/midi_rtmidi.cpp b/src/midi_rtmidi.cpp index d16036bc..a8b81747 100644 --- a/src/midi_rtmidi.cpp +++ b/src/midi_rtmidi.cpp @@ -21,7 +21,7 @@ static void MidiOnError(RtMidiError::Type, const std::string &errorText, void *) fflush(stderr); } -int MIDI_Init(int port) +int MIDI_Init(int port, bool listMidi) { if (s_midi_in) { @@ -36,6 +36,12 @@ int MIDI_Init(int port) unsigned count = s_midi_in->getPortCount(); + if (listMidi) { + for (unsigned i = 0; i < count; i++) { + printf("Port[%u]: %s\n", i, s_midi_in->getPortName(i).c_str()); + } + } + if (count == 0) { printf("No midi input\n"); diff --git a/src/midi_win32.cpp b/src/midi_win32.cpp index c453aea1..8eba10b9 100644 --- a/src/midi_win32.cpp +++ b/src/midi_win32.cpp @@ -101,7 +101,7 @@ void CALLBACK MIDI_Callback( } } -int MIDI_Init(int port) +int MIDI_Init(int port, bool listMidi) { int num = midiInGetNumDevs(); @@ -111,6 +111,14 @@ int MIDI_Init(int port) return 0; } + if (listMidi) { + for (int i = 0; i < num; i++) { + MIDIINCAPSA caps; + midiInGetDevCapsA(i, &caps, sizeof(MIDIINCAPSA)); + printf("Port[%d]: %s\n", i, caps.szPname); + } + } + if (port < 0 || port >= num) { printf("Out of range midi port is requested. Defaulting to port 0\n");