diff --git a/HandheldCompanion.sln b/HandheldCompanion.sln
index 037936fb8..5025c0256 100644
--- a/HandheldCompanion.sln
+++ b/HandheldCompanion.sln
@@ -10,6 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HandheldCompanion", "HandheldCompanion\HandheldCompanion.csproj", "{AD4B9060-93FE-4FD2-B64D-4D31EABC7C4D}"
ProjectSection(ProjectDependencies) = postProject
+ {430DD98B-FF67-42A2-9996-D2F90369E625} = {430DD98B-FF67-42A2-9996-D2F90369E625}
{F7283783-81EF-4CD2-BD86-598FE193C11F} = {F7283783-81EF-4CD2-BD86-598FE193C11F}
EndProjectSection
EndProject
@@ -20,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "steam-hidapi.net", "steam-h
{9B860078-9AD1-45DD-8F85-E6D806E5DC9B} = {9B860078-9AD1-45DD-8F85-E6D806E5DC9B}
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared", "Shared\Shared.csproj", "{430DD98B-FF67-42A2-9996-D2F90369E625}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -52,6 +55,14 @@ Global
{F7283783-81EF-4CD2-BD86-598FE193C11F}.Release|Any CPU.Build.0 = Release|Any CPU
{F7283783-81EF-4CD2-BD86-598FE193C11F}.Release|x64.ActiveCfg = Release|x64
{F7283783-81EF-4CD2-BD86-598FE193C11F}.Release|x64.Build.0 = Release|x64
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Debug|x64.Build.0 = Debug|Any CPU
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Release|Any CPU.Build.0 = Release|Any CPU
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Release|x64.ActiveCfg = Release|Any CPU
+ {430DD98B-FF67-42A2-9996-D2F90369E625}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/HandheldCompanion/ADLX/ADLXBackend.cs b/HandheldCompanion/ADLX/ADLXBackend.cs
index dd78999c1..6af8a92ea 100644
--- a/HandheldCompanion/ADLX/ADLXBackend.cs
+++ b/HandheldCompanion/ADLX/ADLXBackend.cs
@@ -1,4 +1,7 @@
-using System.Runtime.InteropServices;
+using System;
+using System.Runtime.ExceptionServices;
+using System.Runtime.InteropServices;
+using System.Security;
using System.Text;
namespace HandheldCompanion.ADLX
@@ -70,20 +73,17 @@ public enum ADLX_RESULT
ADLX_GPU_INACTIVE /**< @ENG_START_DOX This result indicates that the GPU is inactive. @ENG_END_DOX */
}
- [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool IntializeAdlx();
- [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool InitializeAdlxWithIncompatibleDriver();
+ [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] private static extern bool IntializeAdlx();
+ [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] private static extern bool InitializeAdlxWithIncompatibleDriver();
[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool CloseAdlx();
[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern ADLX_RESULT GetNumberOfDisplays(ref int displayNum);
- [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
- public static extern ADLX_RESULT GetDisplayName(int idx, StringBuilder dispName, int nameLength);
+ [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)] public static extern ADLX_RESULT GetDisplayName(int idx, StringBuilder dispName, int nameLength);
- [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)]
- public static extern ADLX_RESULT GetDisplayGPU(int idx, ref int UniqueId);
+ [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern ADLX_RESULT GetDisplayGPU(int idx, ref int UniqueId);
- [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)]
- public static extern ADLX_RESULT GetGPUIndex(int UniqueId, ref int idx);
+ [DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern ADLX_RESULT GetGPUIndex(int UniqueId, ref int idx);
[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool HasRSRSupport();
[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool GetRSR();
@@ -128,5 +128,20 @@ public enum ADLX_RESULT
[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool SetScalingMode(int displayIdx, int mode);
[DllImport(ADLX_Wrapper, CallingConvention = CallingConvention.Cdecl)] public static extern bool GetAdlxTelemetry(int GPU, ref AdlxTelemetryData adlxTelemetryData);
+
+ static ADLXBackend() { }
+
+ [HandleProcessCorruptedStateExceptions]
+ [SecurityCritical]
+ public static bool SafeIntializeAdlx()
+ {
+ try
+ {
+ return IntializeAdlx();
+ }
+ catch (Exception ex) { }
+
+ return false;
+ }
}
}
diff --git a/HandheldCompanion/ADLX_Wrapper.dll b/HandheldCompanion/ADLX_Wrapper.dll
index a2d2a107a..c359826ed 100644
Binary files a/HandheldCompanion/ADLX_Wrapper.dll and b/HandheldCompanion/ADLX_Wrapper.dll differ
diff --git a/HandheldCompanion/Actions/IActions.cs b/HandheldCompanion/Actions/IActions.cs
index 14a030183..7ec8adefd 100644
--- a/HandheldCompanion/Actions/IActions.cs
+++ b/HandheldCompanion/Actions/IActions.cs
@@ -145,7 +145,7 @@ public virtual void Execute(ButtonFlags button, bool value, ShiftSlot shiftSlot
value = true;
}
- switch(ShiftSlot)
+ switch (ShiftSlot)
{
case ShiftSlot.None:
if (shiftSlot != ShiftSlot.None)
diff --git a/HandheldCompanion/Actions/ShiftActions.cs b/HandheldCompanion/Actions/ShiftActions.cs
index 3a3c05eac..2e1415328 100644
--- a/HandheldCompanion/Actions/ShiftActions.cs
+++ b/HandheldCompanion/Actions/ShiftActions.cs
@@ -1,9 +1,5 @@
-using HandheldCompanion.Inputs;
-using HandheldCompanion.Simulators;
using System;
using System.ComponentModel;
-using System.Numerics;
-using WindowsInput.Events;
namespace HandheldCompanion.Actions
{
diff --git a/HandheldCompanion/App.config b/HandheldCompanion/App.config
index 69abc7893..b7c89a630 100644
--- a/HandheldCompanion/App.config
+++ b/HandheldCompanion/App.config
@@ -10,6 +10,7 @@
+
diff --git a/HandheldCompanion/App.xaml.cs b/HandheldCompanion/App.xaml.cs
index 16075f643..a14babc15 100644
--- a/HandheldCompanion/App.xaml.cs
+++ b/HandheldCompanion/App.xaml.cs
@@ -1,4 +1,5 @@
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using Sentry;
@@ -44,8 +45,9 @@ protected override void OnStartup(StartupEventArgs args)
string myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
string logDirectory = System.IO.Path.Combine(myDocumentsPath, "HandheldCompanion", "logs");
- // Set the LOG_PATH environment variable
+ // Set environment variables
Environment.SetEnvironmentVariable("LOG_PATH", logDirectory);
+ Environment.SetEnvironmentVariable("COMPlus_legacyCorruptedStateExceptionsPolicy", "1");
// initialize log
LogManager.Initialize("HandheldCompanion");
diff --git a/HandheldCompanion/Controllers/GordonController.cs b/HandheldCompanion/Controllers/GordonController.cs
index dda9cd635..7f709f5d9 100644
--- a/HandheldCompanion/Controllers/GordonController.cs
+++ b/HandheldCompanion/Controllers/GordonController.cs
@@ -2,6 +2,7 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using SharpDX.XInput;
using steam_hidapi.net;
diff --git a/HandheldCompanion/Controllers/IController.cs b/HandheldCompanion/Controllers/IController.cs
index 0bbd038b5..3762de794 100644
--- a/HandheldCompanion/Controllers/IController.cs
+++ b/HandheldCompanion/Controllers/IController.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Misc;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Generic;
diff --git a/HandheldCompanion/Controllers/NeptuneController.cs b/HandheldCompanion/Controllers/NeptuneController.cs
index 2eef237f2..b3f66db1e 100644
--- a/HandheldCompanion/Controllers/NeptuneController.cs
+++ b/HandheldCompanion/Controllers/NeptuneController.cs
@@ -2,6 +2,7 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using SharpDX.XInput;
using steam_hidapi.net;
using steam_hidapi.net.Hid;
diff --git a/HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs b/HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs
index b1529784c..fcf607814 100644
--- a/HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs
+++ b/HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Devices;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Generic;
diff --git a/HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs b/HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs
index c0e1603c2..6c0c3a532 100644
--- a/HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs
+++ b/HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Devices;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Generic;
diff --git a/HandheldCompanion/DSU/DSUServer.cs b/HandheldCompanion/DSU/DSUServer.cs
index 4b40713b2..e565563de 100644
--- a/HandheldCompanion/DSU/DSUServer.cs
+++ b/HandheldCompanion/DSU/DSUServer.cs
@@ -4,6 +4,7 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Generic;
diff --git a/HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs b/HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs
index 10ba8e5c1..d1090a209 100644
--- a/HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs
+++ b/HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Inputs;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HidLibrary;
using System;
using System.Collections.Generic;
diff --git a/HandheldCompanion/Devices/ASUS/AsusACPI.cs b/HandheldCompanion/Devices/ASUS/AsusACPI.cs
index ba1cae58a..a811682d9 100644
--- a/HandheldCompanion/Devices/ASUS/AsusACPI.cs
+++ b/HandheldCompanion/Devices/ASUS/AsusACPI.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Management;
using System.Runtime.InteropServices;
@@ -265,8 +265,6 @@ protected byte[] CallMethod(uint MethodID, byte[] args)
BitConverter.GetBytes((uint)args.Length).CopyTo(acpiBuf, 4);
Array.Copy(args, 0, acpiBuf, 8, args.Length);
- // if (MethodID == DEVS) Debug.WriteLine(BitConverter.ToString(acpiBuf, 0, acpiBuf.Length));
-
Control(CONTROL_CODE, acpiBuf, outBuffer);
return outBuffer;
@@ -474,7 +472,6 @@ public void TUFKeyboardRGB(int mode, System.Drawing.Color color, int speed)
setting[5] = (byte)speed;
DeviceSet(TUF_KB, setting, "TUF RGB");
- //Debug.WriteLine(BitConverter.ToString(setting));
}
public void TUFKeyboardPower(bool awake = true, bool boot = false, bool sleep = false, bool shutdown = false)
diff --git a/HandheldCompanion/Devices/GPD/GPDWin4.cs b/HandheldCompanion/Devices/GPD/GPDWin4.cs
index af2bf1ebd..17350f3e8 100644
--- a/HandheldCompanion/Devices/GPD/GPDWin4.cs
+++ b/HandheldCompanion/Devices/GPD/GPDWin4.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Inputs;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Collections.Generic;
using System.Numerics;
diff --git a/HandheldCompanion/Devices/IDevice.cs b/HandheldCompanion/Devices/IDevice.cs
index fdf1b41a8..60e60f4ef 100644
--- a/HandheldCompanion/Devices/IDevice.cs
+++ b/HandheldCompanion/Devices/IDevice.cs
@@ -4,6 +4,7 @@
using HandheldCompanion.Misc;
using HandheldCompanion.Models;
using HandheldCompanion.Sensors;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HidLibrary;
using Nefarius.Utilities.DeviceManagement.PnP;
diff --git a/HandheldCompanion/Devices/Lenovo/LegionGo.cs b/HandheldCompanion/Devices/Lenovo/LegionGo.cs
index e8f4aeb8d..168431494 100644
--- a/HandheldCompanion/Devices/Lenovo/LegionGo.cs
+++ b/HandheldCompanion/Devices/Lenovo/LegionGo.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Misc;
+using HandheldCompanion.Shared;
using HidLibrary;
using Nefarius.Utilities.DeviceManagement.PnP;
using System;
diff --git a/HandheldCompanion/Devices/MSI/ClawA1M.cs b/HandheldCompanion/Devices/MSI/ClawA1M.cs
index 7d562da3d..21175a797 100644
--- a/HandheldCompanion/Devices/MSI/ClawA1M.cs
+++ b/HandheldCompanion/Devices/MSI/ClawA1M.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HidLibrary;
using Nefarius.Utilities.DeviceManagement.PnP;
diff --git a/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2.cs b/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2.cs
index ef464e448..be8b76b09 100644
--- a/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2.cs
+++ b/HandheldCompanion/Devices/OneXPlayer/OneXPlayer2.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Inputs;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System.Numerics;
using WindowsInput.Events;
diff --git a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs
index ae303daad..a1da43c82 100644
--- a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs
+++ b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Inputs;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System.Collections.Generic;
using System.Numerics;
using WindowsInput.Events;
diff --git a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs
index e56ffab89..42a9f1353 100644
--- a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs
+++ b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Inputs;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System.Numerics;
using WindowsInput.Events;
diff --git a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerOneXFly.cs b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerOneXFly.cs
index 05ac3d99e..01d15709e 100644
--- a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerOneXFly.cs
+++ b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerOneXFly.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Inputs;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HidLibrary;
using System;
using System.Collections.Generic;
@@ -7,9 +7,9 @@
using System.Numerics;
using System.Windows.Media;
using WindowsInput.Events;
-namespace HandheldCompanion.Devices;
using static HandheldCompanion.Utils.DeviceUtils;
-
+
+namespace HandheldCompanion.Devices;
public class OneXPlayerOneXFly : IDevice
{
HidDevice hidDevice;
diff --git a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerX1.cs b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerX1.cs
index 7c1b19f50..870498061 100644
--- a/HandheldCompanion/Devices/OneXPlayer/OneXPlayerX1.cs
+++ b/HandheldCompanion/Devices/OneXPlayer/OneXPlayerX1.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Misc.Threading.Tasks;
using HandheldCompanion.Models;
using HandheldCompanion.Sensors;
+using HandheldCompanion.Shared;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
diff --git a/HandheldCompanion/Devices/Valve/SteamDeck.cs b/HandheldCompanion/Devices/Valve/SteamDeck.cs
index ca0adad1d..68e019dd0 100644
--- a/HandheldCompanion/Devices/Valve/SteamDeck.cs
+++ b/HandheldCompanion/Devices/Valve/SteamDeck.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Linq;
diff --git a/HandheldCompanion/GraphicsProcessingUnit/AMDGPU.cs b/HandheldCompanion/GraphicsProcessingUnit/AMDGPU.cs
index a42b489b2..264702508 100644
--- a/HandheldCompanion/GraphicsProcessingUnit/AMDGPU.cs
+++ b/HandheldCompanion/GraphicsProcessingUnit/AMDGPU.cs
@@ -299,9 +299,7 @@ public AMDGPU(AdapterInformation adapterInformation) : base(adapterInformation)
if (result != ADLX_RESULT.ADLX_OK)
return;
- if (adapterCount == 1)
- displayIdx = 0;
- else
+ if (adapterCount > 1)
{
for (int idx = 0; idx < adapterCount; idx++)
{
@@ -322,6 +320,11 @@ public AMDGPU(AdapterInformation adapterInformation) : base(adapterInformation)
}
}
+ // we couldn't pick a display by its name, pick first
+ // todo: improve me
+ if (displayIdx == -1)
+ displayIdx = 0;
+
if (displayIdx != -1)
{
// get the associated GPU UniqueId
diff --git a/HandheldCompanion/HandheldCompanion.csproj b/HandheldCompanion/HandheldCompanion.csproj
index 879636e82..d37c03e88 100644
--- a/HandheldCompanion/HandheldCompanion.csproj
+++ b/HandheldCompanion/HandheldCompanion.csproj
@@ -204,12 +204,9 @@
-
+
-
-
-
@@ -220,19 +217,11 @@
-
-
-
-
-
-
-
-
@@ -242,6 +231,7 @@
+
@@ -276,9 +266,6 @@
-
- PreserveNewest
-
PreserveNewest
@@ -2371,9 +2358,6 @@
..\Resources\Microsoft.Win32.TaskScheduler.dll
-
- ..\Resources\Nefarius.Utilities.DeviceManagement.dll
-
..\Resources\Nefarius.ViGEm.Client.dll
diff --git a/HandheldCompanion/Helpers/RyzenSMU.cs b/HandheldCompanion/Helpers/RyzenSMU.cs
index 50d28b55f..9a2f89331 100644
--- a/HandheldCompanion/Helpers/RyzenSMU.cs
+++ b/HandheldCompanion/Helpers/RyzenSMU.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Runtime.InteropServices;
using System.Threading;
diff --git a/HandheldCompanion/Helpers/VangoghGPU.cs b/HandheldCompanion/Helpers/VangoghGPU.cs
index 9cf85bdf6..b235ddcf9 100644
--- a/HandheldCompanion/Helpers/VangoghGPU.cs
+++ b/HandheldCompanion/Helpers/VangoghGPU.cs
@@ -1,4 +1,5 @@
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
diff --git a/HandheldCompanion/Localization/StaticExtension.cs b/HandheldCompanion/Localization/StaticExtension.cs
index bffa857c8..ffa77cf56 100644
--- a/HandheldCompanion/Localization/StaticExtension.cs
+++ b/HandheldCompanion/Localization/StaticExtension.cs
@@ -1,7 +1,7 @@
-namespace HandheldCompanion.Localization;
-
+
using System.Windows.Data;
+namespace HandheldCompanion.Localization;
public class StaticExtension : Binding
{
public StaticExtension(string name) : base("[" + name + "]")
diff --git a/HandheldCompanion/Localization/TranslationSource.cs b/HandheldCompanion/Localization/TranslationSource.cs
index 1913b2899..fb25c9dc2 100644
--- a/HandheldCompanion/Localization/TranslationSource.cs
+++ b/HandheldCompanion/Localization/TranslationSource.cs
@@ -1,11 +1,9 @@
-using System.Threading;
-
-namespace HandheldCompanion.Localization;
-
-using System.ComponentModel;
+using System.ComponentModel;
using System.Globalization;
using System.Resources;
+using System.Threading;
+namespace HandheldCompanion.Localization;
public class TranslationSource : INotifyPropertyChanged
{
private static readonly TranslationSource instance = new TranslationSource();
diff --git a/HandheldCompanion/Managers/ControllerManager.cs b/HandheldCompanion/Managers/ControllerManager.cs
index 1f5439e4d..d6fe6c96f 100644
--- a/HandheldCompanion/Managers/ControllerManager.cs
+++ b/HandheldCompanion/Managers/ControllerManager.cs
@@ -4,6 +4,7 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Inputs;
using HandheldCompanion.Platforms;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using Nefarius.Utilities.DeviceManagement.Drivers;
diff --git a/HandheldCompanion/Managers/DeviceManager.cs b/HandheldCompanion/Managers/DeviceManager.cs
index 29f275141..5a09bbccc 100644
--- a/HandheldCompanion/Managers/DeviceManager.cs
+++ b/HandheldCompanion/Managers/DeviceManager.cs
@@ -1,6 +1,7 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Managers.Hid;
using HandheldCompanion.Sensors;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using Microsoft.Win32.SafeHandles;
using Nefarius.Utilities.DeviceManagement.PnP;
@@ -9,7 +10,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
@@ -709,7 +709,6 @@ public static void RefreshDisplayAdapters(bool elapsed = false)
else
{
// added device
- Debug.WriteLine("Adapter {0} was added", adapterInformation.Details.Description);
DisplayAdapterArrived?.Invoke(adapterInformation);
adaptersProcessed.Add(adapterInformation.Details.DeviceIdentifier);
}
@@ -725,7 +724,6 @@ public static void RefreshDisplayAdapters(bool elapsed = false)
{
// removed device
AdapterInformation adapterInformation = displayAdapters[deviceIdentifier];
- Debug.WriteLine("Adapter {0} was removed", adapterInformation.Details.Description);
DisplayAdapterRemoved?.Invoke(adapterInformation);
adaptersProcessed.Add(deviceIdentifier);
}
diff --git a/HandheldCompanion/Managers/DynamicLightingManager.cs b/HandheldCompanion/Managers/DynamicLightingManager.cs
index 2de750b76..d7d1fb568 100644
--- a/HandheldCompanion/Managers/DynamicLightingManager.cs
+++ b/HandheldCompanion/Managers/DynamicLightingManager.cs
@@ -2,6 +2,7 @@
using HandheldCompanion.Managers.Desktop;
using HandheldCompanion.Misc;
using HandheldCompanion.Models;
+using HandheldCompanion.Shared;
using SharpDX;
using SharpDX.Direct3D9;
using System;
diff --git a/HandheldCompanion/Managers/GPUManager.cs b/HandheldCompanion/Managers/GPUManager.cs
index f7cb3497d..71d0e6f15 100644
--- a/HandheldCompanion/Managers/GPUManager.cs
+++ b/HandheldCompanion/Managers/GPUManager.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.GraphicsProcessingUnit;
using HandheldCompanion.IGCL;
using HandheldCompanion.Managers.Desktop;
+using HandheldCompanion.Shared;
using SharpDX.Direct3D9;
using System.Collections.Concurrent;
using System.Linq;
@@ -50,7 +51,7 @@ public static async Task Start()
if (!IsLoaded_ADLX)
{
// try to initialized ADLX
- IsLoaded_ADLX = ADLXBackend.IntializeAdlx();
+ IsLoaded_ADLX = ADLXBackend.SafeIntializeAdlx();
if (IsLoaded_ADLX)
LogManager.LogInformation("ADLX was successfully initialized", "GPUManager");
diff --git a/HandheldCompanion/Managers/HotkeysManager.cs b/HandheldCompanion/Managers/HotkeysManager.cs
index 692492c58..4443b660c 100644
--- a/HandheldCompanion/Managers/HotkeysManager.cs
+++ b/HandheldCompanion/Managers/HotkeysManager.cs
@@ -5,6 +5,7 @@
using HandheldCompanion.Commands.Functions.Performance;
using HandheldCompanion.Commands.Functions.Windows;
using HandheldCompanion.Inputs;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using Newtonsoft.Json;
@@ -24,7 +25,7 @@ public static class HotkeysManager
private static readonly string HotkeysPath;
- private static bool IsInitialized;
+ public static bool IsInitialized;
static HotkeysManager()
{
diff --git a/HandheldCompanion/Managers/InputsManager.cs b/HandheldCompanion/Managers/InputsManager.cs
index 04094b5cd..3e9b62cee 100644
--- a/HandheldCompanion/Managers/InputsManager.cs
+++ b/HandheldCompanion/Managers/InputsManager.cs
@@ -4,6 +4,7 @@
using HandheldCompanion.Controllers;
using HandheldCompanion.Devices;
using HandheldCompanion.Inputs;
+using HandheldCompanion.Shared;
using HandheldCompanion.Simulators;
using PrecisionTiming;
using System;
diff --git a/HandheldCompanion/Managers/LayoutManager.cs b/HandheldCompanion/Managers/LayoutManager.cs
index f86194882..7008daab0 100644
--- a/HandheldCompanion/Managers/LayoutManager.cs
+++ b/HandheldCompanion/Managers/LayoutManager.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers.Desktop;
using HandheldCompanion.Misc;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using Newtonsoft.Json;
@@ -341,7 +342,7 @@ public static ControllerState MapController(ControllerState controllerState)
outputState.ButtonState.Clear();
outputState.AxisState.Clear();
outputState.GyroState = new(controllerState.GyroState.Accelerometer, controllerState.GyroState.Gyroscope);
-
+
// we need to check for shifter(s) first
ShiftSlot shiftSlot = ShiftSlot.None;
foreach (KeyValuePair buttonState in controllerState.ButtonState.State)
@@ -370,7 +371,7 @@ public static ControllerState MapController(ControllerState controllerState)
}
}
}
-
+
foreach (KeyValuePair buttonState in controllerState.ButtonState.State)
{
ButtonFlags button = buttonState.Key;
diff --git a/HandheldCompanion/Managers/MultimediaManager.cs b/HandheldCompanion/Managers/MultimediaManager.cs
index c6256f223..ae3641e54 100644
--- a/HandheldCompanion/Managers/MultimediaManager.cs
+++ b/HandheldCompanion/Managers/MultimediaManager.cs
@@ -1,4 +1,5 @@
using HandheldCompanion.Managers.Desktop;
+using HandheldCompanion.Shared;
using Microsoft.Win32;
using NAudio.CoreAudioApi;
using NAudio.CoreAudioApi.Interfaces;
@@ -59,9 +60,6 @@ public static async Task Start()
if (IsInitialized)
return;
- // force trigger events
- SystemEvents_DisplaySettingsChanged(null, null);
-
// manage brightness watcher events
BrightnessWatcher.EventArrived += onWMIEvent;
BrightnessWatcher.Start();
@@ -70,6 +68,9 @@ public static async Task Start()
SystemEvents.DisplaySettingsChanged += SystemEvents_DisplaySettingsChanged;
SettingsManager.SettingValueChanged += SettingsManager_SettingValueChanged;
+ // raise events
+ SystemEvents_DisplaySettingsChanged(null, null);
+
IsInitialized = true;
Initialized?.Invoke();
@@ -189,7 +190,7 @@ public static string GetAdapterFriendlyName(string DeviceName)
friendlyName = PrimaryDisplay.DeviceName;
PathDisplayTarget? PrimaryTarget = GetDisplayTarget(PrimaryDisplay.DevicePath);
- if (PrimaryTarget is not null)
+ if (PrimaryTarget is not null && !string.IsNullOrEmpty(PrimaryTarget.FriendlyName))
friendlyName = PrimaryTarget.FriendlyName;
}
diff --git a/HandheldCompanion/Managers/OSDManager.cs b/HandheldCompanion/Managers/OSDManager.cs
index abfc87f4a..da7a2f2d1 100644
--- a/HandheldCompanion/Managers/OSDManager.cs
+++ b/HandheldCompanion/Managers/OSDManager.cs
@@ -1,4 +1,5 @@
using HandheldCompanion.GraphicsProcessingUnit;
+using HandheldCompanion.Shared;
using PrecisionTiming;
using RTSSSharedMemoryNET;
using System;
diff --git a/HandheldCompanion/Managers/PerformanceManager.cs b/HandheldCompanion/Managers/PerformanceManager.cs
index e08dfb375..d038e0735 100644
--- a/HandheldCompanion/Managers/PerformanceManager.cs
+++ b/HandheldCompanion/Managers/PerformanceManager.cs
@@ -2,6 +2,7 @@
using HandheldCompanion.GraphicsProcessingUnit;
using HandheldCompanion.Misc;
using HandheldCompanion.Processors;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Linq;
diff --git a/HandheldCompanion/Managers/PlatformManager.cs b/HandheldCompanion/Managers/PlatformManager.cs
index d8e8c92cd..5867f6232 100644
--- a/HandheldCompanion/Managers/PlatformManager.cs
+++ b/HandheldCompanion/Managers/PlatformManager.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Misc;
using HandheldCompanion.Platforms;
+using HandheldCompanion.Shared;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
diff --git a/HandheldCompanion/Managers/PowerProfileManager.cs b/HandheldCompanion/Managers/PowerProfileManager.cs
index a925ddd4b..d245f14f0 100644
--- a/HandheldCompanion/Managers/PowerProfileManager.cs
+++ b/HandheldCompanion/Managers/PowerProfileManager.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Misc;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using Newtonsoft.Json;
diff --git a/HandheldCompanion/Managers/ProcessManager.cs b/HandheldCompanion/Managers/ProcessManager.cs
index 14812f3d4..8934608de 100644
--- a/HandheldCompanion/Managers/ProcessManager.cs
+++ b/HandheldCompanion/Managers/ProcessManager.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Controls;
using HandheldCompanion.Misc;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Concurrent;
diff --git a/HandheldCompanion/Managers/ProfileManager.cs b/HandheldCompanion/Managers/ProfileManager.cs
index 69ac867df..15572260b 100644
--- a/HandheldCompanion/Managers/ProfileManager.cs
+++ b/HandheldCompanion/Managers/ProfileManager.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Misc;
using HandheldCompanion.Properties;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using iNKORE.UI.WPF.Modern.Controls;
diff --git a/HandheldCompanion/Managers/SensorsManager.cs b/HandheldCompanion/Managers/SensorsManager.cs
index 28f054bcc..35e4b6cc6 100644
--- a/HandheldCompanion/Managers/SensorsManager.cs
+++ b/HandheldCompanion/Managers/SensorsManager.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Misc;
using HandheldCompanion.Sensors;
+using HandheldCompanion.Shared;
using HandheldCompanion.Views;
using Nefarius.Utilities.DeviceManagement.PnP;
using System;
diff --git a/HandheldCompanion/Managers/SettingsManager.cs b/HandheldCompanion/Managers/SettingsManager.cs
index 6fd1b646e..491a5f40b 100644
--- a/HandheldCompanion/Managers/SettingsManager.cs
+++ b/HandheldCompanion/Managers/SettingsManager.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Processors;
+using HandheldCompanion.Shared;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
diff --git a/HandheldCompanion/Managers/SystemManager.cs b/HandheldCompanion/Managers/SystemManager.cs
index 18e88c23b..2cbb0343b 100644
--- a/HandheldCompanion/Managers/SystemManager.cs
+++ b/HandheldCompanion/Managers/SystemManager.cs
@@ -1,4 +1,5 @@
-using Microsoft.Win32;
+using HandheldCompanion.Shared;
+using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
diff --git a/HandheldCompanion/Managers/TaskManager.cs b/HandheldCompanion/Managers/TaskManager.cs
index f5b3be70c..4d5ddf868 100644
--- a/HandheldCompanion/Managers/TaskManager.cs
+++ b/HandheldCompanion/Managers/TaskManager.cs
@@ -1,4 +1,5 @@
-using Microsoft.Win32.TaskScheduler;
+using HandheldCompanion.Shared;
+using Microsoft.Win32.TaskScheduler;
using System;
using System.Security.Principal;
diff --git a/HandheldCompanion/Managers/TimerManager.cs b/HandheldCompanion/Managers/TimerManager.cs
index d35ada5a1..34d57ac19 100644
--- a/HandheldCompanion/Managers/TimerManager.cs
+++ b/HandheldCompanion/Managers/TimerManager.cs
@@ -1,4 +1,5 @@
-using PrecisionTiming;
+using HandheldCompanion.Shared;
+using PrecisionTiming;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
diff --git a/HandheldCompanion/Managers/ToastManager.cs b/HandheldCompanion/Managers/ToastManager.cs
index 86a289bf1..113661448 100644
--- a/HandheldCompanion/Managers/ToastManager.cs
+++ b/HandheldCompanion/Managers/ToastManager.cs
@@ -1,4 +1,5 @@
-using Microsoft.Toolkit.Uwp.Notifications;
+using HandheldCompanion.Shared;
+using Microsoft.Toolkit.Uwp.Notifications;
using System;
using System.Collections.Concurrent;
using System.Threading;
diff --git a/HandheldCompanion/Managers/UpdateManager.cs b/HandheldCompanion/Managers/UpdateManager.cs
index a3ecb088a..c24c1c0e7 100644
--- a/HandheldCompanion/Managers/UpdateManager.cs
+++ b/HandheldCompanion/Managers/UpdateManager.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Misc;
using HandheldCompanion.Properties;
+using HandheldCompanion.Shared;
using HandheldCompanion.Views;
using Newtonsoft.Json;
using System;
diff --git a/HandheldCompanion/Managers/VirtualManager.cs b/HandheldCompanion/Managers/VirtualManager.cs
index 83d9b000a..8cd354068 100644
--- a/HandheldCompanion/Managers/VirtualManager.cs
+++ b/HandheldCompanion/Managers/VirtualManager.cs
@@ -1,5 +1,6 @@
using HandheldCompanion.Controllers;
using HandheldCompanion.Helpers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Targets;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
diff --git a/HandheldCompanion/Misc/HidHide.cs b/HandheldCompanion/Misc/HidHide.cs
index a08d647db..328571c1f 100644
--- a/HandheldCompanion/Misc/HidHide.cs
+++ b/HandheldCompanion/Misc/HidHide.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views;
using Nefarius.Drivers.HidHide;
diff --git a/HandheldCompanion/Misc/JoyShockLibrary.cs b/HandheldCompanion/Misc/JoyShockLibrary.cs
index 045894eb9..8f3ffe4f3 100644
--- a/HandheldCompanion/Misc/JoyShockLibrary.cs
+++ b/HandheldCompanion/Misc/JoyShockLibrary.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
diff --git a/HandheldCompanion/Misc/PnPUtil.cs b/HandheldCompanion/Misc/PnPUtil.cs
index 50b90768c..fe5b9ac29 100644
--- a/HandheldCompanion/Misc/PnPUtil.cs
+++ b/HandheldCompanion/Misc/PnPUtil.cs
@@ -70,13 +70,6 @@ public static List GetDevices(string className, string status = "/connec
}
}
- // Print the list of Instance ID values
- Debug.WriteLine("The Instance ID values are:");
- foreach (string id in instanceIDs)
- {
- Debug.WriteLine(id);
- }
-
return instanceIDs;
}
diff --git a/HandheldCompanion/Platforms/IPlatform.cs b/HandheldCompanion/Platforms/IPlatform.cs
index c954f45b7..05346849e 100644
--- a/HandheldCompanion/Platforms/IPlatform.cs
+++ b/HandheldCompanion/Platforms/IPlatform.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Generic;
diff --git a/HandheldCompanion/Platforms/RTSS.cs b/HandheldCompanion/Platforms/RTSS.cs
index 37113d901..1837fb48c 100644
--- a/HandheldCompanion/Platforms/RTSS.cs
+++ b/HandheldCompanion/Platforms/RTSS.cs
@@ -1,6 +1,7 @@
using HandheldCompanion.Controls;
using HandheldCompanion.Managers;
using HandheldCompanion.Managers.Desktop;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using RTSSSharedMemoryNET;
using System;
diff --git a/HandheldCompanion/Platforms/Steam.cs b/HandheldCompanion/Platforms/Steam.cs
index db37f63f2..0f02daf72 100644
--- a/HandheldCompanion/Platforms/Steam.cs
+++ b/HandheldCompanion/Platforms/Steam.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using Microsoft.Win32;
using Nefarius.Utilities.DeviceManagement.Drivers;
diff --git a/HandheldCompanion/Processors/Intel/KX.cs b/HandheldCompanion/Processors/Intel/KX.cs
index 467fd2b17..2a85a4937 100644
--- a/HandheldCompanion/Processors/Intel/KX.cs
+++ b/HandheldCompanion/Processors/Intel/KX.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Diagnostics;
diff --git a/HandheldCompanion/Processors/Intel/Rw.cs b/HandheldCompanion/Processors/Intel/Rw.cs
index 3fe9c77ee..53ffe5f6b 100644
--- a/HandheldCompanion/Processors/Intel/Rw.cs
+++ b/HandheldCompanion/Processors/Intel/Rw.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Diagnostics;
using System.IO;
diff --git a/HandheldCompanion/Processors/Processor.cs b/HandheldCompanion/Processors/Processor.cs
index 46d8cc626..681b59280 100644
--- a/HandheldCompanion/Processors/Processor.cs
+++ b/HandheldCompanion/Processors/Processor.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System.Timers;
namespace HandheldCompanion.Processors;
diff --git a/HandheldCompanion/Sensors/IMUAccelerometer.cs b/HandheldCompanion/Sensors/IMUAccelerometer.cs
index cb9de06c0..5a00fe676 100644
--- a/HandheldCompanion/Sensors/IMUAccelerometer.cs
+++ b/HandheldCompanion/Sensors/IMUAccelerometer.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Devices;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Numerics;
using Windows.Devices.Sensors;
diff --git a/HandheldCompanion/Sensors/IMUCalibration.cs b/HandheldCompanion/Sensors/IMUCalibration.cs
index 7b0a8b3e7..6f6470a56 100644
--- a/HandheldCompanion/Sensors/IMUCalibration.cs
+++ b/HandheldCompanion/Sensors/IMUCalibration.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Views;
using Newtonsoft.Json;
using System.Collections.Generic;
diff --git a/HandheldCompanion/Sensors/IMUGyrometer.cs b/HandheldCompanion/Sensors/IMUGyrometer.cs
index 48e47687e..7a94f17a9 100644
--- a/HandheldCompanion/Sensors/IMUGyrometer.cs
+++ b/HandheldCompanion/Sensors/IMUGyrometer.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Devices;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Numerics;
using Windows.Devices.Sensors;
diff --git a/HandheldCompanion/Sensors/SerialUSBIMU.cs b/HandheldCompanion/Sensors/SerialUSBIMU.cs
index c7934de7a..5aec3a058 100644
--- a/HandheldCompanion/Sensors/SerialUSBIMU.cs
+++ b/HandheldCompanion/Sensors/SerialUSBIMU.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using System;
using System.Collections.Generic;
using System.IO.Ports;
diff --git a/HandheldCompanion/Targets/DualShock4Target.cs b/HandheldCompanion/Targets/DualShock4Target.cs
index c4a0161ac..8cb6c6373 100644
--- a/HandheldCompanion/Targets/DualShock4Target.cs
+++ b/HandheldCompanion/Targets/DualShock4Target.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Sensors;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using Nefarius.ViGEm.Client.Exceptions;
using Nefarius.ViGEm.Client.Targets;
diff --git a/HandheldCompanion/Targets/ViGEmTarget.cs b/HandheldCompanion/Targets/ViGEmTarget.cs
index 3e61fa0da..5849b80ac 100644
--- a/HandheldCompanion/Targets/ViGEmTarget.cs
+++ b/HandheldCompanion/Targets/ViGEmTarget.cs
@@ -1,6 +1,6 @@
using HandheldCompanion.Controllers;
using HandheldCompanion.Helpers;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using Nefarius.ViGEm.Client;
using System;
diff --git a/HandheldCompanion/Targets/Xbox360Target.cs b/HandheldCompanion/Targets/Xbox360Target.cs
index 60eb1691e..eb20dc060 100644
--- a/HandheldCompanion/Targets/Xbox360Target.cs
+++ b/HandheldCompanion/Targets/Xbox360Target.cs
@@ -2,6 +2,7 @@
using HandheldCompanion.Helpers;
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using Nefarius.ViGEm.Client.Exceptions;
using Nefarius.ViGEm.Client.Targets;
diff --git a/HandheldCompanion/Utils/EnumUtils.cs b/HandheldCompanion/Utils/EnumUtils.cs
index a9c7f2fb2..e9895a4f6 100644
--- a/HandheldCompanion/Utils/EnumUtils.cs
+++ b/HandheldCompanion/Utils/EnumUtils.cs
@@ -1,5 +1,5 @@
-using HandheldCompanion.Managers;
-using HandheldCompanion.Properties;
+using HandheldCompanion.Properties;
+using HandheldCompanion.Shared;
using System;
using System.ComponentModel;
using System.Linq;
diff --git a/HandheldCompanion/Utils/RegistryWatcher.cs b/HandheldCompanion/Utils/RegistryWatcher.cs
index e3fff6e3b..68c935b00 100644
--- a/HandheldCompanion/Utils/RegistryWatcher.cs
+++ b/HandheldCompanion/Utils/RegistryWatcher.cs
@@ -1,4 +1,4 @@
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using Microsoft.Win32;
using System;
using System.Management;
diff --git a/HandheldCompanion/ViewModels/Pages/HotkeyPageViewModel.cs b/HandheldCompanion/ViewModels/Pages/HotkeyPageViewModel.cs
index 31c07c1b1..843094cda 100644
--- a/HandheldCompanion/ViewModels/Pages/HotkeyPageViewModel.cs
+++ b/HandheldCompanion/ViewModels/Pages/HotkeyPageViewModel.cs
@@ -40,6 +40,11 @@ public HotkeyPageViewModel()
ControllerManager_ControllerSelected(ControllerManager.GetTargetController());
}
+ if (HotkeysManager.IsInitialized)
+ {
+ HotkeysManager_Initialized();
+ }
+
CreateHotkeyCommand = new DelegateCommand(async () =>
{
HotkeysManager.UpdateOrCreateHotkey(new Hotkey());
diff --git a/HandheldCompanion/ViewModels/Pages/PerformancePageViewModel.cs b/HandheldCompanion/ViewModels/Pages/PerformancePageViewModel.cs
index 1e14d025e..b749e01a7 100644
--- a/HandheldCompanion/ViewModels/Pages/PerformancePageViewModel.cs
+++ b/HandheldCompanion/ViewModels/Pages/PerformancePageViewModel.cs
@@ -169,7 +169,16 @@ public double TDPMaximum
}
}
- public double AutoTDPMaximum => MultimediaManager.PrimaryDesktop.devMode.dmDisplayFrequency;
+ public double AutoTDPMaximum
+ {
+ get
+ {
+ if (!MultimediaManager.IsInitialized)
+ return 60.0d;
+
+ return MultimediaManager.PrimaryDesktop.devMode.dmDisplayFrequency;
+ }
+ }
public bool TDPOverrideEnabled
{
diff --git a/HandheldCompanion/ViewModels/Pages/QuickHomePageViewModel.cs b/HandheldCompanion/ViewModels/Pages/QuickHomePageViewModel.cs
index e0ca600dd..07c472ac7 100644
--- a/HandheldCompanion/ViewModels/Pages/QuickHomePageViewModel.cs
+++ b/HandheldCompanion/ViewModels/Pages/QuickHomePageViewModel.cs
@@ -17,6 +17,11 @@ public QuickHomePageViewModel()
HotkeysManager.Updated += HotkeysManager_Updated;
HotkeysManager.Deleted += HotkeysManager_Deleted;
HotkeysManager.Initialized += HotkeysManager_Initialized;
+
+ if (HotkeysManager.IsInitialized)
+ {
+ HotkeysManager_Initialized();
+ }
}
void IDropTarget.DragOver(IDropInfo dropInfo)
diff --git a/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs b/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs
index dfd19a97f..1fe6897b5 100644
--- a/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs
+++ b/HandheldCompanion/Views/Pages/ProfilesPage.xaml.cs
@@ -5,6 +5,7 @@
using HandheldCompanion.Managers.Desktop;
using HandheldCompanion.Misc;
using HandheldCompanion.Platforms;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.ViewModels;
using HandheldCompanion.Views.Pages.Profiles;
diff --git a/HandheldCompanion/Views/Windows/MainWindow.xaml.cs b/HandheldCompanion/Views/Windows/MainWindow.xaml.cs
index 8ac062d97..3d7f26840 100644
--- a/HandheldCompanion/Views/Windows/MainWindow.xaml.cs
+++ b/HandheldCompanion/Views/Windows/MainWindow.xaml.cs
@@ -2,6 +2,7 @@
using HandheldCompanion.Devices;
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.UI;
using HandheldCompanion.Utils;
using HandheldCompanion.Views.Classes;
@@ -198,34 +199,22 @@ public MainWindow(FileVersionInfo _fileVersionInfo, Assembly CurrentAssembly)
ToastManager.IsEnabled = SettingsManager.GetBoolean("ToastEnable");
// start static managers
- HotkeysManager.Start();
OSDManager.Start();
LayoutManager.Start();
SystemManager.Start();
DynamicLightingManager.Start();
- MultimediaManager.Start();
VirtualManager.Start();
SensorsManager.Start();
TimerManager.Start();
- // STA threads
- List STAThreads =
- [
- new Thread(() => ProfileManager.Start()),
- new Thread(() => PowerProfileManager.Start()),
- new Thread(() => GPUManager.Start()),
- ];
-
- // Set the thread to STA
- foreach (Thread thread in STAThreads)
- {
- thread.SetApartmentState(ApartmentState.STA);
- thread.Start();
- }
-
// non-STA threads
List tasks = new List
{
+ Task.Run(() => HotkeysManager.Start()),
+ Task.Run(() => ProfileManager.Start()),
+ Task.Run(() => PowerProfileManager.Start()),
+ Task.Run(() => GPUManager.Start()),
+ Task.Run(() => MultimediaManager.Start()),
Task.Run(() => ControllerManager.Start()),
Task.Run(() => DeviceManager.Start()),
Task.Run(() => PlatformManager.Start()),
diff --git a/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs b/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs
index cd71a1c93..bae22dcb4 100644
--- a/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs
+++ b/HandheldCompanion/Views/Windows/OverlayModel.xaml.cs
@@ -71,8 +71,6 @@ public OverlayModel()
AutoReset = true
};
UpdateTimer.Elapsed += DrawModel;
-
- UpdateModel();
}
private void SettingsManager_SettingValueChanged(string name, object value, bool temporary)
@@ -125,7 +123,9 @@ public void UpdateOverlayMode(OverlayModelMode Modelmode)
return;
this.Modelmode = Modelmode;
- UpdateModel();
+
+ if (IsLoaded)
+ UpdateModel();
}
public void UpdateModel()
@@ -185,6 +185,8 @@ public override void ToggleVisibility()
break;
case Visibility.Collapsed:
case Visibility.Hidden:
+ if (CurrentModel is null)
+ UpdateModel();
UpdateTimer.Start();
try { Show(); } catch { /* ItemsRepeater might have a NaN DesiredSize */ }
break;
diff --git a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs
index 436590de1..88a26aa43 100644
--- a/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs
+++ b/HandheldCompanion/Views/Windows/OverlayQuickTools.xaml.cs
@@ -2,6 +2,7 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using HandheldCompanion.Managers.Desktop;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using HandheldCompanion.Views.Classes;
using HandheldCompanion.Views.QuickPages;
@@ -111,7 +112,7 @@ public OverlayQuickTools()
// manage events
SystemManager.PowerStatusChanged += PowerManager_PowerStatusChanged;
- MultimediaManager.DisplaySettingsChanged += SystemManager_DisplaySettingsChanged;
+ MultimediaManager.DisplaySettingsChanged += MultimediaManager_DisplaySettingsChanged;
SettingsManager.SettingValueChanged += SettingsManager_SettingValueChanged;
ControllerManager.ControllerSelected += ControllerManager_ControllerSelected;
@@ -202,12 +203,8 @@ private void ControllerManager_ControllerSelected(IController Controller)
});
}
- private void SystemManager_DisplaySettingsChanged(DesktopScreen desktopScreen, ScreenResolution resolution)
+ private void MultimediaManager_DisplaySettingsChanged(DesktopScreen desktopScreen, ScreenResolution resolution)
{
- // ignore if we're not ready yet
- if (!MultimediaManager.IsInitialized)
- return;
-
UpdateLocation();
}
@@ -228,6 +225,8 @@ private void UpdateLocation()
// Attempt to find the screen with the specified friendly name
DesktopScreen friendlyScreen = MultimediaManager.AllScreens.Values.FirstOrDefault(a => a.DevicePath.Equals(DevicePath) || a.FriendlyName.Equals(DeviceName)) ?? MultimediaManager.PrimaryDesktop;
+ if (friendlyScreen is null)
+ return;
// Find the corresponding Screen object
targetScreen = Screen.AllScreens.FirstOrDefault(screen => screen.DeviceName.Equals(friendlyScreen.screen.DeviceName));
@@ -250,26 +249,22 @@ private void UpdateLocation()
WindowStyle = WindowStyle.None;
break;
}
- });
- switch (QuickToolsLocation)
- {
- case 0: // Left
- this.SetWindowPosition(WindowPositions.BottomLeft, targetScreen);
- break;
+ switch (QuickToolsLocation)
+ {
+ case 0: // Left
+ this.SetWindowPosition(WindowPositions.BottomLeft, targetScreen);
+ break;
- case 1: // Right
- this.SetWindowPosition(WindowPositions.BottomRight, targetScreen);
- break;
+ case 1: // Right
+ this.SetWindowPosition(WindowPositions.BottomRight, targetScreen);
+ break;
- case 2: // Maximized
- this.SetWindowPosition(WindowPositions.Maximize, targetScreen);
- break;
- }
+ case 2: // Maximized
+ this.SetWindowPosition(WindowPositions.Maximize, targetScreen);
+ break;
+ }
- // UI thread
- Application.Current.Dispatcher.Invoke(() =>
- {
switch (QuickToolsLocation)
{
case 0: // Left
@@ -282,11 +277,11 @@ private void UpdateLocation()
Left -= _Margin;
break;
}
- });
- // used by SlideIn/SlideOut
- _Top = Top;
- _Left = Left;
+ // used by SlideIn/SlideOut
+ _Top = Top;
+ _Left = Left;
+ });
}
private void PowerManager_PowerStatusChanged(PowerStatus status)
diff --git a/HandheldCompanion/WMI.cs b/HandheldCompanion/WMI.cs
index 99ec319cc..502ce40b3 100644
--- a/HandheldCompanion/WMI.cs
+++ b/HandheldCompanion/WMI.cs
@@ -1,5 +1,5 @@
using HandheldCompanion.Extensions;
-using HandheldCompanion.Managers;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Generic;
diff --git a/HandheldCompanion/XInputPlus/XInputPlus.cs b/HandheldCompanion/XInputPlus/XInputPlus.cs
index 88a4f5838..cd552ae2f 100644
--- a/HandheldCompanion/XInputPlus/XInputPlus.cs
+++ b/HandheldCompanion/XInputPlus/XInputPlus.cs
@@ -3,6 +3,7 @@
using HandheldCompanion.Controls;
using HandheldCompanion.Managers;
using HandheldCompanion.Properties;
+using HandheldCompanion.Shared;
using HandheldCompanion.Utils;
using System;
using System.Collections.Generic;
diff --git a/Resources/ricaun.NamedPipeWrapper.Json.1.8.0.dll b/Resources/ricaun.NamedPipeWrapper.Json.1.8.0.dll
new file mode 100644
index 000000000..121978fa0
Binary files /dev/null and b/Resources/ricaun.NamedPipeWrapper.Json.1.8.0.dll differ
diff --git a/HandheldCompanion/Managers/LogManager.cs b/Shared/LogManager.cs
similarity index 97%
rename from HandheldCompanion/Managers/LogManager.cs
rename to Shared/LogManager.cs
index 6faddcdcd..4e9206d29 100644
--- a/HandheldCompanion/Managers/LogManager.cs
+++ b/Shared/LogManager.cs
@@ -5,7 +5,7 @@
using System.Diagnostics;
using ILogger = Microsoft.Extensions.Logging.ILogger;
-namespace HandheldCompanion.Managers;
+namespace HandheldCompanion.Shared;
public static class LogManager
{
diff --git a/Shared/Pipes/PipeClient.cs b/Shared/Pipes/PipeClient.cs
new file mode 100644
index 000000000..158c04b50
--- /dev/null
+++ b/Shared/Pipes/PipeClient.cs
@@ -0,0 +1,118 @@
+using HandheldCompanion.Shared;
+using ricaun.NamedPipeWrapper;
+using System.Collections.Concurrent;
+using System.Timers;
+using Timer = System.Timers.Timer;
+
+namespace Shared.Pipes
+{
+ public class PipeClient
+ {
+ public delegate void ConnectedEventHandler();
+
+ public delegate void DisconnectedEventHandler();
+
+ public delegate void ServerMessageEventHandler(PipeMessage e);
+
+ private const string PipeName = "HandheldCompanion";
+ public NamedPipeClient client;
+
+ private readonly ConcurrentQueue m_queue = new();
+ private readonly Timer m_timer;
+
+ public bool IsConnected;
+
+ public PipeClient()
+ {
+ // monitors processes and settings
+ m_timer = new Timer(1000) { Enabled = false, AutoReset = true };
+ m_timer.Elapsed += SendMessageQueue;
+
+ client = new NamedPipeClient(PipeName);
+ client.AutoReconnect = true;
+ }
+
+ public event ConnectedEventHandler Connected;
+ public event DisconnectedEventHandler Disconnected;
+ public event ServerMessageEventHandler ServerMessage;
+
+ private void OnClientDisconnected(NamedPipeConnection connection)
+ {
+ LogManager.LogInformation("Client {0} disconnected", connection.Id);
+ Disconnected?.Invoke();
+
+ IsConnected = false;
+ }
+
+ public void Open()
+ {
+ client.Disconnected += OnClientDisconnected;
+ client.ServerMessage += OnServerMessage;
+ client.Error += OnError;
+
+ client?.Start();
+ LogManager.LogInformation("{0} has started", "PipeClient");
+ }
+
+ public void Close()
+ {
+ client.Disconnected -= OnClientDisconnected;
+ client.ServerMessage -= OnServerMessage;
+ client.Error -= OnError;
+
+ client?.Stop();
+ LogManager.LogInformation("{0} has stopped", "PipeClient");
+ client = null;
+ }
+
+ private void OnServerMessage(NamedPipeConnection connection, PipeMessage message)
+ {
+ ServerMessage?.Invoke(message);
+
+ switch (message.code)
+ {
+ case PipeCode.SERVER_PING:
+ IsConnected = true;
+ Connected?.Invoke();
+ LogManager.LogInformation("Client {0} is now connected!", connection.Id);
+ break;
+ }
+ }
+
+ private void OnError(Exception exception)
+ {
+ LogManager.LogError("{0} failed. {1}", "PipeClient", exception.Message);
+ }
+
+ public void SendMessage(PipeMessage message)
+ {
+ if (!IsConnected)
+ {
+ Type nodeType = message.GetType();
+
+ m_queue.Enqueue(message);
+ m_timer.Start();
+ return;
+ }
+
+ client?.PushMessage(message);
+ }
+
+ private void SendMessageQueue(object sender, ElapsedEventArgs e)
+ {
+ if (!IsConnected)
+ return;
+
+ foreach (var m in m_queue)
+ client?.PushMessage(m);
+
+ m_queue.Clear();
+ m_timer.Stop();
+ }
+
+ public void ClearQueue()
+ {
+ m_queue.Clear();
+ }
+ }
+}
diff --git a/Shared/Pipes/PipeCode.cs b/Shared/Pipes/PipeCode.cs
new file mode 100644
index 000000000..3534bacf7
--- /dev/null
+++ b/Shared/Pipes/PipeCode.cs
@@ -0,0 +1,8 @@
+namespace Shared.Pipes
+{
+ public enum PipeCode
+ {
+ SERVER_PING = 0, // Sent to client during initialization
+ // args: ...
+ }
+}
diff --git a/Shared/Pipes/PipeMessage.cs b/Shared/Pipes/PipeMessage.cs
new file mode 100644
index 000000000..fb28a5023
--- /dev/null
+++ b/Shared/Pipes/PipeMessage.cs
@@ -0,0 +1,16 @@
+namespace Shared.Pipes
+{
+ public abstract class PipeMessage
+ {
+ public PipeCode code;
+
+ [Serializable]
+ public partial class PipeServerPing : PipeMessage
+ {
+ public PipeServerPing()
+ {
+ code = PipeCode.SERVER_PING;
+ }
+ }
+ }
+}
diff --git a/Shared/Pipes/PipeServer.cs b/Shared/Pipes/PipeServer.cs
new file mode 100644
index 000000000..db3ea3120
--- /dev/null
+++ b/Shared/Pipes/PipeServer.cs
@@ -0,0 +1,132 @@
+using HandheldCompanion.Shared;
+using ricaun.NamedPipeWrapper;
+using System.Collections.Concurrent;
+using System.IO.Pipes;
+using System.Security.AccessControl;
+using System.Security.Principal;
+using System.Timers;
+using static Shared.Pipes.PipeMessage;
+using Timer = System.Timers.Timer;
+
+namespace Shared.Pipes
+{
+ public class PipeServer
+ {
+ public delegate void ClientMessageEventHandler(PipeMessage e);
+
+ public delegate void ConnectedEventHandler();
+
+ public delegate void DisconnectedEventHandler();
+
+ private const string PipeName = "HandheldCompanion";
+ private NamedPipeServer server;
+
+ private readonly ConcurrentQueue m_queue = new();
+ private readonly Timer m_timer;
+
+ public bool IsConnected;
+
+ PipeServer()
+ {
+ // monitors processes and settings
+ m_timer = new Timer(1000) { Enabled = false, AutoReset = true };
+ m_timer.Elapsed += SendMessageQueue;
+
+ PipeSecurity ps = new();
+ SecurityIdentifier sid = new(WellKnownSidType.BuiltinUsersSid, null);
+ PipeAccessRule par = new(sid, PipeAccessRights.ReadWrite, AccessControlType.Allow);
+ ps.AddAccessRule(par);
+
+ server = new NamedPipeServer(PipeName, ps);
+ }
+
+ public event ConnectedEventHandler Connected;
+
+ public event DisconnectedEventHandler Disconnected;
+
+ public event ClientMessageEventHandler ClientMessage;
+
+ public void Open()
+ {
+ server.ClientConnected += OnClientConnected;
+ server.ClientDisconnected += OnClientDisconnected;
+ server.ClientMessage += OnClientMessage;
+ server.Error += OnError;
+ server?.Start();
+
+ LogManager.LogInformation("{0} has started", "PipeServer");
+ }
+
+ public void Close()
+ {
+ server.ClientConnected -= OnClientConnected;
+ server.ClientDisconnected -= OnClientDisconnected;
+ server.ClientMessage -= OnClientMessage;
+ server.Error -= OnError;
+ server?.Stop();
+
+ LogManager.LogInformation("{0} has stopped", "PipeServer");
+ server = null;
+ }
+
+ private void OnClientConnected(NamedPipeConnection connection)
+ {
+ LogManager.LogInformation("Client {0} is now connected!", connection.Id);
+ Connected?.Invoke();
+
+ IsConnected = true;
+
+ // send ping
+ SendMessage(new PipeServerPing());
+ }
+
+ private void OnClientDisconnected(NamedPipeConnection connection)
+ {
+ LogManager.LogInformation("Client {0} disconnected", connection.Id);
+ Disconnected?.Invoke();
+
+ IsConnected = false;
+ }
+
+ private void OnClientMessage(NamedPipeConnection connection, PipeMessage message)
+ {
+ ClientMessage?.Invoke(message);
+ }
+
+ private void OnError(Exception exception)
+ {
+ LogManager.LogError("{0} failed. {1}", "PipeServer", exception.Message);
+ }
+
+ public void SendMessage(PipeMessage message)
+ {
+ if (!IsConnected)
+ {
+ Type nodeType = message.GetType();
+
+ m_queue.Enqueue(message);
+ m_timer.Start();
+ return;
+ }
+
+ server?.PushMessage(message);
+ }
+
+ private void SendMessageQueue(object sender, ElapsedEventArgs e)
+ {
+ if (!IsConnected)
+ return;
+
+ foreach (var m in m_queue)
+ server?.PushMessage(m);
+
+ m_queue.Clear();
+ m_timer.Stop();
+ }
+
+ public void ClearQueue()
+ {
+ m_queue.Clear();
+ }
+ }
+}
diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj
new file mode 100644
index 000000000..5a2d39a99
--- /dev/null
+++ b/Shared/Shared.csproj
@@ -0,0 +1,27 @@
+
+
+
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ..\Resources\ricaun.NamedPipeWrapper.Json.1.8.0.dll
+
+
+
+