mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
Add: [Win32] Select MIDI device by port name
This commit is contained in:
parent
28e11623bd
commit
a933afabfd
@ -370,6 +370,26 @@ const char *MusicDriver_Win32::Start(const char * const *parm)
|
||||
|
||||
int resolution = GetDriverParamInt(parm, "resolution", 5);
|
||||
int port = GetDriverParamInt(parm, "port", -1);
|
||||
const char *portname = GetDriverParam(parm, "portname");
|
||||
|
||||
/* Enumerate ports either for selecting port by name, or for debug output */
|
||||
if (portname != nullptr || _debug_driver_level > 0) {
|
||||
uint numports = midiOutGetNumDevs();
|
||||
DEBUG(driver, 1, "Win32-MIDI: Found %d output devices:", numports);
|
||||
for (uint tryport = 0; tryport < numports; tryport++) {
|
||||
MIDIOUTCAPS moc{};
|
||||
if (midiOutGetDevCaps(tryport, &moc, sizeof(moc)) == MMSYSERR_NOERROR) {
|
||||
char tryportname[128];
|
||||
convert_from_fs(moc.szPname, tryportname, lengthof(tryportname));
|
||||
|
||||
/* Compare requested and detected port name.
|
||||
* If multiple ports have the same name, this will select the last matching port, and the debug output will be confusing. */
|
||||
if (portname != nullptr && strncmp(tryportname, portname, lengthof(tryportname)) == 0) port = tryport;
|
||||
|
||||
DEBUG(driver, 1, "MIDI port %2d: %s%s", tryport, tryportname, (tryport == port) ? " [selected]" : "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UINT devid;
|
||||
if (port < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user