From 688f267903002a23d4c964d75132120ea333416c Mon Sep 17 00:00:00 2001 From: Lesueur Benjamin Date: Sun, 24 Nov 2024 15:32:51 +0100 Subject: [PATCH] Implement Shared project (#372) * implement Shared project * remove NotImplementedException * added try catch to ADLX_Wrapper on IntializeAdlx() * implement PipeServer * update libraries * Remove Debug.WriteLine * On AMDGPU, if we couldn't pick a display by its name, pick first * reduce loading time and improve threading - Make MultimediaManager async - Make HotkeysManager async - Don't load OverlayMode on startup --- HandheldCompanion.sln | 11 ++ HandheldCompanion/ADLX/ADLXBackend.cs | 33 +++-- HandheldCompanion/ADLX_Wrapper.dll | Bin 36864 -> 36864 bytes HandheldCompanion/Actions/IActions.cs | 2 +- HandheldCompanion/Actions/ShiftActions.cs | 4 - HandheldCompanion/App.config | 1 + HandheldCompanion/App.xaml.cs | 4 +- .../Controllers/GordonController.cs | 1 + HandheldCompanion/Controllers/IController.cs | 1 + .../Controllers/NeptuneController.cs | 1 + .../Hints/Hint_LegionGoLegionSpace.cs | 2 +- .../Hints/Hint_RogAllyServiceCheck.cs | 2 +- HandheldCompanion/DSU/DSUServer.cs | 1 + HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs | 2 +- HandheldCompanion/Devices/ASUS/AsusACPI.cs | 5 +- HandheldCompanion/Devices/GPD/GPDWin4.cs | 2 +- HandheldCompanion/Devices/IDevice.cs | 1 + HandheldCompanion/Devices/Lenovo/LegionGo.cs | 1 + HandheldCompanion/Devices/MSI/ClawA1M.cs | 1 + .../Devices/OneXPlayer/OneXPlayer2.cs | 2 +- .../Devices/OneXPlayer/OneXPlayerMini.cs | 2 +- .../Devices/OneXPlayer/OneXPlayerMiniPro.cs | 2 +- .../Devices/OneXPlayer/OneXPlayerOneXFly.cs | 6 +- .../Devices/OneXPlayer/OneXPlayerX1.cs | 1 + HandheldCompanion/Devices/Valve/SteamDeck.cs | 1 + .../GraphicsProcessingUnit/AMDGPU.cs | 9 +- HandheldCompanion/HandheldCompanion.csproj | 20 +-- HandheldCompanion/Helpers/RyzenSMU.cs | 2 +- HandheldCompanion/Helpers/VangoghGPU.cs | 1 + .../Localization/StaticExtension.cs | 4 +- .../Localization/TranslationSource.cs | 8 +- .../Managers/ControllerManager.cs | 1 + HandheldCompanion/Managers/DeviceManager.cs | 4 +- .../Managers/DynamicLightingManager.cs | 1 + HandheldCompanion/Managers/GPUManager.cs | 3 +- HandheldCompanion/Managers/HotkeysManager.cs | 3 +- HandheldCompanion/Managers/InputsManager.cs | 1 + HandheldCompanion/Managers/LayoutManager.cs | 5 +- .../Managers/MultimediaManager.cs | 9 +- HandheldCompanion/Managers/OSDManager.cs | 1 + .../Managers/PerformanceManager.cs | 1 + HandheldCompanion/Managers/PlatformManager.cs | 1 + .../Managers/PowerProfileManager.cs | 1 + HandheldCompanion/Managers/ProcessManager.cs | 1 + HandheldCompanion/Managers/ProfileManager.cs | 1 + HandheldCompanion/Managers/SensorsManager.cs | 1 + HandheldCompanion/Managers/SettingsManager.cs | 1 + HandheldCompanion/Managers/SystemManager.cs | 3 +- HandheldCompanion/Managers/TaskManager.cs | 3 +- HandheldCompanion/Managers/TimerManager.cs | 3 +- HandheldCompanion/Managers/ToastManager.cs | 3 +- HandheldCompanion/Managers/UpdateManager.cs | 1 + HandheldCompanion/Managers/VirtualManager.cs | 1 + HandheldCompanion/Misc/HidHide.cs | 2 +- HandheldCompanion/Misc/JoyShockLibrary.cs | 2 +- HandheldCompanion/Misc/PnPUtil.cs | 7 - HandheldCompanion/Platforms/IPlatform.cs | 2 +- HandheldCompanion/Platforms/RTSS.cs | 1 + HandheldCompanion/Platforms/Steam.cs | 2 +- HandheldCompanion/Processors/Intel/KX.cs | 2 +- HandheldCompanion/Processors/Intel/Rw.cs | 2 +- HandheldCompanion/Processors/Processor.cs | 2 +- HandheldCompanion/Sensors/IMUAccelerometer.cs | 2 +- HandheldCompanion/Sensors/IMUCalibration.cs | 2 +- HandheldCompanion/Sensors/IMUGyrometer.cs | 2 +- HandheldCompanion/Sensors/SerialUSBIMU.cs | 2 +- HandheldCompanion/Targets/DualShock4Target.cs | 1 + HandheldCompanion/Targets/ViGEmTarget.cs | 2 +- HandheldCompanion/Targets/Xbox360Target.cs | 1 + HandheldCompanion/Utils/EnumUtils.cs | 4 +- HandheldCompanion/Utils/RegistryWatcher.cs | 2 +- .../ViewModels/Pages/HotkeyPageViewModel.cs | 5 + .../Pages/PerformancePageViewModel.cs | 11 +- .../Pages/QuickHomePageViewModel.cs | 5 + .../Views/Pages/ProfilesPage.xaml.cs | 1 + .../Views/Windows/MainWindow.xaml.cs | 23 +-- .../Views/Windows/OverlayModel.xaml.cs | 8 +- .../Views/Windows/OverlayQuickTools.xaml.cs | 47 +++---- HandheldCompanion/WMI.cs | 2 +- HandheldCompanion/XInputPlus/XInputPlus.cs | 1 + .../ricaun.NamedPipeWrapper.Json.1.8.0.dll | Bin 0 -> 23040 bytes .../Managers => Shared}/LogManager.cs | 2 +- Shared/Pipes/PipeClient.cs | 118 ++++++++++++++++ Shared/Pipes/PipeCode.cs | 8 ++ Shared/Pipes/PipeMessage.cs | 16 +++ Shared/Pipes/PipeServer.cs | 132 ++++++++++++++++++ Shared/Shared.csproj | 27 ++++ 87 files changed, 484 insertions(+), 144 deletions(-) create mode 100644 Resources/ricaun.NamedPipeWrapper.Json.1.8.0.dll rename {HandheldCompanion/Managers => Shared}/LogManager.cs (97%) create mode 100644 Shared/Pipes/PipeClient.cs create mode 100644 Shared/Pipes/PipeCode.cs create mode 100644 Shared/Pipes/PipeMessage.cs create mode 100644 Shared/Pipes/PipeServer.cs create mode 100644 Shared/Shared.csproj 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 a2d2a107a7cab01a528d584da77b4b123d23d798..c359826edcb85c593b3d02b9f0e4db0cd8219546 100644 GIT binary patch delta 8813 zcmeHMeOQ#$w%_jy%#3_Ee2svB4mt`V;s{tMiZcrOq63188cGa_fL}#5D#z48krLl9 zXqVMF^&IWfI@Z<3Jk{+3lgc_C!;iXJS)8&Ozn-+LL+6%rf9w4~Jonyz?jQG$``me+ z-~85Ed+oLNyWhRn+5=5H#ipHN`y{cKb>vU=e*NRDAlZui&ail^f}9x)YBMD`;-n|{Hpcfij)&1D_ZE--^+J$KzUD$` zYyb8_HIgSnl1-BAEyLI0!14C}E?-wMwx!c^bAMZ$*3DX!_ns$_`dIFVTYr~5&@YI4 zg{=j)v@M;hL*EK!jGeoJul`=!;WeUDV63^<;VJT(hdNksOJJk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jJ~Y`r#l9c>vtlRqnTyk6L8E>Ub^@vEWj<7fC4x-+6F@8R zGx%5qY_MMi$5mpZK~4o<1$xL1*36eXP61C>$@K8i>#sA6m({r}y&9=j2| z9O#2gA6*xKxYaV#9q=3~5Yxpj0Y1b-6`6RfA`>?NufwMq?7jdSZ(V2M)&!x`b4!W{ L=`X?#C*6Mo`GkTQ 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 0000000000000000000000000000000000000000..121978fa0d1b56f123b8ddd4178fe5a1829a260b GIT binary patch literal 23040 zcmeHvd3;;Nwg0(`u4LJgW!Z5;;v{lb;Vlbk*aF0fvlyJ!1`-N5iglBS$htz3LyYTS zmk=QAWew0mfYMTyZnULsXrWLFP3gjG`yR9}g}y$1w1xi4r#uS%{Tkl)oI6@59+5Rr-R2OkhUfs{Xsg&vy>p*T488$o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%C&ZEXJ?WNw&il^>?w2RY)$00 z^=)qHaeC*tf|?V~95Jt%&1+WHH}mBLL54>Da}%jJ#{Wb%7IPr);A9>Ogx|fDeqQY@ zqQ7uHQpBaX{Quw0<>5horY)IV#aHQGJWJ2mwmf9u(hp`r#%MLAqW+ox|9%AcZa|7=8<4dH&3hR$VBK zfty8n46%1YB7LcV|C{3Dyrse>+{#drqOC`ebfeUni+;QR79gU>7~r?qE6{c+Nuc%KyFD^bo1?FD{A-ScLq67zDe*6<`S_! zEtqdB+*b#!Q&QT35nP5>iV@(kx1KESDEw)`uQc*@rco~i`T1KCmvhg1z-OuaN#XY! z*n+`j>)Y_nqMU1`VOw$hO53p|c?;G`O}u&-VS5XHi; 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 + + + +