mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Implemented most LightFX functions
This commit is contained in:
1 parent
c1ef90a4e6
commit
a8202adde8
13 files changed
+752
-314
No files matched your search
@@ -26,13 +26,13 @@
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
@@ -87,13 +87,14 @@
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ModuleDefinitionFile>LightFX2Artemis.def</ModuleDefinitionFile>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
@@ -102,14 +103,12 @@
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ModuleDefinitionFile>LightFX2Artemis.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
@@ -120,15 +119,16 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ModuleDefinitionFile>LightFX2Artemis.def</ModuleDefinitionFile>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
@@ -139,26 +139,25 @@
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(ProjectDir)includes;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<ModuleDefinitionFile>LightFX2Artemis.def</ModuleDefinitionFile>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LightFX2Artemis.def" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\LogiLed2Artemis\main.cpp" />
|
||||
<ClCompile Include="LightFxDevice.cpp" />
|
||||
<ClCompile Include="LightFxLight.cpp" />
|
||||
<ClCompile Include="LightFxState.cpp" />
|
||||
<ClCompile Include="Source.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="LightFxDevice.h" />
|
||||
<ClInclude Include="LightFxLight.h" />
|
||||
<ClInclude Include="LightFxState.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
|
||||
@@ -15,15 +15,16 @@
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="LightFX2Artemis.def">
|
||||
<Filter>Source Files</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\LogiLed2Artemis\main.cpp">
|
||||
<ClCompile Include="LightFxState.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LightFxState.cpp">
|
||||
<ClCompile Include="LightFxDevice.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="LightFxLight.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Source.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@@ -31,5 +32,11 @@
|
||||
<ClInclude Include="LightFxState.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LightFxDevice.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="LightFxLight.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "LightFxDevice.h"
|
||||
|
||||
|
||||
|
||||
LightFxDevice::LightFxDevice()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LightFxDevice::~LightFxDevice()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "LightFxLight.h"
|
||||
|
||||
class LightFxDevice
|
||||
{
|
||||
public:
|
||||
LightFxDevice();
|
||||
~LightFxDevice();
|
||||
LightFxLight Lights[128];
|
||||
};
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "LightFxLight.h"
|
||||
|
||||
|
||||
|
||||
LightFxLight::LightFxLight()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LightFxLight::~LightFxLight()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
#include "includes/LFXDecl.h"
|
||||
|
||||
class LightFxLight
|
||||
{
|
||||
public:
|
||||
LightFxLight();
|
||||
~LightFxLight();
|
||||
PLFX_COLOR Color;
|
||||
};
|
||||
|
||||
@@ -11,3 +11,10 @@ LightFxState::LightFxState(char* game)
|
||||
LightFxState::~LightFxState()
|
||||
{
|
||||
}
|
||||
|
||||
void LightFxState::Update()
|
||||
{
|
||||
// Serialize self
|
||||
|
||||
// Transmit through Pipe
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
#pragma once
|
||||
#include "LightFxDevice.h"
|
||||
|
||||
class LightFxState
|
||||
{
|
||||
public:
|
||||
LightFxState(char* game);
|
||||
~LightFxState();
|
||||
void Update();
|
||||
char* Game;
|
||||
};
|
||||
LightFxDevice Devices[5];
|
||||
};
|
||||
@@ -0,0 +1,212 @@
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
#include <thread>
|
||||
#include <complex>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include "../LightFX2Artemis/LightFxState.h"
|
||||
#include "includes/LFX2.h"
|
||||
#include "includes/LFXDecl.h"
|
||||
#include "includes/log.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
LightFxState* lightFxState;
|
||||
|
||||
char* GetGame()
|
||||
{
|
||||
CHAR szPath[MAX_PATH];
|
||||
GetModuleFileNameA(NULL, szPath, MAX_PATH);
|
||||
|
||||
return szPath;
|
||||
};
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
lightFxState = new LightFxState(GetGame());
|
||||
FILELog::ReportingLevel() = logDEBUG1;
|
||||
FILE* log_fd = fopen("log.txt", "w");
|
||||
Output2FILE::Stream() = log_fd;
|
||||
|
||||
FILE_LOG(logDEBUG1) << "Main called, DLL loaded into " << lightFxState->Game;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Transmit(const char* msg)
|
||||
{
|
||||
//Pipe Init Data
|
||||
HANDLE hPipe1;
|
||||
char buf[100];
|
||||
LPTSTR lpszPipename1 = TEXT("\\\\.\\pipe\\artemis");
|
||||
|
||||
hPipe1 = CreateFile(lpszPipename1, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
||||
if (hPipe1 == NULL || hPipe1 == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Could not open the pipe - " << GetLastError();
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD cbWritten;
|
||||
WriteFile(hPipe1, msg, strlen(msg), &cbWritten, NULL);
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_Initialize()
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_Initialize()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_Release()
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_Release()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_Reset()
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_Reset()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_Update()
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_Update()";
|
||||
|
||||
lightFxState->Update();
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_UpdateDefault()
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_UpdateDefault()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_GetNumDevices(unsigned int* const numDevices)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_GetNumDevices()";
|
||||
|
||||
// Keyboard, mouse, headset, mousemat, generic
|
||||
*numDevices = 5;
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_GetDeviceDescription(const unsigned int devIndex, char* const devDesc, const unsigned int devDescSize, unsigned char* const devType)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_GetDeviceDescription()";
|
||||
|
||||
stringstream ss;
|
||||
ss << "Device " << devIndex;
|
||||
string deviceName = ss.str();
|
||||
if (deviceName.length() > devDescSize)
|
||||
return LFX_ERROR_BUFFSIZE;
|
||||
|
||||
// Just assign similar LFX device types to each index
|
||||
sprintf_s(devDesc, devDescSize, deviceName.c_str());
|
||||
if (devIndex == 0)
|
||||
*devType = LFX_DEVTYPE_KEYBOARD;
|
||||
else if (devIndex == 1)
|
||||
*devType = LFX_DEVTYPE_MOUSE;
|
||||
else if (devIndex == 2)
|
||||
*devType = LFX_DEVTYPE_SPEAKER;
|
||||
else if (devIndex == 3)
|
||||
*devType = LFX_DEVTYPE_GAMEPAD;
|
||||
else
|
||||
*devType = LFX_DEVTYPE_DESKTOP;
|
||||
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_GetNumLights(const unsigned int devIndex, unsigned int* const numLights)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_GetNumLights()";
|
||||
|
||||
// Just do one for now
|
||||
*numLights = 1;
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightDescription(const unsigned int devIndex, const unsigned int lightIndex, char* const lightDesc, const unsigned int lightDescSize)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_GetLightDescription()";
|
||||
|
||||
stringstream ss;
|
||||
ss << "Device " << devIndex << "Light" << lightIndex;
|
||||
string lightDescription = ss.str();
|
||||
if (lightDescription.length() > lightDescSize)
|
||||
return LFX_ERROR_BUFFSIZE;
|
||||
|
||||
sprintf_s(lightDesc, lightDescSize, lightDescription.c_str());
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightLocation(const unsigned int devIndex, const unsigned int lightIndex, PLFX_POSITION const lightLoc)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_GetLightLocation()";
|
||||
|
||||
*lightLoc = LFX_POSITION{ 0,0,0 };
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightColor(const unsigned int devIndex, const unsigned int lightIndex, PLFX_COLOR const lightCol)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_GetLightColor()";
|
||||
|
||||
*lightCol = *lightFxState->Devices[devIndex].Lights[lightIndex].Color;
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightColor(const unsigned int devIndex, const unsigned int lightIndex, const PLFX_COLOR lightCol)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_SetLightColor()";
|
||||
|
||||
lightFxState->Devices[devIndex].Lights[lightIndex].Color = lightCol;
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_Light(const unsigned int locationMask, const unsigned int colorVal)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_Light()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightActionColor(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_SetLightActionColor()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightActionColorEx(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR, const PLFX_COLOR)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_SetLightActionColorEx()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_ActionColor(const unsigned int, const unsigned int, const unsigned int)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_ActionColor()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_ActionColorEx(const unsigned int, const unsigned int, const unsigned int, const unsigned int)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_ActionColorEx()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_SetTiming(const int)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_SetTiming()";
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_GetVersion(char* const version, const unsigned int versionSize)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_GetVersion()";
|
||||
|
||||
sprintf_s(version, versionSize, "2.0.0.0");
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
@@ -1,205 +0,0 @@
|
||||
/***************************************************************
|
||||
|
||||
LFXConfigurator.h - Defines the exports for the LightFX
|
||||
Config 1.0 DLL
|
||||
|
||||
Purpose: Provide library exports for communicating with
|
||||
the LightFX Config 1.0 API
|
||||
|
||||
Copyright (c) 2007 Dell, Inc. All rights reserved.
|
||||
|
||||
Dell, Inc. makes no warranty of any kind with regard
|
||||
to this material, including, but not limited to, the
|
||||
implied warranties of merchantability and fitness for
|
||||
a particular purpose. Dell, Inc. shall not be liable
|
||||
for any errors contained herein, or for incidental or
|
||||
consequential damages in connection with the furnishing,
|
||||
performance or use of this material.
|
||||
|
||||
This document contains proprietary information which
|
||||
is protected by copyright. All rights reserved.
|
||||
Reproduction without the written permission of Dell
|
||||
is strictly forbidden.
|
||||
|
||||
***************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#define _EXPORTING
|
||||
|
||||
#ifdef _EXPORTING // To be used by SDK developer
|
||||
#define FN_DECLSPEC __declspec(dllexport)
|
||||
|
||||
#elif _IMPORTING // To be used for dynamic linking to dll
|
||||
#define FN_DECLSPEC __declspec(dllimport)
|
||||
|
||||
#else // To be used for linking using static library
|
||||
#define FN_DECLSPEC
|
||||
#endif
|
||||
|
||||
#ifdef _STDCALL_SUPPORTED
|
||||
#define STDCALL __stdcall // Declare our calling convention
|
||||
#else
|
||||
#define STDCALL
|
||||
#endif // STDCALL_SUPPORTED
|
||||
|
||||
// Return values
|
||||
#define LFX_RESULT unsigned int
|
||||
#define LFX_SUCCESS 0 // Success
|
||||
#define LFX_FAILURE 1 // Generic failure
|
||||
#define LFX_ERROR_NOINIT 2 // System not initialized yet
|
||||
#define LFX_ERROR_NODEVS 3 // No devices available
|
||||
#define LFX_ERROR_NOLIGHTS 4 // No lights available
|
||||
#define LFX_ERROR_BUFFSIZE 5 // Buffer size too small
|
||||
|
||||
//event position
|
||||
#define LFX_EVENTPOSITION unsigned int
|
||||
#define LFX_FIRSTEVENT 0 // First event
|
||||
#define LFX_NEXTEVENT 1 // Next event
|
||||
|
||||
//event position
|
||||
#define LFX_APPTYPE unsigned int
|
||||
#define LFX_GAME 0 // The application is a game
|
||||
#define LFX_GENERALUSEAPP 1 // It is a general use application
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// LightFX Config 1.0 DLL export function declarations
|
||||
|
||||
/***************************************************************
|
||||
Function: LFX_CONFIGURATOR_Initialize
|
||||
Description:
|
||||
Initializes the LightFX Config 1.0 system.
|
||||
This function must be called prior to any other library calls being made. If this
|
||||
function is not called, the system will not be initialized and the other functions
|
||||
will return LFX_ERROR_NOINIT.
|
||||
Inputs: None
|
||||
Outputs: None
|
||||
Returns:
|
||||
LFX_SUCCESS if the system is successfully initialized, or was already initialized.
|
||||
LFX_FAILURE if initialization fails.
|
||||
***************************************************************/
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_CONFIGURATOR_Initialize();
|
||||
|
||||
/***************************************************************
|
||||
Function: LFX_CONFIGURATOR_Release
|
||||
Description:
|
||||
Release the LightFX Config 1.0 system.
|
||||
This function may be called when the system is no longer needed. If this
|
||||
function is not called, release will still occur on process detach.
|
||||
Inputs: None
|
||||
Outputs: None
|
||||
Returns:
|
||||
LFX_SUCCESS
|
||||
***************************************************************/
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_CONFIGURATOR_Release();
|
||||
|
||||
/***************************************************************
|
||||
Function: LFX_CONFIGURATOR_RegisterConfigurationFile
|
||||
Description:
|
||||
Register an app in order to be read by the AlienFX Editor.
|
||||
Inputs: Application name and full path to the config file
|
||||
Outputs: None
|
||||
Returns:
|
||||
LFX_SUCCESS if the application is successfully registered.
|
||||
LFX_FAILURE if the registration fails.
|
||||
LFX_ERROR_NOINIT if the LFX_CONFIGURATOR_Initialize
|
||||
function was not called before
|
||||
***************************************************************/
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_CONFIGURATOR_RegisterConfigurationFile(char* const appFXName, char* const configurationFileFullPath, const LFX_APPTYPE appType);
|
||||
|
||||
/***************************************************************
|
||||
Function: LFX_CONFIGURATOR_UnregisterConfigurationFile
|
||||
Description:
|
||||
Unregister an app. Once this function is called, the app
|
||||
will not appear in AlienFX Editor and cannot be configured
|
||||
Inputs: Application name
|
||||
Outputs: None
|
||||
Returns:
|
||||
LFX_SUCCESS if the application is successfully unregistered.
|
||||
LFX_FAILURE if the registration fails.
|
||||
LFX_ERROR_NOINIT if the LFX_CONFIGURATOR_Initialize
|
||||
function was not called before
|
||||
***************************************************************/
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_CONFIGURATOR_UnregisterConfigurationFile(char* const appFXName);
|
||||
|
||||
/***************************************************************
|
||||
Function: LFX_CONFIGURATOR_GetUserConfigurationFilePath
|
||||
Description:
|
||||
Get the user's configuration file for an application
|
||||
Inputs: Application name and the size of the buffer where the
|
||||
user's configuration filename is going to be returned
|
||||
Outputs:
|
||||
Populates a character string with the user's configuration file
|
||||
Returns:
|
||||
LFX_SUCCESS if the user configuration file is returned.
|
||||
LFX_FAILURE if the user's configuration file cannot be returned.
|
||||
LFX_ERROR_BUFFSIZE if the buffer provided is too small.
|
||||
LFX_ERROR_NOINIT if the LFX_CONFIGURATOR_Initialize
|
||||
function was not called before
|
||||
***************************************************************/
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_CONFIGURATOR_GetUserConfigurationFilePath(char* const appFXName, char* const userConfigurationFilename, const unsigned int userConfigurationFilenameSize);
|
||||
|
||||
/***************************************************************
|
||||
Function: LFX_CONFIGURATOR_GetConfigurationEvent
|
||||
Description:
|
||||
Get the color configuration for an event
|
||||
Inputs: Application name and event id
|
||||
Outputs:
|
||||
Populates a color array and the amount of colors for that event
|
||||
Returns:
|
||||
LFX_SUCCESS if the colors for the event is returned.
|
||||
LFX_FAILURE if the colors for the event cannot be returned.
|
||||
LFX_ERROR_NOINIT if the LFX_CONFIGURATOR_Initialize
|
||||
function was not called before
|
||||
***************************************************************/
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_CONFIGURATOR_GetConfigurationEvent(char* const appFXName, const unsigned int eventID, unsigned int* &colors, unsigned int &colorCount);
|
||||
|
||||
/***************************************************************
|
||||
Function: LFX_CONFIGURATOR_GetConfigurationEventAt
|
||||
Description:
|
||||
Get the color configuration for an event
|
||||
Inputs: Application name and event position
|
||||
Outputs:
|
||||
Returns the event in that position and data related
|
||||
Populates a character string with the event name
|
||||
Populates a color array and the amount of colors for that event
|
||||
Returns:
|
||||
LFX_SUCCESS if there is an event to be returned.
|
||||
LFX_FAILURE if the event cannot be returned.
|
||||
LFX_ERROR_BUFFSIZE if the buffer provided is too small.
|
||||
LFX_ERROR_NOINIT if the LFX_CONFIGURATOR_Initialize
|
||||
function was not called before
|
||||
***************************************************************/
|
||||
FN_DECLSPEC LFX_RESULT STDCALL LFX_CONFIGURATOR_GetConfigurationEventAt(char* const appFXName, unsigned int position,
|
||||
int &eventID, char* const eventName, const unsigned int eventNameSize, unsigned int* &colors, unsigned int &colorCount);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* end extern "C" */
|
||||
#endif
|
||||
|
||||
// The remaining defines and typedefs are useful for explicitly linking to
|
||||
// the DLL, and can be ignored if using the static lib, or implicitely linking.
|
||||
#define LFX_CONFIGURATOR_DLL_NAME "LightFXConfigurator64.dll"
|
||||
|
||||
// LightFX Config 1.0 DLL export function names
|
||||
#define LFX_CONFIGURATOR_DLL_INITIALIZE "LFX_CONFIGURATOR_Initialize"
|
||||
#define LFX_CONFIGURATOR_DLL_RELEASE "LFX_CONFIGURATOR_Release"
|
||||
#define LFX_CONFIGURATOR_DLL_REGISTERCONFIGURATIONFILE "LFX_CONFIGURATOR_RegisterConfigurationFile"
|
||||
#define LFX_CONFIGURATOR_DLL_UNREGISTERCONFIGURATIONFILE "LFX_CONFIGURATOR_UnregisterConfigurationFile"
|
||||
#define LFX_CONFIGURATOR_DLL_GETUSERCONFIGURATIONFILEPATH "LFX_CONFIGURATOR_GetUserConfigurationFilePath"
|
||||
#define LFX_CONFIGURATOR_DLL_GETCONFIGURATIONEVENT "LFX_CONFIGURATOR_GetConfigurationEvent"
|
||||
#define LFX_CONFIGURATOR_DLL_GETCONFIGURATIONEVENTFROMPOSITION "LFX_CONFIGURATOR_GetConfigurationEventAt"
|
||||
|
||||
|
||||
// LightFX Config 1.0 function pointer declarations
|
||||
typedef LFX_RESULT (*LFXCONFIGURATORINITIALIZE)();
|
||||
typedef LFX_RESULT (*LFXCONFIGURATORRELEASE)();
|
||||
typedef LFX_RESULT (*LFXCONFIGURATORREGISTERCONFIGURATIONFILE)(char* const, char* const, const LFX_APPTYPE);
|
||||
typedef LFX_RESULT (*LFXCONFIGURATORUNREGISTERCONFIGURATIONFILE)(char* const);
|
||||
typedef LFX_RESULT (*LFXCONFIGURATORGETUSERCONFIGURATIONFILEPATH)(char* const, char* const, const unsigned int);
|
||||
typedef LFX_RESULT (*LFXCONFIGURATORGETCONFIGURATIONEVENT)(char* const, const unsigned int, unsigned int*&, unsigned int&);
|
||||
typedef LFX_RESULT (*LFXCONFIGURATORGETCONFIGURATIONEVENTFROMPOSITION)(char* const, unsigned int, int&, char* const, const unsigned int, unsigned int*&, unsigned int&);
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
#ifndef __LOG_H__
|
||||
#define __LOG_H__
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
|
||||
inline std::string NowTime();
|
||||
|
||||
enum TLogLevel {logERROR, logWARNING, logINFO, logDEBUG, logDEBUG1, logDEBUG2, logDEBUG3, logDEBUG4};
|
||||
|
||||
template <typename T>
|
||||
class Log
|
||||
{
|
||||
public:
|
||||
Log();
|
||||
virtual ~Log();
|
||||
std::ostringstream& Get(TLogLevel level = logINFO);
|
||||
public:
|
||||
static TLogLevel& ReportingLevel();
|
||||
static std::string ToString(TLogLevel level);
|
||||
static TLogLevel FromString(const std::string& level);
|
||||
protected:
|
||||
std::ostringstream os;
|
||||
private:
|
||||
Log(const Log&);
|
||||
Log& operator =(const Log&);
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
Log<T>::Log()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostringstream& Log<T>::Get(TLogLevel level)
|
||||
{
|
||||
os << "- " << NowTime();
|
||||
os << " " << ToString(level) << ": ";
|
||||
os << std::string(level > logDEBUG ? level - logDEBUG : 0, '\t');
|
||||
return os;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
Log<T>::~Log()
|
||||
{
|
||||
os << std::endl;
|
||||
T::Output(os.str());
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TLogLevel& Log<T>::ReportingLevel()
|
||||
{
|
||||
static TLogLevel reportingLevel = logDEBUG4;
|
||||
return reportingLevel;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string Log<T>::ToString(TLogLevel level)
|
||||
{
|
||||
static const char* const buffer[] = {"ERROR", "WARNING", "INFO", "DEBUG", "DEBUG1", "DEBUG2", "DEBUG3", "DEBUG4"};
|
||||
return buffer[level];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
TLogLevel Log<T>::FromString(const std::string& level)
|
||||
{
|
||||
if (level == "DEBUG4")
|
||||
return logDEBUG4;
|
||||
if (level == "DEBUG3")
|
||||
return logDEBUG3;
|
||||
if (level == "DEBUG2")
|
||||
return logDEBUG2;
|
||||
if (level == "DEBUG1")
|
||||
return logDEBUG1;
|
||||
if (level == "DEBUG")
|
||||
return logDEBUG;
|
||||
if (level == "INFO")
|
||||
return logINFO;
|
||||
if (level == "WARNING")
|
||||
return logWARNING;
|
||||
if (level == "ERROR")
|
||||
return logERROR;
|
||||
Log<T>().Get(logWARNING) << "Unknown logging level '" << level << "'. Using INFO level as default.";
|
||||
return logINFO;
|
||||
}
|
||||
|
||||
class Output2FILE
|
||||
{
|
||||
public:
|
||||
static FILE*& Stream();
|
||||
static void Output(const std::string& msg);
|
||||
};
|
||||
|
||||
inline FILE*& Output2FILE::Stream()
|
||||
{
|
||||
static FILE* pStream = stderr;
|
||||
return pStream;
|
||||
}
|
||||
|
||||
inline void Output2FILE::Output(const std::string& msg)
|
||||
{
|
||||
FILE* pStream = Stream();
|
||||
if (!pStream)
|
||||
return;
|
||||
fprintf(pStream, "%s", msg.c_str());
|
||||
fflush(pStream);
|
||||
}
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
# if defined (BUILDING_FILELOG_DLL)
|
||||
# define FILELOG_DECLSPEC __declspec (dllexport)
|
||||
# elif defined (USING_FILELOG_DLL)
|
||||
# define FILELOG_DECLSPEC __declspec (dllimport)
|
||||
# else
|
||||
# define FILELOG_DECLSPEC
|
||||
# endif // BUILDING_DBSIMPLE_DLL
|
||||
#else
|
||||
# define FILELOG_DECLSPEC
|
||||
#endif // _WIN32
|
||||
|
||||
class FILELOG_DECLSPEC FILELog : public Log<Output2FILE> {};
|
||||
//typedef Log<Output2FILE> FILELog;
|
||||
|
||||
#ifndef FILELOG_MAX_LEVEL
|
||||
#define FILELOG_MAX_LEVEL logDEBUG4
|
||||
#endif
|
||||
|
||||
#define FILE_LOG(level) \
|
||||
if (level > FILELOG_MAX_LEVEL) ;\
|
||||
else if (level > FILELog::ReportingLevel() || !Output2FILE::Stream()) ; \
|
||||
else FILELog().Get(level)
|
||||
|
||||
#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
inline std::string NowTime()
|
||||
{
|
||||
const int MAX_LEN = 200;
|
||||
char buffer[MAX_LEN];
|
||||
if (GetTimeFormatA(LOCALE_USER_DEFAULT, 0, 0,
|
||||
"HH':'mm':'ss", buffer, MAX_LEN) == 0)
|
||||
return "Error in NowTime()";
|
||||
|
||||
char result[100] = {0};
|
||||
static DWORD first = GetTickCount();
|
||||
std::sprintf(result, "%s.%03ld", buffer, (long)(GetTickCount() - first) % 1000);
|
||||
return result;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
inline std::string NowTime()
|
||||
{
|
||||
char buffer[11];
|
||||
time_t t;
|
||||
time(&t);
|
||||
tm r = {0};
|
||||
strftime(buffer, sizeof(buffer), "%X", localtime_r(&t, &r));
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, 0);
|
||||
char result[100] = {0};
|
||||
std::sprintf(result, "%s.%03ld", buffer, (long)tv.tv_usec / 1000);
|
||||
return result;
|
||||
}
|
||||
|
||||
#endif //WIN32
|
||||
|
||||
#endif //__LOG_H__
|
||||
Reference in new issue
Block a user