diff --git a/.gitignore b/.gitignore
index 0922ac1a4..a6e8a9467 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,6 +15,7 @@
x64/
x86/
build/
+debug/
bld/
[Bb]in/
[Oo]bj/
@@ -190,4 +191,4 @@ FakesAssemblies/
# Visual Studio 6 workspace options file
*.opt
-*.opendb
+*.opendb
diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index b56f3704b..d69864d32 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -191,9 +191,6 @@
..\packages\MahApps.Metro.1.3.0\lib\net45\MahApps.Metro.dll
True
-
- False
-
..\packages\Mono.Cecil.0.9.6.4\lib\net45\Mono.Cecil.dll
True
diff --git a/Artemis/Artemis/Managers/LoopManager.cs b/Artemis/Artemis/Managers/LoopManager.cs
index a7c8e3ccc..b0aefca54 100644
--- a/Artemis/Artemis/Managers/LoopManager.cs
+++ b/Artemis/Artemis/Managers/LoopManager.cs
@@ -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);
diff --git a/Artemis/Artemis/Modules/Games/ProjectCars/Data/_pCarsAPIStruct/pCarsAPI-ReadAPI.cs b/Artemis/Artemis/Modules/Games/ProjectCars/Data/_pCarsAPIStruct/pCarsAPI-ReadAPI.cs
index 1a96c74b5..8412d7363 100644
--- a/Artemis/Artemis/Modules/Games/ProjectCars/Data/_pCarsAPIStruct/pCarsAPI-ReadAPI.cs
+++ b/Artemis/Artemis/Modules/Games/ProjectCars/Data/_pCarsAPIStruct/pCarsAPI-ReadAPI.cs
@@ -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(true, _pcarsapistruct);
}
- catch (Exception ex)
+ catch (Exception)
{
//return false in the tuple as the read failed
return new Tuple(false, _pcarsapistruct);
diff --git a/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj b/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj
index 0c1111fa0..a6252b787 100644
--- a/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj
+++ b/Artemis/LightFX2Artemis/LightFX2Artemis.vcxproj
@@ -1,166 +1,166 @@
-
-
-
-
- Debug
- Win32
-
-
- Release
- Win32
-
-
- Debug
- x64
-
-
- Release
- x64
-
-
-
- {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}
- Win32Proj
- LightFX2Artemis
- 8.1
-
-
-
- Application
- true
- v140
- Unicode
-
-
- Application
- false
- v140
- true
- Unicode
-
-
- DynamicLibrary
- true
- v140
- Unicode
-
-
- DynamicLibrary
- false
- v140
- true
- Unicode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- true
-
-
- true
-
-
- false
-
-
- false
-
-
-
-
-
- Level3
- Disabled
- _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- $(ProjectDir)includes;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- MachineX86
-
-
-
-
-
-
- Level3
- Disabled
- _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
- $(ProjectDir)includes;%(AdditionalIncludeDirectories)
-
-
- Console
- true
- true
- true
- MachineX86
-
-
-
-
- Level3
-
-
- MaxSpeed
- true
- true
- _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
- true
-
-
- Console
- true
- true
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ Debug
+ Win32
+
+
+ Release
+ Win32
+
+
+ Debug
+ x64
+
+
+ Release
+ x64
+
+
+
+ {1A349CF5-2008-41E8-AC13-874CBBCDFA0A}
+ Win32Proj
+ LightFX2Artemis
+ 8.1
+
+
+
+ DynamicLibrary
+ true
+ v140
+ Unicode
+
+
+ Application
+ false
+ v140
+ true
+ Unicode
+
+
+ DynamicLibrary
+ true
+ v140
+ Unicode
+
+
+ DynamicLibrary
+ false
+ v140
+ true
+ Unicode
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+
+
+ Level3
+ Disabled
+ _CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ $(ProjectDir)includes;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ MachineX86
+
+
+
+
+
+
+ Level3
+ Disabled
+ _CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _CRT_SECURE_NO_WARNINGS;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+ $(ProjectDir)includes;%(AdditionalIncludeDirectories)
+
+
+ Console
+ true
+ true
+ true
+ MachineX86
+
+
+
+
+ Level3
+
+
+ MaxSpeed
+ true
+ true
+ _CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
+ true
+
+
+ Console
+ true
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Artemis/LightFX2Artemis/LightFxDevice.cpp b/Artemis/LightFX2Artemis/LightFxDevice.cpp
index ba3ecbff0..39e05a86e 100644
--- a/Artemis/LightFX2Artemis/LightFxDevice.cpp
+++ b/Artemis/LightFX2Artemis/LightFxDevice.cpp
@@ -1,12 +1,32 @@
#include "LightFxDevice.h"
-
+using json = nlohmann::json;
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;
+}
diff --git a/Artemis/LightFX2Artemis/LightFxDevice.h b/Artemis/LightFX2Artemis/LightFxDevice.h
index 0c474fad0..9c4817f6d 100644
--- a/Artemis/LightFX2Artemis/LightFxDevice.h
+++ b/Artemis/LightFX2Artemis/LightFxDevice.h
@@ -1,11 +1,15 @@
#pragma once
#include "LightFxLight.h"
+#include
+
+using json = nlohmann::json;
class LightFxDevice
{
public:
LightFxDevice();
~LightFxDevice();
+ void SetLightFromInt(int lightIndex, const unsigned colorVal);
+ json GetJson();
LightFxLight Lights[128];
};
-
diff --git a/Artemis/LightFX2Artemis/LightFxLight.cpp b/Artemis/LightFX2Artemis/LightFxLight.cpp
index dbdfc9ffc..bb3d5fe19 100644
--- a/Artemis/LightFX2Artemis/LightFxLight.cpp
+++ b/Artemis/LightFX2Artemis/LightFxLight.cpp
@@ -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;
+}
diff --git a/Artemis/LightFX2Artemis/LightFxLight.h b/Artemis/LightFX2Artemis/LightFxLight.h
index 057c4f46b..d67adc20e 100644
--- a/Artemis/LightFX2Artemis/LightFxLight.h
+++ b/Artemis/LightFX2Artemis/LightFxLight.h
@@ -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;
};
-
diff --git a/Artemis/LightFX2Artemis/LightFxState.cpp b/Artemis/LightFX2Artemis/LightFxState.cpp
index cde10490c..168f20eb2 100644
--- a/Artemis/LightFX2Artemis/LightFxState.cpp
+++ b/Artemis/LightFX2Artemis/LightFxState.cpp
@@ -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
+ 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();
}
diff --git a/Artemis/LightFX2Artemis/LightFxState.h b/Artemis/LightFX2Artemis/LightFxState.h
index bd0685668..e2381d9b4 100644
--- a/Artemis/LightFX2Artemis/LightFxState.h
+++ b/Artemis/LightFX2Artemis/LightFxState.h
@@ -3,10 +3,10 @@
class LightFxState
{
-public:
+public:
LightFxState(char* game);
~LightFxState();
- void Update();
+ const char* Update();
char* Game;
LightFxDevice Devices[5];
};
diff --git a/Artemis/LightFX2Artemis/Source.cpp b/Artemis/LightFX2Artemis/Source.cpp
index 57b3c5cdf..e248ea176 100644
--- a/Artemis/LightFX2Artemis/Source.cpp
+++ b/Artemis/LightFX2Artemis/Source.cpp
@@ -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;
}
@@ -147,7 +148,7 @@ FN_DECLSPEC LFX_RESULT STDCALL LFX_GetLightLocation(const unsigned int devIndex,
{
FILE_LOG(logDEBUG1) << "Called LFX_GetLightLocation()";
- *lightLoc = LFX_POSITION{ 0,0,0 };
+ *lightLoc = LFX_POSITION{0,0,0};
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;
}
diff --git a/Artemis/LightFX2Artemis/includes/json.hpp b/Artemis/LightFX2Artemis/includes/json.hpp
new file mode 100644
index 000000000..23058bee3
--- /dev/null
+++ b/Artemis/LightFX2Artemis/includes/json.hpp
@@ -0,0 +1,12201 @@
+/*
+ __ _____ _____ _____
+ __| | __| | | | JSON for Modern C++
+| | |__ | | | | | | version 2.0.9
+|_____|_____|_____|_|___| https://github.com/nlohmann/json
+
+Licensed under the MIT License .
+Copyright (c) 2013-2016 Niels Lohmann .
+
+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.
+*/
+
+#ifndef NLOHMANN_JSON_HPP
+#define NLOHMANN_JSON_HPP
+
+#include // all_of, for_each, transform
+#include // array
+#include // assert
+#include // isdigit
+#include // and, not, or
+#include // isfinite, ldexp, signbit
+#include // nullptr_t, ptrdiff_t, size_t
+#include // int64_t, uint64_t
+#include // strtod, strtof, strtold, strtoul
+#include // strlen
+#include // function, hash, less
+#include // initializer_list
+#include // setw
+#include // istream, ostream
+#include // advance, begin, bidirectional_iterator_tag, distance, end, inserter, iterator, iterator_traits, next, random_access_iterator_tag, reverse_iterator
+#include // numeric_limits
+#include // locale
+#include