Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesCJ60 committed Jan 22, 2023
1 parent 8913514 commit 7622714
Show file tree
Hide file tree
Showing 26 changed files with 1,376 additions and 58 deletions.
9 changes: 9 additions & 0 deletions AATUV3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@
<Compile Include="Pages\AMDCPU\AMDCustomPresets.xaml.cs">
<DependentUpon>AMDCustomPresets.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\APM.xaml.cs">
<DependentUpon>APM.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\FSR.xaml.cs">
<DependentUpon>FSR.xaml</DependentUpon>
</Compile>
Expand All @@ -132,7 +135,9 @@
<Compile Include="Pages\ASUSAC.xaml.cs">
<DependentUpon>ASUSAC.xaml</DependentUpon>
</Compile>
<Compile Include="Scripts\ADLX\ADLXBackend.cs" />
<Compile Include="Scripts\Adpative Modes\Performance\CpuPowerLimiter.cs" />
<Compile Include="Scripts\Adpative Modes\Performance\iGPUClockAdjust.cs" />
<Compile Include="Scripts\GlobalVariables.cs" />
<Compile Include="Scripts\Intel\BindableBase.cs" />
<Compile Include="Scripts\Intel\ChangeTDP.cs" />
Expand Down Expand Up @@ -167,6 +172,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\APM.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\Generic.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
8 changes: 7 additions & 1 deletion App.config
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,13 @@
<value>0,0,0,0,0,0,0,0</value>
</setting>
<setting name="SnowPreset" serializeAs="String">
<value>1</value>
<value>2</value>
</setting>
<setting name="PerOCCCD1" serializeAs="String">
<value>0,0,0,0,0,0,0,0</value>
</setting>
<setting name="isPerOC" serializeAs="String">
<value>False</value>
</setting>
</UXTU.Properties.Settings>
<AATUV3.Properties.Settings>
Expand Down
22 changes: 22 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,44 @@
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Security.Principal;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Interop;
using UXTU.Scripts;
using Windows.Foundation.Metadata;

namespace AATUV3
{

public partial class App : Application
{
//check if program has admin rights
public static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}

private void Application_Startup(object sender, StartupEventArgs e)
{
_ = Tablet.TabletDevices;
new HwndSource(new HwndSourceParameters());

if (!App.IsAdministrator())
{
// Restart and run as admin
var exeName = Process.GetCurrentProcess().MainModule.FileName;
ProcessStartInfo startInfo = new ProcessStartInfo(exeName);
startInfo.Verb = "runas";
startInfo.Arguments = "restart";
Process.Start(startInfo);
System.Windows.Application.Current.Shutdown();
}
}
}
}
143 changes: 124 additions & 19 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,19 @@
using Forms = System.Windows.Forms;
using UXTU.Scripts;
using Microsoft.Win32;
using System.Windows.Forms;
using MessageBox = System.Windows.MessageBox;
using Application = System.Windows.Application;

