1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-31 09:43:46 +00:00

LFX progress

Update .gitignore
This commit is contained in:
SpoinkyNL 2016-12-20 20:20:47 +01:00
parent 1d174a1aa7
commit 4be324dc69
13 changed files with 12438 additions and 192 deletions

1
.gitignore vendored
View File

@ -15,6 +15,7 @@
x64/ x64/
x86/ x86/
build/ build/
debug/
bld/ bld/
[Bb]in/ [Bb]in/
[Oo]bj/ [Oo]bj/

View File

@ -191,9 +191,6 @@
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll</HintPath> <HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL"> <Reference Include="Mono.Cecil, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll</HintPath> <HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll</HintPath>
<Private>True</Private> <Private>True</Private>

View File

@ -22,7 +22,6 @@ namespace Artemis.Managers
private readonly EffectManager _effectManager; private readonly EffectManager _effectManager;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly Timer _loopTimer; private readonly Timer _loopTimer;
private bool _canShowException;
public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager, public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager,
DebugViewModel debugViewModel) DebugViewModel debugViewModel)
@ -31,7 +30,6 @@ namespace Artemis.Managers
_effectManager = effectManager; _effectManager = effectManager;
_deviceManager = deviceManager; _deviceManager = deviceManager;
_debugViewModel = debugViewModel; _debugViewModel = debugViewModel;
_canShowException = true;
// Setup timers // Setup timers
_loopTimer = new Timer(40); _loopTimer = new Timer(40);

View File

