mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-20 15:30:28 +01:00
Move FanMode and OverlayMode to GlobalConfig
This commit is contained in:
parent
39fb809e01
commit
604a7e5b0b
24
CommonHelpers/GlobalConfig.cs
Normal file
24
CommonHelpers/GlobalConfig.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CommonHelpers
|
||||
{
|
||||
public enum FanMode : uint
|
||||
{
|
||||
Default = 17374,
|
||||
SteamOS,
|
||||
Max
|
||||
}
|
||||
|
||||
public enum OverlayMode : uint
|
||||
{
|
||||
FPS = 10032,
|
||||
Minimal,
|
||||
Detail,
|
||||
Full
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
using CommonHelpers;
|
||||
using CommonHelpers;
|
||||
using CommonHelpers.FromLibreHardwareMonitor;
|
||||
using FanControl.Properties;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
@ -40,7 +41,7 @@ namespace FanControl
|
|||
propertyGrid1.SelectedObject = fanControl;
|
||||
propertyGrid1.ExpandAllGridItems();
|
||||
|
||||
foreach (var item in Enum.GetValues(typeof(FanController.FanMode)))
|
||||
foreach (var item in Enum.GetValues(typeof(FanMode)))
|
||||
{
|
||||
fanModeSelectMenu.Items.Add(item);
|
||||
fanModeSelectNotifyMenu.Items.Add(item);
|
||||
|
|
@ -48,12 +49,12 @@ namespace FanControl
|
|||
|
||||
try
|
||||
{
|
||||
var fanMode = Enum.Parse(typeof(FanController.FanMode), Properties.Settings.Default.FanMode);
|
||||
setFanMode((FanController.FanMode)fanMode);
|
||||
var fanMode = Enum.Parse(typeof(FanMode), Properties.Settings.Default.FanMode);
|
||||
setFanMode((FanMode)fanMode);
|
||||
}
|
||||
catch(System.ArgumentException)
|
||||
{
|
||||
setFanMode(FanController.FanMode.Default);
|
||||
setFanMode(FanMode.Default);
|
||||
}
|
||||
|
||||
notifyIcon.ShowBalloonTip(3000, Text, "Fan Control Started", ToolTipIcon.Info);
|
||||
|
|
@ -76,7 +77,7 @@ namespace FanControl
|
|||
}
|
||||
}
|
||||
|
||||
private void setFanMode(FanController.FanMode mode)
|
||||
private void setFanMode(FanMode mode)
|
||||
{
|
||||
fanControl.SetMode(mode);
|
||||
fanModeSelectMenu.SelectedItem = mode;
|
||||
|
|
@ -88,7 +89,7 @@ namespace FanControl
|
|||
private void fanModeSelect_SelectedValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
var comboBox = (ToolStripComboBox)sender;
|
||||
var selectedMode = (FanController.FanMode)comboBox.SelectedItem;
|
||||
var selectedMode = (FanMode)comboBox.SelectedItem;
|
||||
setFanMode(selectedMode);
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +119,7 @@ namespace FanControl
|
|||
private void FanControlForm_FormClosed(object sender, FormClosedEventArgs e)
|
||||
{
|
||||
// Always revert to default on closing
|
||||
fanControl.SetMode(FanController.FanMode.Default);
|
||||
fanControl.SetMode(FanMode.Default);
|
||||
}
|
||||
|
||||
private void fanLoopTimer_Tick(object sender, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -16,13 +16,6 @@ namespace FanControl
|
|||
[RefreshProperties(RefreshProperties.Repaint)]
|
||||
internal partial class FanController : IDisposable
|
||||
{
|
||||
public enum FanMode
|
||||
{
|
||||
Default,
|
||||
SteamOS,
|
||||
Max
|
||||
}
|
||||
|
||||
[CategoryAttribute("Fan")]
|
||||
public FanMode Mode { get; private set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using LibreHardwareMonitor.Hardware;
|
||||
using CommonHelpers;
|
||||
using LibreHardwareMonitor.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using LibreHardwareMonitor.Hardware;
|
||||
using CommonHelpers;
|
||||
using LibreHardwareMonitor.Hardware;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
|
@ -27,7 +28,7 @@ namespace FanControl
|
|||
|
||||
private List<float> AllSamples = new List<float>();
|
||||
|
||||
internal Dictionary<FanController.FanMode, Profile> Profiles { get; set; } = new Dictionary<FanController.FanMode, Profile>();
|
||||
internal Dictionary<FanMode, Profile> Profiles { get; set; } = new Dictionary<FanMode, Profile>();
|
||||
|
||||
internal class Profile
|
||||
{
|
||||
|
|
@ -136,7 +137,7 @@ namespace FanControl
|
|||
sensor.Name == SensorName;
|
||||
}
|
||||
|
||||
public bool Update(ISensor hwSensor, FanController.FanMode mode)
|
||||
public bool Update(ISensor hwSensor, FanMode mode)
|
||||
{
|
||||
if (!Matches(hwSensor))
|
||||
return false;
|
||||
|
|
@ -149,7 +150,7 @@ namespace FanControl
|
|||
hwSensor.Value, mode);
|
||||
}
|
||||
|
||||
public bool Update(string name, float? newValue, FanController.FanMode mode)
|
||||
public bool Update(string name, float? newValue, FanMode mode)
|
||||
{
|
||||
if (!newValue.HasValue || newValue <= 0.0)
|
||||
return false;
|
||||
|
|
@ -174,7 +175,7 @@ namespace FanControl
|
|||
return true;
|
||||
}
|
||||
|
||||
public bool IsValid(FanController.FanMode mode)
|
||||
public bool IsValid(FanMode mode)
|
||||
{
|
||||
// If we have profile, but no sensor value to consume it
|
||||
// it is invalid
|
||||
|
|
@ -217,7 +218,7 @@ namespace FanControl
|
|||
return value;
|
||||
}
|
||||
|
||||
public ushort? CalculateRPM(FanController.FanMode mode)
|
||||
public ushort? CalculateRPM(FanMode mode)
|
||||
{
|
||||
if (!Profiles.ContainsKey(mode) || !Value.HasValue)
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using CommonHelpers;
|
||||
using CommonHelpers;
|
||||
using CommonHelpers.FromLibreHardwareMonitor;
|
||||
using Microsoft.VisualBasic.Logging;
|
||||
using PerformanceOverlay.External;
|
||||
|
|
@ -42,7 +42,7 @@ namespace PerformanceOverlay
|
|||
showItem.Checked = Settings.Default.ShowOSD;
|
||||
contextMenu.Items.Add(showItem);
|
||||
contextMenu.Items.Add(new ToolStripSeparator());
|
||||
foreach (var mode in Enum.GetValues<Overlays.Mode>())
|
||||
foreach (var mode in Enum.GetValues<OverlayMode>())
|
||||
{
|
||||
var modeItem = new ToolStripMenuItem(mode.ToString());
|
||||
modeItem.Tag = mode;
|
||||
|
|
@ -103,7 +103,7 @@ namespace PerformanceOverlay
|
|||
{
|
||||
GlobalHotKey.RegisterHotKey(Settings.Default.CycleOSDShortcut, () =>
|
||||
{
|
||||
var values = Enum.GetValues<Overlays.Mode>().ToList();
|
||||
var values = Enum.GetValues<OverlayMode>().ToList();
|
||||
|
||||
int index = values.IndexOf(Settings.Default.OSDModeParsed);
|
||||
Settings.Default.OSDModeParsed = values[(index + 1) % values.Count];
|
||||
|
|
@ -123,8 +123,8 @@ namespace PerformanceOverlay
|
|||
{
|
||||
foreach (ToolStripItem item in contextMenu.Items)
|
||||
{
|
||||
if (item.Tag is Overlays.Mode)
|
||||
((ToolStripMenuItem)item).Checked = ((Overlays.Mode)item.Tag == Settings.Default.OSDModeParsed);
|
||||
if (item.Tag is OverlayMode)
|
||||
((ToolStripMenuItem)item).Checked = ((OverlayMode)item.Tag == Settings.Default.OSDModeParsed);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using CommonHelpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Policy;
|
||||
|
|
@ -11,19 +12,11 @@ namespace PerformanceOverlay
|
|||
{
|
||||
internal class Overlays
|
||||
{
|
||||
public enum Mode
|
||||
{
|
||||
FPS,
|
||||
Minimal,
|
||||
Detail,
|
||||
Full
|
||||
}
|
||||
|
||||
public class Entry
|
||||
{
|
||||
public String? Text { get; set; }
|
||||
public IList<Mode> Include { get; set; } = new List<Mode>();
|
||||
public IList<Mode> Exclude { get; set; } = new List<Mode>();
|
||||
public IList<OverlayMode> Include { get; set; } = new List<OverlayMode>();
|
||||
public IList<OverlayMode> Exclude { get; set; } = new List<OverlayMode>();
|
||||
public IList<Entry> Nested { get; set; } = new List<Entry>();
|
||||
public String Separator { get; set; } = "";
|
||||
public bool IgnoreMissing { get; set; }
|
||||
|
|
@ -62,7 +55,7 @@ namespace PerformanceOverlay
|
|||
return output;
|
||||
}
|
||||
|
||||
public String? GetValue(Mode mode, Sensors sensors)
|
||||
public String? GetValue(OverlayMode mode, Sensors sensors)
|
||||
{
|
||||
if (Exclude.Count > 0 && Exclude.Contains(mode))
|
||||
return null;
|
||||
|
|
@ -97,7 +90,7 @@ namespace PerformanceOverlay
|
|||
{
|
||||
Nested = {
|
||||
// Simple just FPS
|
||||
new Entry("<C4><FR><C><A><A1><S1><C4> FPS") { Include = { Mode.FPS } },
|
||||
new Entry("<C4><FR><C><A><A1><S1><C4> FPS") { Include = { OverlayMode.FPS } },
|
||||
|
||||
// Minimal and Detail
|
||||
new Entry {
|
||||
|
|
@ -110,7 +103,7 @@ namespace PerformanceOverlay
|
|||
{
|
||||
new Entry("<C4><A0>{BATT_%}<A><A1><S1> %<S><A>"),
|
||||
new Entry("<C4><A0>{BATT_W}<A><A1><S1> W<S><A>") { IgnoreMissing = true },
|
||||
new Entry("C<C4><A0>{BATT_CHARGE_W}<A><A1><S1> W<S><A>") { IgnoreMissing = true, Include = { Mode.Detail } }
|
||||
new Entry("C<C4><A0>{BATT_CHARGE_W}<A><A1><S1> W<S><A>") { IgnoreMissing = true, Include = { OverlayMode.Detail } }
|
||||
}
|
||||
},
|
||||
new Entry
|
||||
|
|
@ -120,7 +113,7 @@ namespace PerformanceOverlay
|
|||
{
|
||||
new Entry("<C4><A0>{GPU_%}<A><A1><S1> %<S><A>"),
|
||||
new Entry("<C4><A0>{GPU_W}<A><A1><S1> W<S><A>"),
|
||||
new Entry("<C4><A0>{GPU_T}<A><A1><S1> C<S><A>") { IgnoreMissing = true, Include = { Mode.Detail } }
|
||||
new Entry("<C4><A0>{GPU_T}<A><A1><S1> C<S><A>") { IgnoreMissing = true, Include = { OverlayMode.Detail } }
|
||||
}
|
||||
},
|
||||
new Entry
|
||||
|
|
@ -130,7 +123,7 @@ namespace PerformanceOverlay
|
|||
{
|
||||
new Entry("<C4><A0>{CPU_%}<A><A1><S1> %<S><A>"),
|
||||
new Entry("<C4><A0>{CPU_W}<A><A1><S1> W<S><A>"),
|
||||
new Entry("<C4><A0>{CPU_T}<A><A1><S1> C<S><A>") { IgnoreMissing = true, Include = { Mode.Detail } }
|
||||
new Entry("<C4><A0>{CPU_T}<A><A1><S1> C<S><A>") { IgnoreMissing = true, Include = { OverlayMode.Detail } }
|
||||
}
|
||||
},
|
||||
new Entry
|
||||
|
|
@ -142,7 +135,7 @@ namespace PerformanceOverlay
|
|||
{
|
||||
Text = "<C1>FAN<C>",
|
||||
Nested = { new Entry("<C4><A5>{FAN_RPM}<A><A1><S1> RPM<S><A>") },
|
||||
Include = { Mode.Detail }
|
||||
Include = { OverlayMode.Detail }
|
||||
},
|
||||
new Entry
|
||||
{
|
||||
|
|
@ -152,11 +145,11 @@ namespace PerformanceOverlay
|
|||
new Entry
|
||||
{
|
||||
Text = "<C2>[OBJ_FT_SMALL]<C><S1> <C4><A0><FT><A><A1> ms<A><S><C>",
|
||||
Include = { Mode.Detail }
|
||||
Include = { OverlayMode.Detail }
|
||||
}
|
||||
},
|
||||
Separator = "<C250>|<C> ",
|
||||
Include = { Mode.Minimal, Mode.Detail }
|
||||
Include = { OverlayMode.Minimal, OverlayMode.Detail }
|
||||
},
|
||||
|
||||
new Entry {
|
||||
|
|
@ -178,12 +171,12 @@ namespace PerformanceOverlay
|
|||
new Entry("[OBJ_FT_LARGE]<S1> <A0><FT><A><A1> ms<A><S><C>"),
|
||||
},
|
||||
Separator = "\r\n",
|
||||
Include = { Mode.Full }
|
||||
Include = { OverlayMode.Full }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static String GetOSD(Mode mode, Sensors sensors)
|
||||
public static String GetOSD(OverlayMode mode, Sensors sensors)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using CommonHelpers;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
@ -9,17 +10,17 @@ namespace PerformanceOverlay
|
|||
{
|
||||
internal partial class Settings
|
||||
{
|
||||
public Overlays.Mode OSDModeParsed
|
||||
public OverlayMode OSDModeParsed
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
return (Mode)Enum.Parse<Mode>(OSDMode);
|
||||
return (OverlayMode)Enum.Parse<OverlayMode>(OSDMode);
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
return Mode.FPS;
|
||||
return OverlayMode.FPS;
|
||||
}
|
||||
}
|
||||
set
|
||||
|
|
|
|||
Loading…
Reference in a new issue