Skip to content

Commit

Permalink
Move files from EA to Public.
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperH2O committed Apr 19, 2024
1 parent cf38ec9 commit 33a981d
Show file tree
Hide file tree
Showing 40 changed files with 5,733 additions and 5,955 deletions.
9 changes: 1 addition & 8 deletions HandheldCompanion/ADLX/ADLXBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace HandheldCompanion.ADLX
{
public class ADLXBackend
public static class ADLXBackend
{
public const string ADLX_Wrapper = @"ADLX_Wrapper.dll";

Expand Down Expand Up @@ -123,12 +123,5 @@ 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);

internal static AdlxTelemetryData GetTelemetryData()
{
AdlxTelemetryData TelemetryData = new();
bool Result = GetAdlxTelemetry(0, ref TelemetryData);
return TelemetryData;
}
}
}
162 changes: 81 additions & 81 deletions HandheldCompanion/App.xaml
Original file line number Diff line number Diff line change
@@ -1,82 +1,82 @@
<Application
x:Class="HandheldCompanion.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:HandheldCompanion.Converters"
xmlns:math="http://hexinnovation.com/math"
xmlns:presets="clr-namespace:HandheldCompanion.Presets"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern">

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources>
<ui:ThemeResources.ThemeDictionaries>
<ResourceDictionary x:Key="Light" ui:ThemeDictionary.Key="Light">
<ResourceDictionary.MergedDictionaries>
<presets:ColorPresetResources TargetTheme="Light" />
<presets:ShapePresetResources />
</ResourceDictionary.MergedDictionaries>
<Thickness x:Key="SearchBoxBorderThickness">0</Thickness>
<SolidColorBrush x:Key="CustomThemeBrush" Color="Red" />
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FFF1F1F1" />
<SolidColorBrush x:Key="PageHeaderForegroundBrush" Color="Black" />
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
<SolidColorBrush x:Key="SearchBoxBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="HomePageBackgroundBrush" Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Transparent" />
<SolidColorBrush x:Key="AppContentBackgroundBrush" Color="{StaticResource SystemAltHighColor}" />
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
</ResourceDictionary>

<ResourceDictionary x:Key="Dark" ui:ThemeDictionary.Key="Dark">
<ResourceDictionary.MergedDictionaries>
<presets:ColorPresetResources TargetTheme="Dark" />
<presets:ShapePresetResources />
</ResourceDictionary.MergedDictionaries>
<Thickness x:Key="SearchBoxBorderThickness">0</Thickness>
<SolidColorBrush x:Key="CustomThemeBrush" Color="Yellow" />
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FF232323" />
<SolidColorBrush x:Key="PageHeaderForegroundBrush" Color="White" />
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
<SolidColorBrush x:Key="SearchBoxBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="HomePageBackgroundBrush" Color="Transparent" />
<SolidColorBrush x:Key="AppContentBackgroundBrush" Color="#FF282828" />
<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Transparent" />
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
</ResourceDictionary>
</ui:ThemeResources.ThemeDictionaries>
</ui:ThemeResources>

<!-- ModernWPF controls resources -->
<ui:XamlControlsResources />

<ResourceDictionary Source="pack://Application:,,,/HandheldCompanion;component/Styles/NavigationView.xaml" />
<ResourceDictionary Source="pack://Application:,,,/HandheldCompanion;component/Styles/Slider.xaml" />
<ResourceDictionary Source="pack://Application:,,,/HandheldCompanion;component/Styles/ToggleSwitch.xaml" />
<ResourceDictionary Source="pack://application:,,,/ColorPicker;component/Styles/DefaultColorPickerStyle.xaml" />

<ResourceDictionary Source="Views/TemplatesDictionary.xaml" />

</ResourceDictionary.MergedDictionaries>

<!-- Other app resources here -->
<converters:InverseAppThemeConverter x:Key="InverseAppThemeConverter" />
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />
<converters:IndexToVisibilityConverter x:Key="IndexToVisibilityConverter" />
<converters:IsEnabledConverter x:Key="IsEnabledConverter" />
<converters:PercentageConverter x:Key="PercentageConverter" />
<converters:InvertBooleanConverter x:Key="InvertBooleanConverter" />
<converters:InvertPercentageConverter x:Key="InvertPercentageConverter" />
<converters:IsNullConverter x:Key="IsNullConverter" />

<math:MathConverter x:Key="Math" />

<Style BasedOn="{StaticResource {x:Static ui:ThemeKeys.ExpanderCardStyleKey}}" TargetType="Expander">
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>

</ResourceDictionary>
</Application.Resources>
<Application
x:Class="HandheldCompanion.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:converters="clr-namespace:HandheldCompanion.Converters"
xmlns:math="http://hexinnovation.com/math"
xmlns:presets="clr-namespace:HandheldCompanion.Presets"
xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern">

