Skip to content

Commit

Permalink
Make MediaKey a measure
Browse files Browse the repository at this point in the history
  • Loading branch information
poiru committed Dec 26, 2015
1 parent 21d194a commit ed2d1ab
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 95 deletions.
9 changes: 5 additions & 4 deletions Build/Installer/Installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ SkipIniMove:
${EndIf}

Rename "$INSTDIR\Addons" "$INSTDIR\Defaults\Addons"
${Locate} "$INSTDIR\Plugins" "/L=F /M=*.dll /G=0" "MoveNonDefaultPlugins"
${Locate} "$INSTDIR\Plugins" "/L=F /M=*.dll /G=0" "HandlePlugins"
${EndIf}

!ifdef INCLUDEFILES
Expand Down Expand Up @@ -767,14 +767,15 @@ Function RenameToRainmeterIni
Push $0
FunctionEnd

Function MoveNonDefaultPlugins
${If} $R7 != "AdvancedCPU.dll"
Function HandlePlugins
${If} $R7 == "MediaKey.dll"
Delete "$R9"
${ElseIf} $R7 != "AdvancedCPU.dll"
${AndIf} $R7 != "CoreTemp.dll"
${AndIf} $R7 != "FileView.dll"
${AndIf} $R7 != "FolderInfo.dll"
${AndIf} $R7 != "InputText.dll"
${AndIf} $R7 != "iTunesPlugin.dll"
${AndIf} $R7 != "MediaKey.dll"
${AndIf} $R7 != "NowPlaying.dll"
${AndIf} $R7 != "PerfMon.dll"
${AndIf} $R7 != "PingPlugin.dll"
Expand Down
1 change: 1 addition & 0 deletions Library/Library.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<ClCompile Include="MeasureCPU.cpp" />
<ClCompile Include="MeasureDiskSpace.cpp" />
<ClCompile Include="MeasureLoop.cpp" />
<ClCompile Include="MeasureMediaKey.cpp" />
<ClCompile Include="MeasureMemory.cpp" />
<ClCompile Include="MeasureNet.cpp" />
<ClCompile Include="MeasureNetIn.cpp" />
Expand Down
6 changes: 6 additions & 0 deletions Library/Library.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
<ClCompile Include="MeasureLoop.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MeasureMediaKey.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MeasureMemory.cpp">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -215,6 +218,9 @@
<ClInclude Include="MeasureLoop.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MeasureMediaKey.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MeasureMemory.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand Down
5 changes: 5 additions & 0 deletions Library/Measure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "StdAfx.h"
#include "Measure.h"
#include "MeasureCPU.h"
#include "MeasureMediaKey.h"
#include "MeasureMemory.h"
#include "MeasurePhysicalMemory.h"
#include "MeasureVirtualMemory.h"
Expand Down Expand Up @@ -724,6 +725,10 @@ Measure* Measure::Create(const WCHAR* measure, Skin* skin, const WCHAR* name)
{
return new MeasureCPU(skin, name);
}
else if (_wcsicmp(L"MediaKey", measure) == 0)
{
return new MeasureMediaKey(skin, name);
}
else if (_wcsicmp(L"Memory", measure) == 0)
{
return new MeasureMemory(skin, name);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
/* Copyright (C) 2010 Rainmeter Project Developers
/* Copyright (C) 2015 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */

#include <windows.h>
#include "../../Library/Export.h" // Rainmeter's exported functions
#include "StdAfx.h"
#include "MeasureMediaKey.h"
#include "Logger.h"

MeasureMediaKey::MeasureMediaKey(Skin* skin, const WCHAR* name) : Measure(skin, name)
{
}

MeasureMediaKey::~MeasureMediaKey()
{
}

void SendKey(WORD key)
{
Expand All @@ -24,8 +33,9 @@ void SendKey(WORD key)
SendInput(1, &input, sizeof(INPUT));
}

PLUGIN_EXPORT void ExecuteBang(LPCTSTR args, UINT id)
void MeasureMediaKey::Command(const std::wstring& command)
{
const WCHAR* args = command.c_str();
if (_wcsicmp(args, L"NextTrack") == 0)
{
SendKey(VK_MEDIA_NEXT_TRACK);
Expand Down Expand Up @@ -56,6 +66,6 @@ PLUGIN_EXPORT void ExecuteBang(LPCTSTR args, UINT id)
}
else
{
RmLog(LOG_WARNING, L"MediaKey.dll: Unknown bang");
LogErrorF(this, L"Unknown command: %s", args);
}
}
29 changes: 29 additions & 0 deletions Library/MeasureMediaKey.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* Copyright (C) 2015 Rainmeter Project Developers
*
* This Source Code Form is subject to the terms of the GNU General Public
* License; either version 2 of the License, or (at your option) any later
* version. If a copy of the GPL was not distributed with this file, You can
* obtain one at <https://www.gnu.org/licenses/gpl-2.0.html>. */

#ifndef RM_LIBRARY_MEASUREMEDIAKEY_H_
#define RM_LIBRARY_MEASUREMEDIAKEY_H_

#include "Measure.h"

class MeasureMediaKey : public Measure
{
public:
MeasureMediaKey(Skin* skin, const WCHAR* name);
virtual ~MeasureMediaKey();

MeasureMediaKey(const MeasureMediaKey& other) = delete;
MeasureMediaKey& operator=(MeasureMediaKey other) = delete;

UINT GetTypeID() override { return TypeID<MeasureMediaKey>(); }

protected:
void UpdateValue() override {};
void Command(const std::wstring& command) override;
};

#endif
2 changes: 1 addition & 1 deletion Library/Skin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2225,7 +2225,7 @@ bool Skin::ReadSkin()
PathFindFileName(m_Parser.ReadString(section, L"Plugin", L"", false).c_str());
PathRemoveExtension(plugin);

const WCHAR* const kOldDefaultPlugins[] = { L"" };
const WCHAR* const kOldDefaultPlugins[] = { L"MediaKey" };
for (const auto* oldDefaultPlugin : kOldDefaultPlugins)
{
if (_wcsicmp(plugin, oldDefaultPlugin) == 0)
Expand Down
40 changes: 0 additions & 40 deletions Plugins/PluginMediaKey/PluginMediaKey.rc

This file was deleted.

35 changes: 0 additions & 35 deletions Plugins/PluginMediaKey/PluginMediaKey.vcxproj

This file was deleted.

10 changes: 0 additions & 10 deletions Rainmeter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PluginInputText", "Plugins\
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginiTunes", "Plugins\PluginiTunes\PluginiTunes.vcxproj", "{A2DD3CBE-B140-4892-A875-24107FA52518}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginMediaKey", "Plugins\PluginMediaKey\PluginMediaKey.vcxproj", "{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginNowPlaying", "Plugins\PluginNowPlaying\PluginNowPlaying.vcxproj", "{C7FECFCD-E6C6-4F95-BB9A-E1762B043969}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginPerfMon", "Plugins\PluginPerfMon\PluginPerfMon.vcxproj", "{5344B52B-BAC3-479C-B41D-D465B8BDA1AD}"
Expand Down Expand Up @@ -221,14 +219,6 @@ Global
{A2DD3CBE-B140-4892-A875-24107FA52518}.Release|Win32.Build.0 = Release|Win32
{A2DD3CBE-B140-4892-A875-24107FA52518}.Release|x64.ActiveCfg = Release|x64
{A2DD3CBE-B140-4892-A875-24107FA52518}.Release|x64.Build.0 = Release|x64
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|Win32.ActiveCfg = Debug|Win32
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|Win32.Build.0 = Debug|Win32
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|x64.ActiveCfg = Debug|x64
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Debug|x64.Build.0 = Debug|x64
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|Win32.ActiveCfg = Release|Win32
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|Win32.Build.0 = Release|Win32
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|x64.ActiveCfg = Release|x64
{EB48A04A-657E-41B8-B2F5-D47F8C30B2B4}.Release|x64.Build.0 = Release|x64
{C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|Win32.ActiveCfg = Debug|Win32
{C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|Win32.Build.0 = Debug|Win32
{C7FECFCD-E6C6-4F95-BB9A-E1762B043969}.Debug|x64.ActiveCfg = Debug|x64
Expand Down

0 comments on commit ed2d1ab

Please sign in to comment.