Skip to content

Commit

Permalink
Merge pull request #546 from microsoft/pete-dev
Browse files Browse the repository at this point in the history
More naming updates/tweaks
  • Loading branch information
Psychlist1972 authored Feb 17, 2025
2 parents ee80acb + 5eadd89 commit a7d6e0c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 18 deletions.
4 changes: 4 additions & 0 deletions docs/developer-how-to/how-to-install-development-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ If you are a regular musician, we generally recommend you stick with what is ins

> Note: The steps in this file will eventually be replaced by developer-mode settings in the MIDI Settings app.
## Enable developer mode

In Windows Settings, you must enable developer mode. System > For Developers >

## Install PowerShell 7

The scripts require PowerShell 7 or newer. You can install PowerShell [following these instructions](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows).
Expand Down
25 changes: 21 additions & 4 deletions src/api/Inc/midi_naming.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ namespace WindowsMidiServicesInternal::Midi1PortNaming
// TEMPORARY code
name = transportSuppliedEndpointName;

if (name.empty())
{
name = blockName;
}


return truncateToWinMMLimit ? name.substr(0, MAXPNAMELEN - 1) : name;
}
Expand Down Expand Up @@ -172,15 +177,27 @@ namespace WindowsMidiServicesInternal::Midi1PortNaming
return name + L" " + suffix;
}

// this is the fallback

// this is the fallback. This needs better calculation to better support block name

std::wstring name;

if (blockName != parentDeviceName)
if (!transportSuppliedEndpointName.empty())
{
if (auto pos = blockName.find(transportSuppliedEndpointName); pos != std::wstring::npos)
{
name = internal::TrimmedWStringCopy(transportSuppliedEndpointName + L" " + internal::TrimmedWStringCopy(blockName.substr(pos + transportSuppliedEndpointName.length())));
}
else
{
name = internal::TrimmedWStringCopy(transportSuppliedEndpointName + L" " + blockName);
}
}
else if (!blockName.empty())
{
name = parentDeviceName + L" " + blockName;
name = blockName;
}
else
else if (!parentDeviceName.empty())
{
name = parentDeviceName;
}
Expand Down
21 changes: 16 additions & 5 deletions src/api/Service/Exe/MidiDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "Midi2KSAggregateTransport.h"
#include "Midi2KSTransport.h"
#include "Midi2LoopbackMidiTransport.h"
// naming
#include "midi_naming.h"



using namespace winrt::Windows::Devices::Enumeration;

Expand Down Expand Up @@ -2466,8 +2470,7 @@ CMidiDeviceManager::SyncMidi1Ports(
{
if (portInfo[flow][groupIndex].IsEnabled && !portInfo[flow][groupIndex].InterfaceId.empty())
{

bool useOldStyleWinMMPortNaming{ true }; // TODO: Get this from reg key and local property
bool useOldStyleWinMMPortNaming{ true }; // TODO: Get this from reg key and local property, not from being hard-coded here

if (interfaceProperties.empty())
{
Expand All @@ -2493,14 +2496,22 @@ CMidiDeviceManager::SyncMidi1Ports(
DEVPROP_TYPE_BYTE, (ULONG)(sizeof(BYTE)), (PVOID)(&(nativeDataFormat)) });
}

//if (transportId == winrt::guid(__uuidof(Midi2KSAggregateTransport)) ||
// transportId == winrt::guid(__uuidof(Midi2LoopbackMidiTransport)) ||
// (transportId == winrt::guid(__uuidof(Midi2KSTransport)) && WI_IsFlagSet(nativeDataFormat, MidiDataFormats::MidiDataFormats_ByteStream)))
// TEMP! This needs to be controlled by a property
if (transportId == winrt::guid(__uuidof(Midi2KSTransport)))
{
useOldStyleWinMMPortNaming = false;
}

// this tells us to use the GTB name, and only the GTB name, as the WinMM port name. It overrides other settings
prop = deviceInfo.Properties().Lookup(STRING_PKEY_MIDI_UseGroupTerminalBlocksForExactMidi1PortNames);
if (prop)
{
usePortInfoName = winrt::unbox_value<bool>(prop);
}
else
{
usePortInfoName = false;
}

prop = deviceInfo.Properties().Lookup(STRING_PKEY_MIDI_CustomEndpointName);
if (prop)
Expand Down
3 changes: 0 additions & 3 deletions src/api/Service/Exe/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ namespace json = ::winrt::Windows::Data::Json;

#include "WindowsMidiServices.h"

// naming
#include "midi_naming.h"

// RPC Calls

#include "MidiSrvRpc.h"
Expand Down
4 changes: 2 additions & 2 deletions src/api/Transport/KSTransport/Midi2.KSMidiEndpointManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ CMidi2KSMidiEndpointManager::OnDeviceAdded(
TraceLoggingWideString(device.Id().c_str(), "device id")
);

DEVPROP_BOOLEAN devPropTrue = DEVPROP_TRUE;
// DEVPROP_BOOLEAN devPropTrue = DEVPROP_TRUE;
DEVPROP_BOOLEAN devPropFalse = DEVPROP_FALSE;

wil::unique_handle hFilter;
Expand Down Expand Up @@ -621,7 +621,7 @@ CMidi2KSMidiEndpointManager::OnDeviceAdded(
else if (MidiPin->NativeDataFormat == KSDATAFORMAT_SUBTYPE_MIDI)
{
// for a native MIDI 1 device, the driver provides a MIDI 1 port name in the GTB
// but it's just the pin (iJack) name, so we still set this to false. Change in behavior.
// but it's just the pin (iJack) name, so we still set this to false. Change in behavior from earlier when this was true.
interfaceDevProperties.push_back({ { PKEY_MIDI_UseGroupTerminalBlocksForExactMidi1PortNames, DEVPROP_STORE_SYSTEM, nullptr },
DEVPROP_TYPE_BOOLEAN, static_cast<ULONG>(sizeof(devPropFalse)), (PVOID) & (devPropFalse) });
}
Expand Down
2 changes: 1 addition & 1 deletion src/app-sdk/midi1monitor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void LoadWinMMDevices()

for (uint16_t i = 0; i < inputDeviceCount; i++)
{
MIDIINCAPSW inputCaps{};
MIDIINCAPSW inputCaps{ 0 };

auto result = midiInGetDevCaps(i, &inputCaps, sizeof(inputCaps));

Expand Down
6 changes: 3 additions & 3 deletions src/oob-setup/api-package/WindowsMidiServices.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

</Component>

<!--

<Component Id="WinMMCompatRegistryEntries"
Bitness="always64"
Directory="SERVICE_INSTALLFOLDER"
Expand All @@ -94,7 +94,7 @@
<RegistryValue Type="integer" Name="MidisrvTransferComplete" Value="0" />
</RegistryKey>
</Component>
-->


<Component Id="ConfigurationRegistryEntries"
Bitness="always64"
Expand Down Expand Up @@ -166,7 +166,7 @@
<Feature Id="WindowsMIDIServices">
<ComponentRef Id="WindowsServiceTransports"/>
<ComponentRef Id="WindowsService"/>
<!--<ComponentRef Id="WinMMCompatRegistryEntries"/> -->
<ComponentRef Id="WinMMCompatRegistryEntries"/>
<!-- <ComponentRef Id="WinMMAPIRedirectDriver"/> -->

<ComponentRef Id="Permission.SharedAppDataFolder"/>
Expand Down

0 comments on commit a7d6e0c

Please sign in to comment.