diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj
index 3a0358555..96489d3c6 100644
--- a/Artemis/Artemis/Artemis.csproj
+++ b/Artemis/Artemis/Artemis.csproj
@@ -38,8 +38,8 @@
https://github.com/SpoinkyNL/Artemis/wiki/Frequently-Asked-Questions-%28FAQ%29
Artemis
Artemis
- 0
- 1.2.0.0
+ 1
+ 1.2.0.1
false
true
true
@@ -471,7 +471,7 @@
-
+
@@ -480,9 +480,7 @@
-
-
-
+
diff --git a/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs b/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs
index 32d9cc77d..8ad21c937 100644
--- a/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs
+++ b/Artemis/Artemis/DeviceProviders/Logitech/LogitechKeyboard.cs
@@ -3,7 +3,7 @@ using System.Threading;
using System.Windows;
using Artemis.DeviceProviders.Logitech.Utilities;
using Artemis.Utilities;
-using Artemis.Utilities.LogitechDll;
+using Artemis.Utilities.DataReaders;
using Microsoft.Win32;
namespace Artemis.DeviceProviders.Logitech
@@ -24,7 +24,7 @@ namespace Artemis.DeviceProviders.Logitech
return false;
}
- if (DllManager.RestoreDll())
+ if (DllManager.RestoreLogitechDll())
RestoreDll();
int majorNum = 0, minorNum = 0, buildNum = 0;
diff --git a/Artemis/Artemis/Managers/MainManager.cs b/Artemis/Artemis/Managers/MainManager.cs
index 1d2693896..8b732b637 100644
--- a/Artemis/Artemis/Managers/MainManager.cs
+++ b/Artemis/Artemis/Managers/MainManager.cs
@@ -5,9 +5,9 @@ using System.Timers;
using Artemis.Events;
using Artemis.Models;
using Artemis.Modules.Effects.ProfilePreview;
+using Artemis.Utilities.DataReaders;
using Artemis.Utilities.GameState;
using Artemis.Utilities.Keyboard;
-using Artemis.Utilities.LogitechDll;
using Artemis.ViewModels;
using Caliburn.Micro;
using Ninject;
diff --git a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs
index 3fa5f39fc..618d90564 100644
--- a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs
+++ b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchModel.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading;
using System.Windows.Media;
using Artemis.Events;
using Artemis.Managers;
@@ -8,7 +9,6 @@ using Artemis.Models;
using Artemis.Models.Interfaces;
using Artemis.Profiles.Layers.Models;
using Artemis.Utilities;
-using Artemis.Utilities.DataReaders;
using Caliburn.Micro;
namespace Artemis.Modules.Games.Overwatch
@@ -17,6 +17,7 @@ namespace Artemis.Modules.Games.Overwatch
{
private readonly IEventAggregator _events;
private DateTime _characterChange;
+ private string _lastMessage;
// Using sticky values on these since they can cause flickering
private StickyValue _stickyStatus;
private StickyValue _stickyUltimateReady;
@@ -34,7 +35,6 @@ namespace Artemis.Modules.Games.Overwatch
Enabled = Settings.Enabled;
Initialized = false;
- MmfReader = new MmfReader("overwatchMmf", MainManager.Logger);
LoadOverwatchCharacters();
}
@@ -45,8 +45,6 @@ namespace Artemis.Modules.Games.Overwatch
public List OverwatchCharacters { get; set; }
- public MmfReader MmfReader { get; set; }
-
public int Scale { get; set; }
private void LoadOverwatchCharacters()
@@ -82,15 +80,27 @@ namespace Artemis.Modules.Games.Overwatch
_stickyStatus = new StickyValue(300);
_stickyUltimateReady = new StickyValue(350);
_stickyUltimateUsed = new StickyValue(350);
+ MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
+
Initialized = true;
}
public override void Dispose()
{
+ Initialized = false;
+
_stickyStatus.Dispose();
_stickyUltimateReady.Dispose();
_stickyUltimateUsed.Dispose();
- Initialized = false;
+
+ MainManager.PipeServer.PipeMessage -= PipeServerOnPipeMessage;
+ }
+
+ private void PipeServerOnPipeMessage(string message)
+ {
+
+ _lastMessage = message;
+
}
public override void Update()
@@ -110,7 +120,12 @@ namespace Artemis.Modules.Games.Overwatch
public void UpdateOverwatch()
{
var gameDataModel = (OverwatchDataModel) DataModel;
- var colors = MmfReader.GetColorArray();
+
+ if (_lastMessage == null)
+ return;
+
+ var colors = ParseColorArray(_lastMessage);
+
if (colors == null)
return;
@@ -135,6 +150,41 @@ namespace Artemis.Modules.Games.Overwatch
ParseAbilities(gameDataModel, colors);
}
+ public Color[,] ParseColorArray(string arrayString)
+ {
+ if (string.IsNullOrEmpty(arrayString))
+ return null;
+ var intermediateArray = arrayString.Split('|');
+ if (intermediateArray[0] == "1" || intermediateArray.Length < 2)
+ return null;
+ var array = intermediateArray[1].Substring(1).Split(' ');
+ if (!array.Any())
+ return null;
+
+ try
+ {
+ var colors = new Color[6, 22];
+ foreach (var intermediate in array)
+ {
+ if (intermediate.Length > 16)
+ continue;
+
+ // Can't parse to a byte directly since it may contain values >254
+ var parts = intermediate.Split(',').Select(int.Parse).ToArray();
+ if (parts[0] >= 5 && parts[1] >= 21)
+ continue;
+
+ colors[parts[0], parts[1]] = Color.FromRgb((byte) parts[2], (byte) parts[3], (byte) parts[4]);
+ }
+ return colors;
+ }
+ catch (FormatException e)
+ {
+ MainManager.Logger.Trace(e, "Failed to parse to color array");
+ return null;
+ }
+ }
+
private void ParseGameSate(OverwatchDataModel gameDataModel, Color[,] colors)
{
if (_ultimateUsed.AddSeconds(5) >= DateTime.Now)
diff --git a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs
index 494e60558..c02fd90a6 100644
--- a/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs
+++ b/Artemis/Artemis/Modules/Games/Overwatch/OverwatchViewModel.cs
@@ -1,9 +1,8 @@
-using System;
-using System.IO;
+using System.IO;
using System.Windows.Forms;
using Artemis.InjectionFactories;
using Artemis.Managers;
-using Artemis.Properties;
+using Artemis.Utilities.DataReaders;
using Artemis.ViewModels.Abstract;
using Caliburn.Micro;
using Microsoft.Win32;
@@ -72,14 +71,7 @@ namespace Artemis.Modules.Games.Overwatch
return;
}
- try
- {
- File.WriteAllBytes(path + @"\RzChromaSDK64.dll", Resources.RzChromaSDK64);
- }
- catch (Exception e)
- {
- Logger?.Error(e, "Couldn't place Overwatch DLL, Overwatch support won't work.");
- }
+ DllManager.PlaceRazerDll(path);
}
}
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs
index a817bd567..8f7cdb600 100644
--- a/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs
+++ b/Artemis/Artemis/Modules/Games/TheDivision/TheDivisionModel.cs
@@ -5,7 +5,7 @@ using Artemis.Managers;
using Artemis.Models;
using Artemis.Profiles.Layers.Models;
using Artemis.Utilities;
-using Artemis.Utilities.LogitechDll;
+using Artemis.Utilities.DataReaders;
namespace Artemis.Modules.Games.TheDivision
{
@@ -34,11 +34,13 @@ namespace Artemis.Modules.Games.TheDivision
Task.Factory.StartNew(() =>
{
Thread.Sleep(2000);
- DllManager.RestoreDll();
+ DllManager.RestoreLogitechDll();
});
_stickyAmmo.Dispose();
_stickyHp.Dispose();
+
+ MainManager.PipeServer.PipeMessage -= PipeServerOnPipeMessage;
}
public override void Enable()
@@ -48,7 +50,7 @@ namespace Artemis.Modules.Games.TheDivision
_stickyAmmo = new StickyValue(200);
_stickyHp = new StickyValue(200);
- DllManager.PlaceDll();
+ DllManager.PlaceLogitechDll();
MainManager.PipeServer.PipeMessage += PipeServerOnPipeMessage;
Initialized = true;
diff --git a/Artemis/Artemis/Resources/RzChromaSDK64.dll b/Artemis/Artemis/Resources/RzChromaSDK64.dll
index 12fb41954..4ffde6f3e 100644
Binary files a/Artemis/Artemis/Resources/RzChromaSDK64.dll and b/Artemis/Artemis/Resources/RzChromaSDK64.dll differ
diff --git a/Artemis/Artemis/Utilities/LogitechDll/DllManager.cs b/Artemis/Artemis/Utilities/DataReaders/DllManager.cs
similarity index 78%
rename from Artemis/Artemis/Utilities/LogitechDll/DllManager.cs
rename to Artemis/Artemis/Utilities/DataReaders/DllManager.cs
index 2387e1695..6f82a3b77 100644
--- a/Artemis/Artemis/Utilities/LogitechDll/DllManager.cs
+++ b/Artemis/Artemis/Utilities/DataReaders/DllManager.cs
@@ -1,91 +1,116 @@
-using System;
-using System.IO;
-using Artemis.Properties;
-using Microsoft.Win32;
-
-namespace Artemis.Utilities.LogitechDll
-{
- internal static class DllManager
- {
- private const string LogitechPath = @"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\";
-
- public static bool RestoreDll()
- {
- if (!File.Exists(LogitechPath + @"\LogitechLed.dll") || !File.Exists(LogitechPath + @"\artemis.txt"))
- return false;
-
- try
- {
- // Get rid of our own DLL
- File.Delete(LogitechPath + @"\LogitechLed.dll");
-
- // Restore the backup
- if (File.Exists(LogitechPath + @"\LogitechLed.dll.bak"))
- File.Copy(LogitechPath + @"\LogitechLed.dll.bak", LogitechPath + @"\LogitechLed.dll");
-
- File.Delete(LogitechPath + @"\artemis.txt");
-
- return true;
- }
- catch (Exception)
- {
- return false;
- }
- }
-
- public static void PlaceDll()
- {
- if (DllPlaced())
- return;
-
- // Create directory structure, just in case
- Directory.CreateDirectory(LogitechPath + @"");
-
- // Backup the existing DLL
- if (File.Exists(LogitechPath + @"\LogitechLed.dll"))
- {
- if (File.Exists(LogitechPath + @"\LogitechLed.dll.bak"))
- File.Delete(LogitechPath + @"\LogitechLed.dll.bak");
- File.Move(LogitechPath + @"\LogitechLed.dll", LogitechPath + @"\LogitechLed.dll.bak");
- }
-
- // Copy our own DLL in place
- File.WriteAllBytes(LogitechPath + @"\LogitechLED.dll",
- Resources.LogitechLED);
-
- // A token to show the file is placed
- File.Create(LogitechPath + @"\artemis.txt");
-
- // If the user doesn't have a Logitech device, the CLSID will be missing
- // and we should create it ourselves.
- if (!RegistryKeyPlaced())
- PlaceRegistryKey();
- }
-
- public static bool DllPlaced()
- {
- if (!Directory.Exists(LogitechPath + @""))
- return false;
- if (!RegistryKeyPlaced())
- return false;
-
- return File.Exists(LogitechPath + @"\artemis.txt");
- }
-
- private static bool RegistryKeyPlaced()
- {
- var key = Registry
- .LocalMachine.OpenSubKey(
- @"SOFTWARE\Classes\CLSID\{a6519e67-7632-4375-afdf-caa889744403}\ServerBinary");
- return key != null;
- }
-
- private static void PlaceRegistryKey()
- {
- var key = Registry
- .LocalMachine.OpenSubKey(
- @"SOFTWARE\Classes\CLSID\{a6519e67-7632-4375-afdf-caa889744403}\ServerBinary", true);
- key?.SetValue(null, LogitechPath + @"\LogitechLed.dll");
- }
- }
+using System;
+using System.IO;
+using Artemis.Modules.Games.Overwatch;
+using Artemis.Properties;
+using Microsoft.Win32;
+using NLog;
+
+namespace Artemis.Utilities.DataReaders
+{
+ internal static class DllManager
+ {
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+ #region Logitech
+
+ private const string LogitechPath = @"C:\Program Files\Logitech Gaming Software\SDK\LED\x64\";
+
+ public static bool RestoreLogitechDll()
+ {
+ if (!File.Exists(LogitechPath + @"\LogitechLed.dll") || !File.Exists(LogitechPath + @"\artemis.txt"))
+ return false;
+
+ try
+ {
+ // Get rid of our own DLL
+ File.Delete(LogitechPath + @"\LogitechLed.dll");
+
+ // Restore the backup
+ if (File.Exists(LogitechPath + @"\LogitechLed.dll.bak"))
+ File.Copy(LogitechPath + @"\LogitechLed.dll.bak", LogitechPath + @"\LogitechLed.dll");
+
+ File.Delete(LogitechPath + @"\artemis.txt");
+
+ return true;
+ }
+ catch (Exception)
+ {
+ return false;
+ }
+ }
+
+ public static void PlaceLogitechDll()
+ {
+ if (DllPlaced())
+ return;
+
+ // Create directory structure, just in case
+ Directory.CreateDirectory(LogitechPath + @"");
+
+ // Backup the existing DLL
+ if (File.Exists(LogitechPath + @"\LogitechLed.dll"))
+ {
+ if (File.Exists(LogitechPath + @"\LogitechLed.dll.bak"))
+ File.Delete(LogitechPath + @"\LogitechLed.dll.bak");
+ File.Move(LogitechPath + @"\LogitechLed.dll", LogitechPath + @"\LogitechLed.dll.bak");
+ }
+
+ // Copy our own DLL in place
+ File.WriteAllBytes(LogitechPath + @"\LogitechLED.dll",
+ Resources.LogitechLED);
+
+ // A token to show the file is placed
+ File.Create(LogitechPath + @"\artemis.txt");
+
+ // If the user doesn't have a Logitech device, the CLSID will be missing
+ // and we should create it ourselves.
+ if (!RegistryKeyPlaced())
+ PlaceRegistryKey();
+ }
+
+ public static bool DllPlaced()
+ {
+ if (!Directory.Exists(LogitechPath + @""))
+ return false;
+ if (!RegistryKeyPlaced())
+ return false;
+
+ return File.Exists(LogitechPath + @"\artemis.txt");
+ }
+
+ private static bool RegistryKeyPlaced()
+ {
+ var key = Registry
+ .LocalMachine.OpenSubKey(
+ @"SOFTWARE\Classes\CLSID\{a6519e67-7632-4375-afdf-caa889744403}\ServerBinary");
+ return key != null;
+ }
+
+ private static void PlaceRegistryKey()
+ {
+ var key = Registry
+ .LocalMachine.OpenSubKey(
+ @"SOFTWARE\Classes\CLSID\{a6519e67-7632-4375-afdf-caa889744403}\ServerBinary", true);
+ key?.SetValue(null, LogitechPath + @"\LogitechLed.dll");
+ }
+
+ #endregion
+
+ #region Razer
+
+ public static void PlaceRazerDll(string path)
+ {
+ try
+ {
+ File.WriteAllBytes(path + @"\RzChromaSDK64.dll", Resources.RzChromaSDK64);
+ Logger.Debug("Successfully placed Razer DLL in {0}", path);
+ }
+ catch (Exception e)
+ {
+ Logger.Error(e, "Couldn't place Razer DLL in {0}", path);
+ }
+ }
+
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Utilities/DataReaders/MmfReader.cs b/Artemis/Artemis/Utilities/DataReaders/MmfReader.cs
deleted file mode 100644
index 51c0aaf57..000000000
--- a/Artemis/Artemis/Utilities/DataReaders/MmfReader.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System;
-using System.IO;
-using System.IO.MemoryMappedFiles;
-using System.Linq;
-using System.Text;
-using System.Windows.Media;
-using Ninject.Extensions.Logging;
-
-namespace Artemis.Utilities.DataReaders
-{
- ///
- /// A helper class for reading memory managed files
- ///
- public class MmfReader
- {
- private readonly ILogger _logger;
-
- public MmfReader(string mmfName, ILogger logger)
- {
- _logger = logger;
- MmfName = mmfName;
- }
-
- public string MmfName { get; set; }
-
- ///
- /// Turns the MMF into an color array
- ///
- ///
- public Color[,] GetColorArray()
- {
- var mffString = ReadMmf(MmfName);
- if (string.IsNullOrEmpty(mffString))
- return null;
- var intermediateArray = mffString.Split('|');
- if (intermediateArray[0] == "1" || intermediateArray.Length < 2)
- return null;
- var array = intermediateArray[1].Substring(1).Split(' ');
- if (!array.Any())
- return null;
-
- try
- {
- var colors = new Color[6, 22];
- foreach (var intermediate in array)
- {
- if (intermediate.Length > 16)
- continue;
-
- // Can't parse to a byte directly since it may contain values >254
- var parts = intermediate.Split(',').Select(int.Parse).ToArray();
- if (parts[0] >= 5 && parts[1] >= 21)
- continue;
-
- colors[parts[0], parts[1]] = Color.FromRgb((byte) parts[2], (byte) parts[3], (byte) parts[4]);
- }
- return colors;
- }
- catch (FormatException e)
- {
- _logger.Trace(e, "Failed to parse to color array");
- return null;
- }
- }
-
- ///
- /// Reads the contents of the given MFF into a string
- ///
- ///
- ///
- private string ReadMmf(string fileName)
- {
- try
- {
- using (var mmf = MemoryMappedFile.OpenExisting(fileName))
- {
- using (var stream = mmf.CreateViewStream())
- {
- using (var binReader = new BinaryReader(stream))
- {
- var allBytes = binReader.ReadBytes((int) stream.Length);
- return Encoding.UTF8.GetString(allBytes, 0, allBytes.Length);
- }
- }
- }
- }
- catch (FileNotFoundException e)
- {
- _logger.Trace(e, "Failed to read mff");
- return null;
- //ignored
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Utilities/LogitechDll/PipeServer.cs b/Artemis/Artemis/Utilities/DataReaders/PipeServer.cs
similarity index 93%
rename from Artemis/Artemis/Utilities/LogitechDll/PipeServer.cs
rename to Artemis/Artemis/Utilities/DataReaders/PipeServer.cs
index 3958c5040..6cd907c3d 100644
--- a/Artemis/Artemis/Utilities/LogitechDll/PipeServer.cs
+++ b/Artemis/Artemis/Utilities/DataReaders/PipeServer.cs
@@ -1,131 +1,131 @@
-using System;
-using System.Diagnostics;
-using System.IO.Pipes;
-using System.Security.AccessControl;
-using System.Security.Principal;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Artemis.Utilities.LogitechDll
-{
- // Delegate for passing received message back to caller
- public delegate void DelegateMessage(string reply);
-
- public class PipeServer
- {
- private string _pipeName;
-
- public bool Running { get; set; }
- public event DelegateMessage PipeMessage;
-
- public void Start(string pipeName)
- {
- Running = true;
- _pipeName = pipeName;
- var task = new Task(PipeLoop);
- task.Start();
- }
-
- public void Stop()
- {
- Running = false;
- }
-
- private void PipeLoop()
- {
- try
- {
- var security = new PipeSecurity();
- var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
- security.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl,
- AccessControlType.Allow));
-
- while (Running)
- {
- var namedPipeServerStream = new NamedPipeServerStream(_pipeName, PipeDirection.In, 254,
- PipeTransmissionMode.Byte, PipeOptions.None, 254, 254, security);
-
- namedPipeServerStream.WaitForConnection();
- var buffer = new byte[254];
- namedPipeServerStream.Read(buffer, 0, 254);
- namedPipeServerStream.Close();
-
- var task = new Task(() => HandleMessage(buffer));
- task.Start();
- }
- }
- catch
- {
- // ignored
- }
- }
-
- private void HandleMessage(byte[] buffer)
- {
- var request = Encoding.ASCII.GetString(buffer);
- PipeMessage?.Invoke(request);
- }
-
- public void Listen(string pipeName)
- {
- try
- {
- var security = new PipeSecurity();
- var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
- security.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl, AccessControlType.Allow));
-
- // Set to class level var so we can re-use in the async callback method
- _pipeName = pipeName;
- // Create the new async pipe
- var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.In, 254, PipeTransmissionMode.Byte,
- PipeOptions.Asynchronous, 254, 254, security);
-
- // Wait for a connection
- pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, pipeServer);
- }
- catch (Exception oEx)
- {
- Debug.WriteLine(oEx.Message);
- }
- }
-
- private void WaitForConnectionCallBack(IAsyncResult iar)
- {
- try
- {
- // Get the pipe
- var pipeServer = (NamedPipeServerStream) iar.AsyncState;
- // End waiting for the connection
- pipeServer.EndWaitForConnection(iar);
-
- var buffer = new byte[255];
-
- // Read the incoming message
- pipeServer.Read(buffer, 0, 255);
-
- // Convert byte buffer to string
- var stringData = Encoding.UTF8.GetString(buffer, 0, buffer.Length);
-
- // Pass message back to calling form
- PipeMessage?.Invoke(stringData);
-
- // Kill original sever and create new wait server
- pipeServer.Close();
-
- var security = new PipeSecurity();
- var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
- security.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl, AccessControlType.Allow));
-
- pipeServer = new NamedPipeServerStream(_pipeName, PipeDirection.In, 254, PipeTransmissionMode.Byte,
- PipeOptions.Asynchronous, 254, 254, security);
-
- // Recursively wait for the connection again and again....
- pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, pipeServer);
- }
- catch
- {
- // ignored
- }
- }
- }
+using System;
+using System.Diagnostics;
+using System.IO.Pipes;
+using System.Security.AccessControl;
+using System.Security.Principal;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Artemis.Utilities.DataReaders
+{
+ // Delegate for passing received message back to caller
+ public delegate void DelegateMessage(string reply);
+
+ public class PipeServer
+ {
+ private string _pipeName;
+
+ public bool Running { get; set; }
+ public event DelegateMessage PipeMessage;
+
+ public void Start(string pipeName)
+ {
+ Running = true;
+ _pipeName = pipeName;
+ var task = new Task(PipeLoop);
+ task.Start();
+ }
+
+ public void Stop()
+ {
+ Running = false;
+ }
+
+ private void PipeLoop()
+ {
+ try
+ {
+ var security = new PipeSecurity();
+ var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
+ security.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl,
+ AccessControlType.Allow));
+
+ while (Running)
+ {
+ var namedPipeServerStream = new NamedPipeServerStream(_pipeName, PipeDirection.In, 254,
+ PipeTransmissionMode.Byte, PipeOptions.None, 4096, 4096, security);
+
+ namedPipeServerStream.WaitForConnection();
+ var buffer = new byte[4096];
+ namedPipeServerStream.Read(buffer, 0, 4096);
+ namedPipeServerStream.Close();
+
+ var task = new Task(() => HandleMessage(buffer));
+ task.Start();
+ }
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+
+ private void HandleMessage(byte[] buffer)
+ {
+ var request = Encoding.ASCII.GetString(buffer);
+ PipeMessage?.Invoke(request);
+ }
+
+ public void Listen(string pipeName)
+ {
+ try
+ {
+ var security = new PipeSecurity();
+ var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
+ security.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl, AccessControlType.Allow));
+
+ // Set to class level var so we can re-use in the async callback method
+ _pipeName = pipeName;
+ // Create the new async pipe
+ var pipeServer = new NamedPipeServerStream(pipeName, PipeDirection.In, 254, PipeTransmissionMode.Byte,
+ PipeOptions.Asynchronous, 254, 254, security);
+
+ // Wait for a connection
+ pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, pipeServer);
+ }
+ catch (Exception oEx)
+ {
+ Debug.WriteLine(oEx.Message);
+ }
+ }
+
+ private void WaitForConnectionCallBack(IAsyncResult iar)
+ {
+ try
+ {
+ // Get the pipe
+ var pipeServer = (NamedPipeServerStream) iar.AsyncState;
+ // End waiting for the connection
+ pipeServer.EndWaitForConnection(iar);
+
+ var buffer = new byte[255];
+
+ // Read the incoming message
+ pipeServer.Read(buffer, 0, 255);
+
+ // Convert byte buffer to string
+ var stringData = Encoding.UTF8.GetString(buffer, 0, buffer.Length);
+
+ // Pass message back to calling form
+ PipeMessage?.Invoke(stringData);
+
+ // Kill original sever and create new wait server
+ pipeServer.Close();
+
+ var security = new PipeSecurity();
+ var sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
+ security.AddAccessRule(new PipeAccessRule(sid, PipeAccessRights.FullControl, AccessControlType.Allow));
+
+ pipeServer = new NamedPipeServerStream(_pipeName, PipeDirection.In, 254, PipeTransmissionMode.Byte,
+ PipeOptions.Asynchronous, 254, 254, security);
+
+ // Recursively wait for the connection again and again....
+ pipeServer.BeginWaitForConnection(WaitForConnectionCallBack, pipeServer);
+ }
+ catch
+ {
+ // ignored
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/Artemis/Artemis/Utilities/LogitechDll/NamedPipeServer.cs b/Artemis/Artemis/Utilities/LogitechDll/NamedPipeServer.cs
deleted file mode 100644
index b11bfab08..000000000
--- a/Artemis/Artemis/Utilities/LogitechDll/NamedPipeServer.cs
+++ /dev/null
@@ -1,186 +0,0 @@
-using System;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading;
-using Microsoft.Win32.SafeHandles;
-
-namespace Artemis.Utilities.LogitechDll
-{
- public class NamedPipeServer
- {
- public const uint DUPLEX = 0x00000003;
- public const uint FILE_FLAG_OVERLAPPED = 0x40000000;
-
- public const int BUFFER_SIZE = 100;
- private SafeFileHandle clientHandle;
- public Client clientse;
- public int ClientType;
- private Thread listenThread;
-
- public string pipeName;
-
- public NamedPipeServer(string PName, int Mode)
- {
- pipeName = PName;
- ClientType = Mode; //0 Reading Pipe, 1 Writing Pipe
- }
-
- public event PipeDataReceivedEventHandler PipeDataReceived;
-
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern SafeFileHandle CreateNamedPipe(
- string pipeName,
- uint dwOpenMode,
- uint dwPipeMode,
- uint nMaxInstances,
- uint nOutBufferSize,
- uint nInBufferSize,
- uint nDefaultTimeOut,
- IntPtr lpSecurityAttributes);
-
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern int ConnectNamedPipe(
- SafeFileHandle hNamedPipe,
- IntPtr lpOverlapped);
-
- [DllImport("kernel32.dll", SetLastError = true)]
- public static extern int DisconnectNamedPipe(
- SafeFileHandle hNamedPipe);
-
- public void Start()
- {
- listenThread = new Thread(ListenForClients);
- listenThread.Start();
- }
-
- private void ListenForClients()
- {
- while (true)
- {
- clientHandle = CreateNamedPipe(pipeName, DUPLEX | FILE_FLAG_OVERLAPPED, 0, 255, BUFFER_SIZE, BUFFER_SIZE,
- 0, IntPtr.Zero);
- //could not create named pipe
- if (clientHandle.IsInvalid)
- return;
-
- var success = ConnectNamedPipe(clientHandle, IntPtr.Zero);
-
- //could not connect client
- if (success == 0)
- return;
-
- clientse = new Client();
- clientse.handle = clientHandle;
- clientse.stream = new FileStream(clientse.handle, FileAccess.ReadWrite, BUFFER_SIZE, true);
-
- if (ClientType == 0)
- {
- var readThread = new Thread(Read);
- readThread.Start();
- }
- }
- }
-
- private void Read()
- {
- //Client client = (Client)clientObj;
- //clientse.stream = new FileStream(clientse.handle, FileAccess.ReadWrite, BUFFER_SIZE, true);
- byte[] buffer = null;
- var encoder = new ASCIIEncoding();
-
- while (true)
- {
- var bytesRead = 0;
-
- try
- {
- buffer = new byte[BUFFER_SIZE];
- bytesRead = clientse.stream.Read(buffer, 0, BUFFER_SIZE);
- }
- catch
- {
- //read error has occurred
- break;
- }
-
- //client has disconnected
- if (bytesRead == 0)
- break;
-
- //fire message received event
- //if (this.MessageReceived != null)
- // this.MessageReceived(clientse, encoder.GetString(buffer, 0, bytesRead));
-
- var ReadLength = 0;
- for (var i = 0; i < BUFFER_SIZE; i++)
- {
- if (buffer[i].ToString("x2") != "cc")
- {
- ReadLength++;
- }
- else
- break;
- }
- if (ReadLength > 0)
- {
- var Rc = new byte[ReadLength];
- Buffer.BlockCopy(buffer, 0, Rc, 0, ReadLength);
- OnPipeDataReceived(new PipeDataReceivedEventArgs(encoder.GetString(Rc, 0, ReadLength)));
-
- buffer.Initialize();
- }
- }
-
- //clean up resources
- clientse.stream.Close();
- clientse.handle.Close();
- }
-
- public void SendMessage(string message, Client client)
- {
- var encoder = new ASCIIEncoding();
- var messageBuffer = encoder.GetBytes(message);
-
- if (client.stream.CanWrite)
- {
- client.stream.Write(messageBuffer, 0, messageBuffer.Length);
- client.stream.Flush();
- }
- }
-
- public void StopServer()
- {
- //clean up resources
-
- DisconnectNamedPipe(clientHandle);
-
-
- listenThread.Abort();
- }
-
- private void OnPipeDataReceived(PipeDataReceivedEventArgs e)
- {
- PipeDataReceived?.Invoke(this, e);
- }
-
- public class Client
- {
- public SafeFileHandle handle;
- public FileStream stream;
- }
- }
-
- public delegate void PipeDataReceivedEventHandler(
- object sender, PipeDataReceivedEventArgs pipeDataReceivedEventArgs);
-
- public class PipeDataReceivedEventArgs
- {
- public PipeDataReceivedEventArgs(string data)
- {
- Data = data;
- }
-
- public string Data { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Artemis/Artemis/Utilities/Updater.cs b/Artemis/Artemis/Utilities/Updater.cs
index 587cc74c8..da3bda3bb 100644
--- a/Artemis/Artemis/Utilities/Updater.cs
+++ b/Artemis/Artemis/Utilities/Updater.cs
@@ -15,12 +15,12 @@ namespace Artemis.Utilities
{
public static class Updater
{
- public static int CurrentVersion = 120;
+ public static int CurrentVersion = 1211;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public static async Task CheckForUpdate(MetroDialogService dialogService)
{
- Logger.Info("Checking for updates - Current version: 1.2.0");
+ Logger.Info("Checking for updates - Current version: 1.2.1.1 beta");
if (!General.Default.CheckForUpdates)
return null;
diff --git a/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs b/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
index c4b4223f5..2d1ff3388 100644
--- a/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
+++ b/Artemis/Artemis/ViewModels/SystemTrayViewModel.cs
@@ -132,7 +132,7 @@ namespace Artemis.ViewModels
var dialog = await DialogService.ShowProgressDialog("Enabling keyboard",
"Artemis is still busy trying to enable your last used keyboard. " +
- "Please wait while the progress completes");
+ "Please wait while the process completes");
dialog.SetIndeterminate();
while (MainManager.DeviceManager.ChangingKeyboard)
diff --git a/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml b/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml
index 8a03e5159..8e9f297a4 100644
--- a/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml
+++ b/Artemis/Artemis/Views/Flyouts/FlyoutSettingsView.xaml
@@ -113,7 +113,7 @@
-