@ -7,12 +7,10 @@ namespace Artemis.Modules.Games.ProjectCars.Data
{ {
public class pCarsAPI_GetData public class pCarsAPI_GetData
{ {
private static pCarsAPIStruct structCurrent = new pCarsAPIStruct();
private static MemoryMappedFile memoryMappedFile; private static MemoryMappedFile memoryMappedFile;
private static GCHandle handle; private static GCHandle handle;
private static int sharedmemorysize; private static int sharedmemorysize;
private static byte[] sharedMemoryReadBuffer; private static byte[] sharedMemoryReadBuffer;
private static bool isSharedMemoryInitialised;
private static bool InitialiseSharedMemory() private static bool InitialiseSharedMemory()
{ {
@ -21,11 +19,10 @@ namespace Artemis.Modules.Games.ProjectCars.Data
memoryMappedFile = MemoryMappedFile.OpenExisting("$pcars$"); memoryMappedFile = MemoryMappedFile.OpenExisting("$pcars$");
sharedmemorysize = Marshal.SizeOf(typeof(pCarsAPIStruct)); sharedmemorysize = Marshal.SizeOf(typeof(pCarsAPIStruct));
sharedMemoryReadBuffer = new byte[sharedmemorysize]; sharedMemoryReadBuffer = new byte[sharedmemorysize];
isSharedMemoryInitialised = true;
return true; return true;
} }
catch (Exception ex) catch (Exception)
{ {
return false; return false;
} }
@ -42,8 +39,8 @@ namespace Artemis.Modules.Games.ProjectCars.Data
using (var sharedMemoryStreamView = memoryMappedFile.CreateViewStream()) using (var sharedMemoryStreamView = memoryMappedFile.CreateViewStream())
{ {
var _SharedMemoryStream = new BinaryReader(sharedMemoryStreamView); var sharedMemoryStream = new BinaryReader(sharedMemoryStreamView);
sharedMemoryReadBuffer = _SharedMemoryStream.ReadBytes(sharedmemorysize); sharedMemoryReadBuffer = sharedMemoryStream.ReadBytes(sharedmemorysize);
handle = GCHandle.Alloc(sharedMemoryReadBuffer, GCHandleType.Pinned); handle = GCHandle.Alloc(sharedMemoryReadBuffer, GCHandleType.Pinned);
_pcarsapistruct = _pcarsapistruct =
(pCarsAPIStruct) Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(pCarsAPIStruct)); (pCarsAPIStruct) Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(pCarsAPIStruct));
@ -52,7 +49,7 @@ namespace Artemis.Modules.Games.ProjectCars.Data
return new Tuple<bool, pCarsAPIStruct>(true, _pcarsapistruct); return new Tuple<bool, pCarsAPIStruct>(true, _pcarsapistruct);
} }
catch (Exception ex) catch (Exception)
{ {
//return false in the tuple as the read failed //return false in the tuple as the read failed
return new Tuple<bool, pCarsAPIStruct>(false, _pcarsapistruct); return new Tuple<bool, pCarsAPIStruct>(false, _pcarsapistruct);

View File

@ -26,7 +26,7 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>

View File

@ -1,5 +1,5 @@
#include "LightFxDevice.h" #include "LightFxDevice.h"
using json = nlohmann::json;
LightFxDevice::LightFxDevice() LightFxDevice::LightFxDevice()
@ -10,3 +10,23 @@ LightFxDevice::LightFxDevice()
LightFxDevice::~LightFxDevice() LightFxDevice::~LightFxDevice()
{ {
} }
void LightFxDevice::SetLightFromInt(int lightIndex, const unsigned colorVal)
{
Lights[lightIndex].Color->brightness = (colorVal >> 24) & 0xFF;
Lights[lightIndex].Color->red = (colorVal >> 16) & 0xFF;
Lights[lightIndex].Color->green = (colorVal >> 8) & 0xFF;
Lights[lightIndex].Color->blue = colorVal & 0xFF;
}
json LightFxDevice::GetJson()
{
json j;
j["lights"] = {};
for (LightFxLight light : Lights)
{
j["lights"].push_back(light.GetJson());
}
return j;
}

View File

@ -1,11 +1,15 @@
#pragma once #pragma once
#include "LightFxLight.h" #include "LightFxLight.h"
#include <json.hpp>
using json = nlohmann::json;
class LightFxDevice class LightFxDevice
{ {
public: public:
LightFxDevice(); LightFxDevice();
~LightFxDevice(); ~LightFxDevice();
void SetLightFromInt(int lightIndex, const unsigned colorVal);
json GetJson();
LightFxLight Lights[128]; LightFxLight Lights[128];
}; };

View File

@ -1,7 +1,6 @@
#include "LightFxLight.h" #include "LightFxLight.h"
LightFxLight::LightFxLight() LightFxLight::LightFxLight()
{ {
} }
@ -10,3 +9,15 @@ LightFxLight::LightFxLight()
LightFxLight::~LightFxLight() LightFxLight::~LightFxLight()
{ {
} }
json LightFxLight::GetJson()
{
json j;
j["color"] = {
{"red", Color->red},
{"green", Color->green},
{"blue", Color->blue},
{"brightness", Color->brightness}
};
return j;
}

View File

@ -1,11 +1,14 @@
#pragma once #pragma once
#include "includes/LFXDecl.h" #include "includes/LFXDecl.h"
#include "json.hpp"
using json = nlohmann::json;
class LightFxLight class LightFxLight
{ {
public: public:
LightFxLight(); LightFxLight();
~LightFxLight(); ~LightFxLight();
json GetJson();
PLFX_COLOR Color; PLFX_COLOR Color;
}; };

View File

@ -1,6 +1,7 @@
#include "LightFxState.h" #include "LightFxState.h"
#include "json.hpp"
using json = nlohmann::json;
LightFxState::LightFxState(char* game) LightFxState::LightFxState(char* game)
{ {
@ -12,9 +13,16 @@ LightFxState::~LightFxState()
{ {
} }
void LightFxState::Update() const char* LightFxState::Update()
{ {
// Serialize self json j;
j["game"] = Game;
j["devices"] = {};
for (LightFxDevice device : Devices)
{
j["devices"].push_back(device.GetJson());
}
// Transmit through Pipe std::string s = j.dump();
return s.c_str();
} }

View File

@ -6,7 +6,7 @@ class LightFxState
public: public:
LightFxState(char* game); LightFxState(char* game);
~LightFxState(); ~LightFxState();
void Update(); const char* Update();
char* Game; char* Game;
LightFxDevice Devices[5]; LightFxDevice Devices[5];
}; };

View File

@ -25,7 +25,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID)
{ {
if (fdwReason == DLL_PROCESS_ATTACH) if (fdwReason == DLL_PROCESS_ATTACH)
{ {
lightFxState = new LightFxState(GetGame()); lightFxState = new LightFxState("Payday2");
FILELog::ReportingLevel() = logDEBUG1; FILELog::ReportingLevel() = logDEBUG1;
FILE* log_fd = fopen("log.txt", "w"); FILE* log_fd = fopen("log.txt", "w");
Output2FILE::Stream() = log_fd; Output2FILE::Stream() = log_fd;
@ -75,7 +75,8 @@ FN_DECLSPEC LFX_RESULT STDCALL LFX_Update()
{ {
FILE_LOG(logDEBUG1) << "Called LFX_Update()"; FILE_LOG(logDEBUG1) << "Called LFX_Update()";
lightFxState->Update(); const char* jsonString = lightFxState->Update();
FILE_LOG(logDEBUG1) << "JSON: " << jsonString;
return LFX_SUCCESS; return LFX_SUCCESS;
} }
@ -147,7 +148,7 @@ FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightLocation(const unsigned int devIndex,
{ {
FILE_LOG(logDEBUG1) << "Called LFX_GetLightLocation()"; FILE_LOG(logDEBUG1) << "Called LFX_GetLightLocation()";
*lightLoc = LFX_POSITION{ 0,0,0 }; *lightLoc = LFX_POSITION{0,0,0};
return LFX_SUCCESS; return LFX_SUCCESS;
} }
@ -170,6 +171,11 @@ FN_DECLSPEC LFX_RESULT STDCALL LFX_SetLightColor(const unsigned int devIndex, co
FN_DECLSPEC LFX_RESULT STDCALL LFX_Light(const unsigned int locationMask, const unsigned int colorVal) FN_DECLSPEC LFX_RESULT STDCALL LFX_Light(const unsigned int locationMask, const unsigned int colorVal)
{ {
FILE_LOG(logDEBUG1) << "Called LFX_Light()"; FILE_LOG(logDEBUG1) << "Called LFX_Light()";
for (LightFxDevice device : lightFxState->Devices)
{
device.SetLightFromInt(0, colorVal);
}
return LFX_SUCCESS; return LFX_SUCCESS;
} }

File diff suppressed because it is too large Load Diff