Skip to content

Commit

Permalink
Merge EA into Mainline
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie committed Feb 3, 2024
1 parent a1c4de0 commit 86e1462
Show file tree
Hide file tree
Showing 24 changed files with 2,801 additions and 1,912 deletions.
10 changes: 5 additions & 5 deletions HandheldCompanion.iss
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,10 @@ end;
procedure Dependency_AddHideHide;
begin
Dependency_Add('HidHide_1.4.192_x64.exe',
Dependency_Add('HidHide_1.4.202_x64.exe',
'/quiet /norestart',
'HidHide Drivers',
'https://github.com/nefarius/HidHide/releases/download/v1.4.192.0/HidHide_1.4.192_x64.exe',
'https://github.com/nefarius/HidHide/releases/download/v1.4.202.0/HidHide_1.4.202_x64.exe',
'', True, False);
end;
Expand Down Expand Up @@ -364,7 +364,7 @@ end;

#define MyAppSetupName 'Handheld Companion'
#define MyBuildId 'HandheldCompanion'
#define MyAppVersion '0.20.3.1'
#define MyAppVersion '0.20.4.0'
#define MyAppPublisher 'BenjaminLSR'
#define MyAppCopyright 'Copyright @ BenjaminLSR'
#define MyAppURL 'https://github.com/Valkirie/HandheldCompanion'
Expand Down Expand Up @@ -482,7 +482,7 @@ begin
if not(keepHidhideCheckbox.Checked) then
begin
if(ShellExec('', 'msiexec.exe', '/X{BE49B9DE-F8EB-4F54-B312-DD4B601985FC}', '', SW_SHOW, ewWaitUntilTerminated, resultCode)) then
if(ShellExec('', 'msiexec.exe', '/X{50D7EB6D-6A4A-4A38-B09C-CC28F75F082E} /L*V "C:\HidHide-Uninstall.log"', '', SW_SHOW, ewWaitUntilTerminated, resultCode)) then
begin
log('Successfully executed Hidhide uninstaller');
if(resultCode = 0) then
Expand Down Expand Up @@ -580,4 +580,4 @@ begin
Result := True;
end;
#endif
#endif
2 changes: 1 addition & 1 deletion HandheldCompanion/Controls/Mapping/ButtonMapping.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using iNKORE.UI.WPF.Modern.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Linq;

namespace HandheldCompanion.Controls;

Expand Down
4 changes: 2 additions & 2 deletions HandheldCompanion/Devices/AYANEO/AYANEODevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public AYANEODevice()
{
prevPowerStatus = SystemInformation.PowerStatus.PowerLineStatus;
prevBatteryLevelPercentage = (int)(SystemInformation.PowerStatus.BatteryLifePercent * 100);
PowerManager.PowerStatusChanged += PowerManager_PowerStatusChanged;
SystemManager.PowerStatusChanged += PowerManager_PowerStatusChanged;
}

private void PowerManager_PowerStatusChanged(PowerStatus powerStatus)
Expand Down Expand Up @@ -101,7 +101,7 @@ public override bool SetLedBrightness(int brightness)
// so that we can let people mess with brightness slider
return base.SetLedBrightness(brightness);
}

