From d93ef7f826a065fd2c320d7de7fee9a07eaf342e Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Wed, 10 May 2017 18:35:36 +0000 Subject: [PATCH] Add support for selecting midi devices by name to win32 midi. Rewritten patch of rcblanke. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4017 --- src/gui/midi_win32.h | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gui/midi_win32.h b/src/gui/midi_win32.h index 670027ee..b1163838 100644 --- a/src/gui/midi_win32.h +++ b/src/gui/midi_win32.h @@ -41,9 +41,24 @@ public: if(conf && *conf) { std::string strconf(conf); std::istringstream configmidi(strconf); - unsigned int nummer = midiOutGetNumDevs(); + unsigned int total = midiOutGetNumDevs(); + unsigned int nummer = total; configmidi >> nummer; - if(nummer < midiOutGetNumDevs()){ + if (configmidi.fail() && total) { + lowcase(strconf); + for(unsigned int i = 0; i< total;i++) { + MIDIOUTCAPS mididev; + midiOutGetDevCaps(i, &mididev, sizeof(MIDIOUTCAPS)); + std::string devname(mididev.szPname); + lowcase(devname); + if (devname.find(strconf) != std::string::npos) { + nummer = i; + break; + } + } + } + + if (nummer < total) { MIDIOUTCAPS mididev; midiOutGetDevCaps(nummer, &mididev, sizeof(MIDIOUTCAPS)); LOG_MSG("MIDI: win32 selected %s",mididev.szPname);