mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Starting point for 1.3 beta:
Changes to multiple files to change version number Changes by JamesAC / spx to improve management of Windows Mssages, mostly to support working with the DexPot folks Addition of the Win7AudioPlugin plugin by reiswaffle. This includes plugin code and changes to the Rainmeter.sln project file.
This commit is contained in:
parent
c84f3bd35b
commit
34387ce2cf
@ -28,8 +28,8 @@ LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,2,0,438
|
||||
PRODUCTVERSION 1,2,0,438
|
||||
FILEVERSION 1,3,0,440
|
||||
PRODUCTVERSION 1,3,0,440
|
||||
FILEFLAGSMASK 0x17L
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@ -45,12 +45,12 @@ BEGIN
|
||||
BLOCK "040b04b0"
|
||||
BEGIN
|
||||
VALUE "FileDescription", "Rainmeter - A Customizable Resource Meter"
|
||||
VALUE "FileVersion", "1, 2, 0, 438"
|
||||
VALUE "FileVersion", "1, 3, 0, 440"
|
||||
VALUE "InternalName", "Rainmeter"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2010 - Rainy"
|
||||
VALUE "OriginalFilename", "Rainmeter.exe"
|
||||
VALUE "ProductName", "Rainmeter"
|
||||
VALUE "ProductVersion", "1, 2, 0, 438"
|
||||
VALUE "ProductVersion", "1, 3, 0, 440"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
@ -32,13 +32,13 @@
|
||||
#define MAKE_VER(major, minor1, minor2) major * 1000000 + minor1 * 1000 + minor2
|
||||
|
||||
#define APPNAME L"Rainmeter"
|
||||
#define APPVERSION L"1.2"
|
||||
#define APPVERSION L"1.3"
|
||||
#ifdef _WIN64
|
||||
#define APPBITS L"(64-bit)"
|
||||
#else
|
||||
#define APPBITS L"(32-bit)"
|
||||
#endif
|
||||
#define RAINMETER_VERSION MAKE_VER(1, 2, 0)
|
||||
#define RAINMETER_VERSION MAKE_VER(1, 3, 0)
|
||||
|
||||
enum PLATFORM
|
||||
{
|
||||
|
@ -615,6 +615,55 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_QUERY_RAINMETER:
|
||||
|
||||
if (Rainmeter && IsWindow((HWND)lParam))
|
||||
{
|
||||
if(wParam == RAINMETER_QUERY_ID_SKINS_PATH)
|
||||
{
|
||||
std::wstring path = Rainmeter->GetSkinPath();
|
||||
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
cds.dwData = RAINMETER_QUERY_ID_SKINS_PATH;
|
||||
cds.cbData = (path.size() + 1) * 2;
|
||||
cds.lpData = (LPVOID) path.c_str();
|
||||
|
||||
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
|
||||
{
|
||||
std::wstring path = Rainmeter->GetSettingsPath();
|
||||
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
cds.dwData = RAINMETER_QUERY_ID_SKINS_PATH;
|
||||
cds.cbData = (path.size() + 1) * 2;
|
||||
cds.lpData = (LPVOID) path.c_str();
|
||||
|
||||
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
else if(wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
|
||||
{
|
||||
std::wstring path = Rainmeter->GetPluginPath();
|
||||
|
||||
COPYDATASTRUCT cds;
|
||||
|
||||
cds.dwData = RAINMETER_QUERY_ID_SKINS_PATH;
|
||||
cds.cbData = (path.size() + 1) * 2;
|
||||
cds.lpData = (LPVOID) path.c_str();
|
||||
|
||||
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
case WM_TIMER:
|
||||
if (tray && tray->m_Measure)
|
||||
{
|
||||
|
@ -59,6 +59,13 @@
|
||||
#define ID_CONTEXT_SKINMENU_MONITOR_PRIMARY 4048
|
||||
#define ID_CONTEXT_SKINMENU_MONITOR_AUTOSELECT 4049
|
||||
|
||||
#define WM_QUERY_RAINMETER WM_APP + 1000
|
||||
|
||||
#define RAINMETER_QUERY_ID_SKINS_PATH 4101
|
||||
#define RAINMETER_QUERY_ID_SETTINGS_PATH 4102
|
||||
#define RAINMETER_QUERY_ID_PLUGINS_PATH 4103
|
||||
|
||||
|
||||
#define ID_CONFIG_EDIT 30000
|
||||
#define ID_CONFIG_FIRST 30001
|
||||
#define ID_CONFIG_LAST 33000
|
||||
|
638
Plugins/PluginWin7Audio/PluginWin7Audio.vcproj
Normal file
638
Plugins/PluginWin7Audio/PluginWin7Audio.vcproj
Normal file
@ -0,0 +1,638 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="PluginWin7Audio"
|
||||
ProjectGUID="{6D032D6B-7656-4743-B454-3388E2921EB0}"
|
||||
RootNamespace="PluginWin7Audio"
|
||||
TargetFrameworkVersion="0"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\x32/Debug"
|
||||
IntermediateDirectory=".\x32/Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginWindowMessage.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;PluginWin7Audio_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginWin7Audio.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1035"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Rainmeter.lib"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/Win7AudioPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="../../Library/x32/Debug"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\x32/Debug/Win7AudioPlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/Win7AudioPlugin.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="3"
|
||||
TypeLibraryName=".\x32/Debug/PluginWindowMessage.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginWindowMessage.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1035"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/WindowMessagePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\x32/Debug/WindowMessagePlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/WindowMessagePlugin.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release64|Win32"
|
||||
OutputDirectory=".\x64/Release"
|
||||
IntermediateDirectory=".\x64/Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginWindowMessage.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GL /EHsc /GA "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginWindowMessage.pch"
|
||||
AssemblerListingLocation=".\x64/Release/"
|
||||
ObjectFile=".\x64/Release/"
|
||||
ProgramDataBaseFileName=".\x64/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/machine:AMD64 /LTCG "
|
||||
AdditionalDependencies="bufferoverflowU.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/WindowMessagePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
ProgramDatabaseFile=".\x64/Release/WindowMessagePlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/WindowMessagePlugin.lib"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release64|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="3"
|
||||
TypeLibraryName=".\x64/Release/PluginWindowMessage.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GL /EHsc /GA "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginWin7Audio_EXPORTS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginWindowMessage.pch"
|
||||
AssemblerListingLocation=".\x64/Release/"
|
||||
ObjectFile=".\x64/Release/"
|
||||
ProgramDataBaseFileName=".\x64/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/machine:AMD64 /LTCG "
|
||||
AdditionalDependencies="odbc32.lib odbccp32.lib Rainmeter.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/Win7AudioPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\Library\x64\Release"
|
||||
GenerateDebugInformation="false"
|
||||
ProgramDatabaseFile=".\x64/Release/Win7AudioPlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/Win7AudioPlugin.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\x32/Release"
|
||||
IntermediateDirectory=".\x32/Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginWindowMessage.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginWin7Audio_EXPORTS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginWin7Audio.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="Rainmeter.lib"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/Win7AudioPlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
AdditionalLibraryDirectories="..\..\Library\x32\Release"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\x32/Release/Win7AudioPlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/Win7AudioPlugin.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="false"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="true"
|
||||
SuppressStartupBanner="true"
|
||||
TargetEnvironment="3"
|
||||
TypeLibraryName=".\x32/Release/PluginWindowMessage.tlb"
|
||||
HeaderFileName=""
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginWindowMessage.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="true"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/WindowMessagePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="true"
|
||||
ProgramDatabaseFile=".\x32/Release/WindowMessagePlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/WindowMessagePlugin.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath=".\PolicyConfig.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Win7AudioPlugin.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release64|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release64|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginWindowMessage_EXPORTS;$(NoInherit)"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
90
Plugins/PluginWin7Audio/PolicyConfig.h
Normal file
90
Plugins/PluginWin7Audio/PolicyConfig.h
Normal file
@ -0,0 +1,90 @@
|
||||
// ----------------------------------------------------------------------------
|
||||
// PolicyConfig.h
|
||||
// Undocumented COM-interface IPolicyConfig.
|
||||
// Use for set default audio render endpoint
|
||||
// @author EreTIk
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// class CPolicyConfigClient
|
||||
// {294935CE-F637-4E7C-A41B-AB255460B862}
|
||||
//
|
||||
// interface IPolicyConfig
|
||||
// {568b9108-44bf-40b4-9006-86afe5b5a620}
|
||||
//
|
||||
// Query interface:
|
||||
// CComPtr<IPolicyConfig> PolicyConfig;
|
||||
// PolicyConfig.CoCreateInstance(__uuidof(CPolicyConfigClient));
|
||||
// ----------------------------------------------------------------------------
|
||||
class DECLSPEC_UUID("294935CE-F637-4E7C-A41B-AB255460B862")
|
||||
CPolicyConfigClient;
|
||||
interface IPolicyConfig : public IUnknown
|
||||
{
|
||||
public:
|
||||
|
||||
virtual HRESULT GetMixFormat(
|
||||
PCWSTR,
|
||||
WAVEFORMATEX **
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetDeviceFormat(
|
||||
PCWSTR,
|
||||
INT,
|
||||
WAVEFORMATEX **
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetDeviceFormat(
|
||||
PCWSTR,
|
||||
WAVEFORMATEX *,
|
||||
WAVEFORMATEX *
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetProcessingPeriod(
|
||||
PCWSTR,
|
||||
INT,
|
||||
PINT64,
|
||||
PINT64
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetProcessingPeriod(
|
||||
PCWSTR,
|
||||
PINT64
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetShareMode(
|
||||
PCWSTR,
|
||||
struct DeviceShareMode *
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetShareMode(
|
||||
PCWSTR,
|
||||
struct DeviceShareMode *
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE GetPropertyValue(
|
||||
PCWSTR,
|
||||
const PROPERTYKEY &,
|
||||
PROPVARIANT *
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetPropertyValue(
|
||||
PCWSTR,
|
||||
const PROPERTYKEY &,
|
||||
PROPVARIANT *
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetDefaultEndpoint(
|
||||
__in PCWSTR wszDeviceId,
|
||||
__in ERole eRole
|
||||
);
|
||||
|
||||
virtual HRESULT STDMETHODCALLTYPE SetEndpointVisibility(
|
||||
PCWSTR,
|
||||
INT
|
||||
);
|
||||
};
|
||||
interface DECLSPEC_UUID("568b9108-44bf-40b4-9006-86afe5b5a620")
|
||||
IPolicyConfig;
|
514
Plugins/PluginWin7Audio/Win7AudioPlugin.cpp
Normal file
514
Plugins/PluginWin7Audio/Win7AudioPlugin.cpp
Normal file
@ -0,0 +1,514 @@
|
||||
/*
|
||||
Copyright (C) 2010 Stefan Hiller
|
||||
|
||||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <time.h>
|
||||
|
||||
#include <Mmdeviceapi.h>
|
||||
#include <Endpointvolume.h>
|
||||
#include <Functiondiscoverykeys_devpkey.h>
|
||||
#include "PolicyConfig.h"
|
||||
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
#define SAFE_RELEASE(punk) \
|
||||
if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) UINT Update(UINT id);
|
||||
//__declspec( dllexport ) double Update2(UINT id);
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
__declspec( dllexport ) void ExecuteBang(LPCTSTR args, UINT id);
|
||||
}
|
||||
|
||||
static BOOL com_initialized = FALSE;
|
||||
static BOOL instance_created = FALSE;
|
||||
static BOOL is_mute = FALSE;
|
||||
static float master_volume = 0.5f;
|
||||
|
||||
static enum VolumeAction
|
||||
{
|
||||
INIT,
|
||||
TOGGLE_MUTE,
|
||||
GET_VOLUME
|
||||
};
|
||||
|
||||
const static CLSID CLSID_MMDeviceEnumerator = __uuidof(MMDeviceEnumerator);
|
||||
const static IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
|
||||
const static IID IID_CPolicyConfigClient = __uuidof(CPolicyConfigClient);
|
||||
const static IID IID_IPolicyConfig = __uuidof(IPolicyConfig);
|
||||
const static IID IID_IAudioEndpointVolume = __uuidof(IAudioEndpointVolume);
|
||||
|
||||
static IMMDeviceEnumerator *pEnumerator = 0;
|
||||
static IMMDeviceCollection *pCollection = 0;
|
||||
|
||||
static std::vector<std::wstring> endpointIDs;
|
||||
|
||||
UINT CleanUp()
|
||||
{
|
||||
SAFE_RELEASE(pCollection);
|
||||
SAFE_RELEASE(pEnumerator);
|
||||
instance_created = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool InitCom()
|
||||
{
|
||||
if (!com_initialized) com_initialized = SUCCEEDED(CoInitialize(0));
|
||||
if (!com_initialized)
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: COM initialization failed!");
|
||||
return false;
|
||||
}
|
||||
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, 0, CLSCTX_ALL,
|
||||
IID_IMMDeviceEnumerator, (void**)&pEnumerator);
|
||||
instance_created = (S_OK == hr && pEnumerator);
|
||||
if (!instance_created)
|
||||
{
|
||||
std::wstring dbg_str = L"Win7AudioPlugin: COM instance creation failed!";
|
||||
if (hr == REGDB_E_CLASSNOTREG) dbg_str += L" REGDB_E_CLASSNOTREG";
|
||||
else if (hr == CLASS_E_NOAGGREGATION) dbg_str += L" CLASS_E_NOAGGREGATION";
|
||||
else if (hr == E_NOINTERFACE) dbg_str += L" E_NOINTERFACE";
|
||||
else
|
||||
{
|
||||
static WCHAR e_code[256];
|
||||
wsprintf(e_code, L" %li", (long)hr);
|
||||
|
||||
dbg_str += e_code;
|
||||
}
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", dbg_str.c_str());
|
||||
return CleanUp() != 0;
|
||||
}
|
||||
if (S_OK != pEnumerator->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pCollection) || !pCollection)
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Could not enumerate AudioEndpoints!");
|
||||
return CleanUp() != 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void UnInitCom()
|
||||
{
|
||||
CleanUp();
|
||||
if (com_initialized) CoUninitialize();
|
||||
com_initialized = FALSE;
|
||||
}
|
||||
|
||||
HRESULT RegisterDevice(PCWSTR devID)
|
||||
{
|
||||
HRESULT hr = S_FALSE;
|
||||
try
|
||||
{
|
||||
InitCom();
|
||||
IPolicyConfig *pPolicyConfig;
|
||||
|
||||
hr = CoCreateInstance(IID_CPolicyConfigClient, NULL,
|
||||
CLSCTX_ALL, IID_IPolicyConfig,
|
||||
(LPVOID *)&pPolicyConfig);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
hr = pPolicyConfig->SetDefaultEndpoint(devID, eConsole);
|
||||
if (hr == S_OK)
|
||||
{
|
||||
hr = pPolicyConfig->SetDefaultEndpoint(devID, eCommunications);
|
||||
}
|
||||
SAFE_RELEASE(pPolicyConfig);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: RegisterDevice - Exception!");
|
||||
hr = S_FALSE;
|
||||
}
|
||||
UnInitCom();
|
||||
return hr;
|
||||
}
|
||||
|
||||
std::wstring GetDefaultID()
|
||||
{
|
||||
std::wstring id_default = L"";
|
||||
IMMDevice * pEndpoint = 0;
|
||||
try
|
||||
{
|
||||
if (pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pEndpoint) == S_OK)
|
||||
{
|
||||
LPWSTR pwszID = 0;
|
||||
if (pEndpoint->GetId(&pwszID) == S_OK)
|
||||
{
|
||||
id_default = std::wstring(pwszID);
|
||||
}
|
||||
CoTaskMemFree(pwszID);
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: GetDefaultID - Exception!");
|
||||
id_default = L"Exception";
|
||||
}
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
return id_default;
|
||||
}
|
||||
|
||||
bool GetWin7AudioState(const VolumeAction action)
|
||||
{
|
||||
IMMDevice * pEndpoint = 0;
|
||||
IAudioEndpointVolume * pEndptVol = 0;
|
||||
bool success = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (InitCom())
|
||||
{
|
||||
if (pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pEndpoint) == S_OK)
|
||||
{
|
||||
if (pEndpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, 0, (void**)&pEndptVol) == S_OK)
|
||||
{
|
||||
if (pEndptVol->GetMute(&is_mute) == S_OK && action == TOGGLE_MUTE)
|
||||
{
|
||||
success = pEndptVol->SetMute(is_mute == TRUE ? FALSE : TRUE, 0) == S_OK;
|
||||
}
|
||||
// get current volume
|
||||
float vol = 0.0f;
|
||||
if (action != TOGGLE_MUTE && pEndptVol->GetMasterVolumeLevelScalar(&vol) == S_OK)
|
||||
{
|
||||
master_volume = vol;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Win7ToggleMute - Exception!");
|
||||
}
|
||||
SAFE_RELEASE(pEndptVol)
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
UnInitCom();
|
||||
return success;
|
||||
}
|
||||
|
||||
UINT GetIndex()
|
||||
{
|
||||
|
||||
std::wstring id_default = L"";
|
||||
if (InitCom()) id_default = GetDefaultID();
|
||||
UnInitCom();
|
||||
|
||||
for (UINT i = 0; i < endpointIDs.size(); i++)
|
||||
{
|
||||
if (endpointIDs[i].compare(id_default) == 0) return i + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool SetWin7Volume(UINT volume, int offset = 0)
|
||||
{
|
||||
IMMDevice * pEndpoint = 0;
|
||||
IAudioEndpointVolume * pEndptVol = 0;
|
||||
bool success = false;
|
||||
|
||||
try
|
||||
{
|
||||
if (InitCom())
|
||||
{
|
||||
if (pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pEndpoint) == S_OK)
|
||||
{
|
||||
if (pEndpoint->Activate(IID_IAudioEndpointVolume, CLSCTX_ALL, 0, (void**)&pEndptVol) == S_OK)
|
||||
{
|
||||
pEndptVol->SetMute(FALSE, 0);
|
||||
float vol = 0.0f;
|
||||
if (offset != 0) // change master volume + offset
|
||||
{
|
||||
float off = static_cast<float>(offset) / 100.0f;
|
||||
vol = master_volume + off;
|
||||
vol = (vol < 0.0f) ? 0.0f : ((vol > 1.0f) ? 1.0f : vol);
|
||||
}
|
||||
else
|
||||
{
|
||||
vol = (float)volume / 100.0f;
|
||||
}
|
||||
// set to volume
|
||||
success = pEndptVol->SetMasterVolumeLevelScalar(vol, 0) == S_OK;
|
||||
if (success) success = pEndptVol->GetMasterVolumeLevelScalar(&vol) == S_OK;
|
||||
if (success) master_volume = vol;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: SetWin7Volume - Exception!");
|
||||
}
|
||||
SAFE_RELEASE(pEndptVol)
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
UnInitCom();
|
||||
return success;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
The return value can also be 0, which means that Rainmeter will
|
||||
track the maximum value automatically. The parameters for this
|
||||
function are:
|
||||
|
||||
instance The instance of this DLL
|
||||
iniFile The name of the ini-file (usually Rainmeter.ini)
|
||||
section The name of the section in the ini-file for this measure
|
||||
id The identifier for the measure. This is used to identify the measures that use the same plugin.
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
if (!InitCom())
|
||||
{
|
||||
UnInitCom();
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT count;
|
||||
if (!pCollection || (S_OK != pCollection->GetCount(&count)))
|
||||
{
|
||||
UnInitCom();
|
||||
return 0;
|
||||
}
|
||||
endpointIDs = std::vector<std::wstring>(count);
|
||||
|
||||
for (UINT i = 0; i < count; i++)
|
||||
{
|
||||
IMMDevice *pEndpoint = 0;
|
||||
|
||||
// Get pointer to endpoint number i.
|
||||
if (pCollection->Item(i, &pEndpoint) == S_OK)
|
||||
{
|
||||
// Get the endpoint ID string.
|
||||
LPWSTR pwszID = 0;
|
||||
if (pEndpoint->GetId(&pwszID) == S_OK)
|
||||
{
|
||||
endpointIDs[i] = std::wstring(pwszID);
|
||||
}
|
||||
CoTaskMemFree(pwszID);
|
||||
}
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
}
|
||||
UnInitCom();
|
||||
GetWin7AudioState(INIT);
|
||||
return 100;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
GetWin7AudioState(GET_VOLUME);
|
||||
UINT volume = is_mute == TRUE ? 0 : static_cast<UINT>(master_volume * 100.0f + 0.5f); // rounding up at 0.5
|
||||
return volume > 100 ? 100 : volume;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
//double Update2(UINT id)
|
||||
//{
|
||||
// return 0;
|
||||
//}
|
||||
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
static WCHAR result[256];
|
||||
wsprintf(result, L"ERROR");
|
||||
try {
|
||||
if (!InitCom() || !pEnumerator)
|
||||
{
|
||||
UnInitCom();
|
||||
wsprintf(result, L"ERROR - Initializing COM");
|
||||
return result;
|
||||
}
|
||||
|
||||
IMMDevice * pEndpoint = 0;
|
||||
if (pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pEndpoint) == S_OK)
|
||||
{
|
||||
IPropertyStore * pProps = 0;
|
||||
if (pEndpoint->OpenPropertyStore(STGM_READ, &pProps) == S_OK)
|
||||
{
|
||||
PROPVARIANT varName;
|
||||
PropVariantInit(&varName);
|
||||
if (pProps->GetValue(PKEY_Device_DeviceDesc, &varName) == S_OK)
|
||||
{
|
||||
wcsncpy(result, varName.pwszVal, 255);
|
||||
PropVariantClear(&varName);
|
||||
SAFE_RELEASE(pProps)
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
UnInitCom();
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
PropVariantClear(&varName);
|
||||
SAFE_RELEASE(pProps)
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
wsprintf(result, L"ERROR - Getting Device Description");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SAFE_RELEASE(pProps)
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
wsprintf(result, L"ERROR - Getting Property");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SAFE_RELEASE(pEndpoint)
|
||||
wsprintf(result, L"ERROR - Getting Default Device");
|
||||
}
|
||||
} catch (...) {
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: GetString - Exception!");
|
||||
wsprintf(result, L"Exception");
|
||||
}
|
||||
UnInitCom();
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
If the measure needs to free resources before quitting.
|
||||
The plugin can export Finalize function, which is called
|
||||
when Rainmeter quits (or refreshes).
|
||||
*/
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
UnInitCom();
|
||||
}
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1005;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"reiswaffel.deviantart.com";
|
||||
}
|
||||
|
||||
void ExecuteBang(LPCTSTR args, UINT id)
|
||||
{
|
||||
std::wstring wholeBang = args;
|
||||
|
||||
size_t pos = wholeBang.find(' ');
|
||||
if (pos != -1)
|
||||
{
|
||||
std::wstring bang = wholeBang.substr(0, pos);
|
||||
wholeBang.erase(0, pos + 1);
|
||||
|
||||
if (_wcsicmp(bang.c_str(), L"SetOutputIndex") == 0)
|
||||
{
|
||||
// Parse parameters
|
||||
int index = 0;
|
||||
if (1 == swscanf_s(wholeBang.c_str(), L"%d", &index))
|
||||
{
|
||||
if (endpointIDs.size() <= 0)
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: No device found!");
|
||||
return;
|
||||
}
|
||||
// set to endpoint [index-1]
|
||||
if (index <= 0) index = 1;
|
||||
else if (index > (int)endpointIDs.size()) index = (int)endpointIDs.size();
|
||||
RegisterDevice(endpointIDs[index - 1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"SetVolume") == 0)
|
||||
{
|
||||
// Parse parameters
|
||||
int volume = 0;
|
||||
if (1 == swscanf_s(wholeBang.c_str(), L"%d", &volume))
|
||||
{
|
||||
if (!SetWin7Volume(volume < 0 ? 0 : (volume > 100 ? 100 : (UINT)volume)))
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Error setting volume!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
|
||||
}
|
||||
}
|
||||
else if (_wcsicmp(bang.c_str(), L"ChangeVolume") == 0)
|
||||
{
|
||||
// Parse parameters
|
||||
int offset = 0;
|
||||
if (1 == swscanf_s(wholeBang.c_str(), L"%d", &offset) && offset)
|
||||
{
|
||||
if (!SetWin7Volume(0, offset))
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Error changing volume!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Incorrect number of arguments for the bang!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Unknown bang!");
|
||||
}
|
||||
|
||||
}
|
||||
else if (_wcsicmp(wholeBang.c_str(), L"ToggleNext") == 0)
|
||||
{
|
||||
//LSLog(LOG_NOTICE, L"Rainmeter", L"Win7AudioPlugin: Next device.");
|
||||
const UINT i = GetIndex();
|
||||
if (i) RegisterDevice(endpointIDs[(i == endpointIDs.size()) ? 0 : i].c_str());
|
||||
else LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Update error - Try refresh!");
|
||||
}
|
||||
else if (_wcsicmp(wholeBang.c_str(), L"TogglePrevious") == 0)
|
||||
{
|
||||
const UINT i = GetIndex();
|
||||
if (i) RegisterDevice(endpointIDs[(i == 1) ? endpointIDs.size() - 1 : i - 2].c_str());
|
||||
else LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Update error - Try refresh!");
|
||||
}
|
||||
else if (_wcsicmp(wholeBang.c_str(), L"ToggleMute") == 0)
|
||||
{
|
||||
if (!GetWin7AudioState(TOGGLE_MUTE)) LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Mute Toggle Error!");
|
||||
}
|
||||
else
|
||||
{
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", L"Win7AudioPlugin: Unknown bang!");
|
||||
}
|
||||
}
|
@ -87,6 +87,11 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginWifiStatus", "Plugins
|
||||
{BE9D2400-7F1C-49D6-8498-5CE495491AD6} = {BE9D2400-7F1C-49D6-8498-5CE495491AD6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginWin7Audio", "Plugins\PluginWin7Audio\PluginWin7Audio.vcproj", "{6D032D6B-7656-4743-B454-3388E2921EB0}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{BE9D2400-7F1C-49D6-8498-5CE495491AD6} = {BE9D2400-7F1C-49D6-8498-5CE495491AD6}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
@ -279,6 +284,18 @@ Global
|
||||
{45A34285-56DD-4521-912B-3F884D36FA35}.Release64|Win32.Build.0 = Release64|Win32
|
||||
{45A34285-56DD-4521-912B-3F884D36FA35}.Release64|x64.ActiveCfg = Release64|x64
|
||||
{45A34285-56DD-4521-912B-3F884D36FA35}.Release64|x64.Build.0 = Release64|x64
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Debug|x64.Build.0 = Debug|x64
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release|Win32.Build.0 = Release|Win32
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release|x64.ActiveCfg = Release|x64
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release|x64.Build.0 = Release|x64
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release64|Win32.ActiveCfg = Release64|Win32
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release64|Win32.Build.0 = Release64|Win32
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release64|x64.ActiveCfg = Release64|x64
|
||||
{6D032D6B-7656-4743-B454-3388E2921EB0}.Release64|x64.Build.0 = Release64|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -1,2 +1,2 @@
|
||||
#pragma once
|
||||
const int revision_number = 438;
|
||||
const int revision_number = 440;
|
Loading…
Reference in New Issue
Block a user