Added: Support for having individual configurations for multiple devices. This is possible via the new command "Device" that allows to select the output devices to which the following commands (filters etc.) should be applied. The Configurator got a new button to generate a Device command for the selected connection(s).
This commit is contained in:
1 parent
7758366b58
commit
ef61580c19
17 files changed
+290
-92
No files matched your search
@@ -20,6 +20,7 @@
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#include <commctrl.h>
|
||||
#include "../StringHelper.h"
|
||||
#include "../RegistryHelper.h"
|
||||
#include "Configurator.h"
|
||||
|
||||
@@ -41,11 +42,15 @@ void Configurator::onInitDialog(HWND hDlg)
|
||||
okButton = GetDlgItem(hDlg, IDOK);
|
||||
cancelButton = GetDlgItem(hDlg, IDCANCEL);
|
||||
requestLabel = GetDlgItem(hDlg, IDC_REQUEST);
|
||||
copyDeviceCommandButton = GetDlgItem(hDlg, IDC_COPY_DEVICE_COMMAND);
|
||||
|
||||
wchar_t stringBuf[255];
|
||||
LoadStringW(hInstance, IDS_REQUEST, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
SetWindowTextW(requestLabel, stringBuf);
|
||||
|
||||
LoadStringW(hInstance, IDS_COPY_DEVICE_COMMAND, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
SetWindowTextW(copyDeviceCommandButton, stringBuf);
|
||||
|
||||
ListView_SetExtendedListViewStyle(deviceList, ListView_GetExtendedListViewStyle(deviceList) | LVS_EX_CHECKBOXES);
|
||||
LVCOLUMN column;
|
||||
column.pszText = stringBuf;
|
||||
@@ -139,6 +144,8 @@ void Configurator::onLvnItemChanged(unsigned sourceId, LPNMLISTVIEW info)
|
||||
}
|
||||
|
||||
EnableWindow(okButton, changed);
|
||||
|
||||
EnableWindow(copyDeviceCommandButton, ListView_GetSelectedCount(deviceList) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,8 +175,45 @@ void Configurator::onButtonClicked(unsigned sourceId)
|
||||
MessageBoxW(hDlg, e.getMessage().c_str(), L"Error while accessing the registry", MB_ICONERROR | MB_OK);
|
||||
}
|
||||
}
|
||||
else if(sourceId = IDC_COPY_DEVICE_COMMAND)
|
||||
{
|
||||
wstring command = L"Device: ";
|
||||
|
||||
if(cmdLine == L"/i")
|
||||
bool first = true;
|
||||
for(int i = 0; i < ListView_GetItemCount(deviceList); i++)
|
||||
{
|
||||
LVITEM item;
|
||||
item.iItem = i;
|
||||
item.iSubItem = 0;
|
||||
item.mask = LVIF_PARAM | LVIF_STATE;
|
||||
item.stateMask = LVIS_SELECTED;
|
||||
ListView_GetItem(deviceList, &item);
|
||||
|
||||
if(item.state & LVIS_SELECTED)
|
||||
{
|
||||
if(first)
|
||||
first = false;
|
||||
else
|
||||
command += L"; ";
|
||||
|
||||
DeviceAPOInfo info = apoInfos[item.lParam];
|
||||
command += StringHelper::replaceCharacters(info.deviceName + L" " + info.connectionName + L" " + info.deviceGuid, L";", L' ');
|
||||
}
|
||||
}
|
||||
|
||||
OpenClipboard(hDlg);
|
||||
|
||||
HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, (command.length() + 1) * sizeof(wchar_t));
|
||||
wchar_t* data = (wchar_t*)GlobalLock(hData);
|
||||
memcpy(data, command.c_str(), (command.length() + 1) * sizeof(wchar_t));
|
||||
GlobalUnlock(data);
|
||||
|
||||
SetClipboardData(CF_UNICODETEXT, hData);
|
||||
|
||||
CloseClipboard();
|
||||
}
|
||||
|
||||
if((sourceId == IDOK || sourceId == IDCANCEL) && cmdLine == L"/i")
|
||||
{
|
||||
wchar_t stringBuf[255];
|
||||
LoadStringW(hInstance, IDS_AFTERINSTALL, stringBuf, sizeof(stringBuf)/sizeof(wchar_t));
|
||||
@@ -229,10 +273,10 @@ INT_PTR CALLBACK dlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
configurator->onButtonClicked(LOWORD(wParam));
|
||||
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
configurator->onButtonClicked(LOWORD(wParam));
|
||||
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "resource.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "DeviceAPOInfo.h"
|
||||
#include "../DeviceAPOInfo.h"
|
||||
|
||||
class Configurator
|
||||
{
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
HWND deviceList;
|
||||
HWND okButton;
|
||||
HWND cancelButton;
|
||||
HWND copyDeviceCommandButton;
|
||||
HWND requestLabel;
|
||||
std::wstring cmdLine;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -19,15 +19,17 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\DeviceAPOInfo.h" />
|
||||
<ClInclude Include="..\RegistryHelper.h" />
|
||||
<ClInclude Include="..\StringHelper.h" />
|
||||
<ClInclude Include="Configurator.h" />
|
||||
<ClInclude Include="DeviceAPOInfo.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\DeviceAPOInfo.cpp" />
|
||||
<ClCompile Include="..\RegistryHelper.cpp" />
|
||||
<ClCompile Include="..\StringHelper.cpp" />
|
||||
<ClCompile Include="Configurator.cpp" />
|
||||
<ClCompile Include="DeviceAPOInfo.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="Configurator.rc" />
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
This file is part of EqualizerAPO, a system-wide equalizer.
|
||||
Copyright (C) 2012 Jonas Thedering
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "DeviceAPOInfo.h"
|
||||
|
||||
#include "../EqualizerAPO.h"
|
||||
#include "../ParametricEQ.h"
|
||||
#include "../RegistryHelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
#define renderKeyPath L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\MMDevices\\Audio\\Render"
|
||||
static const wchar_t* connectionValueName = L"{a45c254e-df1c-4efd-8020-67d146a850e0},2";
|
||||
static const wchar_t* deviceValueName = L"{b3f8fa53-0004-438e-9003-51a46e139bfc},6";
|
||||
static const wchar_t* apoGuidValueName = L"{d04e05a6-594b-4fb6-a80d-01af5eed7d1d},1";
|
||||
|
||||
vector<DeviceAPOInfo> DeviceAPOInfo::loadAllInfos()
|
||||
{
|
||||
vector<DeviceAPOInfo> result;
|
||||
vector<wstring> deviceGuidStrings = RegistryHelper::enumSubKeys(renderKeyPath);
|
||||
for(vector<wstring>::iterator it = deviceGuidStrings.begin(); it != deviceGuidStrings.end(); it++)
|
||||
{
|
||||
wstring deviceGuidString = *it;
|
||||
|
||||
if(!RegistryHelper::keyExists(renderKeyPath L"\\" + deviceGuidString + L"\\FxProperties"))
|
||||
continue;
|
||||
|
||||
wstring connectionName = RegistryHelper::readValue(renderKeyPath L"\\" + deviceGuidString + L"\\Properties", connectionValueName);
|
||||
wstring deviceName = RegistryHelper::readValue(renderKeyPath L"\\" + deviceGuidString + L"\\Properties", deviceValueName);
|
||||
wstring apoGuidString = RegistryHelper::readValue(renderKeyPath L"\\" + deviceGuidString + L"\\FxProperties", apoGuidValueName);
|
||||
|
||||
GUID apoGuid;
|
||||
if(!SUCCEEDED(CLSIDFromString(apoGuidString.c_str(), &apoGuid)))
|
||||
continue;
|
||||
|
||||
bool installed = false;
|
||||
if(apoGuid == __uuidof(EqualizerAPO))
|
||||
{
|
||||
installed = true;
|
||||
}
|
||||
|
||||
DeviceAPOInfo info = {deviceName, connectionName, deviceGuidString, apoGuidString, installed};
|
||||
result.push_back(info);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void DeviceAPOInfo::install()
|
||||
{
|
||||
RegistryHelper::createKey(APP_REGPATH L"\\Child APOs");
|
||||
|
||||
RegistryHelper::writeValue(APP_REGPATH L"\\Child APOs", deviceGuid, originalApoGuid);
|
||||
|
||||
RegistryHelper::saveToFile(renderKeyPath L"\\" + deviceGuid + L"\\FxProperties", apoGuidValueName,
|
||||
L"backup_" + RegistryHelper::replaceIllegalCharacters(deviceName) + L"_" + RegistryHelper::replaceIllegalCharacters(connectionName) + L".reg");
|
||||
|
||||
RegistryHelper::writeValue(renderKeyPath L"\\" + deviceGuid + L"\\FxProperties", apoGuidValueName, RegistryHelper::getGuidString(__uuidof(EqualizerAPO)));
|
||||
}
|
||||
|
||||
void DeviceAPOInfo::uninstall()
|
||||
{
|
||||
wstring originalChildApoGuid = RegistryHelper::readValue(APP_REGPATH L"\\Child APOs", deviceGuid);
|
||||
|
||||
RegistryHelper::writeValue(renderKeyPath L"\\" + deviceGuid + L"\\FxProperties", apoGuidValueName, originalChildApoGuid);
|
||||
|
||||
RegistryHelper::deleteValue(APP_REGPATH L"\\Child APOs", deviceGuid);
|
||||
|
||||
if(RegistryHelper::valueCount(APP_REGPATH L"\\Child APOs") == 0)
|
||||
RegistryHelper::deleteKey(APP_REGPATH L"\\Child APOs");
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
This file is part of EqualizerAPO, a system-wide equalizer.
|
||||
Copyright (C) 2012 Jonas Thedering
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class DeviceAPOInfo
|
||||
{
|
||||
public:
|
||||
static std::vector<DeviceAPOInfo> loadAllInfos();
|
||||
void install();
|
||||
void uninstall();
|
||||
|
||||
std::wstring deviceName;
|
||||
std::wstring connectionName;
|
||||
std::wstring deviceGuid;
|
||||
std::wstring originalApoGuid;
|
||||
bool isInstalled;
|
||||
};
|
||||
Binary file not shown.
Reference in new issue
Block a user