Skip to content
This repository has been archived by the owner on May 30, 2018. It is now read-only.

Commit

Permalink
Add config to change the filename of Alienware's LightFX.dll
Browse files Browse the repository at this point in the history
  • Loading branch information
Archomeda committed Mar 10, 2015
1 parent e20571d commit 7184ed3
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 46 deletions.
93 changes: 60 additions & 33 deletions src/Config/MainConfigFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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();
}
}

Expand All @@ -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();
}
}
}
}
}

Expand Down
15 changes: 9 additions & 6 deletions src/Config/MainConfigFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,23 @@ namespace lightfx {
bool AutoUpdatesEnabled = true;
managers::LogLevel MinimumLogLevel = managers::LogLevel::Info;

std::map<std::wstring, bool> EnabledDevices = {};

bool TrayIconEnabled = true;
bool TrayIconUseGameIcon = false;

int LogitechColorRangeOutMin = 0;
int LogitechColorRangeOutMax = 255;
int LogitechColorRangeInMin = 0;
int LogitechColorRangeInMax = 100;
std::map<std::wstring, bool> 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";

Expand Down
10 changes: 5 additions & 5 deletions src/Devices/LightFX2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand All @@ -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")) {
Expand Down
10 changes: 9 additions & 1 deletion src/Devices/LightFX2.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#pragma once

// Standard includes
#include <string>

// 3rd party includes
#include "LFX2.h"

Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion src/Managers/DeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7184ed3

Please sign in to comment.