Skip to content

Commit

Permalink
Merge pull request #36 from project-sbc/Working_Test
Browse files Browse the repository at this point in the history
Working test
  • Loading branch information
project-sbc authored Oct 18, 2022
2 parents 2ad38ba + 8079cee commit c7e0302
Show file tree
Hide file tree
Showing 30 changed files with 3,222 additions and 1,297 deletions.
107 changes: 64 additions & 43 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public static class GlobalVariables
public static int cpuActiveCores = 0;
public static int maxCpuCores = 1;
public static int baseCPUSpeed = 1000;


public static bool needCPUMaxFreqRead = false;
public static bool needActiveCoreRead = false;
//RTSS fps limit
public static string FPSLimit = "Unlocked";

Expand Down Expand Up @@ -167,7 +167,9 @@ public MainWindow()
_ = Tablet.TabletDevices;

//test code here

//RunCLI.RunCommand(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile + ""));
//System.Windows.Forms.MessageBox.Show(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "\\Playnite\\Playnite.FullscreenApp.exe --start"));

}

private void setUpNotifyIcon()
Expand Down Expand Up @@ -287,40 +289,53 @@ private bool ButtonComboPress(Gamepad gp,string BC)
bool result = false;

//split string into array
string[] strBC = BC.Split('+');
//gamepad flag array
GamepadButtonFlags[] qamButtonCombo = new GamepadButtonFlags[strBC.Length];
int intCount = 0;
foreach (var bc in strBC)
{
//for each string lookup in the dictionary for the gamepad flag
qamButtonCombo[intCount] = buttonLookUp[bc];
intCount++;
}
//set bool to true
bool oldGamepadPress = true;
bool GamepadPress = true;
foreach (GamepadButtonFlags button in qamButtonCombo)


if (BC.IndexOf("+") > 0)
{
//the press scenario is defined when the old gamepad state doesn't have all buttons pressed but the new state does. This will turn the bool false if any of the buttons arent pressed
if (!gamepad.Buttons.HasFlag(button))
string[] strBC = BC.Split('+');

//gamepad flag array
GamepadButtonFlags[] ButtonCombo = new GamepadButtonFlags[strBC.Length];
int intCount = 0;

foreach (var bc in strBC)
{
oldGamepadPress = false;
//for each string lookup in the dictionary for the gamepad flag
ButtonCombo[intCount] = buttonLookUp[bc];
intCount++;
}
if (!gp.Buttons.HasFlag(button))

//set bool to true
bool oldGamepadPress = true;
bool GamepadPress = true;
foreach (GamepadButtonFlags button in ButtonCombo)
{
GamepadPress = false;
//the press scenario is defined when the old gamepad state doesn't have all buttons pressed but the new state does. This will turn the bool false if any of the buttons arent pressed
if (!gamepad.Buttons.HasFlag(button))
{
oldGamepadPress = false;
}
if (!gp.Buttons.HasFlag(button))
{
GamepadPress = false;
}
}
//button press is true when current gamepadpress is true and the old gamepad state is false
if (!oldGamepadPress && GamepadPress)
{
result = true;
}
else
{
result = false;
}



}
//button press is true when current gamepadpress is true and the old gamepad state is false
if (!oldGamepadPress && GamepadPress)
{
result = true;
}
else
{
result = false;
}



return result;

Expand All @@ -338,6 +353,10 @@ private void timerTick(object sender, EventArgs e)
getController();
}
}
else if (!controller.IsConnected)
{
getController();
}


if (controller != null)
Expand All @@ -359,6 +378,18 @@ private void timerTick(object sender, EventArgs e)
{
PowerControlPanel.Classes.EnableFSR.EnableFSR.enableDisableFSR();
}
if (ButtonComboPress(currentGamepad, Properties.Settings.Default.gameLauncherButtonCombo))
{
if (Properties.Settings.Default.gameLauncher == "Steam")
{
PowerControlPanel.Classes.Steam.Steam.openSteamBigPicture();
}
if (Properties.Settings.Default.gameLauncher == "PlayNite")
{
PowerControlPanel.Classes.Playnite.Playnite.playniteToggle();
}

}

