From c7e6f438037d77646c5458574200e317f4fa0da5 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Thu, 15 Dec 2016 17:56:33 +0100 Subject: [PATCH] Added LightFX project --- Artemis/Artemis.sln | 30 ++ Artemis/LightFX2Artemis/LightFX2Artemis.def | 23 + .../LightFX2Artemis/LightFX2Artemis.vcxproj | 167 +++++++ .../LightFX2Artemis.vcxproj.filters | 35 ++ Artemis/LightFX2Artemis/LightFxState.cpp | 13 + Artemis/LightFX2Artemis/LightFxState.h | 8 + Artemis/LightFX2Artemis/includes/LFX2.h | 439 ++++++++++++++++++ .../includes/LFXConfigurator.h | 205 ++++++++ Artemis/LightFX2Artemis/includes/LFXDecl.h | 238 ++++++++++ Artemis/LogiLed2Artemis/main.cpp | 328 +++---------- 10 files changed, 1216 insertions(+), 270 deletions(-) create mode 100644 Artemis/LightFX2Artemis/LightFX2Artemis.def create mode 100644 Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj create mode 100644 Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj.filters create mode 100644 Artemis/LightFX2Artemis/LightFxState.cpp create mode 100644 Artemis/LightFX2Artemis/LightFxState.h create mode 100644 Artemis/LightFX2Artemis/includes/LFX2.h create mode 100644 Artemis/LightFX2Artemis/includes/LFXConfigurator.h create mode 100644 Artemis/LightFX2Artemis/includes/LFXDecl.h diff --git a/Artemis/Artemis.sln b/Artemis/Artemis.sln index 69fb5b679..785b97bb9 100644 --- a/Artemis/Artemis.sln +++ b/Artemis/Artemis.sln @@ -13,6 +13,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LogiLed2Artemis", "LogiLed2 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis86Wrapper", "Artemis86Wrapper\Artemis86Wrapper.csproj", "{47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LightFX2Artemis", "LightFX2Artemis\LightFX2Artemis.vcxproj", "{1A349CF5-2008-41E8-AC13-874CBBCDFA0A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CD_ROM|Any CPU = CD_ROM|Any CPU @@ -178,6 +180,34 @@ Global {47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x64.Build.0 = Release|Any CPU {47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x86.ActiveCfg = Release|Any CPU {47A9BBFD-4BEA-4D7D-8AB7-896E760B2CF2}.SingleImage|x86.Build.0 = Release|Any CPU + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|Any CPU.ActiveCfg = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|Any CPU.Build.0 = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x64.ActiveCfg = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x64.Build.0 = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x86.ActiveCfg = Release|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.CD_ROM|x86.Build.0 = Release|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x64.ActiveCfg = Debug|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x64.Build.0 = Debug|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x86.ActiveCfg = Debug|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Debug|x86.Build.0 = Debug|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|Any CPU.ActiveCfg = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|Any CPU.Build.0 = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x64.ActiveCfg = Debug|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x64.Build.0 = Debug|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x86.ActiveCfg = Debug|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.DVD-5|x86.Build.0 = Debug|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|Any CPU.ActiveCfg = Release|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x64.ActiveCfg = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x64.Build.0 = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x86.ActiveCfg = Release|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.Release|x86.Build.0 = Release|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|Any CPU.ActiveCfg = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|Any CPU.Build.0 = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x64.ActiveCfg = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x64.Build.0 = Release|x64 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x86.ActiveCfg = Release|Win32 + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}.SingleImage|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Artemis/LightFX2Artemis/LightFX2Artemis.def b/Artemis/LightFX2Artemis/LightFX2Artemis.def new file mode 100644 index 000000000..671cfeed5 --- /dev/null +++ b/Artemis/LightFX2Artemis/LightFX2Artemis.def @@ -0,0 +1,23 @@ +LIBRARY + +EXPORTS + + LFX_Initialize + LFX_Release + LFX_Reset + LFX_Update + LFX_UpdateDefault + LFX_GetNumDevices + LFX_GetDeviceDescription + LFX_GetNumLights + LFX_GetLightDescription + LFX_GetLightLocation + LFX_GetLightColor + LFX_SetLightColor + LFX_Light + LFX_SetLightActionColor + LFX_SetLightActionColorEx + LFX_ActionColor + LFX_ActionColorEx + LFX_SetTiming + LFX_GetVersion \ No newline at end of file diff --git a/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj b/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj new file mode 100644 index 000000000..fc6862a2e --- /dev/null +++ b/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj @@ -0,0 +1,167 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {1A349CF5-2008-41E8-AC13-874CBBCDFA0A} + Win32Proj + LightFX2Artemis + 8.1 + + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + DynamicLibrary + true + v140 + Unicode + + + DynamicLibrary + false + v140 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + true + + + false + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + LightFX2Artemis.def + + + + + + + Level3 + Disabled + _DEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + $(ProjectDir)includes;%(AdditionalIncludeDirectories) + + + Windows + true + LightFX2Artemis.def + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + LightFX2Artemis.def + + + + + Level3 + + + MaxSpeed + true + true + NDEBUG;_WINDOWS;_USRDLL;LIGHTFX2ARTEMIS_EXPORTS;%(PreprocessorDefinitions) + true + $(ProjectDir)includes;%(AdditionalIncludeDirectories) + + + Windows + true + true + true + LightFX2Artemis.def + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj.filters b/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj.filters new file mode 100644 index 000000000..e323a0c78 --- /dev/null +++ b/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj.filters @@ -0,0 +1,35 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/Artemis/LightFX2Artemis/LightFxState.cpp b/Artemis/LightFX2Artemis/LightFxState.cpp new file mode 100644 index 000000000..cffd42dd7 --- /dev/null +++ b/Artemis/LightFX2Artemis/LightFxState.cpp @@ -0,0 +1,13 @@ +#include "LightFxState.h" + + + +LightFxState::LightFxState(char* game) +{ + Game = game; +} + + +LightFxState::~LightFxState() +{ +} diff --git a/Artemis/LightFX2Artemis/LightFxState.h b/Artemis/LightFX2Artemis/LightFxState.h new file mode 100644 index 000000000..606d27ae3 --- /dev/null +++ b/Artemis/LightFX2Artemis/LightFxState.h @@ -0,0 +1,8 @@ +#pragma once +class LightFxState +{ +public: + LightFxState(char* game); + ~LightFxState(); + char* Game; +}; \ No newline at end of file diff --git a/Artemis/LightFX2Artemis/includes/LFX2.h b/Artemis/LightFX2Artemis/includes/LFX2.h new file mode 100644 index 000000000..3e89cf83b --- /dev/null +++ b/Artemis/LightFX2Artemis/includes/LFX2.h @@ -0,0 +1,439 @@ +/********************************************************* + +LFX2.h - Defines the exports for the LightFX 2.0 DLL + +Purpose: Provide library exports for communicating with + the LightFX 2.0 API + +Copyright (c) 2007 Dell, Inc. All rights reserved. + Date: 8/7/2007 + +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 + +#include "LFXDecl.h" +#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 + +#ifdef __cplusplus +extern "C" { +#endif + +// LightFX 2.0 DLL export function declarations + +/********************************************************* +Function: LFX_Initialize +Description: + Initializes the LightFX 2.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 or LFX_FAILURE. +Inputs: None +Outputs: None +Returns: + LFX_SUCCESS if the system is successfully initialized, or was already initialized. + LFX_ERROR_NODEVS if the system is initialized, but no devices are available. + LFX_FAILURE if initialization fails. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_Initialize(); + +/********************************************************* +Function: LFX_Release +Description: + Release the LightFX 2.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. +PnP Note: + An application may want to release the system and initialize it again in + response to a device arrival notification, to account for new devices added + while the application is running. +Inputs: None +Outputs: None +Returns: + LFX_SUCCESS +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_Release(); + +/********************************************************* +Function: LFX_Reset +Description: + Reset the state of the system to 'off' for any lights attached to any devices. + Note that the change(s) to the physical light(s) do not occur immediately, rather + only after an LFX_Update() call is made. + To disable all lights, call LFX_Reset(), immediately followed by LFX_Update(). +Inputs: None +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if there are no devices available to reset. + LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_Reset(); + +/********************************************************* +Function: LFX_Update +Description: + Update the entire system, submitting any state changes to hardware + made since the last LFX_Reset() call. +Inputs: None +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available. + LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_Update(); + +/********************************************************* +Function: LFX_UpdateDefault +Description: + Update the entire system, submitting any state changes made since the last LFX_Reset() + call to the hardware, and set the appropriate flags to make the new state the + power-on default. +Note: Not all devices will support this functionality. +Inputs: None +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_UpdateDefault(); + +/********************************************************* +Function: LFX_GetNumDevices +Description: + Get the number of devices attached to the LightFX system +Inputs: None +Outputs: Populates a uint with the current number of attached devices. +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available, leaving the param untouched. + LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetNumDevices(unsigned int* const); + +/********************************************************* +Function: LFX_GetDeviceDescription +Description: + Get the description of a device attached to the system +Inputs: Accepts an index to the device +Outputs: + Populates a character string with the device's description + Populates a ushort with the device type (see LFXDecl.h for device types) +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available. + LFX_ERROR_BUFFSIZE if the buffer provided is too small. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetDeviceDescription(const unsigned int, char* const, const unsigned int, unsigned char* const); + +/********************************************************* +Function: LFX_GetNumLights +Description: + Get the number of lights attached to a device in the LightFX system +Inputs: Accepts an index to the device +Outputs: Populates a uint with the current number of attached lights for the device index. +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available at the index provided. + LFX_ERROR_NOLIGHTS if no lights are available at the device index provided. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetNumLights(const unsigned int, unsigned int* const); + +/********************************************************* +Function: LFX_GetLightDescription +Description: + Get the description of a light attached to a device +Inputs: Accepts an index to the device and an index to the light +Outputs: Populates a character string with the light's description +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available at the index provided. + LFX_ERROR_NOLIGHTS if no lights are available at the device and light index provided. + LFX_ERROR_BUFFSIZE if the buffer provided is too small in size. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightDescription(const unsigned int, const unsigned int, char* const, const unsigned int); + +/********************************************************* +Function: LFX_GetLightLocation +Description: + Get the location of a light attached to a device +Inputs: Accepts an index to the device and an index to the light +Outputs: Populates a LFX_POSITION structure with the light's position (see LFXDecl.h + for more information). +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available at the index provided. + LFX_ERROR_NOLIGHTS if no lights are available at the device and light index provided. + LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightLocation(const unsigned int, const unsigned int, PLFX_POSITION const); + +/********************************************************* +Function: LFX_GetLightColor +Description: + Get the current color of a light attached to a device +Important: + This function provides the current color stored in the active state + since the last LFX_Reset() call, it does not necessarily reflect the color of the + physical light. To ensure that the returned value represents the state of the + physical light, call LFX_GetLightColor immediately after a call to LFX_Update() and + before the next call to LFX_Reset(). +Inputs: Accepts an index to the device and an index to the light +Outputs: Populates a LFX_COLOR structure with the light's description +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NODEVS if the system is initialized but no devices are available at the index provided. + LFX_ERROR_NOLIGHTS if no lights are available at the device and light index provided. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightColor(const unsigned int, const unsigned int, PLFX_COLOR const); + +/********************************************************* +Function: LFX_SetLightColor +Description: + Sets the current color of a light attached to a device +Important: + This function changes the current color stored in the active state + since the last LFX_Reset() call. It does NOT immediately update the physical light + settings, until a call to LFX_Update() is made. +Inputs: Accepts an index to the device, an index to the light, and a new LFX_COLOR value +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightColor(const unsigned int, const unsigned int, const PLFX_COLOR); + +/********************************************************* +Function: LFX_Light +Description: + Sets the color of a location for any devices with lights in that + corresponding location. +Important: + This function changes the current color stored in the active state + since the last LFX_Reset() call. It does NOT immediately update the physical light + settings, until a call to LFX_Update() is made. +Location Mask Note: + Location mask is a 32-bit field, where each of the first 27 bits represent + a zone in the virtual cube representing the system (see LFXDecl.h) +Color Packing Note: + Color is packed into a 32-bit value, as follows: + Bits 0-7: Blue + Bits 8-15: Green + Bits 16-23: Red + Bits 24-32: Brightness +Inputs: Accepts a 32-bit location mask and a packed color value +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NOLIGHTS if no lights were found at the location mask specified. + LFX_FAILURE if some other error occurred + LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_Light(const unsigned int, const unsigned int); + +/********************************************************* +Function: LFX_SetLightActionColor +Description: + Sets the primary color and an action type to a light +Important: + This function changes the current color and action type stored in the active state + since the last LFX_Reset() call. It does NOT immediately update the physical light + settings, until a call to LFX_Update() is made. If the action type is a morph, then + the secondary color for the action is black. +Inputs: Accepts an index to the device, an index to the light, an action type, and a new primary LFX_COLOR value +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightActionColor(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR); + +/********************************************************* +Function: LFX_SetLightActionColorEx +Description: + Sets the primary and secondary colors and an action type to a light +Important: + This function changes the current color and action type stored in the active state + since the last LFX_Reset() call. It does NOT immediately update the physical light + settings, until a call to LFX_Update() is made. If the action type is not a morph, + then the secondary color is ignored. +Inputs: Accepts an index to the device, an index to the light, an action type, and two LFX_COLOR values +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightActionColorEx(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR, const PLFX_COLOR); + +/********************************************************* +Function: LFX_ActionColor +Description: + Sets the primary color and an action type for any devices with lights in a location. +Important: + This function changes the current primary color and action type stored in the active state + since the last LFX_Reset() call. It does NOT immediately update the physical light + settings, until a call to LFX_Update() is made. If the action type is a morph, then + the secondary color for the action is black. +Location Mask Note: + Location mask is a 32-bit field, where each of the first 27 bits represent + a zone in the virtual cube representing the system (see LFXDecl.h) +Color Packing Note: + Color is packed into a 32-bit value, as follows: + Bits 0-7: Blue + Bits 8-15: Green + Bits 16-23: Red + Bits 24-32: Brightness +Inputs: Accepts a 32-bit location mask and a packed color value +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NOLIGHTS if no lights were found at the location mask specified. + LFX_FAILURE if some other error occurred + LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_ActionColor(const unsigned int, const unsigned int, const unsigned int); + +/********************************************************* +Function: LFX_ActionColorEx +Description: + Sets the primary and secondary color and an action type for any devices with lights in a location. +Important: + This function changes the current primary and secondary color and action type stored in the active state + since the last LFX_Reset() call. It does NOT immediately update the physical light + settings, until a call to LFX_Update() is made. If the action type is not a morph, + then the secondary color is ignored. +Location Mask Note: + Location mask is a 32-bit field, where each of the first 27 bits represent + a zone in the virtual cube representing the system (see LFXDecl.h) +Color Packing Note: + Color is packed into a 32-bit value, as follows: + Bits 0-7: Blue + Bits 8-15: Green + Bits 16-23: Red + Bits 24-32: Brightness +Inputs: Accepts a 32-bit location mask and a packed color value +Outputs: None +Returns: + LFX_ERROR_NOINIT if the system is not yet initialized. + LFX_ERROR_NOLIGHTS if no lights were found at the location mask specified. + LFX_FAILURE if some other error occurred + LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_ActionColorEx(const unsigned int, const unsigned int, const unsigned int, const unsigned int); + +/********************************************************* +Function: LFX_SetTiming +Description: + Sets the tempo for actions. +Important: + This function changes the current tempo or timing to be used for the + next actions. It does NOT immediately update the physical light + settings, until a call to LFX_Update() is made. +Timing Note: + Is a value between min and max tempo allowed for the main device. + If a value lower than min or a value greather than max is entered, + the value is readjusted to those extremes. +Inputs: Accepts a 32-bit timing value +Outputs: None +Returns: + LFX_FAILURE if changing tempo is not supported or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetTiming(const int); + +/********************************************************* +Function: LFX_GetVersion +Description: + Get API Version +Inputs: Accepts the buffer and buffer size +Outputs: + Populates a character string with the API version +Returns: + LFX_ERROR_BUFFSIZE if the buffer provided is too small. + LFX_FAILURE or LFX_SUCCESS otherwise. +*********************************************************/ +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetVersion(char* const, const unsigned int); + +#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_DLL_NAME "LightFX.dll" + +// LightFX 2.0 DLL export function names +#define LFX_DLL_INITIALIZE "LFX_Initialize" +#define LFX_DLL_RELEASE "LFX_Release" +#define LFX_DLL_RESET "LFX_Reset" +#define LFX_DLL_UPDATE "LFX_Update" +#define LFX_DLL_UPDATEDEFAULT "LFX_UpdateDefault" +#define LFX_DLL_GETNUMDEVICES "LFX_GetNumDevices" +#define LFX_DLL_GETDEVDESC "LFX_GetDeviceDescription" +#define LFX_DLL_GETNUMLIGHTS "LFX_GetNumLights" +#define LFX_DLL_GETLIGHTDESC "LFX_GetLightDescription" +#define LFX_DLL_GETLIGHTLOC "LFX_GetLightLocation" +#define LFX_DLL_GETLIGHTCOL "LFX_GetLightColor" +#define LFX_DLL_SETLIGHTCOL "LFX_SetLightColor" +#define LFX_DLL_LIGHT "LFX_Light" +#define LFX_DLL_SETLIGHTACTIONCOLOR "LFX_SetLightActionColor" +#define LFX_DLL_SETLIGHTACTIONCOLOREX "LFX_SetLightActionColorEx" +#define LFX_DLL_ACTIONCOLOR "LFX_ActionColor" +#define LFX_DLL_ACTIONCOLOREX "LFX_ActionColorEx" +#define LFX_DLL_SETTIMING "LFX_SetTiming" +#define LFX_DLL_GETVERSION "LFX_GetVersion" + +// LightFX 2.0 function pointer declarations +typedef LFX_RESULT (*LFX2INITIALIZE)(); +typedef LFX_RESULT (*LFX2RELEASE)(); +typedef LFX_RESULT (*LFX2RESET)(); +typedef LFX_RESULT (*LFX2UPDATE)(); +typedef LFX_RESULT (*LFX2UPDATEDEFAULT)(); +typedef LFX_RESULT (*LFX2GETNUMDEVICES)(unsigned int* const); +typedef LFX_RESULT (*LFX2GETDEVDESC)(const unsigned int, char* const, const unsigned int, unsigned char* const); +typedef LFX_RESULT (*LFX2GETNUMLIGHTS)(const unsigned int, unsigned int* const); +typedef LFX_RESULT (*LFX2GETLIGHTDESC)(const unsigned int, const unsigned int, char* const, const unsigned int); +typedef LFX_RESULT (*LFX2GETLIGHTLOC)(const unsigned int, const unsigned int, PLFX_POSITION const); +typedef LFX_RESULT (*LFX2GETLIGHTCOL)(const unsigned int, const unsigned int, PLFX_COLOR const); +typedef LFX_RESULT (*LFX2SETLIGHTCOL)(const unsigned int, const unsigned int, const PLFX_COLOR); +typedef LFX_RESULT (*LFX2LIGHT)(const unsigned int, const unsigned int); +typedef LFX_RESULT (*LFX2SETLIGHTACTIONCOLOR)(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR); +typedef LFX_RESULT (*LFX2SETLIGHTACTIONCOLOREX)(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR, const PLFX_COLOR); +typedef LFX_RESULT (*LFX2ACTIONCOLOR)(const unsigned int, const unsigned int, const unsigned int); +typedef LFX_RESULT (*LFX2ACTIONCOLOREX)(const unsigned int, const unsigned int, const unsigned int, const unsigned int); +typedef LFX_RESULT (*LFX2SETTIMING)(const int); +typedef LFX_RESULT (*LFX2GETVERSION)(char* const, const unsigned int); \ No newline at end of file diff --git a/Artemis/LightFX2Artemis/includes/LFXConfigurator.h b/Artemis/LightFX2Artemis/includes/LFXConfigurator.h new file mode 100644 index 000000000..b8472f805 --- /dev/null +++ b/Artemis/LightFX2Artemis/includes/LFXConfigurator.h @@ -0,0 +1,205 @@ +/*************************************************************** + +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&); + diff --git a/Artemis/LightFX2Artemis/includes/LFXDecl.h b/Artemis/LightFX2Artemis/includes/LFXDecl.h new file mode 100644 index 000000000..5688ba71c --- /dev/null +++ b/Artemis/LightFX2Artemis/includes/LFXDecl.h @@ -0,0 +1,238 @@ +/********************************************************* + +LFXDecl.h - definitions for Dell LightFX 2.0 + +Purpose: Provide definitions for communicating with + the LightFX 2.0 API + +Copyright (c) 2007 Dell, Inc. All rights reserved. + Date: 6/21/2007 + +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 + +// Helper release and delete functions, used in cleanup routines +#define LFX_SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } } +#define LFX_SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } } +#define LFX_SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } } + +#define LFX_DEF_STRING_SIZE 255 // Default string size +#define LFX_MAX_STRING_SIZE 255 // Maximum string size +#define LFX_MAX_COLOR_VALUE 255 // Maximum color value + +#define LFX_MINIMUM_DEVICE_SIZE 3 // Min device physical size/bounds in cm +#define LFX_SEGMENTS_PER_AXIS 3 // Each location axis (x,y,z) has 3 segments (e.g. left,center,right), resulting in 27 possible locations + +// LightFX 1.x legacy support +#define LFX_INTENSITY_CONV 36 // Brightness/intensity conversion factor +#define LFX_INDEX_COLOR_COUNT 17 // 16 colors, plus 0 for "off" + +// Type definitions +#define LFX_PROTOCOL_UNKNOWN 0x00 +#define LFX_PROTOCOL_LFX1 0x01 +#define LFX_PROTOCOL_ESA 0x28 +#define LFX_PROTOCOL_OTHER 0xFF + +#define LFX_CATEGORY_UNKNOWN 0x00 +#define LFX_CATEGORY_SYSTEM 0x01 +#define LFX_CATEGORY_PERIPH 0x02 +#define LFX_CATEGORY_OTHER 0xFF + +#define LFX_DEVTYPE_UNKNOWN 0x00 +#define LFX_DEVTYPE_NOTEBOOK 0x01 +#define LFX_DEVTYPE_DESKTOP 0x02 +#define LFX_DEVTYPE_SERVER 0x03 +#define LFX_DEVTYPE_DISPLAY 0x04 +#define LFX_DEVTYPE_MOUSE 0x05 +#define LFX_DEVTYPE_KEYBOARD 0x06 +#define LFX_DEVTYPE_GAMEPAD 0x07 +#define LFX_DEVTYPE_SPEAKER 0x08 +#define LFX_DEVTYPE_OTHER 0xFF + +// 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 + +// Translation layer position/location encoding +// Note: This is a bit mask, with 27 zones encoded into 32 bits +// Bits 0 through 8 are all part of the front-most plane (closest to the user) +// Bits 9 through 17 are all part of the middle plane (mid-way from the user) +// Bits 18 through 27 are all part of the back-most plane (furthest from the user) +// Bits 28 through 32 are reserved +// +// Bits 0 through 8 are split into lower, middle and upper sections (relative to the floor & ceiling) +// +// Bit 0: [ FRONT, LOWER, LEFT ] +// Bit 1: [ FRONT, LOWER, CENTER ] +// Bit 2: [ FRONT, LOWER, RIGHT ] +// +// Bit 3: [ FRONT, MIDDLE, LEFT ] +// Bit 4: [ FRONT, MIDDLE, CENTER ] +// Bit 5: [ FRONT, MIDDLE, RIGHT ] +// +// Bit 6: [ FRONT, UPPER, LEFT ] +// Bit 7: [ FRONT, UPPER, CENTER ] +// Bit 8: [ FRONT, UPPER, RIGHT ] +// +// Bits 9 through 17 are split into lower, middle and upper sections as well +// +// Bit 9: [ MIDDLE, LOWER, LEFT ] +// Bit 10: [ MIDDLE, LOWER, CENTER ] +// Bit 11: [ MIDDLE, LOWER, RIGHT ] +// +// Bit 12: [ MIDDLE, MIDDLE, LEFT ] +// Bit 13: [ MIDDLE, MIDDLE, CENTER ] +// Bit 14: [ MIDDLE, MIDDLE, RIGHT ] +// +// Bit 15: [ MIDDLE, UPPER, LEFT ] +// Bit 16: [ MIDDLE, UPPER, CENTER ] +// Bit 17: [ MIDDLE, UPPER, RIGHT ] +// +// Similar with bits 18 through 26 +// +// Bit 18: [ BACK, LOWER, LEFT ] +// Bit 19: [ BACK, LOWER, CENTER ] +// Bit 20: [ BACK, LOWER, RIGHT ] +// +// Bit 21: [ BACK, MIDDLE, LEFT ] +// Bit 22: [ BACK, MIDDLE, CENTER ] +// Bit 23: [ BACK, MIDDLE, RIGHT ] +// +// Bit 24: [ BACK, UPPER, LEFT ] +// Bit 25: [ BACK, UPPER, CENTER ] +// Bit 26: [ BACK, UPPER, RIGHT ] +// +// Bits 27 through 32 are reserved + +// Near Z-plane light definitions +#define LFX_FRONT_LOWER_LEFT 0x00000001 +#define LFX_FRONT_LOWER_CENTER 0x00000002 +#define LFX_FRONT_LOWER_RIGHT 0x00000004 + +#define LFX_FRONT_MIDDLE_LEFT 0x00000008 +#define LFX_FRONT_MIDDLE_CENTER 0x00000010 +#define LFX_FRONT_MIDDLE_RIGHT 0x00000020 + +#define LFX_FRONT_UPPER_LEFT 0x00000040 +#define LFX_FRONT_UPPER_CENTER 0x00000080 +#define LFX_FRONT_UPPER_RIGHT 0x00000100 + +// Mid Z-plane light definitions +#define LFX_MIDDLE_LOWER_LEFT 0x00000200 +#define LFX_MIDDLE_LOWER_CENTER 0x00000400 +#define LFX_MIDDLE_LOWER_RIGHT 0x00000800 + +#define LFX_MIDDLE_MIDDLE_LEFT 0x00001000 +#define LFX_MIDDLE_MIDDLE_CENTER 0x00002000 +#define LFX_MIDDLE_MIDDLE_RIGHT 0x00004000 + +#define LFX_MIDDLE_UPPER_LEFT 0x00008000 +#define LFX_MIDDLE_UPPER_CENTER 0x00010000 +#define LFX_MIDDLE_UPPER_RIGHT 0x00020000 + +// Far Z-plane light definitions +#define LFX_REAR_LOWER_LEFT 0x00040000 +#define LFX_REAR_LOWER_CENTER 0x00080000 +#define LFX_REAR_LOWER_RIGHT 0x00100000 + +#define LFX_REAR_MIDDLE_LEFT 0x00200000 +#define LFX_REAR_MIDDLE_CENTER 0x00400000 +#define LFX_REAR_MIDDLE_RIGHT 0x00800000 + +#define LFX_REAR_UPPER_LEFT 0x01000000 +#define LFX_REAR_UPPER_CENTER 0x02000000 +#define LFX_REAR_UPPER_RIGHT 0x04000000 + +// Combination bit masks +#define LFX_ALL 0x07FFFFFF +#define LFX_ALL_RIGHT 0x04924924 +#define LFX_ALL_LEFT 0x01249249 +#define LFX_ALL_UPPER 0x070381C0 +#define LFX_ALL_LOWER 0x001C0E07 +#define LFX_ALL_FRONT 0x000001FF +#define LFX_ALL_REAR 0x07FC0000 + +// Translation layer color encoding +#define LFX_OFF 0x00000000 +#define LFX_BLACK 0x00000000 +#define LFX_RED 0x00FF0000 +#define LFX_GREEN 0x0000FF00 +#define LFX_BLUE 0x000000FF +#define LFX_WHITE 0x00FFFFFF +#define LFX_YELLOW 0x00FFFF00 +#define LFX_ORANGE 0x00FF8000 +#define LFX_PINK 0x00FF80FF +#define LFX_CYAN 0x0000FFFF + +// Translation layer brightness encoding +#define LFX_FULL_BRIGHTNESS 0xFF000000 +#define LFX_HALF_BRIGHTNESS 0x80000000 +#define LFX_MIN_BRIGHTNESS 0x00000000 + +// Predifined kinds of actions +#define LFX_ACTION_MORPH 0x00000001 +#define LFX_ACTION_PULSE 0x00000002 +#define LFX_ACTION_COLOR 0x00000003 + +// Color, encoded into 4 unsigned chars +typedef struct _LFX_COLOR +{ + unsigned char red; + unsigned char green; + unsigned char blue; + unsigned char brightness; + +}LFX_COLOR, *PLFX_COLOR; + +/************************************************************************************** +IMPORTANT NOTE: + +The semantics of LightFX position, location mask, and bounds are defined as follows: + +BOUNDS are the physical bounds, in centimeters, of any given device/enclosure, + relative to an anchor point at the lower, left, rear corner +POSITION is a physical position, in centimeters, of any given light relative to + the lower, left, rear corner of the device's bounding box. +LOCATION (or "location mask") is a 32-bit mask that denotes one or more light positions + in terms of the device's bounding box. There are 27 bits for each smaller cube + within this bounding box, divided evenly. (Imagine a Rubick's cube...) + +BOUNDS or POSITION may be encoded into a LFX_POSITION structure, so it is important to +examine the context of the usage to determine what the data inside the structure refers to. + +LOCATION should always be encoded into a 32-bit (or larger) value; see the bit field +declarations above. +***************************************************************************************/ + +/* Position, encoded into a 3-axis value. +Note that these are relative to the lower, left, rear +corner of the device's bounding box. +X increases from left to right. +Y increases from bottom to top. +Z increases from back to front. */ +typedef struct _LFX_POSITION +{ + unsigned char x; + unsigned char y; + unsigned char z; + +} LFX_POSITION, *PLFX_POSITION; \ No newline at end of file diff --git a/Artemis/LogiLed2Artemis/main.cpp b/Artemis/LogiLed2Artemis/main.cpp index 8181302bf..29297e64c 100644 --- a/Artemis/LogiLed2Artemis/main.cpp +++ b/Artemis/LogiLed2Artemis/main.cpp @@ -1,109 +1,45 @@ -// Original work by VRocker https://github.com/VRocker/LogiLed2Corsair -// I'm mainly a C# developer, and these modification aren't a piece of art, but it suits our needs. - -// The MIT License (MIT) -// -// Copyright (c) 2015 VRocker -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - #include "main.h" #include #include #include -#include "LogiLedDefs.h" #define WIN32_LEAN_AND_MEAN #include #include #include #include +#include "../LightFX2Artemis/LightFxState.h" +#include "LFX2.h" + using namespace std; -static bool g_hasInitialised = false; + static bool mustLog = false; -static int throttle = 0; -const char* game = ""; +LightFxState* lightFxState; - -const char* GetGame() +char* GetGame() { - CHAR divisionFind[] = ("Division"); - CHAR gtaFind[] = ("GTA"); CHAR szPath[MAX_PATH]; - GetModuleFileNameA(NULL, szPath, MAX_PATH); - char *output; - output = strstr(szPath, divisionFind); - if (output) - return "division"; - output = strstr(szPath, gtaFind); - if (output) - return "gta"; - - return "bf1"; + return szPath; }; BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID) { if (fdwReason == DLL_PROCESS_ATTACH) - { - game = GetGame(); - + { + lightFxState = new LightFxState(GetGame()); if (mustLog) { ofstream myfile; myfile.open("log.txt", ios::out | ios::app); - myfile << "Main called, DLL loaded into " << game << "\n"; + myfile << "Main called, DLL loaded into " << lightFxState->Game << "\n"; myfile.close(); } } return true; } -bool LogiLedInit() -{ - g_hasInitialised = true; - return true; -} - -bool LogiLedGetSdkVersion(int* majorNum, int* minorNum, int* buildNum) -{ - // Mimic the SDK version - *majorNum = 8; - *minorNum = 81; - *buildNum = 15; - - return true; -} - -bool LogiLedSetTargetDevice(int targetDevice) -{ - // Logitech SDK says this function returns false if LogiLedInit hasn't been called - return g_hasInitialised; -} - -bool LogiLedSaveCurrentLighting() -{ - return true; -} - void Transmit(const char* msg) { //Pipe Init Data @@ -128,245 +64,97 @@ void Transmit(const char* msg) WriteFile(hPipe1, msg, strlen(msg), &cbWritten, NULL); } -// LogiLedSetLighting appears to have an undocumented extra argument -bool LogiLedSetLighting(int redPercentage, int greenPercentage, int bluePercentage, int custom = 0) +FN_DECLSPEC LFX_RESULT STDCALL LFX_Initialize() { - // GTA goes mental on the SetLighting calls, lets only send one in every 20 - if (game == "gta") - { - throttle++; - if (throttle > 20) - throttle = 0; - else - return true; - } - - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - if (custom == 0) - { - myfile << "LogiLedSetLighting called\n"; - } - else - { - myfile << "LogiLedSetLighting called with custom " << custom << "\n"; - } - myfile.close(); - } - ostringstream os; - os << "0 " << hex << custom << " " << dec << redPercentage << " " << greenPercentage << " " << bluePercentage; - Transmit(os.str().c_str()); - - return true; + return LFX_SUCCESS; } -bool LogiLedRestoreLighting() +FN_DECLSPEC LFX_RESULT STDCALL LFX_Release() { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedRestoreLighting called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedFlashLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval) +FN_DECLSPEC LFX_RESULT STDCALL LFX_Reset() { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedFlashLighting called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedPulseLighting(int redPercentage, int greenPercentage, int bluePercentage, int milliSecondsDuration, int milliSecondsInterval) +FN_DECLSPEC LFX_RESULT STDCALL LFX_Update() { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedPulseLighting called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedStopEffects() +FN_DECLSPEC LFX_RESULT STDCALL LFX_UpdateDefault() { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedStopEffects called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedSetLightingFromBitmap(unsigned char bitmap[]) +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetNumDevices(unsigned int* const) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedSetLightingFromBitmap called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedSetLightingForKeyWithScanCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage) +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetDeviceDescription(const unsigned int, char* const, const unsigned int, unsigned char* const) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedSetLightingForKeyWithScanCode called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedSetLightingForKeyWithHidCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage) +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetNumLights(const unsigned int, unsigned int* const) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedSetLightingForKeyWithHidCode called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedSetLightingForKeyWithQuartzCode(int keyCode, int redPercentage, int greenPercentage, int bluePercentage) +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightDescription(const unsigned int, const unsigned int, char* const, const unsigned int) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedSetLightingForKeyWithQuartzCode called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedSetLightingForKeyWithKeyName(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage) +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightLocation(const unsigned int, const unsigned int, PLFX_POSITION const) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedSetLightingForKeyWithKeyName called\n"; - myfile.close(); - } - - // Only transmit interesting keys. This can most likely be done prettier, but I'm no C++ dev. - if (game == "division" && (keyName == LogiLed::F1 || keyName == LogiLed::F2 || keyName == LogiLed::F3 || keyName == LogiLed::F4 || keyName == LogiLed::R || keyName == LogiLed::G || keyName == LogiLed::V)) - { - ostringstream os; - os << "1 " << keyName << " " << redPercentage << " " << greenPercentage << " " << bluePercentage; - string s = os.str(); - Transmit(os.str().c_str()); - return true; - } - - ostringstream os; - os << "1 " << keyName << " " << redPercentage << " " << greenPercentage << " " << bluePercentage; - string s = os.str(); - Transmit(os.str().c_str()); - return true; + return LFX_SUCCESS; } -bool LogiLedSaveLightingForKey(LogiLed::KeyName keyName) +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightColor(const unsigned int, const unsigned int, PLFX_COLOR const) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedSaveLightingForKey called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedRestoreLightingForKey(LogiLed::KeyName keyName) +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightColor(const unsigned int, const unsigned int, const PLFX_COLOR) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedRestoreLightingForKey called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedFlashSingleKey(LogiLed::KeyName keyName, int redPercentage, int greenPercentage, int bluePercentage, int msDuration, int msInterval) +FN_DECLSPEC LFX_RESULT STDCALL LFX_Light(const unsigned int, const unsigned int) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedFlashSingleKey called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedPulseSingleKey(LogiLed::KeyName keyName, int startRedPercentage, int startGreenPercentage, int startBluePercentage, int finishRedPercentage, int finishGreenPercentage, int finishBluePercentage, int msDuration, bool isInfinite) +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightActionColor(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedPulseSingleKey called\n"; - myfile.close(); - } - - return true; + return LFX_SUCCESS; } -bool LogiLedStopEffectsOnKey(LogiLed::KeyName keyName) -{ - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedStopEffectsOnKey called\n"; - myfile.close(); - } - - return true; +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightActionColorEx(const unsigned int, const unsigned int, const unsigned int, const PLFX_COLOR, const PLFX_COLOR) +{ + return LFX_SUCCESS; } -void LogiLedShutdown() +FN_DECLSPEC LFX_RESULT STDCALL LFX_ActionColor(const unsigned int, const unsigned int, const unsigned int) { - if (mustLog) - { - ofstream myfile; - myfile.open("log.txt", ios::out | ios::app); - myfile << "LogiLedShutdown called\n"; - myfile.close(); - } - - g_hasInitialised = false; + return LFX_SUCCESS; +} + +FN_DECLSPEC LFX_RESULT STDCALL LFX_ActionColorEx(const unsigned int, const unsigned int, const unsigned int, const unsigned int) +{ + return LFX_SUCCESS; +} + +FN_DECLSPEC LFX_RESULT STDCALL LFX_SetTiming(const int) +{ + return LFX_SUCCESS; +} + +FN_DECLSPEC LFX_RESULT STDCALL LFX_GetVersion(char* const, const unsigned int) +{ + return LFX_SUCCESS; }