mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2025-12-06 07:12:01 +01:00
This adds a Steam Shortcuts, Desktop Mode, and X360 Emulation - Supports all Steam Shortcuts (including on-screen keyboard, and brightness) - Supports Desktop mode (with a scroll on left pad and left stick), and trackpoint (on right stick) - Supports X360 mode: hold Options for 1s to switch between Desktop and X360 - Holding Steam button enables Desktop like controls and stops passing all inputs to X360
64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Management;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace PowerControl.Helpers
|
|
{
|
|
/// <summary>
|
|
/// Taken from: https://gist.github.com/maxkoshevoi/b8a1ad91f4d2a9fd3931168c14080694
|
|
/// </summary>
|
|
public static class WindowsSettingsBrightnessController
|
|
{
|
|
public static void Increase(int brightness)
|
|
{
|
|
var current = Get();
|
|
current += brightness;
|
|
current = Math.Clamp(current, 0, 100);
|
|
Set(current);
|
|
}
|
|
|
|
public static int Get(double roundValue = 10.0)
|
|
{
|
|
return (int)(Math.Round(Get() / roundValue) * roundValue);
|
|
}
|
|
|
|
public static int Get()
|
|
{
|
|
try
|
|
{
|
|
using var mclass = new ManagementClass("WmiMonitorBrightness")
|
|
{
|
|
Scope = new ManagementScope(@"\\.\root\wmi")
|
|
};
|
|
using var instances = mclass.GetInstances();
|
|
foreach (ManagementObject instance in instances)
|
|
{
|
|
return (byte)instance.GetPropertyValue("CurrentBrightness");
|
|
}
|
|
return -1;
|
|
}
|
|
catch
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
public static void Set(int brightness)
|
|
{
|
|
using var mclass = new ManagementClass("WmiMonitorBrightnessMethods")
|
|
{
|
|
Scope = new ManagementScope(@"\\.\root\wmi")
|
|
};
|
|
using var instances = mclass.GetInstances();
|
|
var args = new object[] { 1, brightness };
|
|
foreach (ManagementObject instance in instances)
|
|
{
|
|
instance.InvokeMethod("WmiSetBrightness", args);
|
|
}
|
|
}
|
|
}
|
|
}
|