mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-01-02 10:43:31 +00:00
LFX progress
Update .gitignore
This commit is contained in:
parent
1d174a1aa7
commit
4be324dc69
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,7 @@
|
||||
x64/
|
||||
x86/
|
||||
build/
|
||||
debug/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
@ -191,9 +191,6 @@
|
||||
<HintPath>..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</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">
|
||||
<HintPath>..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
|
||||
@ -22,7 +22,6 @@ namespace Artemis.Managers
|
||||
private readonly EffectManager _effectManager;
|
||||
private readonly ILogger _logger;
|
||||
private readonly Timer _loopTimer;
|
||||
private bool _canShowException;
|
||||
|
||||
public LoopManager(ILogger logger, EffectManager effectManager, DeviceManager deviceManager,
|
||||
DebugViewModel debugViewModel)
|
||||
@ -31,7 +30,6 @@ namespace Artemis.Managers
|
||||
_effectManager = effectManager;
|
||||
_deviceManager = deviceManager;
|
||||
_debugViewModel = debugViewModel;
|
||||
_canShowException = true;
|
||||
|
||||
// Setup timers
|
||||
_loopTimer = new Timer(40);
|
||||
|
||||
@ -7,12 +7,10 @@ namespace Artemis.Modules.Games.ProjectCars.Data
|
||||
{
|
||||
public class pCarsAPI_GetData
|
||||
{
|
||||
private static pCarsAPIStruct structCurrent = new pCarsAPIStruct();
|
||||
private static MemoryMappedFile memoryMappedFile;
|
||||
private static GCHandle handle;
|
||||
private static int sharedmemorysize;
|
||||
private static byte[] sharedMemoryReadBuffer;
|
||||
private static bool isSharedMemoryInitialised;
|
||||
|
||||
private static bool InitialiseSharedMemory()
|
||||
{
|
||||
@ -21,11 +19,10 @@ namespace Artemis.Modules.Games.ProjectCars.Data
|
||||
memoryMappedFile = MemoryMappedFile.OpenExisting("$pcars$");
|
||||
sharedmemorysize = Marshal.SizeOf(typeof(pCarsAPIStruct));
|
||||
sharedMemoryReadBuffer = new byte[sharedmemorysize];
|
||||
isSharedMemoryInitialised = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -42,8 +39,8 @@ namespace Artemis.Modules.Games.ProjectCars.Data
|
||||
|
||||
using (var sharedMemoryStreamView = memoryMappedFile.CreateViewStream())
|
||||
{
|
||||
var _SharedMemoryStream = new BinaryReader(sharedMemoryStreamView);
|
||||
sharedMemoryReadBuffer = _SharedMemoryStream.ReadBytes(sharedmemorysize);
|
||||
var sharedMemoryStream = new BinaryReader(sharedMemoryStreamView);
|
||||
sharedMemoryReadBuffer = sharedMemoryStream.ReadBytes(sharedmemorysize);
|
||||
handle = GCHandle.Alloc(sharedMemoryReadBuffer, GCHandleType.Pinned);
|
||||
_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);
|
||||
}
|
||||
catch (Exception ex)
|
||||
catch (Exception)
|
||||
{
|
||||
//return false in the tuple as the read failed
|
||||
return new Tuple<bool, pCarsAPIStruct>(false, _pcarsapistruct);
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
#include "LightFxDevice.h"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
|
||||
LightFxDevice::LightFxDevice()
|
||||
@ -10,3 +10,23 @@ 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;
|
||||
}
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
#pragma once
|
||||
#include "LightFxLight.h"
|
||||
#include <json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
class LightFxDevice
|
||||
{
|
||||
public:
|
||||
LightFxDevice();
|
||||
~LightFxDevice();
|
||||
void SetLightFromInt(int lightIndex, const unsigned colorVal);
|
||||
json GetJson();
|
||||
LightFxLight Lights[128];
|
||||
};
|
||||
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
#include "LightFxLight.h"
|
||||
|
||||
|
||||
|
||||
LightFxLight::LightFxLight()
|
||||
{
|
||||
}
|
||||
@ -10,3 +9,15 @@ 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;
|
||||
}
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
#pragma once
|
||||
#include "includes/LFXDecl.h"
|
||||
#include "json.hpp"
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
class LightFxLight
|
||||
{
|
||||
public:
|
||||
LightFxLight();
|
||||
~LightFxLight();
|
||||
json GetJson();
|
||||
PLFX_COLOR Color;
|
||||
};
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "LightFxState.h"
|
||||
#include "json.hpp"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
LightFxState::LightFxState(char* game)
|
||||
{
|
||||
@ -12,9 +13,16 @@ LightFxState::~LightFxState()
|
||||
{
|
||||
}
|
||||
|
||||
void LightFxState::Update()
|
||||
const char* LightFxState::Update()
|
||||
{
|
||||
// Serialize self
|
||||
|
||||
// Transmit through Pipe
|
||||
json j;
|
||||
j["game"] = Game;
|
||||
j["devices"] = {};
|
||||
for (LightFxDevice device : Devices)
|
||||
{
|
||||
j["devices"].push_back(device.GetJson());
|
||||
}
|
||||
|
||||
std::string s = j.dump();
|
||||
return s.c_str();
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ class LightFxState
|
||||
public:
|
||||
LightFxState(char* game);
|
||||
~LightFxState();
|
||||
void Update();
|
||||
const char* Update();
|
||||
char* Game;
|
||||
LightFxDevice Devices[5];
|
||||
};
|
||||
|
||||
@ -25,7 +25,7 @@ BOOL WINAPI DllMain(HINSTANCE hInst, DWORD fdwReason, LPVOID)
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_ATTACH)
|
||||
{
|
||||
lightFxState = new LightFxState(GetGame());
|
||||
lightFxState = new LightFxState("Payday2");
|
||||
FILELog::ReportingLevel() = logDEBUG1;
|
||||
FILE* log_fd = fopen("log.txt", "w");
|
||||
Output2FILE::Stream() = log_fd;
|
||||
@ -75,7 +75,8 @@ FN_DECLSPEC LFX_RESULT STDCALL LFX_Update()
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_Update()";
|
||||
|
||||
lightFxState->Update();
|
||||
const char* jsonString = lightFxState->Update();
|
||||
FILE_LOG(logDEBUG1) << "JSON: " << jsonString;
|
||||
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)
|
||||
{
|
||||
FILE_LOG(logDEBUG1) << "Called LFX_Light()";
|
||||
|
||||
for (LightFxDevice device : lightFxState->Devices)
|
||||
{
|
||||
device.SetLightFromInt(0, colorVal);
|
||||
}
|
||||
return LFX_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
12201
Artemis/LightFX2Artemis/includes/json.hpp
Normal file
12201
Artemis/LightFX2Artemis/includes/json.hpp
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user