From 1b8992d3cd2d9da40680e78d3be3e71a1e57becd Mon Sep 17 00:00:00 2001 From: project-sbc <78889381+project-sbc@users.noreply.github.com> Date: Wed, 5 Oct 2022 12:55:45 -0400 Subject: [PATCH 01/11] add fps limit to other pages --- .../StartUp/Resources/StringResources.xaml | 1 + .../Resources/StringResources.zh-Hans.xaml | 1 + PowerControlPanel/Pages/HomePage.xaml | 13 +++++++++-- PowerControlPanel/Pages/HomePage.xaml.cs | 22 +++++++++++++++++++ PowerControlPanel/Pages/SliderHomePage.xaml | 22 +++++++++++++++++++ .../Pages/SliderHomePage.xaml.cs | 21 +++++++++++++++++- 6 files changed, 77 insertions(+), 3 deletions(-) diff --git a/PowerControlPanel/Classes/StartUp/Resources/StringResources.xaml b/PowerControlPanel/Classes/StartUp/Resources/StringResources.xaml index fc8e075..23158e1 100644 --- a/PowerControlPanel/Classes/StartUp/Resources/StringResources.xaml +++ b/PowerControlPanel/Classes/StartUp/Resources/StringResources.xaml @@ -26,6 +26,7 @@ Display Resolution Display Refresh Rate Display Scaling (%) + FPS Limit Active Profile SYSTEM CONTROLS diff --git a/PowerControlPanel/Classes/StartUp/Resources/StringResources.zh-Hans.xaml b/PowerControlPanel/Classes/StartUp/Resources/StringResources.zh-Hans.xaml index 1c3534d..164dc75 100644 --- a/PowerControlPanel/Classes/StartUp/Resources/StringResources.zh-Hans.xaml +++ b/PowerControlPanel/Classes/StartUp/Resources/StringResources.zh-Hans.xaml @@ -27,6 +27,7 @@ 显示分辨率 屏幕刷新率 显示比例 + FPS Limit Active Profile diff --git a/PowerControlPanel/Pages/HomePage.xaml b/PowerControlPanel/Pages/HomePage.xaml index 3986b6b..f035f94 100644 --- a/PowerControlPanel/Pages/HomePage.xaml +++ b/PowerControlPanel/Pages/HomePage.xaml @@ -234,12 +234,12 @@ - + - + + + + + + + + diff --git a/PowerControlPanel/Pages/HomePage.xaml.cs b/PowerControlPanel/Pages/HomePage.xaml.cs index 0d27a37..dce24d7 100644 --- a/PowerControlPanel/Pages/HomePage.xaml.cs +++ b/PowerControlPanel/Pages/HomePage.xaml.cs @@ -113,6 +113,7 @@ private void displayItemSourceBind() cboRefreshRate.ItemsSource = GlobalVariables.refreshRates; cboResolution.ItemsSource = GlobalVariables.resolutions; + cboFPSLimit.ItemsSource = GlobalVariables.FPSLimits; changingResolution = true; cboResolution.SelectedIndex = 0; @@ -250,6 +251,22 @@ private void loadUpdateValues() changingScaling = false; } + + + + } + + if (PowerControlPanel.Classes.ChangeFPSLimit.ChangeFPSLimit.rtssRunning()) + { + cboFPSLimit.Text = GlobalVariables.FPSLimit; + + rdFPSLimit.Height = new GridLength(50); + dpFPSLimit.Visibility = Visibility.Visible; + } + else + { + rdFPSLimit.Height = new GridLength(0); + dpFPSLimit.Visibility = Visibility.Collapsed; } //profile @@ -893,5 +910,10 @@ private void enableControlProfile_Toggled(object sender, RoutedEventArgs e) } } + + private void cboFPSLimit_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + PowerControlPanel.Classes.ChangeFPSLimit.ChangeFPSLimit.changeLimit(cboFPSLimit.SelectedValue.ToString()); + } } } diff --git a/PowerControlPanel/Pages/SliderHomePage.xaml b/PowerControlPanel/Pages/SliderHomePage.xaml index 270b81e..6b39c66 100644 --- a/PowerControlPanel/Pages/SliderHomePage.xaml +++ b/PowerControlPanel/Pages/SliderHomePage.xaml @@ -299,7 +299,29 @@ + + + + + + + + + + + + diff --git a/PowerControlPanel/Pages/SliderHomePage.xaml.cs b/PowerControlPanel/Pages/SliderHomePage.xaml.cs index f50657b..42afc3b 100644 --- a/PowerControlPanel/Pages/SliderHomePage.xaml.cs +++ b/PowerControlPanel/Pages/SliderHomePage.xaml.cs @@ -109,10 +109,12 @@ private void displayItemSourceBind() cboRefreshRate.ItemsSource = GlobalVariables.refreshRates; cboResolution.ItemsSource = GlobalVariables.resolutions; + cboFPSLimit.ItemsSource = GlobalVariables.FPSLimits; changingResolution = true; cboResolution.SelectedIndex = 0; changingResolution = false; + } @@ -256,6 +258,20 @@ private void loadUpdateValues() } } + if (PowerControlPanel.Classes.ChangeFPSLimit.ChangeFPSLimit.rtssRunning()) + { + cboFPSLimit.Text = GlobalVariables.FPSLimit; + + + bdFPSLimit.Visibility = Visibility.Visible; + } + else + { + + bdFPSLimit.Visibility = Visibility.Collapsed; + } + + //system values if (enableSystem) { @@ -728,6 +744,9 @@ private void Page_Loaded(object sender, RoutedEventArgs e) handleVisibility(); } - + private void cboFPSLimit_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + PowerControlPanel.Classes.ChangeFPSLimit.ChangeFPSLimit.changeLimit(cboFPSLimit.SelectedValue.ToString()); + } } } From 7c1ac0f220a384cb4e76359c1f2a151a895e5b62 Mon Sep 17 00:00:00 2001 From: project-sbc <78889381+project-sbc@users.noreply.github.com> Date: Thu, 6 Oct 2022 06:29:55 -0400 Subject: [PATCH 02/11] fixed issue where no button combo causes crash --- MainWindow.xaml.cs | 65 +++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 27 deletions(-) diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 6e59407..d199aa9 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -288,39 +288,50 @@ private bool ButtonComboPress(Gamepad gp,string BC) //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 (strBC.Length > 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)) + //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; From 3c0e81b6c5b728d193d737e672596f0f6038aac1 Mon Sep 17 00:00:00 2001 From: project-sbc <78889381+project-sbc@users.noreply.github.com> Date: Thu, 6 Oct 2022 17:52:51 -0400 Subject: [PATCH 03/11] updates --- MainWindow.xaml.cs | 10 +++--- .../Classes/ChangeTDP/ChangeTDP.cs | 1 + .../Classes/changeCPU/ChangeCPU.cs | 3 +- PowerControlPanel/Pages/SliderHomePage.xaml | 16 ++++----- .../Pages/SliderHomePage.xaml.cs | 33 +++++-------------- 5 files changed, 26 insertions(+), 37 deletions(-) diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index d199aa9..3bbab38 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -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"; @@ -287,10 +287,12 @@ private bool ButtonComboPress(Gamepad gp,string BC) bool result = false; //split string into array - string[] strBC = BC.Split('+'); + - if (strBC.Length > 0) + if (BC.IndexOf("+") > 0) { + string[] strBC = BC.Split('+'); + //gamepad flag array GamepadButtonFlags[] ButtonCombo = new GamepadButtonFlags[strBC.Length]; int intCount = 0; diff --git a/PowerControlPanel/Classes/ChangeTDP/ChangeTDP.cs b/PowerControlPanel/Classes/ChangeTDP/ChangeTDP.cs index c2b759a..8ff617a 100644 --- a/PowerControlPanel/Classes/ChangeTDP/ChangeTDP.cs +++ b/PowerControlPanel/Classes/ChangeTDP/ChangeTDP.cs @@ -117,6 +117,7 @@ public void changeTDP(int pl1TDP, int pl2TDP) //read tdp after changing readTDP(); + GlobalVariables.needTDPRead = false; } catch (Exception ex) { diff --git a/PowerControlPanel/Classes/changeCPU/ChangeCPU.cs b/PowerControlPanel/Classes/changeCPU/ChangeCPU.cs index f10364c..f54ae74 100644 --- a/PowerControlPanel/Classes/changeCPU/ChangeCPU.cs +++ b/PowerControlPanel/Classes/changeCPU/ChangeCPU.cs @@ -103,7 +103,7 @@ public static void changeCPUMaxFrequency(int maxCPU) RunCLI.RunCommand(" /S scheme_current", false, "C:\\windows\\system32\\powercfg.exe", 1000); readCPUMaxFrequency(); - + GlobalVariables.needCPUMaxFreqRead = false; } @@ -123,6 +123,7 @@ public static void changeActiveCores(double coreCount) } RunCLI.RunCommand(" /S scheme_current", false, "C:\\windows\\system32\\powercfg.exe", 1000); readActiveCores(); + GlobalVariables.needActiveCoreRead = false; } diff --git a/PowerControlPanel/Pages/SliderHomePage.xaml b/PowerControlPanel/Pages/SliderHomePage.xaml index 6b39c66..8c9e055 100644 --- a/PowerControlPanel/Pages/SliderHomePage.xaml +++ b/PowerControlPanel/Pages/SliderHomePage.xaml @@ -35,7 +35,7 @@ - + @@ -63,7 +63,7 @@ - + @@ -93,7 +93,7 @@ @@ -116,7 +116,7 @@ @@ -138,7 +138,7 @@ @@ -163,7 +163,7 @@ - - - - - - - - - - - - - - - - - - + - - - - - - - - - +