diff --git a/src/Config/MainConfigFile.cpp b/src/Config/MainConfigFile.cpp index ea6258b..43b9dc8 100644 --- a/src/Config/MainConfigFile.cpp +++ b/src/Config/MainConfigFile.cpp @@ -20,6 +20,10 @@ #define CONF_DEVICES L"Devices" #define CONF_DEVICES_ENABLED L"EnabledDevices" +#define CONF_DEVICES_LIGHTFX L"LightFX" +#define CONF_DEVICES_LIGHTFX_ALIENWAREDLL L"AlienwareDllName" +#define CONF_DEVICES_LIGHTFX_ALIENWAREBACKUPDLL L"AlienwareBackupDllName" + #define CONF_DEVICES_LOGITECH L"Logitech" #define CONF_DEVICES_LOGITECH_COLORRANGE L"ColorRange" #define CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN L"LightFXMin" @@ -51,20 +55,24 @@ namespace lightfx { } LFXE_API void MainConfigFile::LoadDefaults() { + this->AutoUpdatesEnabled = true; this->MinimumLogLevel = LogLevel::Info; this->TrayIconEnabled = true; this->TrayIconUseGameIcon = false; - this->LogitechColorRangeOutMin = 0; - this->LogitechColorRangeOutMax = 255; - this->LogitechColorRangeInMin = 0; - this->LogitechColorRangeInMax = 100; + this->AlienwareDllName = L"LightFX.dll"; + this->AlienwareBackupDllName = L"LightFX_.dll"; this->LightpackHost = L"127.0.0.1"; this->LightpackPort = L"3636"; this->LightpackKey = L""; + this->LogitechColorRangeOutMin = 0; + this->LogitechColorRangeOutMax = 255; + this->LogitechColorRangeInMin = 0; + this->LogitechColorRangeInMax = 100; + this->GuildWars2TeamColorEnabled = true; this->GuildWars2TeamColorAnimation = L"Pulse"; } @@ -128,18 +136,13 @@ namespace lightfx { } obj.AddMember(CONF_DEVICES_ENABLED, objEnabledDevices, allocator); - // Logitech - WValue objLogitech(kObjectType); + // LightFX + WValue objLightfx(kObjectType); - // Logitech color range - WValue objLogitechColorRange(kObjectType); - objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN, this->LogitechColorRangeOutMin, allocator); - objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX, this->LogitechColorRangeOutMax, allocator); - objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMIN, this->LogitechColorRangeInMin, allocator); - objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMAX, this->LogitechColorRangeInMax, allocator); - objLogitech.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE, objLogitechColorRange, allocator); - - obj.AddMember(CONF_DEVICES_LOGITECH, objLogitech, allocator); + // LightFX Alienware DLL name + objLightfx.AddMember(CONF_DEVICES_LIGHTFX_ALIENWAREDLL, this->MakeJsonWString(this->AlienwareDllName, allocator), allocator); + objLightfx.AddMember(CONF_DEVICES_LIGHTFX_ALIENWAREBACKUPDLL, this->MakeJsonWString(this->AlienwareBackupDllName, allocator), allocator); + obj.AddMember(CONF_DEVICES_LIGHTFX, objLightfx, allocator); // Lightpack WValue objLightpack(kObjectType); @@ -153,6 +156,19 @@ namespace lightfx { obj.AddMember(CONF_DEVICES_LIGHTPACK, objLightpack, allocator); + // Logitech + WValue objLogitech(kObjectType); + + // Logitech color range + WValue objLogitechColorRange(kObjectType); + objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN, this->LogitechColorRangeOutMin, allocator); + objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX, this->LogitechColorRangeOutMax, allocator); + objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMIN, this->LogitechColorRangeInMin, allocator); + objLogitechColorRange.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMAX, this->LogitechColorRangeInMax, allocator); + objLogitech.AddMember(CONF_DEVICES_LOGITECH_COLORRANGE, objLogitechColorRange, allocator); + + obj.AddMember(CONF_DEVICES_LOGITECH, objLogitech, allocator); + return obj; } @@ -228,24 +244,14 @@ namespace lightfx { } } - // Logitech - if (objDevices.HasMember(CONF_DEVICES_LOGITECH) && objDevices[CONF_DEVICES_LOGITECH].IsObject()) { - const WValue& objLogitech = objDevices[CONF_DEVICES_LOGITECH]; - // Logitech color range - if (objLogitech.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE) && objLogitech[CONF_DEVICES_LOGITECH_COLORRANGE].IsObject()) { - const WValue& colorRange = objLogitech[CONF_DEVICES_LOGITECH_COLORRANGE]; - if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN].IsInt()) { - this->LogitechColorRangeOutMin = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN].GetInt(); - } - if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX].IsInt()) { - this->LogitechColorRangeOutMax = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX].GetInt(); - } - if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMIN) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMIN].IsInt()) { - this->LogitechColorRangeInMin = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMIN].GetInt(); - } - if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMAX) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMAX].IsInt()) { - this->LogitechColorRangeInMax = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMAX].GetInt(); - } + // LightFX + if (objDevices.HasMember(CONF_DEVICES_LIGHTFX) && objDevices[CONF_DEVICES_LIGHTFX].IsObject()) { + const WValue& objLightfx = objDevices[CONF_DEVICES_LIGHTFX]; + if (objLightfx.HasMember(CONF_DEVICES_LIGHTFX_ALIENWAREDLL) && objLightfx[CONF_DEVICES_LIGHTFX_ALIENWAREDLL].IsString()) { + this->AlienwareDllName = objLightfx[CONF_DEVICES_LIGHTFX_ALIENWAREDLL].GetString(); + } + if (objLightfx.HasMember(CONF_DEVICES_LIGHTFX_ALIENWAREBACKUPDLL) && objLightfx[CONF_DEVICES_LIGHTFX_ALIENWAREBACKUPDLL].IsString()) { + this->AlienwareBackupDllName = objLightfx[CONF_DEVICES_LIGHTFX_ALIENWAREBACKUPDLL].GetString(); } } @@ -266,6 +272,27 @@ namespace lightfx { } } } + + // Logitech + if (objDevices.HasMember(CONF_DEVICES_LOGITECH) && objDevices[CONF_DEVICES_LOGITECH].IsObject()) { + const WValue& objLogitech = objDevices[CONF_DEVICES_LOGITECH]; + // Logitech color range + if (objLogitech.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE) && objLogitech[CONF_DEVICES_LOGITECH_COLORRANGE].IsObject()) { + const WValue& colorRange = objLogitech[CONF_DEVICES_LOGITECH_COLORRANGE]; + if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN].IsInt()) { + this->LogitechColorRangeOutMin = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMIN].GetInt(); + } + if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX].IsInt()) { + this->LogitechColorRangeOutMax = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_OUTMAX].GetInt(); + } + if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMIN) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMIN].IsInt()) { + this->LogitechColorRangeInMin = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMIN].GetInt(); + } + if (colorRange.HasMember(CONF_DEVICES_LOGITECH_COLORRANGE_INMAX) && colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMAX].IsInt()) { + this->LogitechColorRangeInMax = colorRange[CONF_DEVICES_LOGITECH_COLORRANGE_INMAX].GetInt(); + } + } + } } } diff --git a/src/Config/MainConfigFile.h b/src/Config/MainConfigFile.h index ac50bf0..44f40c5 100644 --- a/src/Config/MainConfigFile.h +++ b/src/Config/MainConfigFile.h @@ -27,20 +27,23 @@ namespace lightfx { bool AutoUpdatesEnabled = true; managers::LogLevel MinimumLogLevel = managers::LogLevel::Info; - std::map EnabledDevices = {}; - bool TrayIconEnabled = true; bool TrayIconUseGameIcon = false; - int LogitechColorRangeOutMin = 0; - int LogitechColorRangeOutMax = 255; - int LogitechColorRangeInMin = 0; - int LogitechColorRangeInMax = 100; + std::map EnabledDevices = {}; + + std::wstring AlienwareDllName = L"LightFX.dll"; + std::wstring AlienwareBackupDllName = L"LightFX_.dll"; std::wstring LightpackHost = L"127.0.0.1"; std::wstring LightpackPort = L"3636"; std::wstring LightpackKey = L""; + int LogitechColorRangeOutMin = 0; + int LogitechColorRangeOutMax = 255; + int LogitechColorRangeInMin = 0; + int LogitechColorRangeInMax = 100; + bool GuildWars2TeamColorEnabled = true; std::wstring GuildWars2TeamColorAnimation = L"Pulse"; diff --git a/src/Devices/LightFX2.cpp b/src/Devices/LightFX2.cpp index 9a7087b..dd8a4e8 100644 --- a/src/Devices/LightFX2.cpp +++ b/src/Devices/LightFX2.cpp @@ -38,14 +38,14 @@ LFX2GETVERSION LightFX_GetVersion; HINSTANCE hInstanceLightFX = NULL; -LFXE_API bool InitializeLightFX() { +LFXE_API bool InitializeLightFX(std::wstring name, std::wstring backupName) { if (hInstanceLightFX) { return true; } - // Check if there's a local LightFX_.dll - if (FileExists(L"LightFX_.dll")) { - hInstanceLightFX = LoadLibraryW(L"LightFX_.dll"); + // Check if there's a local dll + if (FileExists(backupName)) { + hInstanceLightFX = LoadLibraryW(backupName.c_str()); // Check if we are accidentally loading ourselves if (GetProcAddress(hInstanceLightFX, "LFXE_GetVersion")) { @@ -56,7 +56,7 @@ LFXE_API bool InitializeLightFX() { // Try to load the global one if (!hInstanceLightFX) { - hInstanceLightFX = LoadLibraryW((GetSystemFolder() + L"/LightFX.dll").c_str()); + hInstanceLightFX = LoadLibraryW((GetSystemFolder() + name).c_str()); // Check if we are accidentally loading ourselves if (GetProcAddress(hInstanceLightFX, "LFXE_GetVersion")) { diff --git a/src/Devices/LightFX2.h b/src/Devices/LightFX2.h index ad6e46c..f74da7f 100644 --- a/src/Devices/LightFX2.h +++ b/src/Devices/LightFX2.h @@ -1,5 +1,8 @@ #pragma once +// Standard includes +#include + // 3rd party includes #include "LFX2.h" @@ -27,6 +30,11 @@ extern LFX2ACTIONCOLOREX LightFX_ActionColorEx; extern LFX2SETTIMING LightFX_SetTiming; extern LFX2GETVERSION LightFX_GetVersion; -LFXE_API bool InitializeLightFX(); +#pragma warning(push) +#pragma warning(disable : 4251) + +LFXE_API bool InitializeLightFX(std::wstring name, std::wstring backupName); LFXE_API bool IsLightFXInitialized(); LFXE_API bool ReleaseLightFX(); + +#pragma warning(pop) diff --git a/src/Managers/DeviceManager.cpp b/src/Managers/DeviceManager.cpp index 5b6c062..b5f2408 100644 --- a/src/Managers/DeviceManager.cpp +++ b/src/Managers/DeviceManager.cpp @@ -44,7 +44,7 @@ namespace lightfx { } // Load native LightFX devices - if (InitializeLightFX()) { + if (InitializeLightFX(config->AlienwareDllName, config->AlienwareBackupDllName)) { LOG(LogLevel::Debug, L"Alienware LightFX.dll loaded"); LFX_RESULT result;