mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Dimming hotkeys
This commit is contained in:
@@ -25,19 +25,26 @@ namespace GHelper.Display
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBrightness(int brightness = -1)
|
||||
public int SetBrightness(int brightness = -1, int delta = 0)
|
||||
{
|
||||
if (!AppConfig.IsOLED()) return;
|
||||
if (!AppConfig.IsOLED()) return -1;
|
||||
|
||||
if (brightness >= 0) AppConfig.Set("brightness", brightness);
|
||||
else brightness = AppConfig.Get("brightness");
|
||||
if (brightness < 0) brightness = AppConfig.Get("brightness", 100);
|
||||
brightness = Math.Max(0, Math.Min(100, brightness + delta));
|
||||
|
||||
if (brightness >= 0) Task.Run(() =>
|
||||
AppConfig.Set("brightness", brightness);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
//Logger.WriteLine($"Brightness: {brightness}");
|
||||
bool isGameVisual = System.IO.Directory.Exists("C:\\ProgramData\\ASUS\\GameVisual") ;
|
||||
var splendid = Environment.SystemDirectory + "\\DriverStore\\FileRepository\\asussci2.inf_amd64_f2eed2fae3b45a67\\ASUSOptimization\\AsusSplendid.exe";
|
||||
ProcessHelper.RunCMD(splendid, (AppConfig.IsROG() ? 19 : 9) + " 0 " + (40 + brightness * 0.6));
|
||||
var result = ProcessHelper.RunCMD(splendid, (isGameVisual ? 19 : 9) + " 0 " + (40 + brightness * 0.6));
|
||||
if (result.Contains("file not exist")) SetGamma(brightness);
|
||||
});
|
||||
|
||||
Program.settingsForm.VisualiseBrightness();
|
||||
|
||||
return brightness;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -244,6 +244,13 @@ namespace GHelper.Input
|
||||
|
||||
}
|
||||
|
||||
static void SetBrightnessDimming(int delta)
|
||||
{
|
||||
int brightness = screenControl.SetBrightness(delta: delta);
|
||||
if (brightness >= 0)
|
||||
Program.toast.RunToast(brightness + "%", (delta < 0) ? ToastIcon.BrightnessDown : ToastIcon.BrightnessUp);
|
||||
}
|
||||
|
||||
public void KeyPressed(object sender, KeyPressedEventArgs e)
|
||||
{
|
||||
|
||||
@@ -698,8 +705,14 @@ namespace GHelper.Input
|
||||
if (AppConfig.IsDUO()) SetScreenpad(-10);
|
||||
else Program.settingsForm.BeginInvoke(Program.settingsForm.CycleMatrix, -1);
|
||||
}
|
||||
else if (Control.ModifierKeys == Keys.Control && AppConfig.IsOLED())
|
||||
{
|
||||
SetBrightnessDimming(-10);
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Down, "Brightness");
|
||||
}
|
||||
break;
|
||||
case 32: // FN+F8
|
||||
if (Control.ModifierKeys == Keys.Shift)
|
||||
@@ -707,8 +720,14 @@ namespace GHelper.Input
|
||||
if (AppConfig.IsDUO()) SetScreenpad(10);
|
||||
else Program.settingsForm.BeginInvoke(Program.settingsForm.CycleMatrix, 1);
|
||||
}
|
||||
else if (Control.ModifierKeys == Keys.Control && AppConfig.IsOLED())
|
||||
{
|
||||
SetBrightnessDimming(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Up, "Brightness");
|
||||
}
|
||||
break;
|
||||
case 133: // Camera Toggle
|
||||
ToggleCamera();
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace GHelper
|
||||
buttonScreenAuto.AccessibleName = Properties.Strings.AutoMode;
|
||||
//button60Hz.AccessibleName = "60Hz Refresh Rate";
|
||||
//button120Hz.AccessibleName = "Maximum Refresh Rate";
|
||||
|
||||
|
||||
panelKeyboard.AccessibleName = Properties.Strings.LaptopKeyboard;
|
||||
buttonKeyboard.AccessibleName = Properties.Strings.ExtraSettings;
|
||||
buttonKeyboardColor.AccessibleName = Properties.Strings.LaptopKeyboard + " " + Properties.Strings.Color;
|
||||
@@ -219,7 +219,7 @@ namespace GHelper
|
||||
sliderBattery.ValueChanged += SliderBattery_ValueChanged;
|
||||
Program.trayIcon.MouseMove += TrayIcon_MouseMove;
|
||||
|
||||
sensorTimer = new System.Timers.Timer(AppConfig.Get("sensor_timer",1000));
|
||||
sensorTimer = new System.Timers.Timer(AppConfig.Get("sensor_timer", 1000));
|
||||
sensorTimer.Elapsed += OnTimedEvent;
|
||||
sensorTimer.Enabled = true;
|
||||
|
||||
@@ -262,22 +262,25 @@ namespace GHelper
|
||||
public void InitBrightness()
|
||||
{
|
||||
if (!AppConfig.IsOLED()) return;
|
||||
|
||||
panelGamma.Visible = true;
|
||||
|
||||
int brightness = AppConfig.Get("brightness");
|
||||
if (brightness >= 0) sliderGamma.Value = brightness;
|
||||
labelGamma.Text = sliderGamma.Value + "%";
|
||||
VisualiseBrightness();
|
||||
|
||||
sliderGamma.ValueChanged += SliderGamma_ValueChanged;
|
||||
sliderGamma.MouseUp += SliderGamma_ValueChanged;
|
||||
}
|
||||
|
||||
public void VisualiseBrightness()
|
||||
{
|
||||
Invoke(delegate
|
||||
{
|
||||
sliderGamma.Value = AppConfig.Get("brightness", 100);
|
||||
labelGamma.Text = sliderGamma.Value + "%";
|
||||
});
|
||||
}
|
||||
|
||||
private void SliderGamma_ValueChanged(object? sender, EventArgs e)
|
||||
{
|
||||
screenControl.SetBrightness(sliderGamma.Value);
|
||||
labelGamma.Text = sliderGamma.Value + "%";
|
||||
}
|
||||
|
||||
private void ButtonOverlay_Click(object? sender, EventArgs e)
|
||||
@@ -351,7 +354,7 @@ namespace GHelper
|
||||
|
||||
public void VisualiseBacklight(int backlight)
|
||||
{
|
||||
buttonBacklight.Text = Math.Round((double)backlight*33.33).ToString() + "%";
|
||||
buttonBacklight.Text = Math.Round((double)backlight * 33.33).ToString() + "%";
|
||||
}
|
||||
|
||||
public void VisualiseFPSLimit(int limit)
|
||||
@@ -848,7 +851,7 @@ namespace GHelper
|
||||
FansToggle();
|
||||
}
|
||||
|
||||
private void SetColorPicker(string colorField = "aura_color")
|
||||
private void SetColorPicker(string colorField = "aura_color")
|
||||
{
|
||||
ColorDialog colorDlg = new ColorDialog();
|
||||
colorDlg.AllowFullOpen = true;
|
||||
@@ -953,7 +956,7 @@ namespace GHelper
|
||||
|
||||
buttonMatrix.Visible = false;
|
||||
checkMatrixLid.Visible = true;
|
||||
}
|
||||
}
|
||||
|
||||
comboMatrix.SelectedIndex = Math.Min(AppConfig.Get("matrix_brightness", 0), comboMatrix.Items.Count - 1);
|
||||
comboMatrixRunning.SelectedIndex = Math.Min(AppConfig.Get("matrix_running", 0), comboMatrixRunning.Items.Count - 1);
|
||||
@@ -1286,11 +1289,13 @@ namespace GHelper
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(delegate {
|
||||
Invoke(delegate
|
||||
{
|
||||
labelPerf.Text = modeText;
|
||||
panelPerformance.AccessibleName = labelPerf.Text;
|
||||
});
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
labelPerf.Text = modeText;
|
||||
panelPerformance.AccessibleName = labelPerf.Text;
|
||||
@@ -1465,7 +1470,7 @@ namespace GHelper
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
VisualizeXGM(GPUMode);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user