<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ui:ThemeResources>
<ui:ThemeResources.ThemeDictionaries>
<ResourceDictionary x:Key="Light" ui:ThemeDictionary.Key="Light">
<ResourceDictionary.MergedDictionaries>
<presets:ColorPresetResources TargetTheme="Light" />
<presets:ShapePresetResources />
</ResourceDictionary.MergedDictionaries>
<Thickness x:Key="SearchBoxBorderThickness">0</Thickness>
<SolidColorBrush x:Key="CustomThemeBrush" Color="Red" />
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FFF1F1F1" />
<SolidColorBrush x:Key="PageHeaderForegroundBrush" Color="Black" />
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
<SolidColorBrush x:Key="SearchBoxBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="HomePageBackgroundBrush" Color="Transparent" />
<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Transparent" />
<SolidColorBrush x:Key="AppContentBackgroundBrush" Color="{StaticResource SystemAltHighColor}" />
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
</ResourceDictionary>

<ResourceDictionary x:Key="Dark" ui:ThemeDictionary.Key="Dark">
<ResourceDictionary.MergedDictionaries>
<presets:ColorPresetResources TargetTheme="Dark" />
<presets:ShapePresetResources />
</ResourceDictionary.MergedDictionaries>
<Thickness x:Key="SearchBoxBorderThickness">0</Thickness>
<SolidColorBrush x:Key="CustomThemeBrush" Color="Yellow" />
<SolidColorBrush x:Key="AppBackgroundBrush" Color="#FF232323" />
<SolidColorBrush x:Key="PageHeaderForegroundBrush" Color="White" />
<Thickness x:Key="ControlExampleDisplayBorderThickness">0</Thickness>
<SolidColorBrush x:Key="SearchBoxBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="HomePageBackgroundBrush" Color="Transparent" />
<SolidColorBrush x:Key="AppContentBackgroundBrush" Color="#FF282828" />
<SolidColorBrush x:Key="NavigationViewExpandedPaneBackground" Color="Transparent" />
<StaticResource x:Key="ControlExampleDisplayBrush" ResourceKey="SolidBackgroundFillColorBaseBrush" />
</ResourceDictionary>
</ui:ThemeResources.ThemeDictionaries>
</ui:ThemeResources>

<!-- ModernWPF controls resources -->
<ui:XamlControlsResources />

<ResourceDictionary Source="pack://Application:,,,/HandheldCompanion;component/Styles/NavigationView.xaml" />
<ResourceDictionary Source="pack://Application:,,,/HandheldCompanion;component/Styles/Slider.xaml" />
<ResourceDictionary Source="pack://Application:,,,/HandheldCompanion;component/Styles/ToggleSwitch.xaml" />
<ResourceDictionary Source="pack://application:,,,/ColorPicker;component/Styles/DefaultColorPickerStyle.xaml" />

<ResourceDictionary Source="Views/TemplatesDictionary.xaml" />

</ResourceDictionary.MergedDictionaries>

<!-- Other app resources here -->
<converters:InverseAppThemeConverter x:Key="InverseAppThemeConverter" />
<converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
<converters:InverseBooleanToVisibilityConverter x:Key="InverseBooleanToVisibilityConverter" />
<converters:IndexToVisibilityConverter x:Key="IndexToVisibilityConverter" />
<converters:IsEnabledConverter x:Key="IsEnabledConverter" />
<converters:PercentageConverter x:Key="PercentageConverter" />
<converters:InvertBooleanConverter x:Key="InvertBooleanConverter" />
<converters:InvertPercentageConverter x:Key="InvertPercentageConverter" />
<converters:IsNullConverter x:Key="IsNullConverter" />

<math:MathConverter x:Key="Math" />

<Style BasedOn="{StaticResource {x:Static ui:ThemeKeys.ExpanderCardStyleKey}}" TargetType="Expander">
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>

</ResourceDictionary>
</Application.Resources>
</Application>
3 changes: 3 additions & 0 deletions HandheldCompanion/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ 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
LogManager.Initialize("HandheldCompanion");
LogManager.LogInformation("{0} ({1})", CurrentAssembly.GetName(), fileVersionInfo.FileVersion);
Expand Down
52 changes: 0 additions & 52 deletions HandheldCompanion/Devices/AYANEO/AYANEODevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,8 @@ protected enum LEDGroup
AYA = 4,
}

private int prevBatteryLevelPercentage;
private PowerLineStatus prevPowerStatus;

public AYANEODevice()
{
this.prevPowerStatus = SystemInformation.PowerStatus.PowerLineStatus;
this.prevBatteryLevelPercentage = (int)(SystemInformation.PowerStatus.BatteryLifePercent * 100);
SystemManager.PowerStatusChanged += PowerManager_PowerStatusChanged;
}

public override string GetGlyph(ButtonFlags button)
Expand All @@ -44,51 +38,5 @@ public override string GetGlyph(ButtonFlags button)

return defaultGlyph;
}

private void PowerManager_PowerStatusChanged(PowerStatus powerStatus)
{
// Ayaneo devices automatically set LED color and or effect in the following scenarios
// - Plugged in, charging
// - Fully charged, battery 100%
// - Battery almost empty, battery 5% or less
// This function overrides this change based on settings

// Get power information and bettery as a % of 100
int currentBatteryLevelPercentage = (int)(powerStatus.BatteryLifePercent * 100);

// Check if the device went from battery to charging
if (powerStatus.PowerLineStatus == PowerLineStatus.Online && this.prevPowerStatus == PowerLineStatus.Offline)
{
LogManager.LogDebug("Ayaneo LED, device went from battery to charging, apply color");
base.PowerStatusChange(this);
}

// Check if the device went from charging to battery
if (powerStatus.PowerLineStatus == PowerLineStatus.Offline && this.prevPowerStatus == PowerLineStatus.Online)
{
LogManager.LogDebug("Ayaneo LED, device went from charging to battery, apply color");
base.PowerStatusChange(this);
}

// Check for the battery level change scenarios

// Check if the battery went from 99 or lower to 100
if (this.prevBatteryLevelPercentage <= 99 && currentBatteryLevelPercentage >= 100)
{
LogManager.LogDebug("Ayaneo LED, device went from < 99% battery to 100%, apply color");
base.PowerStatusChange(this);
}

// Check if the battery went from 6 or higher to 5 or lower
if (this.prevBatteryLevelPercentage >= 6 && currentBatteryLevelPercentage <= 5)
{
LogManager.LogDebug("Ayaneo LED, device went from > 5% battery <= 5%, apply color");
base.PowerStatusChange(this);
}

// Track battery level % and power status for next round
this.prevBatteryLevelPercentage = currentBatteryLevelPercentage;
this.prevPowerStatus = powerStatus.PowerLineStatus;
}
}
}
34 changes: 29 additions & 5 deletions HandheldCompanion/Devices/AYANEO/AYANEODeviceCEc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ public AYANEODeviceCEc()
));
}

public override bool Open()
{
if (!base.Open()) return false;
lock (this.updateLock)
{
this.CEcControl_RgbHoldControl();
}
return true;
}

public override void Close()
{
lock (this.updateLock)
{
this.CEcControl_RgbReleaseControl();
}
base.Close();
}

public override bool SetLedStatus(bool status)
{
lock (this.updateLock)
Expand Down Expand Up @@ -159,11 +178,6 @@ private void CEcRgb_GlobalOff(LEDGroup group)
this.CEcRgb_I2cWrite(group, 0x02, 0xc0);
}

private void CEcRgb_SlowOff(LEDGroup group)
{
this.CEcRgb_I2cWrite(group, 0x02, 0xc0 + (byte)'\a');
}

private void CEcRgb_SetColorAll(LEDGroup group, Color color)
{
foreach (int zone in this.rgbZones)
Expand Down Expand Up @@ -215,5 +229,15 @@ protected virtual void CEcControl_RgbI2cWrite(LEDGroup group, byte command, byte
Thread.Sleep(5); // AYASpace does this so copied it here
this.ECRAMWrite(0xbf, 0xfe);
}

protected virtual void CEcControl_RgbHoldControl()
{
this.ECRAMWrite(0xbf, 0xfe);
}

protected virtual void CEcControl_RgbReleaseControl()
{
this.ECRAMWrite(0xbf, 0x00);
}
}
}
21 changes: 18 additions & 3 deletions HandheldCompanion/Devices/AYANEO/AYANEODeviceCEii.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,30 @@ protected override void CEcControl_RgbI2cWrite(LEDGroup group, byte command, byt
Thread.Sleep(10); // AYASpace does this so copied it here
}

public bool ECRamDirectWrite(byte address, byte data, byte offset = 0xd1)
{
ushort address2 = BitConverter.ToUInt16(new byte[] { (byte)address, offset }, 0);
return base.ECRamDirectWrite(address2, this.ECDetails, data);
}

protected override void CEcControl_RgbHoldControl()
{
this.CEiiEcHelper_RgbStart();
}

protected override void CEcControl_RgbReleaseControl()
{
this.CEiiEcHelper_RgbStop();
}

protected void CEiiEcHelper_RgbStart()
{
this.ECRamDirectWrite(0x87, 0xa5);
}

public bool ECRamDirectWrite(byte address, byte data, byte offset = 0xd1)
protected void CEiiEcHelper_RgbStop()
{
ushort address2 = BitConverter.ToUInt16(new byte[] { (byte)address, offset }, 0);
return base.ECRamDirectWrite(address2, this.ECDetails, data);
this.ECRamDirectWrite(0x87, 0x00);
}
}
}
Loading

0 comments on commit 33a981d

Please sign in to comment.