//set currentgamepad snapshot to global gamepad for comparison
gamepad = currentGamepad;
Expand Down Expand Up @@ -549,7 +580,6 @@ private void OSKEvent()

private void QAMEvent()
{

handleOpenCloseQAM();
}

Expand All @@ -562,18 +592,9 @@ void initializeNavigationFrame()
HamburgerMenuControl.Content = this.navigationServiceEx.Frame;
// Navigate to the home page.

if (Properties.Settings.Default.homePageTypeMW == "Grouped Slider")
{

this.Loaded += (sender, args) => this.navigationServiceEx.Navigate(new Uri("PowerControlPanel/Pages/HomePage.xaml", UriKind.RelativeOrAbsolute));
}
if (Properties.Settings.Default.homePageTypeMW == "Slider")
{
this.Loaded += (sender, args) => this.navigationServiceEx.Navigate(new Uri("PowerControlPanel/Pages/SliderHomePage.xaml", UriKind.RelativeOrAbsolute));
}
if (Properties.Settings.Default.homePageTypeMW == "Tile")
{
this.Loaded += (sender, args) => this.navigationServiceEx.Navigate(new Uri("PowerControlPanel/Pages/TileHomePage.xaml", UriKind.RelativeOrAbsolute));
}

}

private void HamburgerMenuControl_OnItemInvoked(object sender, HamburgerMenuItemInvokedEventArgs e)
Expand Down
14 changes: 9 additions & 5 deletions Power Control Panel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
<PlatformTarget>x64</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon>Resources\Pictures\PCP.ico</ApplicationIcon>
<Version>0.1.13.0</Version>
<Version>0.2.2.0</Version>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
</PropertyGroup>

<ItemGroup>
<None Remove="PowerControlPanel\Logs\application_log.txt" />
<None Remove="PowerControlPanel\ProfileData\Profiles_Template.xml" />
<None Remove="ProjectSBC.png" />
<None Remove="Resources\AMD\RyzenAdj\inpoutx64.dll" />
<None Remove="Resources\AMD\RyzenAdj\libryzenadj.dll" />
<None Remove="Resources\AMD\RyzenAdj\ryzenadj.exe" />
Expand All @@ -37,7 +38,6 @@
<None Remove="Resources\Intel\MSR\WinRing0x64.dll" />
<None Remove="Resources\Intel\MSR\WinRing0x64.sys" />
<None Remove="Resources\Intel\RW\Rw.exe" />
<None Remove="Resources\Pictures\ProjectSBC.png" />
<None Remove="Resources\QRes\QRes.exe" />
<None Remove="Resources\SetDPI\SetDpi.exe" />
</ItemGroup>
Expand Down Expand Up @@ -104,9 +104,6 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\Pictures\PCP.ico" />
<Content Include="Resources\Pictures\ProjectSBC.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Resources\QRes\QRes.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
Expand All @@ -124,6 +121,7 @@
<PackageReference Include="MahApps.Metro" Version="2.4.9" />
<PackageReference Include="MahApps.Metro.IconPacks.FontAwesome" Version="4.11.0" />
<PackageReference Include="MahApps.Metro.IconPacks.Material" Version="4.11.0" />
<PackageReference Include="MahApps.Metro.IconPacks.SimpleIcons" Version="4.11.0" />
<PackageReference Include="SecretNest.SequentialScheduler" Version="1.0.2" />
<PackageReference Include="SharpDX.XInput" Version="4.2.0" />
<PackageReference Include="squirrel.windows" Version="2.0.1" />
Expand Down Expand Up @@ -180,4 +178,10 @@
<Folder Include="PowerControlPanel\Pages\Settings\" />
</ItemGroup>

