diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fb23a1a..8c0f100 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,6 +5,7 @@ on: - '**/**.md' env: + RELEASE_NAME: SteamDeckTools DOTNET_VERSION: '6.0.x' jobs: @@ -38,13 +39,13 @@ jobs: echo "MajorVer=$majorVer LastVer=$lastVer NextVer=$nextVer" echo "RELEASE_VERSION=$nextVer" >> $GITHUB_ENV - name: Build - run: dotnet build --configuration Release --output "FanControl-${{ env.RELEASE_VERSION }}/" "/property:Version=${{ env.RELEASE_VERSION }}" + run: dotnet build --configuration Release --output "${{ env.SteamDeckTools }}-${{ env.RELEASE_VERSION }}/" "/property:Version=${{ env.RELEASE_VERSION }}" - name: Test run: dotnet test --no-restore --verbosity normal - uses: vimtor/action-zip@v1 with: - files: FanControl-${{ env.RELEASE_VERSION }} - dest: FanControl-${{ env.RELEASE_VERSION }}.zip + files: ${{ env.SteamDeckTools }}-${{ env.RELEASE_VERSION }} + dest: ${{ env.SteamDeckTools }}-${{ env.RELEASE_VERSION }}.zip recursive: true - uses: ncipollo/release-action@v1 with: diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index c73cb79..e5f38dc 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -2,6 +2,7 @@ on: pull_request: env: + RELEASE_NAME: SteamDeckTools DOTNET_VERSION: '6.0.x' jobs: @@ -16,11 +17,11 @@ jobs: - name: Install dependencies run: dotnet restore - name: Build without Version - run: dotnet build --configuration Release --output FanControl-develop/ + run: dotnet build --configuration Release --output ${{ env.SteamDeckTools }}-develop/ - name: Test run: dotnet test --no-restore --verbosity normal - uses: vimtor/action-zip@v1 with: - files: FanControl-develop - dest: FanControl-develop.zip + files: ${{ env.SteamDeckTools }}-develop + dest: ${{ env.SteamDeckTools }}-develop.zip recursive: true diff --git a/CommonHelpers/CommonHelpers.csproj b/CommonHelpers/CommonHelpers.csproj new file mode 100644 index 0000000..e3c69ee --- /dev/null +++ b/CommonHelpers/CommonHelpers.csproj @@ -0,0 +1,20 @@ + + + + net6.0-windows + enable + true + enable + + + + + + + + + PreserveNewest + + + + diff --git a/FanControl/FromLibreHardwareMonitor/StartupManager.cs b/CommonHelpers/FromLibreHardwareMonitor/StartupManager.cs similarity index 93% rename from FanControl/FromLibreHardwareMonitor/StartupManager.cs rename to CommonHelpers/FromLibreHardwareMonitor/StartupManager.cs index 639d915..27d9700 100644 --- a/FanControl/FromLibreHardwareMonitor/StartupManager.cs +++ b/CommonHelpers/FromLibreHardwareMonitor/StartupManager.cs @@ -15,18 +15,21 @@ using Microsoft.Win32.TaskScheduler; using Action = Microsoft.Win32.TaskScheduler.Action; using Task = Microsoft.Win32.TaskScheduler.Task; -namespace FanControl.FromLibreHardwareMonitor +namespace CommonHelpers.FromLibreHardwareMonitor { public class StartupManager { private const string RegistryPath = @"Software\Microsoft\Windows\CurrentVersion\Run"; private bool _startup; - public const string Description = "Starts Steam Deck Fan Control on Windows startup."; - public const string NameOf = "Steam Deck Fan Control"; + public String NameOf { get; set; } + public String Description { get; set; } - public StartupManager() + public StartupManager(String name, String description) { + NameOf = name; + Description = description; + if (Environment.OSVersion.Platform >= PlatformID.Unix) { IsAvailable = false; @@ -131,7 +134,7 @@ namespace FanControl.FromLibreHardwareMonitor } } - private static Task GetTask() + private Task GetTask() { try { @@ -164,19 +167,19 @@ namespace FanControl.FromLibreHardwareMonitor TaskService.Instance.RootFolder.RegisterTaskDefinition(NameOf, taskDefinition); } - private static void DeleteTask() + private void DeleteTask() { Task task = GetTask(); task?.Folder.DeleteTask(task.Name, false); } - private static void CreateRegistryKey() + private void CreateRegistryKey() { RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistryPath); registryKey?.SetValue(NameOf, Application.ExecutablePath); } - private static void DeleteRegistryKey() + private void DeleteRegistryKey() { RegistryKey registryKey = Registry.CurrentUser.CreateSubKey(RegistryPath); registryKey?.DeleteValue(NameOf); diff --git a/FanControl/InpOut.cs b/CommonHelpers/InpOut.cs similarity index 98% rename from FanControl/InpOut.cs rename to CommonHelpers/InpOut.cs index 87275b8..39cf4c0 100644 --- a/FanControl/InpOut.cs +++ b/CommonHelpers/InpOut.cs @@ -5,7 +5,7 @@ using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; -namespace FanControl +namespace CommonHelpers { internal class InpOut { diff --git a/FanControl/Vlv0100.cs b/CommonHelpers/Vlv0100.cs similarity index 98% rename from FanControl/Vlv0100.cs rename to CommonHelpers/Vlv0100.cs index eb6dfd0..39ba423 100644 --- a/FanControl/Vlv0100.cs +++ b/CommonHelpers/Vlv0100.cs @@ -6,9 +6,9 @@ using System.Net.NetworkInformation; using System.Text; using System.Threading.Tasks; -namespace FanControl +namespace CommonHelpers { - internal class Vlv0100 + public class Vlv0100 { // Those addresses are taken from DSDT for VLV0100 // and might change at any time with a BIOS update diff --git a/FanControl/inpoutx64.dll b/CommonHelpers/inpoutx64.dll similarity index 100% rename from FanControl/inpoutx64.dll rename to CommonHelpers/inpoutx64.dll diff --git a/FanControl/FanControl.csproj b/FanControl/FanControl.csproj index 51cc293..6c464a9 100644 --- a/FanControl/FanControl.csproj +++ b/FanControl/FanControl.csproj @@ -16,6 +16,10 @@ + + + + True diff --git a/FanControl/FanControlForm.cs b/FanControl/FanControlForm.cs index f616e09..7bc0d3d 100644 --- a/FanControl/FanControlForm.cs +++ b/FanControl/FanControlForm.cs @@ -1,4 +1,4 @@ -using FanControl.FromLibreHardwareMonitor; +using CommonHelpers.FromLibreHardwareMonitor; using System; using System.Collections.Generic; using System.ComponentModel; @@ -17,7 +17,10 @@ namespace FanControl public partial class FanControlForm : Form { private FanController fanControl = new FanController(); - private StartupManager startupManager = new StartupManager(); + private StartupManager startupManager = new StartupManager( + "Steam Deck Fan Control", + "Starts Steam Deck Fan Control on Windows startup." + ); public FanControlForm() { diff --git a/FanControl/FanController.cs b/FanControl/FanController.cs index aa251a7..de541ab 100644 --- a/FanControl/FanController.cs +++ b/FanControl/FanController.cs @@ -8,6 +8,7 @@ using System.Diagnostics.Metrics; using System.Linq; using System.Text; using System.Threading.Tasks; +using CommonHelpers; namespace FanControl { diff --git a/FanControl/FanControllerSensors.cs b/FanControl/FanControllerSensors.cs index e7959dd..b473013 100644 --- a/FanControl/FanControllerSensors.cs +++ b/FanControl/FanControllerSensors.cs @@ -29,7 +29,7 @@ namespace FanControl FanMode.Max, new FanSensor.Profile() { Type = FanSensor.Profile.ProfileType.Constant, - MinRPM = Vlv0100.MAX_FAN_RPM + MinRPM = CommonHelpers.Vlv0100.MAX_FAN_RPM } }, { diff --git a/FanControl/Program.cs b/FanControl/Program.cs index 64b85a3..aa153d2 100644 --- a/FanControl/Program.cs +++ b/FanControl/Program.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using LibreHardwareMonitor.Hardware; +using CommonHelpers; namespace FanControl { diff --git a/PerformanceOverlay/App.config b/PerformanceOverlay/App.config index b3fb96a..104b0a5 100644 --- a/PerformanceOverlay/App.config +++ b/PerformanceOverlay/App.config @@ -4,6 +4,9 @@
+ +
+ @@ -15,4 +18,14 @@ + + + + F11 + + + Shift+F11 + + + \ No newline at end of file diff --git a/PerformanceOverlay/Controller.cs b/PerformanceOverlay/Controller.cs index 498b6e0..decf7ed 100644 --- a/PerformanceOverlay/Controller.cs +++ b/PerformanceOverlay/Controller.cs @@ -1,8 +1,10 @@ -using PerformanceOverlay.External; +using Microsoft.VisualBasic.Logging; +using PerformanceOverlay.External; using RTSSSharedMemoryNET; using System; using System.Collections.Generic; using System.ComponentModel; +using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -63,22 +65,27 @@ namespace PerformanceOverlay osdTimer.Interval = 250; osdTimer.Enabled = true; - GlobalHotKey.RegisterHotKey("F11", () => + if (Settings.Default.ShowOSDShortcut != "") { - showItem.Checked = !showItem.Checked; - }); + GlobalHotKey.RegisterHotKey(Settings.Default.ShowOSDShortcut, () => + { + showItem.Checked = !showItem.Checked; + }); + } - // Select next overlay - GlobalHotKey.RegisterHotKey("Shift+F11", () => + if (Settings.Default.CycleOSDShortcut != "") { - var values = Enum.GetValues().ToList(); + GlobalHotKey.RegisterHotKey(Settings.Default.CycleOSDShortcut, () => + { + var values = Enum.GetValues().ToList(); - int index = values.IndexOf(Settings.Default.OSDModeParsed); - Settings.Default.OSDModeParsed = values[(index + 1) % values.Count]; + int index = values.IndexOf(Settings.Default.OSDModeParsed); + Settings.Default.OSDModeParsed = values[(index + 1) % values.Count]; - showItem.Checked = true; - updateContextItems(contextMenu); - }); + showItem.Checked = true; + updateContextItems(contextMenu); + }); + } } private void updateContextItems(ContextMenuStrip contextMenu) @@ -117,6 +124,11 @@ namespace PerformanceOverlay { if (osd == null) osd = new OSD("PerformanceOverlay"); + + uint offset = 0; + osdEmbedGraph(ref offset, ref osdOverlay, "[OBJ_FT_SMALL]", -8, -1, 1, 0, 50000.0f, EMBEDDED_OBJECT_GRAPH.FLAG_FRAMETIME); + osdEmbedGraph(ref offset, ref osdOverlay, "[OBJ_FT_LARGE]", -32, -2, 1, 0, 50000.0f, EMBEDDED_OBJECT_GRAPH.FLAG_FRAMETIME); + osd.Update(osdOverlay); } catch(SystemException) @@ -125,6 +137,15 @@ namespace PerformanceOverlay } } + private uint osdEmbedGraph(ref uint offset, ref String osdOverlay, String name, int dwWidth, int dwHeight, int dwMargin, float fltMin, float fltMax, EMBEDDED_OBJECT_GRAPH dwFlags) + { + uint size = osd.EmbedGraph(offset, new float[0], 0, dwWidth, dwHeight, dwMargin, fltMin, fltMax, dwFlags); + if (size > 0) + osdOverlay = osdOverlay.Replace(name, ""); + offset += size; + return size; + } + private void ExitItem_Click(object? sender, EventArgs e) { Application.Exit(); diff --git a/PerformanceOverlay/Overlays.cs b/PerformanceOverlay/Overlays.cs index 228fee4..c2f3180 100644 --- a/PerformanceOverlay/Overlays.cs +++ b/PerformanceOverlay/Overlays.cs @@ -90,14 +90,16 @@ namespace PerformanceOverlay public static readonly String[] Helpers = { "", - "", + "", }; public static readonly Entry OSD = new Entry { Nested = { + // Simple just FPS new Entry { Text = " FPS", Include = { Mode.FPS } }, + // Minimal and Detail new Entry { Nested = { @@ -107,7 +109,7 @@ namespace PerformanceOverlay Nested = { new Entry("{BATT_%} %"), - new Entry("{BATT_W} W") + new Entry("{BATT_W} W") { IgnoreMissing = true } } }, new Entry @@ -117,7 +119,7 @@ namespace PerformanceOverlay { new Entry("{GPU_%} %"), new Entry("{GPU_W} W"), - new Entry { Text = "{GPU_T} C", IgnoreMissing = true } + new Entry { Text = "{GPU_T} C", IgnoreMissing = true, Include = { Mode.Detail } } } }, new Entry @@ -127,51 +129,57 @@ namespace PerformanceOverlay { new Entry("{CPU_%} %"), new Entry("{CPU_W} W"), - new Entry { Text = "{CPU_T} C", IgnoreMissing = true } + new Entry { Text = "{CPU_T} C", IgnoreMissing = true, Include = { Mode.Detail } } } }, new Entry { Text = "RAM", - Nested = - { - new Entry("{MEM_GB} GiB") - } + Nested = { new Entry("{MEM_GB} GiB") } + }, + new Entry + { + Text = "FAN", + Nested = { new Entry("{FAN_RPM} RPM") }, + Include = { Mode.Detail } }, new Entry { Text = "", - Nested = - { - new Entry(" FPS") - } + Nested = { new Entry(" FPS") } }, new Entry { - Text = "" + Text = "[OBJ_FT_SMALL] ms", + Include = { Mode.Detail } } }, Separator = "| ", - Include = { Mode.Minimal } + Include = { Mode.Minimal, Mode.Detail } }, - new Entry { Text = "MEM {MEM_MB} MB", Exclude = { Mode.FPS, Mode.Minimal } }, - new Entry { Text = "CPU {CPU_%} %", Exclude = { Mode.FPS, Mode.Minimal } }, - new Entry { Text = "RAM {GPU_MB} MB", Exclude = { Mode.FPS, Mode.Minimal } }, - new Entry { Text = " FPS ms", Exclude = { Mode.FPS, Mode.Minimal } }, new Entry { - Text = "BAT ", - Nested = { - new Entry("{BATT_%} %"), - new Entry("{BATT_W} W") + Nested = + { + new Entry { Text = "CPU {CPU_%} % {CPU_T} C" }, + new Entry { Text = "GPU {GPU_%} % {GPU_T} C" }, + new Entry { Text = "RAM {MEM_MB} MB{GPU_MB} MB" }, + new Entry { Text = "FAN {FAN_RPM} RPM" }, + new Entry { Text = " FPS ms" }, + new Entry { + Text = "BAT ", + Nested = { + new Entry("{BATT_%} %"), + new Entry("{BATT_W} W") + } + }, + new Entry { Text = "Frametime" }, + new Entry { Text = "[OBJ_FT_LARGE] ms" }, }, - Exclude = { Mode.FPS, Mode.Minimal } - }, - new Entry { Text = "Frametime", Exclude = { Mode.FPS, Mode.Minimal } }, - new Entry { Text = "", Exclude = { Mode.FPS, Mode.Minimal } }, - new Entry { Text = " ms", Exclude = { Mode.FPS, Mode.Minimal } } - }, - Separator = "\r\n" + Separator = "\r\n", + Include = { Mode.All } + } + } }; public static String GetOSD(Mode mode, Sensors sensors) diff --git a/PerformanceOverlay/PerformanceOverlay.csproj b/PerformanceOverlay/PerformanceOverlay.csproj index c671cce..b88a21f 100644 --- a/PerformanceOverlay/PerformanceOverlay.csproj +++ b/PerformanceOverlay/PerformanceOverlay.csproj @@ -27,6 +27,10 @@ + + + + RTSSSharedMemoryNET.dll diff --git a/PerformanceOverlay/Program.cs b/PerformanceOverlay/Program.cs index b862fbc..d91ff99 100644 --- a/PerformanceOverlay/Program.cs +++ b/PerformanceOverlay/Program.cs @@ -1,4 +1,5 @@ using RTSSSharedMemoryNET; +using System.Diagnostics; namespace PerformanceOverlay { @@ -13,8 +14,13 @@ namespace PerformanceOverlay { foreach (var entry in RTSSSharedMemoryNET.OSD.GetOSDEntries()) { - Console.WriteLine("Entry: {0}", entry.Owner); - Console.WriteLine("\t", entry.Text); + Trace.WriteLine("Entry: {0}", entry.Owner); + Trace.WriteLine("\t", entry.Text); + + using (var newOSD = new OSD("New OSD")) + { + newOSD.Update(entry.Text); + } } } catch(SystemException) diff --git a/PerformanceOverlay/Sensors.cs b/PerformanceOverlay/Sensors.cs index 4916efa..212a5c9 100644 --- a/PerformanceOverlay/Sensors.cs +++ b/PerformanceOverlay/Sensors.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; +using System.Windows.Navigation; using static PerformanceOverlay.Sensors; namespace PerformanceOverlay @@ -207,6 +208,16 @@ namespace PerformanceOverlay SensorName = "Charge/Discharge Rate", Format = "F1" } + }, + { + "FAN_RPM", new UserValueSensor() + { + Value = delegate () + { + return (float)CommonHelpers.Vlv0100.GetFanRPM(); + }, + Format = "F0" + } } }; diff --git a/PerformanceOverlay/Settings.Designer.cs b/PerformanceOverlay/Settings.Designer.cs index 7956a7f..ad276cf 100644 --- a/PerformanceOverlay/Settings.Designer.cs +++ b/PerformanceOverlay/Settings.Designer.cs @@ -46,5 +46,23 @@ namespace PerformanceOverlay { this["OSDMode"] = value; } } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("F11")] + public string ShowOSDShortcut { + get { + return ((string)(this["ShowOSDShortcut"])); + } + } + + [global::System.Configuration.ApplicationScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("Shift+F11")] + public string CycleOSDShortcut { + get { + return ((string)(this["CycleOSDShortcut"])); + } + } } } diff --git a/PerformanceOverlay/Settings.settings b/PerformanceOverlay/Settings.settings index 5191aa6..67d0f90 100644 --- a/PerformanceOverlay/Settings.settings +++ b/PerformanceOverlay/Settings.settings @@ -8,5 +8,11 @@ FPS + + F11 + + + Shift+F11 + \ No newline at end of file diff --git a/SteamDeckTools.sln b/SteamDeckTools.sln index df09d7d..41fc546 100644 --- a/SteamDeckTools.sln +++ b/SteamDeckTools.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FanControl", "FanControl\Fa EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PerformanceOverlay", "PerformanceOverlay\PerformanceOverlay.csproj", "{DCA71DCC-A3ED-4890-A56C-3E2183A3C023}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommonHelpers", "CommonHelpers\CommonHelpers.csproj", "{17728E90-015B-4221-8AA8-68FB359FA12F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -41,6 +43,18 @@ Global {DCA71DCC-A3ED-4890-A56C-3E2183A3C023}.Release|x64.Build.0 = Release|Any CPU {DCA71DCC-A3ED-4890-A56C-3E2183A3C023}.Release|x86.ActiveCfg = Release|Any CPU {DCA71DCC-A3ED-4890-A56C-3E2183A3C023}.Release|x86.Build.0 = Release|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Debug|x64.ActiveCfg = Debug|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Debug|x64.Build.0 = Debug|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Debug|x86.ActiveCfg = Debug|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Debug|x86.Build.0 = Debug|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Release|Any CPU.Build.0 = Release|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Release|x64.ActiveCfg = Release|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Release|x64.Build.0 = Release|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Release|x86.ActiveCfg = Release|Any CPU + {17728E90-015B-4221-8AA8-68FB359FA12F}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE