2011-01-26 13:57:57 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2011 Arthur Liberman
|
|
|
|
|
|
|
|
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
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-01-26 13:57:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <windows.h>
|
2012-01-08 17:35:29 +00:00
|
|
|
#include <wchar.h>
|
2011-01-26 13:57:57 +00:00
|
|
|
#include "CoreTempProxy.h"
|
2011-02-03 18:09:24 +00:00
|
|
|
#include "../../Library/Export.h" // Rainmeter's exported functions
|
|
|
|
#include "../../Library/DisableThreadLibraryCalls.h" // contains DllMain entry point
|
2011-01-30 09:31:41 +00:00
|
|
|
|
2011-01-26 13:57:57 +00:00
|
|
|
typedef enum eMeasureType
|
|
|
|
{
|
|
|
|
MeasureTemperature,
|
|
|
|
MeasureMaxTemperature,
|
|
|
|
MeasureTjMax,
|
|
|
|
MeasureLoad,
|
|
|
|
MeasureVid,
|
|
|
|
MeasureCpuSpeed,
|
|
|
|
MeasureBusSpeed,
|
|
|
|
MeasureBusMultiplier,
|
|
|
|
MeasureCpuName
|
|
|
|
};
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
struct MeasureData
|
|
|
|
{
|
|
|
|
eMeasureType type;
|
|
|
|
int index;
|
|
|
|
|
|
|
|
MeasureData() : type(), index() {}
|
|
|
|
};
|
|
|
|
|
2011-01-26 13:57:57 +00:00
|
|
|
CoreTempProxy proxy;
|
|
|
|
|
|
|
|
eMeasureType convertStringToMeasureType(LPCWSTR i_String);
|
|
|
|
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2);
|
|
|
|
float getHighestTemp();
|
|
|
|
|
2012-02-02 07:39:14 +00:00
|
|
|
PLUGIN_EXPORT void Initialize(void** data, void* rm)
|
2011-01-26 13:57:57 +00:00
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
MeasureData* measure = new MeasureData;
|
|
|
|
*data = measure;
|
|
|
|
}
|
2011-01-26 13:57:57 +00:00
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
|
|
|
|
{
|
|
|
|
MeasureData* measure = (MeasureData*)data;
|
|
|
|
|
|
|
|
LPCWSTR value = RmReadString(rm, L"CoreTempType", L"Temperature");
|
2012-02-09 04:14:41 +00:00
|
|
|
measure->type = convertStringToMeasureType(value);
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2012-02-09 04:14:41 +00:00
|
|
|
if (measure->type == MeasureTemperature || measure->type == MeasureTjMax || measure->type == MeasureLoad)
|
2012-01-08 17:35:29 +00:00
|
|
|
{
|
|
|
|
measure->index = RmReadInt(rm, L"CoreTempIndex", 0);
|
|
|
|
}
|
2011-01-26 13:57:57 +00:00
|
|
|
}
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
PLUGIN_EXPORT double Update(void* data)
|
2011-01-26 13:57:57 +00:00
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
MeasureData* measure = (MeasureData*)data;
|
2011-01-26 13:57:57 +00:00
|
|
|
double result = 0;
|
|
|
|
|
|
|
|
if (proxy.GetData())
|
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
switch (measure->type)
|
2011-11-08 05:42:54 +00:00
|
|
|
{
|
|
|
|
case MeasureTemperature:
|
2012-01-08 17:35:29 +00:00
|
|
|
result = proxy.GetTemp(measure->index);
|
2011-11-08 05:42:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureMaxTemperature:
|
|
|
|
result = getHighestTemp();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureTjMax:
|
2012-01-08 17:35:29 +00:00
|
|
|
result = proxy.GetTjMax(measure->index);
|
2011-11-08 05:42:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureLoad:
|
2012-01-08 17:35:29 +00:00
|
|
|
result = proxy.GetCoreLoad(measure->index);
|
2011-11-08 05:42:54 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureVid:
|
|
|
|
result = proxy.GetVID();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureCpuSpeed:
|
|
|
|
result = proxy.GetCPUSpeed();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureBusSpeed:
|
|
|
|
result = proxy.GetFSBSpeed();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureBusMultiplier:
|
|
|
|
result = proxy.GetMultiplier();
|
|
|
|
break;
|
|
|
|
}
|
2011-01-26 13:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
PLUGIN_EXPORT LPCWSTR GetString(void* data)
|
2011-01-26 13:57:57 +00:00
|
|
|
{
|
2012-01-08 17:35:29 +00:00
|
|
|
MeasureData* measure = (MeasureData*)data;
|
|
|
|
static WCHAR buffer[128];
|
2011-11-08 05:42:54 +00:00
|
|
|
|
2012-01-08 17:35:29 +00:00
|
|
|
switch (measure->type)
|
2011-11-08 05:42:54 +00:00
|
|
|
{
|
|
|
|
case MeasureVid:
|
|
|
|
_snwprintf_s(buffer, _TRUNCATE, L"%.4f", proxy.GetVID());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MeasureCpuName:
|
|
|
|
_snwprintf_s(buffer, _TRUNCATE, L"%S", proxy.GetCPUName());
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffer;
|
2011-01-26 13:57:57 +00:00
|
|
|
}
|
|
|
|
|
2012-02-04 08:52:56 +00:00
|
|
|
PLUGIN_EXPORT void Finalize(void* data)
|
|
|
|
{
|
|
|
|
MeasureData* measure = (MeasureData*)data;
|
|
|
|
delete measure;
|
|
|
|
}
|
|
|
|
|
2011-01-26 13:57:57 +00:00
|
|
|
bool areStringsEqual(LPCWSTR i_String1, LPCWSTR i_Strting2)
|
|
|
|
{
|
|
|
|
return _wcsicmp(i_String1, i_Strting2) == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
eMeasureType convertStringToMeasureType(LPCWSTR i_String)
|
|
|
|
{
|
|
|
|
eMeasureType result;
|
|
|
|
|
|
|
|
if (areStringsEqual(i_String, L"Temperature"))
|
|
|
|
{
|
|
|
|
result = MeasureTemperature;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"MaxTemperature"))
|
|
|
|
{
|
|
|
|
result = MeasureMaxTemperature;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"TjMax"))
|
|
|
|
{
|
|
|
|
result = MeasureTjMax;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"Load"))
|
|
|
|
{
|
|
|
|
result = MeasureLoad;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"Vid"))
|
|
|
|
{
|
|
|
|
result = MeasureVid;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"CpuSpeed"))
|
|
|
|
{
|
|
|
|
result = MeasureCpuSpeed;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"BusSpeed"))
|
|
|
|
{
|
|
|
|
result = MeasureBusSpeed;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"BusMultiplier"))
|
|
|
|
{
|
|
|
|
result = MeasureBusMultiplier;
|
|
|
|
}
|
|
|
|
else if (areStringsEqual(i_String, L"CpuName"))
|
|
|
|
{
|
|
|
|
result = MeasureCpuName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = MeasureTemperature;
|
2012-01-08 17:35:29 +00:00
|
|
|
RmLog(LOG_WARNING, L"CoreTemp.dll: Invalid CoreTempType");
|
2011-01-26 13:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
float getHighestTemp()
|
|
|
|
{
|
|
|
|
float temp = -255;
|
|
|
|
UINT coreCount = proxy.GetCoreCount();
|
|
|
|
|
|
|
|
for (UINT i = 0; i < coreCount; ++i)
|
|
|
|
{
|
|
|
|
if (temp < proxy.GetTemp(i))
|
|
|
|
{
|
|
|
|
temp = proxy.GetTemp(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
}
|