private void SetLEDColor(Color color)
{
using (new ScopedLock(updateLock))
Expand Down
35 changes: 31 additions & 4 deletions HandheldCompanion/HandheldCompanion.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<StartupObject>HandheldCompanion.App</StartupObject>
<OutputPath>$(SolutionDir)bin\$(Configuration)</OutputPath>
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
<Version>0.20.3.1</Version>
<Version>0.20.4.0</Version>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>AnyCPU;x64;x86</Platforms>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down Expand Up @@ -73,6 +73,7 @@
<None Remove="Resources\device_gpd4.png" />
<None Remove="Resources\device_gpd_win2.png" />
<None Remove="Resources\device_gpd_winmax2.png" />
<None Remove="Resources\device_gpd_winmini.png" />
<None Remove="Resources\device_legion_go.png" />
<None Remove="Resources\device_onexplayer_2.png" />
<None Remove="Resources\device_onexplayer_mini.png" />
Expand Down Expand Up @@ -107,6 +108,7 @@
<ItemGroup>
<Resource Include="Resources\device_aya_kun.png" />
<Resource Include="Resources\device_cncdan_nucdeck.png" />
<Resource Include="Resources\device_gpd_winmini.png" />
<Resource Include="Resources\device_legion_go.png" />
</ItemGroup>

Expand Down Expand Up @@ -141,6 +143,9 @@

<ItemGroup>
<PackageReference Include="Crc32.NET" Version="1.2.0" />
<PackageReference Include="dotnetCampus.WPF" Version="6.0.4-alpha07-test07" />
<PackageReference Include="dotnetCampus.WPF.Dependencies" Version="6.0.4-alpha07-test07" />
<PackageReference Include="dotnetCampus.WPF.Resource" Version="6.0.4-alpha07-test07" />
<PackageReference Include="GregsStack.InputSimulatorStandard" Version="1.3.5" />
<PackageReference Include="HelixToolkit.Core.Wpf" Version="2.24.0" />
<PackageReference Include="iNKORE.UI.WPF.Modern" Version="0.9.25.1" />
Expand All @@ -151,7 +156,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="NAudio" Version="2.2.0" />
<PackageReference Include="NAudio" Version="2.2.1" />
<PackageReference Include="NAudio.Vorbis" Version="1.5.0" />
<PackageReference Include="Nefarius.Drivers.HidHide" Version="1.12.2" />
<PackageReference Include="Nefarius.Utilities.DeviceManagement" Version="3.17.406" />
<PackageReference Include="Nefarius.ViGEm.Client" Version="1.21.256" />
Expand Down Expand Up @@ -220,10 +226,10 @@
</ItemGroup>

<ItemGroup>
<None Update="ADLX_3DSettings.dll">
<None Update="ADLX_Wrapper.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ADLX_DisplaySettings.dll">
<None Update="IGCL_Wrapper.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="JoyShockLibrary.dll">
Expand Down Expand Up @@ -2264,6 +2270,27 @@
<None Update="ucrtbased.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UI\Audio\bong_001.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UI\Audio\drop_001.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UI\Audio\drop_002.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UI\Audio\glitch_004.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UI\Audio\switch_004.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UI\Audio\switch_005.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="UI\Audio\switch_007.ogg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="vcruntime140d.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
28 changes: 16 additions & 12 deletions HandheldCompanion/Managers/DynamicLightingManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media;
using static HandheldCompanion.Utils.DeviceUtils;
using Timer = System.Timers.Timer;
Expand Down Expand Up @@ -47,7 +48,7 @@ static DynamicLightingManager()
rightLedTracker = new ColorTracker();

SettingsManager.SettingValueChanged += SettingsManager_SettingValueChanged;
SystemManager.DisplaySettingsChanged += SystemManager_DisplaySettingsChanged;
MultimediaManager.DisplaySettingsChanged += SystemManager_DisplaySettingsChanged;
MainWindow.CurrentDevice.PowerStatusChanged += CurrentDevice_PowerStatusChanged;

ambilightThread = new Thread(ambilightThreadLoop);
Expand All @@ -60,7 +61,7 @@ static DynamicLightingManager()
DynamicLightingTimer.Elapsed += (sender, e) => UpdateLED();
}

public static void Start(bool service = false)
public static void Start()
{
IsInitialized = true;
Initialized?.Invoke();
Expand All @@ -73,8 +74,7 @@ public static void Stop()
if (!IsInitialized)
return;

ambilightThreadRunning = false;
ambilightThread.Join();
StopAmbilight();

ReleaseDirect3DDevice();

Expand Down Expand Up @@ -107,7 +107,7 @@ private static void SystemManager_DisplaySettingsChanged(Desktop.ScreenResolutio
StartAmbilight();
}

private static void InitializeDirect3DDevice()
private static async void InitializeDirect3DDevice()
{
try
{
Expand All @@ -121,8 +121,8 @@ private static void InitializeDirect3DDevice()
{
if (ex.ResultCode == ResultCode.DeviceLost)
{
while (device.TestCooperativeLevel() == ResultCode.DeviceLost)
Thread.Sleep(100);
while (device is not null && device.TestCooperativeLevel() == ResultCode.DeviceLost)
await Task.Delay(100);

// Recreate the device and resources
ReleaseDirect3DDevice();
Expand Down Expand Up @@ -309,11 +309,15 @@ private static void StartAmbilight()

private static void StopAmbilight()
{
if (!ambilightThreadRunning)
return;

ambilightThreadRunning = false;
ambilightThread.Join();
// suspend watchdog
if (ambilightThread is not null)
{
ambilightThreadRunning = false;
// Ensure the thread has finished execution
if (ambilightThread.IsAlive)
ambilightThread.Join();
ambilightThread = null;
}
}

private static Color CalculateColorAverage(int x, int y)
Expand Down
Loading

0 comments on commit 86e1462

Please sign in to comment.