mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ab08bd8ab4 | ||
|
|
9f157d323e | ||
|
|
9c236ca17b | ||
|
|
ba8effcaad | ||
|
|
28f8cc95fd | ||
|
|
07f1edb02f | ||
|
|
6758d9224d | ||
|
|
5e51511df0 | ||
|
|
e71d283474 | ||
|
|
d0f0bd9155 |
@@ -691,4 +691,9 @@ public static class AppConfig
|
||||
return ContainsModel("G834JYR") || Is("force_miniled");
|
||||
}
|
||||
|
||||
public static bool SaveDimming()
|
||||
{
|
||||
return Is("save_dimming");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@ namespace GHelper.Battery
|
||||
if (AppConfig.IsChargeLimit6080())
|
||||
{
|
||||
if (limit > 85) limit = 100;
|
||||
else if (limit >= 80) limit = 80;
|
||||
else if (limit < 60) limit = 60;
|
||||
else limit = 80;
|
||||
}
|
||||
|
||||
Program.acpi.DeviceSet(AsusACPI.BatteryLimit, limit, "BatteryLimit");
|
||||
|
||||
@@ -211,9 +211,14 @@ namespace GHelper.Display
|
||||
|
||||
AppConfig.Set("gamut", mode);
|
||||
|
||||
if (RunSplendid(SplendidCommand.GamutMode, 0, mode)) return;
|
||||
|
||||
if (_init)
|
||||
var result = RunSplendid(SplendidCommand.GamutMode, 0, mode);
|
||||
if (result == 0) return;
|
||||
if (result == -1)
|
||||
{
|
||||
Logger.WriteLine("Gamut setting refused, reverting.");
|
||||
RunSplendid(SplendidCommand.GamutMode, 0, (int)GetDefaultGamut());
|
||||
}
|
||||
if (result == 1 && _init)
|
||||
{
|
||||
_init = false;
|
||||
RunSplendid(SplendidCommand.Init);
|
||||
@@ -253,9 +258,14 @@ namespace GHelper.Display
|
||||
break;
|
||||
}
|
||||
|
||||
if (RunSplendid(mode, 0, balance)) return;
|
||||
|
||||
if (_init)
|
||||
var result = RunSplendid(mode, 0, balance);
|
||||
if (result == 0) return;
|
||||
if (result == -1)
|
||||
{
|
||||
Logger.WriteLine("Visual setting refused, reverting.");
|
||||
RunSplendid(SplendidCommand.Default, 0, DefaultColorTemp);
|
||||
}
|
||||
if (result == 1 && _init)
|
||||
{
|
||||
_init = false;
|
||||
RunSplendid(SplendidCommand.Init);
|
||||
@@ -288,7 +298,7 @@ namespace GHelper.Display
|
||||
return _splendidPath;
|
||||
}
|
||||
|
||||
private static bool RunSplendid(SplendidCommand command, int? param1 = null, int? param2 = null)
|
||||
private static int RunSplendid(SplendidCommand command, int? param1 = null, int? param2 = null)
|
||||
{
|
||||
var splendid = GetSplendidPath();
|
||||
bool isVivo = AppConfig.IsVivoZenPro();
|
||||
@@ -298,10 +308,11 @@ namespace GHelper.Display
|
||||
{
|
||||
if (command == SplendidCommand.DimmingVisual && isVivo) command = SplendidCommand.DimmingVivo;
|
||||
var result = ProcessHelper.RunCMD(splendid, (int)command + " " + param1 + " " + param2);
|
||||
if (result.Contains("file not exist") || (result.Length == 0 && !isVivo)) return false;
|
||||
if (result.Contains("file not exist") || (result.Length == 0 && !isVivo)) return 1;
|
||||
if (result.Contains("return code: -1")) return -1;
|
||||
}
|
||||
|
||||
return true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static void BrightnessTimerTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
@@ -309,28 +320,46 @@ namespace GHelper.Display
|
||||
brightnessTimer.Stop();
|
||||
|
||||
|
||||
if (RunSplendid(SplendidCommand.DimmingVisual, 0, (int)(40 + _brightness * 0.6))) return;
|
||||
if (RunSplendid(SplendidCommand.DimmingVisual, 0, (int)(40 + _brightness * 0.6)) == 0) return;
|
||||
|
||||
if (_init)
|
||||
{
|
||||
_init = false;
|
||||
RunSplendid(SplendidCommand.Init);
|
||||
RunSplendid(SplendidCommand.Init, 4);
|
||||
if (RunSplendid(SplendidCommand.DimmingVisual, 0, (int)(40 + _brightness * 0.6))) return;
|
||||
if (RunSplendid(SplendidCommand.DimmingVisual, 0, (int)(40 + _brightness * 0.6)) == 0) return;
|
||||
}
|
||||
|
||||
// GammaRamp Fallback
|
||||
SetGamma(_brightness);
|
||||
}
|
||||
|
||||
public static void InitBrightness()
|
||||
{
|
||||
if (!AppConfig.IsOLED()) return;
|
||||
if (!AppConfig.SaveDimming()) return;
|
||||
|
||||
int brightness = GetBrightness();
|
||||
if (brightness >= 0) SetBrightness(brightness);
|
||||
}
|
||||
|
||||
private static bool IsOnBattery()
|
||||
{
|
||||
return AppConfig.SaveDimming() && SystemInformation.PowerStatus.PowerLineStatus != PowerLineStatus.Online;
|
||||
}
|
||||
|
||||
public static int GetBrightness()
|
||||
{
|
||||
return AppConfig.Get(IsOnBattery() ? "brightness_battery" : "brightness", 100);
|
||||
}
|
||||
|
||||
public static int SetBrightness(int brightness = -1, int delta = 0)
|
||||
{
|
||||
if (!AppConfig.IsOLED()) return -1;
|
||||
|
||||
if (brightness < 0) brightness = AppConfig.Get("brightness", 100);
|
||||
if (brightness < 0) GetBrightness();
|
||||
|
||||
_brightness = Math.Max(0, Math.Min(100, brightness + delta));
|
||||
AppConfig.Set("brightness", _brightness);
|
||||
AppConfig.Set(IsOnBattery() ? "brightness_battery" : "brightness", _brightness);
|
||||
|
||||
brightnessTimer.Start();
|
||||
|
||||
|
||||
@@ -76,7 +76,8 @@ namespace GHelper
|
||||
customActions.Remove("fnlock");
|
||||
break;
|
||||
case "fnv":
|
||||
customActions[""] = EMPTY;
|
||||
customActions[""] = Properties.Strings.VisualMode;
|
||||
customActions.Remove("visual");
|
||||
break;
|
||||
case "fne":
|
||||
customActions[""] = "Calculator";
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<AssemblyVersion>0.190</AssemblyVersion>
|
||||
<AssemblyVersion>0.191</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
|
||||
@@ -41,7 +41,7 @@ public static class NvidiaSmi
|
||||
public static int GetMaxGPUPower()
|
||||
{
|
||||
string output = RunNvidiaSmiCommand("--query-gpu=power.max_limit --format csv,noheader,nounits");
|
||||
output = output.Trim().Trim('\n', '\r');
|
||||
output = output.Trim().Trim('\n', '\r').Replace(".00","").Replace(",00", "");
|
||||
|
||||
if (float.TryParse(output, out float floatValue))
|
||||
{
|
||||
|
||||
@@ -228,24 +228,31 @@ namespace GHelper.Input
|
||||
}
|
||||
|
||||
|
||||
static void SetBrightness(int delta)
|
||||
static void SetBrightness(bool up, bool hotkey = false)
|
||||
{
|
||||
int brightness = -1;
|
||||
|
||||
if (isTUF) brightness = ScreenBrightness.Get();
|
||||
if (AppConfig.SwappedBrightness()) delta = -delta;
|
||||
if (AppConfig.SwappedBrightness() && !hotkey) up = !up;
|
||||
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, delta > 0 ? AsusACPI.Brightness_Up : AsusACPI.Brightness_Down, "Brightness");
|
||||
int step = AppConfig.Get("brightness_step", 10);
|
||||
if (step != 10)
|
||||
{
|
||||
Program.toast.RunToast(ScreenBrightness.Adjust(up ? step : -step) + "%", up ? ToastIcon.BrightnessUp : ToastIcon.BrightnessDown);
|
||||
return;
|
||||
}
|
||||
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, up ? AsusACPI.Brightness_Up : AsusACPI.Brightness_Down, "Brightness");
|
||||
|
||||
if (isTUF)
|
||||
{
|
||||
if (AppConfig.SwappedBrightness()) return;
|
||||
if (delta < 0 && brightness <= 0) return;
|
||||
if (delta > 0 && brightness >= 100) return;
|
||||
if (!up && brightness <= 0) return;
|
||||
if (up && brightness >= 100) return;
|
||||
|
||||
Thread.Sleep(100);
|
||||
if (brightness == ScreenBrightness.Get())
|
||||
Program.toast.RunToast(ScreenBrightness.Adjust(delta) + "%", (delta < 0) ? ToastIcon.BrightnessDown : ToastIcon.BrightnessUp);
|
||||
Program.toast.RunToast(ScreenBrightness.Adjust(up ? step : -step) + "%", up ? ToastIcon.BrightnessUp : ToastIcon.BrightnessDown);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -275,7 +282,7 @@ namespace GHelper.Input
|
||||
KeyboardHook.KeyPress(Keys.VolumeUp);
|
||||
return;
|
||||
case Keys.F4:
|
||||
KeyProcess("m3");
|
||||
ToggleMic();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -294,10 +301,10 @@ namespace GHelper.Input
|
||||
HandleEvent(199); // Backlight cycle
|
||||
return;
|
||||
case Keys.F5:
|
||||
SetBrightness(-10);
|
||||
SetBrightness(false);
|
||||
return;
|
||||
case Keys.F6:
|
||||
SetBrightness(+10);
|
||||
SetBrightness(true);
|
||||
return;
|
||||
case Keys.F7:
|
||||
KeyboardHook.KeyKeyPress(Keys.LWin, Keys.P);
|
||||
@@ -306,7 +313,7 @@ namespace GHelper.Input
|
||||
HandleEvent(126); // Emojis
|
||||
return;
|
||||
case Keys.F9:
|
||||
KeyProcess("m3"); // MicMute
|
||||
ToggleMic(); // MicMute
|
||||
return;
|
||||
case Keys.F10:
|
||||
HandleEvent(133); // Camera Toggle
|
||||
@@ -365,10 +372,10 @@ namespace GHelper.Input
|
||||
KeyboardHook.KeyPress(Keys.Snapshot);
|
||||
break;
|
||||
case Keys.F7:
|
||||
SetBrightness(-10);
|
||||
SetBrightness(false);
|
||||
break;
|
||||
case Keys.F8:
|
||||
SetBrightness(+10);
|
||||
SetBrightness(true);
|
||||
break;
|
||||
case Keys.F9:
|
||||
KeyboardHook.KeyKeyPress(Keys.LWin, Keys.P);
|
||||
@@ -407,7 +414,7 @@ namespace GHelper.Input
|
||||
{
|
||||
if (e.Key == keyProfile) modeControl.CyclePerformanceMode();
|
||||
if (e.Key == keyApp) Program.SettingsToggle();
|
||||
if (e.Key == Keys.F20) KeyProcess("m3");
|
||||
if (e.Key == Keys.F20) ToggleMic();
|
||||
}
|
||||
|
||||
if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt))
|
||||
@@ -417,10 +424,10 @@ namespace GHelper.Input
|
||||
switch (e.Key)
|
||||
{
|
||||
case Keys.F1:
|
||||
SetBrightness(-10);
|
||||
SetBrightness(false);
|
||||
break;
|
||||
case Keys.F2:
|
||||
SetBrightness(10);
|
||||
SetBrightness(true);
|
||||
break;
|
||||
case Keys.F3:
|
||||
Program.settingsForm.gpuControl.ToggleXGM(true);
|
||||
@@ -462,11 +469,11 @@ namespace GHelper.Input
|
||||
{
|
||||
case Keys.VolumeDown:
|
||||
// Screen brightness down on CTRL+VolDown
|
||||
SetBrightness(-10);
|
||||
SetBrightness(false);
|
||||
break;
|
||||
case Keys.VolumeUp:
|
||||
// Screen brightness up on CTRL+VolUp
|
||||
SetBrightness(+10);
|
||||
SetBrightness(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -504,6 +511,8 @@ namespace GHelper.Input
|
||||
action = "micmute";
|
||||
if (name == "fnc")
|
||||
action = "fnlock";
|
||||
if (name == "fnv")
|
||||
action = "visual";
|
||||
if (name == "fne")
|
||||
action = "calculator";
|
||||
}
|
||||
@@ -558,15 +567,13 @@ namespace GHelper.Input
|
||||
ToggleFnLock();
|
||||
break;
|
||||
case "micmute":
|
||||
bool muteStatus = Audio.ToggleMute();
|
||||
Program.toast.RunToast(muteStatus ? Properties.Strings.Muted : Properties.Strings.Unmuted, muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
|
||||
if (AppConfig.IsVivoZenbook()) Program.acpi.DeviceSet(AsusACPI.MicMuteLed, muteStatus ? 1 : 0, "MicmuteLed");
|
||||
ToggleMic();
|
||||
break;
|
||||
case "brightness_up":
|
||||
SetBrightness(+10);
|
||||
SetBrightness(true);
|
||||
break;
|
||||
case "brightness_down":
|
||||
SetBrightness(-10);
|
||||
SetBrightness(false);
|
||||
break;
|
||||
case "screenpad_up":
|
||||
SetScreenpad(10);
|
||||
@@ -593,6 +600,14 @@ namespace GHelper.Input
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void ToggleMic()
|
||||
{
|
||||
bool muteStatus = Audio.ToggleMute();
|
||||
Program.toast.RunToast(muteStatus ? Properties.Strings.Muted : Properties.Strings.Unmuted, muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
|
||||
if (AppConfig.IsVivoZenbook()) Program.acpi.DeviceSet(AsusACPI.MicMuteLed, muteStatus ? 1 : 0, "MicmuteLed");
|
||||
}
|
||||
|
||||
static bool GetTouchpadState()
|
||||
{
|
||||
using (var key = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\PrecisionTouchPad\Status", false))
|
||||
@@ -777,7 +792,7 @@ namespace GHelper.Input
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Down, "Brightness");
|
||||
SetBrightness(false, true);
|
||||
}
|
||||
break;
|
||||
case 32: // FN+F8
|
||||
@@ -792,7 +807,7 @@ namespace GHelper.Input
|
||||
}
|
||||
else
|
||||
{
|
||||
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Up, "Brightness");
|
||||
SetBrightness(true, true);
|
||||
}
|
||||
break;
|
||||
case 133: // Camera Toggle
|
||||
|
||||
@@ -256,6 +256,8 @@ namespace GHelper
|
||||
settingsForm.AutoKeyboard();
|
||||
}
|
||||
|
||||
VisualControl.InitBrightness();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -453,7 +453,7 @@ namespace GHelper
|
||||
Invoke(delegate
|
||||
{
|
||||
sliderGammaIgnore = true;
|
||||
sliderGamma.Value = AppConfig.Get("brightness", 100);
|
||||
sliderGamma.Value = VisualControl.GetBrightness();
|
||||
labelGamma.Text = sliderGamma.Value + "%";
|
||||
sliderGammaIgnore = false;
|
||||
});
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
Small and lightweight Armoury Crate alternative for Asus laptops offering almost same functionality without extra load and unnecessary services.
|
||||
|
||||
Works with all popular models, such as ROG Zephyrus G14, G15, G16, M16, Flow X13, Flow X16, Flow Z13, DUO, TUF Series, Strix or Scar Series, ProArt, Vivobook, Zenbook, ROG Ally / Ally X and many more!
|
||||
Works with all popular models, such as ROG Zephyrus G14, G15, G16, M16, Flow X13, Flow X16, Flow Z13, DUO, TUF Series, Strix or Scar Series, ProArt, Vivobook, Zenbook, ROG Ally or Ally X and many more!
|
||||
|
||||
# [:floppy_disk:Download](https://github.com/seerge/g-helper/releases/latest/download/GHelper.zip)
|
||||
**⭐ If you like the app - please spread the word about it online**
|
||||
|
||||
Reference in New Issue
Block a user