namespace AATUV3
{
public partial class MainWindow : Window
{
//check if program has admin rights
public static bool IsAdministrator()
{
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
return principal.IsInRole(WindowsBuiltInRole.Administrator);
}

public static string menu = "";
public static string AppName = "";
public static string mbo = "";
public static Timer reApply;
public static System.Threading.Timer reApply;

[DllImport("inpoutx64.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
Expand All @@ -61,17 +57,6 @@ public static bool IsAdministrator()

public MainWindow()
{
if (!MainWindow.IsAdministrator())
{
// Restart and run as admin
var exeName = Process.GetCurrentProcess().MainModule.FileName;
ProcessStartInfo startInfo = new ProcessStartInfo(exeName);
startInfo.Verb = "runas";
startInfo.Arguments = "restart";
Process.Start(startInfo);
this.Close();
}

InitializeComponent();
//load main menu on load
PagesNavigation.Navigate(new System.Uri("Pages/HomeMenu.xaml", UriKind.RelativeOrAbsolute));
Expand Down Expand Up @@ -274,6 +259,7 @@ public MainWindow()

private void OnPowerChange(object s, PowerModeChangedEventArgs e)
{
int i = 0;
switch (e.Mode)
{
case PowerModes.Resume:
Expand All @@ -290,6 +276,124 @@ private void OnPowerChange(object s, PowerModeChangedEventArgs e)
case PowerModes.Suspend:
break;
}

if (e.Mode == Microsoft.Win32.PowerModes.StatusChange)
{
if ((bool)Settings.Default.isCPUCO == true)
{
if ((int)Settings.Default.COCPU >= 0)
{
SendCommand.set_coall((uint)Settings.Default.COCPU);
}
else
{
SendCommand.set_coall(Convert.ToUInt32(0x100000 - (uint)(-1 * (int)Settings.Default.COCPU)));
}
i++;
}

if ((bool)Settings.Default.isGPUCO == true)
{
if ((int)Settings.Default.COiGPU >= 0)
{
SendCommand.set_cogfx((uint)Settings.Default.COiGPU);
}
else
{
SendCommand.set_cogfx(Convert.ToUInt32(0x100000 - (uint)(-1 * (int)Settings.Default.COiGPU)));
}
i++;
}

//if (cbiGPU.IsChecked == true)
//{
// SendCommand.set_gfx_clk((uint)nudiGPU.Value);
// i++;
//}

string CCD1output = Settings.Default.PerCOCCD1;
string[] CCD1 = CCD1output.Split(',');

string CCD2output = Settings.Default.PerCOCCD2;
string[] CCD2 = CCD2output.Split(',');

if (Settings.Default.isPerCO == true)
{
int x = 0;
do
{
int CCD, CCX, CORE, magnitude, magnitude2;

CCD = 0;
CCX = 0;
CORE = x;

magnitude = Convert.ToInt32(CCD1[x]);
magnitude2 = Convert.ToInt32(CCD2[x]);

if (Families.FAMID == 3 || Families.FAMID == 7 || Families.FAMID == 8)
{
int value = (CORE << 20) | (magnitude & 0xFFFF);
SendCommand.set_coper(Convert.ToUInt32(value));
}
else if (magnitude >= 0)
{
uint CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);
}
else
{
magnitude = magnitude * -1;
uint CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude) & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude) & 0xFFFFF);
SendCommand.set_coper(CO);
}

if (magnitude2 >= 0)
{
uint CO;
if (Families.FAMID == 6 || Families.FAMID == 10)
{
CCD = 1;
CCX = 0;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | magnitude & 0xFFFFF);
SendCommand.set_coper(CO);
}
}
else
{
magnitude2 = magnitude2 * -1;
uint CO;
if (Families.FAMID == 6 || Families.FAMID == 10)
{
CCX = 0;
CCD = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude2) & 0xFFFFF);
SendCommand.set_coper(CO);

CCX = 1;
CO = Convert.ToUInt32(((CCD << 4 | CCX % 1 & 15) << 4 | CORE % 8 & 15) << 20 | (0x100000 - magnitude2) & 0xFFFFF);
SendCommand.set_coper(CO);
}
}

x++;
}
while (x < 8);
i++;
}
}
}

private void btnClose_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -459,6 +563,7 @@ private void rdAdaptive_Click(object sender, RoutedEventArgs e)
if (AppName.Contains("AMD APU"))
{
//Load menu
//PagesNavigation.Navigate(new System.Uri("Pages/APM.xaml", UriKind.RelativeOrAbsolute));
PagesNavigation.Navigate(new System.Uri("Pages/ComingSoon.xaml", UriKind.RelativeOrAbsolute));
//Set menu lable to menu name
menu = (string)rdAdaptive.Content;
Expand Down
2 changes: 1 addition & 1 deletion NumericSpinner.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="22" />
<ColumnDefinition Width="21" />
</Grid.ColumnDefinitions>
<TextBox x:Name="tb_main" x:FieldModifier="private" FontWeight="Medium" FontSize="12" VerticalContentAlignment="Center" Padding="5,-3"
Grid.Column="0" Grid.RowSpan="2" Text="0" Background="Transparent" BorderBrush="Transparent" BorderThickness="0" Foreground="White">
Expand Down
Loading

0 comments on commit 7622714

Please sign in to comment.