Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EA to public #1070

Merged
merged 73 commits into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
e121a8e
Implement CustomWpf (#154)
Valkirie Jan 12, 2024
69453a4
Implement support for Intel Graphics Control Library (IGCL) (#158)
Valkirie Jan 13, 2024
efd3d01
Implement new UI classes (#153)
Valkirie Jan 13, 2024
16fb364
Improve ADLX and IGCL (#160)
Valkirie Jan 15, 2024
38440d6
Allow OSD customization (#161)
0SkillAllLuck Jan 15, 2024
70ebce9
Change Serilog.Sinks.File MinimumLevel to Information
Valkirie Jan 19, 2024
905bbc5
Update README.md to include Droix Discord link (#168)
CasperH2O Jan 19, 2024
009f5c2
Improvement Increased gyro aiming down sites multiplier lower range. …
CasperH2O Jan 19, 2024
7c5fa1b
Translation and localization update (#167)
CasperH2O Jan 19, 2024
6c1dcb5
Support GPD WIN MINI (Initial) (#169)
CasperH2O Jan 24, 2024
9334357
Build 0.20.4.0
CasperH2O Jan 29, 2024
a0a753a
do not try and restore default GPU frequency on AMD GPUs
Valkirie Jan 30, 2024
44786fa
Update HidHide to 1.4.202 (#182)
Valkirie Feb 3, 2024
2b07581
Added support for multi-display and multi-GPU configurations (#186)
Valkirie Feb 16, 2024
0820fdb
Misc fixes (#189)
Valkirie Feb 18, 2024
671d686
MVVM Rework - Batch 1 (#193)
CasperH2O Feb 29, 2024
15e5362
Build 0.20.5.0
CasperH2O Feb 29, 2024
0b16640
Build 0.20.5.1
CasperH2O Mar 5, 2024
1895d59
Implement JibbSmart's GamepadMotionHelper (#206)
Valkirie Mar 18, 2024
3f84666
Build 0.20.5.2
CasperH2O Mar 18, 2024
d5512e4
InnoSetup Update (#209)
CasperH2O Mar 22, 2024
69ace20
Build 0.20.5.3
CasperH2O Mar 22, 2024
76f4380
implement enum SteeringAxis
Valkirie Mar 25, 2024
efaf17d
Support for MSI Claw (#213)
romracer Mar 30, 2024
2ec8425
fix profile management
Valkirie Mar 31, 2024
bfed49f
Build 0.20.5.4
CasperH2O Mar 30, 2024
523c86d
Build 0.20.5.5
CasperH2O Apr 4, 2024
9451cae
Update RTSS to 7.3.6
Apr 4, 2024
dc1fcbb
implement automatic Roll/Yaw swap (#229)
Valkirie Apr 7, 2024
e76fe46
code cleanup
Valkirie Apr 8, 2024
e5149d0
Build 0.20.5.6
CasperH2O Apr 8, 2024
f8858f7
Crash on launch (#238)
romracer Apr 11, 2024
42c71c2
Prevent crash when deleting profiles (#240)
romracer Apr 12, 2024
5dd9202
initialize all MotherboardInfo getters with static object
Valkirie Apr 12, 2024
40fa40d
Set the default log directory to the exe's current location
romracer Apr 14, 2024
4fae43d
Changes profiles to ConcurrentDictionary (#252)
romracer Apr 15, 2024
5df48c1
Fixed an issue preventing GPU clock from being set on latest Steam De…
Valkirie Apr 22, 2024
693c7e5
Fixed an issue causing a crash when profile.Path is null
Valkirie Apr 23, 2024
56943d6
fixed an issue causing a crash when halting performance manager and p…
Valkirie May 4, 2024
d24155c
made MotherboardInfo more robust
Valkirie May 6, 2024
bab7774
GPD Win 4 2024 and RyzenAdj Hawk Point Updatede (#228)
CasperH2O May 6, 2024
caa830e
Fix 3D overlay motion (#259)
CasperH2O May 7, 2024
a8164c9
AOKZOE A2 Support
CasperH2O May 9, 2024
af2663d
Build 0.21.1.0
CasperH2O May 9, 2024
8b92ad8
Fix Custom OSD Battery Level Valkirie/HandheldCompanion#1055
CasperH2O May 10, 2024
04f09ba
Build 0.21.1.1
CasperH2O May 13, 2024
38455fb
Improve controller manager and virtual manager relationship (#272)
Valkirie May 23, 2024
4c50029
Quick tools profile page power preset, fix glyph, expand default fals…
CasperH2O May 23, 2024
ef9d8b5
Fix button prompt visibility and placement HandheldCompanion#1063 (#270)
CasperH2O May 23, 2024
fa23a8c
Fix OSD selection without usable RTSS Valkirie/HandheldCompanion#1030…
CasperH2O May 23, 2024
d4c47e4
3D Overlay fixes (#268)
CasperH2O May 23, 2024
b91e7d5
[AYANEO] Add FlipKB and FlipDS (#267)
0SkillAllLuck May 23, 2024
2cff438
Add trackpad glyphs to GetGlyph functions (#273)
CasperH2O May 23, 2024
2a50fc2
Fix 3D overlay shoulder buttons rotating incorrectly with face camera…
CasperH2O May 23, 2024
9dc5a76
Improve ClawA1M Open and Close logic (#276)
Valkirie May 24, 2024
2ef15c6
ROGAlly and ClawA1M Open/Close logic tweak
Valkirie May 24, 2024
2daf267
OneXPlayer X1 Support
joshuatam May 25, 2024
b46b29c
Update to latest build (#278)
Valkirie May 27, 2024
62b0f9e
Fixed an issue causing a crash on null GetGlyph()
Valkirie May 27, 2024
16ffec7
prevent profile processing if string.IsNullOrEmpty(Name or Path)
Valkirie May 27, 2024
79dec40
Fix DualSense touchpad range mapping.
CasperH2O May 27, 2024
a020510
Build 0.21.2.0
CasperH2O May 27, 2024
ffe956e
Fixed an issue causing a crash when trying to initialize ViGEm client…
Valkirie May 28, 2024
78a8959
Fix a few issues with sensor management (#283)
Valkirie May 28, 2024
5b8f4aa
Improve profile management robustness (#282)
Valkirie May 28, 2024
29fa60c
Fixed an issue causing a crash when AppCompatRegistry can't be accessed
Valkirie May 29, 2024
4efeae8
Fixed an issue creating a blank profile when a null or Empty ProcessE…
Valkirie May 29, 2024
cb1400b
Build 0.21.2.1
Valkirie May 29, 2024
eb46968
Build 0.21.2.3
Valkirie May 29, 2024
1bd6651
Use TheNathannator ViGEm.NET bugfix branche (#285)
Valkirie May 31, 2024
5a8235b
Fix QT default location in settings (again)
CasperH2O May 31, 2024
fd57191
AOKZOE A2 LED control
CasperH2O May 31, 2024
0ca78e6
Build 0.21.2.4
CasperH2O May 31, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion HandheldCompanion.iss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define InstallerVersion '0.2'
#define MyAppSetupName 'Handheld Companion'
#define MyBuildId 'HandheldCompanion'
#define MyAppVersion '0.21.0.1'
#define MyAppVersion '0.21.2.4'
#define MyAppPublisher 'BenjaminLSR'
#define MyAppCopyright 'Copyright @ BenjaminLSR'
#define MyAppURL 'https://github.com/Valkirie/HandheldCompanion'
Expand Down
13 changes: 2 additions & 11 deletions HandheldCompanion/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,6 @@
<setting name="OverlayControllerRestingPitch" serializeAs="String">
<value>0</value>
</setting>
<setting name="OverlayControllerRestingYaw" serializeAs="String">
<value>0</value>
</setting>
<setting name="OverlayControllerRestingRoll" serializeAs="String">
<value>0</value>
</setting>
<setting name="SensorPlacementUpsideDown" serializeAs="String">
<value>False</value>
</setting>
Expand All @@ -87,7 +81,7 @@
<value>30</value>
</setting>
<setting name="OverlayRenderAntialiasing" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
<setting name="OverlayFaceCamera" serializeAs="String">
<value>True</value>
Expand Down Expand Up @@ -186,7 +180,7 @@
<value>True</value>
</setting>
<setting name="QuickToolsLocation" serializeAs="String">
<value>3</value>
<value>1</value>
</setting>
<setting name="QuicktoolsBackdrop" serializeAs="String">
<value>1</value>
Expand Down Expand Up @@ -269,9 +263,6 @@
<setting name="OnScreenDisplayVRAMLevel" serializeAs="String">
<value>2</value>
</setting>
<setting name="OnScreenDisplayBatteryLevel" serializeAs="String">
<value>2</value>
</setting>
<setting name="OnScreenDisplayFPSLevel" serializeAs="String">
<value>2</value>
</setting>
Expand Down
4 changes: 1 addition & 3 deletions HandheldCompanion/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ protected override void OnStartup(StartupEventArgs args)
var CurrentAssembly = Assembly.GetExecutingAssembly();
var fileVersionInfo = FileVersionInfo.GetVersionInfo(CurrentAssembly.Location);

// set environment variables
Environment.SetEnvironmentVariable("APP_BASE_DIRECTORY", AppContext.BaseDirectory);

// initialize log
Environment.SetEnvironmentVariable("APP_BASE_DIRECTORY", AppContext.BaseDirectory);
LogManager.Initialize("HandheldCompanion");
LogManager.LogInformation("{0} ({1})", CurrentAssembly.GetName(), fileVersionInfo.FileVersion);

Expand Down
49 changes: 33 additions & 16 deletions HandheldCompanion/Controls/ProcessEx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,38 +71,55 @@ public static string GetAppCompatFlags(string Path)
if (string.IsNullOrEmpty(Path))
return string.Empty;

using (var key = Registry.CurrentUser.OpenSubKey(AppCompatRegistry))
lock (registryLock)
{
string valueStr = (string)key?.GetValue(Path);
return valueStr;
try
{
using (var key = Registry.CurrentUser.OpenSubKey(AppCompatRegistry))
{
string valueStr = (string)key?.GetValue(Path);
return valueStr;
}
}
catch { }
}

return string.Empty;
}

private static object registryLock = new();
public static void SetAppCompatFlag(string Path, string Flag, bool value)
{
if (string.IsNullOrEmpty(Path))
return;

using (var key = Registry.CurrentUser.CreateSubKey(AppCompatRegistry, RegistryKeyPermissionCheck.ReadWriteSubTree))
lock (registryLock)
{
if (key != null)
try
{
List<string> values = new List<string> { "~" }; ;
string valueStr = (string)key.GetValue(Path);
using (var key = Registry.CurrentUser.CreateSubKey(AppCompatRegistry, RegistryKeyPermissionCheck.ReadWriteSubTree))
{
if (key != null)
{
List<string> values = new List<string> { "~" }; ;
string valueStr = (string)key.GetValue(Path);

if (!string.IsNullOrEmpty(valueStr))
values = valueStr.Split(' ').ToList();
if (!string.IsNullOrEmpty(valueStr))
values = valueStr.Split(' ').ToList();

values.Remove(Flag);
values.Remove(Flag);

if (value)
values.Add(Flag);
if (value)
values.Add(Flag);

if (values.Count == 1 && values[0] == "~" && !string.IsNullOrEmpty(valueStr))
key.DeleteValue(Path);
else
key.SetValue(Path, string.Join(" ", values), RegistryValueKind.String);
if (values.Count == 1 && values[0] == "~" && !string.IsNullOrEmpty(valueStr))
key.DeleteValue(Path);
else
key.SetValue(Path, string.Join(" ", values), RegistryValueKind.String);
}
}
}
catch { }
}
}

Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ public override string GetGlyph(ButtonFlags button)
return "\u2211";
}

return defaultGlyph;
return base.GetGlyph(button);
}
}
166 changes: 166 additions & 0 deletions HandheldCompanion/Devices/AOKZOE/AOKZOEA2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
using HidLibrary;
using System;
using System.Linq;
using System.Windows.Media;
using static HandheldCompanion.Utils.DeviceUtils;

namespace HandheldCompanion.Devices;

public class AOKZOEA2 : AOKZOEA1Pro
{
HidDevice hidDevice;

public AOKZOEA2()
{
// device specific settings
ProductModel = "AOKZOEA2";

// device specific capacities
Capabilities |= DeviceCapabilities.DynamicLighting;
Capabilities |= DeviceCapabilities.DynamicLightingBrightness;
DynamicLightingCapabilities |= LEDLevel.SolidColor;
DynamicLightingCapabilities |= LEDLevel.Rainbow;

// LED HID Device
_vid = 0x1A2C;
_pid = 0xB001;
}
public override bool IsReady()
{
// Prepare list for all HID devices
HidDevice[] HidDeviceList = HidDevices.Enumerate(_vid, new int[] { _pid }).ToArray();

// Check every HID device to find LED device
foreach (HidDevice device in HidDeviceList)
{
// OneXFly device for LED control does not support a FeatureReport, hardcoded to match the Interface Number
if (device.IsConnected && device.DevicePath.Contains("&mi_00"))
{
hidDevice = device;
return true;
}
}

return false;
}

public override bool SetLedBrightness(int brightness)
{
// OneXFly brightness range is: 0 - 4 range, 0 is off, convert from 0 - 100 % range
brightness = (int)Math.Round(brightness / 20.0);

// Check if device is availible
if (hidDevice is null || !hidDevice.IsConnected)
return false;

// Define the HID message for setting brightness.
byte[] msg = { 0x00, 0x07, 0xFF, 0xFD, 0x01, 0x05, (byte)brightness };

// Write the HID message to set the LED brightness.
hidDevice.Write(msg);

return true;
}

public override bool SetLedColor(Color mainColor, Color secondaryColor, LEDLevel level, int speed = 100)
{
if (!DynamicLightingCapabilities.HasFlag(level))
return false;

// Data message consists of a prefix, LED option, RGB data, and closing byte (0x00)
byte[] prefix = { 0x00, 0x07, 0xFF };
byte[] LEDOption = { 0x00 };
byte[] rgbData = { 0x00 };

// Perform functions and command build-up based on LED level
switch (level)
{
case LEDLevel.SolidColor:
// Find nearest possible color due to RGB limitations of the device
Color ledColor = FindClosestColor(mainColor);

LEDOption = new byte[] { 0xFE };

// RGB data repeats 20 times, fill accordingly
rgbData = Enumerable.Repeat(new[] { ledColor.R, ledColor.G, ledColor.B }, 20)
.SelectMany(colorBytes => colorBytes)
.ToArray();
break;

case LEDLevel.Rainbow:
// OneXConsole "Flowing Light" effect as a rainbow effect
LEDOption = new byte[] { 0x03 };

// RGB data empty, repeats 60 times, fill accordingly
rgbData = Enumerable.Repeat((byte)0x00, 60).ToArray();
break;

default:
return false;
}

// Check if device is availible
if (hidDevice is null || !hidDevice.IsConnected)
return false;

// Combine prefix, LED Option, RGB data, and closing byte (0x00)
byte[] msg = prefix.Concat(LEDOption).Concat(rgbData).Concat(new byte[] { 0x00 }).ToArray();

// Write the HID message to set the RGB color effect
hidDevice.Write(msg);

return true;
}

static Color FindClosestColor(Color inputColor)
{
// Predefined colors that work on the device
Color[] predefinedColors = new Color[]
{
Color.FromRgb(255, 0, 0), // Red (255,0,0)
Color.FromRgb(255, 82, 0), // Orange (255, 165, 0)
Color.FromRgb(255, 255, 0), // Yellow (255, 255, 0)
Color.FromRgb(130, 255, 0), // Lime Green (50, 205, 50)
Color.FromRgb(0, 255, 0), // Green (0, 128, 0)
Color.FromRgb(0, 255, 110), // Turquoise (Cyan) (0, 255, 255)
Color.FromRgb(0, 255, 255), // Teal (0, 128, 128)
Color.FromRgb(130, 255, 255), // Blue (? ? ?)
Color.FromRgb(0, 0, 255), // Dark Blue (? ? ?)
Color.FromRgb(122, 0, 255), // Purple (Violet) (128, 0, 128)
Color.FromRgb(255, 0, 255), // Pink (255, 182, 193)
Color.FromRgb(255, 0, 129), // Magenta (255, 0, 255)
};

// Initialize with the first color
Color closestColor = predefinedColors[0];
double minDistance = CalculateDistance(inputColor, closestColor);

// Iterate through predefined colors to find the closest one
foreach (var predefinedColor in predefinedColors)
{
double distance = CalculateDistance(inputColor, predefinedColor);

// Update closest color if a closer one is found
if (distance < minDistance)
{
minDistance = distance;
closestColor = predefinedColor;
}
}

// Return the closest predefined color
return closestColor;
}

static double CalculateDistance(Color color1, Color color2)
{
// Helper method to calculate the Euclidean distance between two colors

int deltaR = color2.R - color1.R;
int deltaG = color2.G - color1.G;
int deltaB = color2.B - color1.B;

// Euclidean distance formula
return Math.Sqrt(deltaR * deltaR + deltaG * deltaG + deltaB * deltaB);
}
}
36 changes: 20 additions & 16 deletions HandheldCompanion/Devices/ASUS/ROGAlly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,15 @@ public override bool Open()
if (asusACPI is null)
return false;

if (hidDevices.TryGetValue(INPUT_HID_ID, out HidDevice device))
{
device.OpenDevice();
device.MonitorDeviceEvents = true;

Task<HidReport> ReportDevice = Task.Run(async () => await device.ReadReportAsync());
ReportDevice.ContinueWith(t => OnReport(ReportDevice.Result, device));
}

Comment on lines +331 to +339
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review asynchronous task handling and device management.

The asynchronous handling of device reports and the management of device connections could be improved for better error handling and resource management.

- Task<HidReport> ReportDevice = Task.Run(async () => await device.ReadReportAsync());
- ReportDevice.ContinueWith(t => OnReport(ReportDevice.Result, device));
+ await device.ReadReportAsync().ContinueWith(t => OnReport(t.Result, device), TaskContinuationOptions.OnlyOnRanToCompletion);

Additionally, consider handling exceptions and ensuring that devices are properly released if an error occurs or the device is disconnected.

Also applies to: 389-399

Committable suggestion was skipped due low confidence.

// force M1/M2 to send F17 and F18
ConfigureController(true);

Expand Down Expand Up @@ -369,32 +378,27 @@ public override bool IsReady()

if (device.ReadFeatureData(out byte[] data, INPUT_HID_ID))
{
device.OpenDevice();
device.MonitorDeviceEvents = true;

hidDevices[INPUT_HID_ID] = device;

Task<HidReport> ReportDevice = Task.Run(async () => await device.ReadReportAsync());
ReportDevice.ContinueWith(t => OnReport(ReportDevice.Result, device));
}
else if (device.ReadFeatureData(out data, AURA_HID_ID))
{
hidDevices[AURA_HID_ID] = device;
}
}

hidDevices.TryGetValue(INPUT_HID_ID, out HidDevice hidDevice);
if (hidDevice is null || !hidDevice.IsConnected)
return false;
if (hidDevices.TryGetValue(INPUT_HID_ID, out HidDevice hidDevice))
{
PnPDevice pnpDevice = PnPDevice.GetDeviceByInterfaceId(hidDevice.DevicePath);
string device_parent = pnpDevice.GetProperty<string>(DevicePropertyKey.Device_Parent);

PnPDevice pnpDevice = PnPDevice.GetDeviceByInterfaceId(hidDevice.DevicePath);
string device_parent = pnpDevice.GetProperty<string>(DevicePropertyKey.Device_Parent);
PnPDevice pnpParent = PnPDevice.GetDeviceByInstanceId(device_parent);
Guid parent_guid = pnpParent.GetProperty<Guid>(DevicePropertyKey.Device_ClassGuid);
string parent_instanceId = pnpParent.GetProperty<string>(DevicePropertyKey.Device_InstanceId);

PnPDevice pnpParent = PnPDevice.GetDeviceByInstanceId(device_parent);
Guid parent_guid = pnpParent.GetProperty<Guid>(DevicePropertyKey.Device_ClassGuid);
string parent_instanceId = pnpParent.GetProperty<string>(DevicePropertyKey.Device_InstanceId);
return DeviceHelper.IsDeviceAvailable(parent_guid, parent_instanceId);
}

return DeviceHelper.IsDeviceAvailable(parent_guid, parent_instanceId);
return false;
}

private void OnReport(HidReport result, HidDevice device)
Expand Down Expand Up @@ -612,7 +616,7 @@ public override string GetGlyph(ButtonFlags button)
return "\u2213";
}

return defaultGlyph;
return base.GetGlyph(button);
}

private void ConfigureController(bool Remap)
Expand Down
2 changes: 1 addition & 1 deletion HandheldCompanion/Devices/AYANEO/AYANEO2021.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ public override string GetGlyph(ButtonFlags button)
return "\u243D";
}

return defaultGlyph;
return base.GetGlyph(button);
}
}
Loading
Loading