<ItemGroup>
<Resource Include="ProjectSBC.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Resource>
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions PowerControlPanel/Classes/ChangeGPUCLK/ChangeGPUCLK.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ public static void changeAMDGPUClock(int gpuclk)
lock (objLock)
{
if (gpuclk > Properties.Settings.Default.maxGPUCLK) { gpuclk = Properties.Settings.Default.maxGPUCLK; }
commandArguments = " --set-gfx=" + gpuclk.ToString();
commandArguments = " --gfx-clk=" + gpuclk.ToString();
//StreamWriterLog.startStreamWriter("Read TDP AMD processRyzenAj=" + processRyzenAdj + "; commandarugment=" + commandArguments);

result = RunCLI.RunCommand(commandArguments, true, processRyzenAdj);
result = RunCLI.RunCommand(commandArguments, false, processRyzenAdj);

GlobalVariables.gpuclk = gpuclk.ToString();

Expand Down
1 change: 1 addition & 0 deletions PowerControlPanel/Classes/ChangeTDP/ChangeTDP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void changeTDP(int pl1TDP, int pl2TDP)

//read tdp after changing
readTDP();
GlobalVariables.needTDPRead = false;
}
catch (Exception ex)
{
Expand Down
59 changes: 59 additions & 0 deletions PowerControlPanel/Classes/Playnite/Playnite.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Power_Control_Panel.PowerControlPanel.Classes.Playnite
{
public static class Playnite
{
public static void playniteToggle()
{
if (Properties.Settings.Default.directoryPlaynite != "")
{
if (playniteRunning())
{
RunCLI.RunCommand(" --shutdown", false, Properties.Settings.Default.directoryPlaynite + "\\Playnite.FullscreenApp.exe", 6000, false);
}
else
{
RunCLI.RunCommand(" --startfullscreen", false, Properties.Settings.Default.directoryPlaynite + "\\Playnite.FullscreenApp.exe", 6000, false);
}
}


}
public static void setPlayniteDirectory()
{
if (Properties.Settings.Default.directoryPlaynite == "")
{
if (File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Playnite") + "\\Playnite.FullscreenApp.exe"))
{
Properties.Settings.Default.directoryPlaynite = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Playnite");
}
}

}
private static bool playniteRunning()
{


Process[] pname = Process.GetProcessesByName("Playnite.FullscreenApp");
if (pname.Length != 0)
{
return true;

}
else
{
return false;
}

}

}
}
5 changes: 2 additions & 3 deletions PowerControlPanel/Classes/RunCLI/RunCLI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Power_Control_Panel.PowerControlPanel.Classes
public static class RunCLI
{

public static string RunCommand(string arguments, bool readOutput, string processName = "cmd.exe", int waitExit=6000)
public static string RunCommand(string arguments, bool readOutput, string processName = "cmd.exe", int waitExit=6000, bool runasadmin=true)
{
//Runs CLI, if readOutput is true then returns output

Expand All @@ -28,8 +28,7 @@ public static string RunCommand(string arguments, bool readOutput, string proces
//startInfo.Arguments = "/c " + arguments;
startInfo.Arguments = arguments;
startInfo.CreateNoWindow = true;

startInfo.Verb = "runas";
if (runasadmin) { startInfo.Verb = "runas"; }
startInfo.RedirectStandardError = readOutput;
startInfo.RedirectStandardOutput = readOutput;
process.EnableRaisingEvents = true;
Expand Down
27 changes: 25 additions & 2 deletions PowerControlPanel/Classes/StartUp/Resources/StringResources.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<system:String x:Key="Display_Resolution">Display Resolution</system:String>
<system:String x:Key="Display_Refresh">Display Refresh Rate</system:String>
<system:String x:Key="Display_Scaling">Display Scaling (%)</system:String>
<system:String x:Key="FPS_Limit">FPS Limit</system:String>
<system:String x:Key="ActiveProfile">Active Profile</system:String>

<system:String x:Key="SystemControls">SYSTEM CONTROLS</system:String>
Expand All @@ -49,7 +50,8 @@
<system:String x:Key="Show">Show</system:String>
<system:String x:Key="Hide">Hide</system:String>
<system:String x:Key="Close">Close</system:String>

<system:String x:Key="Open">Open</system:String>
<system:String x:Key="Auto">Auto</system:String>
<!-- Tile Homepage -->
<system:String x:Key="TileHomePage_TDP">TDP</system:String>
<system:String x:Key="TileHomePage_TDPBoost">TDP Boost</system:String>
Expand All @@ -59,12 +61,29 @@
<system:String x:Key="TileHomePage_Brightness">Brightness</system:String>
<system:String x:Key="TileHomePage_Volume">Volume</system:String>
<system:String x:Key="TileHomePage_GPUCLK">GPU Clock</system:String>
<system:String x:Key="TileHomePage_Display">Display</system:String>
<system:String x:Key="TileHomePage_Resolution">Display Resolution</system:String>
<system:String x:Key="TileHomePage_Scaling">Display Scaling</system:String>
<system:String x:Key="TileHomePage_Refresh">Display Refresh</system:String>
<system:String x:Key="TileHomePage_ActiveProfile">Active Profile</system:String>
<system:String x:Key="TileHomePage_FPSLimit">FPS Limit</system:String>
<system:String x:Key="TileHomePage_FanSpeed">Fan Speed</system:String>

<system:String x:Key="TileHomePage_Intel">Intel</system:String>
<system:String x:Key="TileHomePage_PlayNite">PlayNite</system:String>
<system:String x:Key="TileHomePage_Steam">Steam</system:String>
<system:String x:Key="TileHomePage_ChangeView">Change View Style</system:String>


<system:String x:Key="HomePage_TDPSettings">TDP Settings</system:String>
<system:String x:Key="HomePage_CPUSettings">CPU Settings</system:String>
<system:String x:Key="HomePage_DisplaySettings">Display Settings</system:String>
<system:String x:Key="HomePage_AMDSettings">AMD Settings</system:String>
<system:String x:Key="HomePage_ProfileSettings">Profile Settings</system:String>
<system:String x:Key="HomePage_VolumeSettings">Volume Settings</system:String>
<system:String x:Key="HomePage_BrightnessSettings">Brightness Settings</system:String>
<system:String x:Key="HomePage_FPSSettings">FPS Limit Settings</system:String>

<!-- Settings {DynamicResource HomePage_Brightness} -->

<system:String x:Key="Settings_UpdateSettings">Check For Updates</system:String>
Expand All @@ -81,13 +100,17 @@
<system:String x:Key="Settings_MainWindowStyle">Main Window Home Page Style (Restart App)</system:String>
<system:String x:Key="Settings_QAMStyle">Quick Access Menu Home Page Style</system:String>
<system:String x:Key="Settings_Language">Language/语言</system:String>

<system:String x:Key="Settings_SteamDirectory">Steam Directory</system:String>
<system:String x:Key="Settings_PlayNiteDirectory">PlayNite Directory</system:String>

<system:String x:Key="Settings_IntelTDPType">TDP Set Type</system:String>
<system:String x:Key="Settings_AMDMaxGPUClk">Set Max GPU Clock (MHz)</system:String>
<system:String x:Key="Settings_ControllerShortCuts">Controller Short Cuts</system:String>
<system:String x:Key="Settings_ShortCutQAM">Quick Access Menu</system:String>
<system:String x:Key="Settings_ShortCutOSK">OSK</system:String>
<system:String x:Key="Settings_ShortCutFSR">FSR</system:String>

<system:String x:Key="Settings_ShortCutGameLauncher">Game Launcher</system:String>
<!-- AppSettings -->
<system:String x:Key="AppSettings_Applications">Applications</system:String>
<system:String x:Key="AppSettings_AddProfile">ADD PROFILE</system:String>
Expand Down
Loading

0 comments on commit c7e0302

Please sign in to comment.