mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Native brightness OSD
This commit is contained in:
@@ -26,7 +26,7 @@ namespace GHelper.AnimeMatrix
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
mat = new AnimeMatrixDevice();
|
mat = new AnimeMatrixDevice();
|
||||||
mat.WakeUp();
|
Task.Run(mat.WakeUp);
|
||||||
matrixTimer = new System.Timers.Timer(100);
|
matrixTimer = new System.Timers.Timer(100);
|
||||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||||
}
|
}
|
||||||
@@ -123,6 +123,11 @@ namespace GHelper.AnimeMatrix
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
StopMatrixAudio();
|
||||||
|
}
|
||||||
|
|
||||||
void StopMatrixAudio()
|
void StopMatrixAudio()
|
||||||
{
|
{
|
||||||
if (AudioDevice is not null)
|
if (AudioDevice is not null)
|
||||||
|
|||||||
@@ -193,10 +193,11 @@ namespace GHelper
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TouchpadToggle()
|
public static bool TouchpadToggle()
|
||||||
{
|
{
|
||||||
HidDevice? input = GetInputDevice();
|
HidDevice? input = GetInputDevice();
|
||||||
if (input != null) input.WriteFeatureData(new byte[] { HID_ID,0xf4,0x6b});
|
if (input != null) return input.WriteFeatureData(new byte[] { HID_ID,0xf4,0x6b});
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RunListener(Action<int> KeyHandler)
|
public static void RunListener(Action<int> KeyHandler)
|
||||||
@@ -249,36 +250,41 @@ namespace GHelper
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Task.Run(() =>
|
||||||
var devices = GetHidDevices(deviceIds);
|
|
||||||
foreach (HidDevice device in devices)
|
|
||||||
{
|
{
|
||||||
device.OpenDevice();
|
var devices = GetHidDevices(deviceIds);
|
||||||
device.WriteFeatureData(LED_INIT1);
|
foreach (HidDevice device in devices)
|
||||||
device.WriteFeatureData(LED_INIT2);
|
{
|
||||||
device.WriteFeatureData(LED_INIT3);
|
device.OpenDevice();
|
||||||
device.WriteFeatureData(LED_INIT4);
|
device.WriteFeatureData(LED_INIT1);
|
||||||
device.WriteFeatureData(LED_INIT5);
|
device.WriteFeatureData(LED_INIT2);
|
||||||
device.CloseDevice();
|
device.WriteFeatureData(LED_INIT3);
|
||||||
}
|
device.WriteFeatureData(LED_INIT4);
|
||||||
|
device.WriteFeatureData(LED_INIT5);
|
||||||
|
device.CloseDevice();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void ApplyBrightness(int brightness)
|
public static void ApplyBrightness(int brightness)
|
||||||
{
|
{
|
||||||
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
|
Task.Run(() =>
|
||||||
|
|
||||||
var devices = GetHidDevices(deviceIds);
|
|
||||||
foreach (HidDevice device in devices)
|
|
||||||
{
|
{
|
||||||
device.OpenDevice();
|
byte[] msg = { 0x5d, 0xba, 0xc5, 0xc4, (byte)brightness };
|
||||||
device.WriteFeatureData(msg);
|
|
||||||
Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + ":" + BitConverter.ToString(msg));
|
|
||||||
device.CloseDevice();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (AppConfig.ContainsModel("TUF"))
|
var devices = GetHidDevices(deviceIds);
|
||||||
Program.acpi.TUFKeyboardBrightness(brightness);
|
foreach (HidDevice device in devices)
|
||||||
|
{
|
||||||
|
device.OpenDevice();
|
||||||
|
device.WriteFeatureData(msg);
|
||||||
|
Logger.WriteLine("USB-KB " + device.Capabilities.FeatureReportByteLength + ":" + BitConverter.ToString(msg));
|
||||||
|
device.CloseDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AppConfig.ContainsModel("TUF"))
|
||||||
|
Program.acpi.TUFKeyboardBrightness(brightness);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public static class HardwareControl
|
|||||||
if (fan > fanMax && fan < 110) SetFanMax(fan);
|
if (fan > fanMax && fan < 110) SetFanMax(fan);
|
||||||
|
|
||||||
if (AppConfig.getConfig("fan_rpm") == 1)
|
if (AppConfig.getConfig("fan_rpm") == 1)
|
||||||
return GHelper.Properties.Strings.FanSpeed + (fan * 100).ToString() + GHelper.Properties.Strings.RPM;
|
return GHelper.Properties.Strings.FanSpeed + (fan * 100).ToString() + "RPM";
|
||||||
else
|
else
|
||||||
return GHelper.Properties.Strings.FanSpeed + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm
|
return GHelper.Properties.Strings.FanSpeed + Math.Min(Math.Round((float)fan / fanMax * 100), 100).ToString() + "%"; // relatively to 6000 rpm
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -213,16 +213,18 @@ namespace GHelper
|
|||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, backlightNames[backlight], ToastIcon.BacklightUp);
|
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, backlightNames[backlight], ToastIcon.BacklightUp);
|
||||||
break;
|
break;
|
||||||
case 16: // FN+F7
|
case 16: // FN+F7
|
||||||
brightness = ScreenBrightness.Adjust(-10);
|
Program.acpi.DeviceSet(AsusACPI.UniversalControl, 0x10, "Brightness");
|
||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, brightness + "%", ToastIcon.BrightnessDown);
|
//brightness = ScreenBrightness.Adjust(-10);
|
||||||
|
//Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, brightness + "%", ToastIcon.BrightnessDown);
|
||||||
break;
|
break;
|
||||||
case 32: // FN+F8
|
case 32: // FN+F8
|
||||||
brightness = ScreenBrightness.Adjust(+10);
|
Program.acpi.DeviceSet(AsusACPI.UniversalControl, 0x20, "Brightness");
|
||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, brightness + "%", ToastIcon.BrightnessUp);
|
//brightness = ScreenBrightness.Adjust(+10);
|
||||||
|
//Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, brightness + "%", ToastIcon.BrightnessUp);
|
||||||
break;
|
break;
|
||||||
case 107: // FN+F10
|
case 107: // FN+F10
|
||||||
bool touchpadState = GetTouchpadState();
|
bool touchpadState = GetTouchpadState();
|
||||||
AsusUSB.TouchpadToggle();
|
if (!AsusUSB.TouchpadToggle()) Program.acpi.DeviceSet(AsusACPI.UniversalControl, 0x6B, "Touchpad");
|
||||||
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad);
|
Program.settingsForm.BeginInvoke(Program.settingsForm.RunToast, touchpadState ? "Off" : "On", ToastIcon.Touchpad);
|
||||||
break;
|
break;
|
||||||
case 108: // FN+F11
|
case 108: // FN+F11
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ namespace GHelper
|
|||||||
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture;
|
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentUICulture;
|
||||||
Debug.WriteLine(CultureInfo.CurrentUICulture);
|
Debug.WriteLine(CultureInfo.CurrentUICulture);
|
||||||
|
|
||||||
//Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("es");
|
//Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("uk");
|
||||||
|
|
||||||
CheckProcesses();
|
CheckProcesses();
|
||||||
|
|
||||||
@@ -65,7 +65,7 @@ namespace GHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger.WriteLine("------------");
|
Logger.WriteLine("------------");
|
||||||
Logger.WriteLine("App launched: " + AppConfig.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + (IsUserAdministrator() ? "A" : ""));
|
Logger.WriteLine("App launched: " + AppConfig.GetModel() + " :" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + CultureInfo.CurrentUICulture + (IsUserAdministrator() ? "A" : ""));
|
||||||
|
|
||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
|
|
||||||
|
|||||||
2
app/Properties/Strings.Designer.cs
generated
2
app/Properties/Strings.Designer.cs
generated
@@ -169,7 +169,7 @@ namespace GHelper.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Auto adjust Windows Power Mode.
|
/// Looks up a localized string similar to Auto adjust Windows Power Modes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string ApplyWindowsPowerPlan {
|
internal static string ApplyWindowsPowerPlan {
|
||||||
get {
|
get {
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
<value>Apply Power Limits</value>
|
<value>Apply Power Limits</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ApplyWindowsPowerPlan" xml:space="preserve">
|
<data name="ApplyWindowsPowerPlan" xml:space="preserve">
|
||||||
<value>Auto adjust Windows Power Mode</value>
|
<value>Auto adjust Windows Power Modes</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="AuraBreathe" xml:space="preserve">
|
<data name="AuraBreathe" xml:space="preserve">
|
||||||
<value>Breathe</value>
|
<value>Breathe</value>
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
<value>Застосувати потужність</value>
|
<value>Застосувати потужність</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="ApplyWindowsPowerPlan" xml:space="preserve">
|
<data name="ApplyWindowsPowerPlan" xml:space="preserve">
|
||||||
<value>Автоматично застосовувати Windows Power Mode</value>
|
<value>Автоматично застосовувати Windows Power Modes</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="AuraBreathe" xml:space="preserve">
|
<data name="AuraBreathe" xml:space="preserve">
|
||||||
<value>Дихання</value>
|
<value>Дихання</value>
|
||||||
|
|||||||
@@ -889,6 +889,7 @@ namespace GHelper
|
|||||||
|
|
||||||
private void ButtonQuit_Click(object? sender, EventArgs e)
|
private void ButtonQuit_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
matrix.Dispose();
|
||||||
Close();
|
Close();
|
||||||
Program.trayIcon.Visible = false;
|
Program.trayIcon.Visible = false;
|
||||||
Application.Exit();
|
Application.Exit();
|
||||||
|
|||||||
Reference in New Issue
Block a user