Compare commits

..

10 Commits

Author SHA1 Message Date
Serge
f326fa99cc Cleanup 2024-02-12 10:14:52 +01:00
Serge
ab44dbf2b4 More slash modes 2024-02-11 21:39:43 +01:00
Serge
6e88cd2304 Merge branch 'main' into slash_lightning 2024-02-11 16:23:51 +01:00
Serge
7639950843 Slash tweaks 2024-02-11 16:08:30 +01:00
Serge
c4cd7748f6 UI tweaks 2024-02-11 12:06:54 +01:00
Serge
1adec8b6c9 Slash Interval settings 2024-02-11 12:03:11 +01:00
Serge
ae298873ca Minor tweaks 2024-02-11 11:44:40 +01:00
Serge
773a5899d1 Slash Lightning tweaks 2024-02-10 23:11:31 +01:00
Serge
72888401b9 Slash lightning UI tweaks 2024-02-10 22:49:17 +01:00
Serge
6a44c42cbf Slash Lightning 2024-02-10 22:04:45 +01:00
12 changed files with 40 additions and 155 deletions

View File

@@ -46,6 +46,7 @@ public class AsusACPI
public const int KB_DUO_PgUpDn = 0x4B;
public const int KB_DUO_SecondDisplay = 0x6A;
public const int Touchpad_Toggle = 0x6B;
public const int ChargerMode = 0x0012006C;
@@ -105,7 +106,7 @@ public class AsusACPI
public const int TUF_KB2 = 0x0010005a;
public const int TUF_KB_STATE = 0x00100057;
public const int MicMuteLed = 0x00040017;
public const int MICMUTE_LED = 0x00040017;
public const int TabletState = 0x00060077;
public const int FnLock = 0x00100023;
@@ -113,8 +114,6 @@ public class AsusACPI
public const int ScreenPadToggle = 0x00050031;
public const int ScreenPadBrightness = 0x00050032;
public const int CameraLed = 0x00060079;
public const int BootSound = 0x00130022;
public const int Tablet_Notebook = 0;
@@ -514,25 +513,16 @@ public class AsusACPI
default: fan_mode = 0; break;
}
byte[] result;
switch (device)
{
case AsusFan.GPU:
result = DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
break;
return DeviceGetBuffer(DevsGPUFanCurve, fan_mode);
case AsusFan.Mid:
result = DeviceGetBuffer(DevsMidFanCurve, fan_mode);
break;
return DeviceGetBuffer(DevsMidFanCurve, fan_mode);
default:
result = DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
break;
return DeviceGetBuffer(DevsCPUFanCurve, fan_mode);
}
Logger.WriteLine($"GetFan {device} :" + BitConverter.ToString(result));
return result;
}
public static bool IsInvalidCurve(byte[] curve)
@@ -674,32 +664,22 @@ public class AsusACPI
}
}
public string ScanRange()
public void ScanRange()
{
int value;
string appPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\GHelper";
string logFile = appPath + "\\scan.txt";
using (StreamWriter w = File.AppendText(logFile))
for (uint i = 0x00000000; i <= 0x00160000; i++)
{
w.WriteLine($"Scan started {DateTime.Now}");
for (uint i = 0x00000000; i <= 0x00160000; i += 0x10000)
{
for (uint j = 0x00; j <= 0xFF; j++)
value = DeviceGet(i);
if (value >= 0)
using (StreamWriter w = File.AppendText(logFile))
{
uint id = i + j;
value = DeviceGet(id);
if (value >= 0)
{
w.WriteLine(id.ToString("X8") + ": " + value.ToString("X4") + " (" + value + ")");
}
w.WriteLine(i.ToString("X8") + ": " + value.ToString("X4") + " (" + value + ")");
w.Close();
}
}
w.WriteLine($"---------------------");
w.Close();
}
return logFile;
}
public void TUFKeyboardBrightness(int brightness)

19
app/Extra.Designer.cs generated
View File

@@ -120,7 +120,6 @@ namespace GHelper
comboAPU = new RComboBox();
pictureAPUMem = new PictureBox();
labelAPUMem = new Label();
pictureScan = new PictureBox();
panelServices.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureService).BeginInit();
panelBindingsHeader.SuspendLayout();
@@ -145,7 +144,6 @@ namespace GHelper
((System.ComponentModel.ISupportInitialize)pictureHibernate).BeginInit();
panelAPU.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureAPUMem).BeginInit();
((System.ComponentModel.ISupportInitialize)pictureScan).BeginInit();
SuspendLayout();
//
// panelServices
@@ -1005,7 +1003,6 @@ namespace GHelper
//
panelSettingsHeader.AutoSize = true;
panelSettingsHeader.BackColor = SystemColors.ControlLight;
panelSettingsHeader.Controls.Add(pictureScan);
panelSettingsHeader.Controls.Add(pictureLog);
panelSettingsHeader.Controls.Add(pictureSettings);
panelSettingsHeader.Controls.Add(labelSettings);
@@ -1266,20 +1263,6 @@ namespace GHelper
labelAPUMem.TabIndex = 0;
labelAPUMem.Text = "Memory Assigned to GPU";
//
// pictureScan
//
pictureScan.Anchor = AnchorStyles.Top | AnchorStyles.Right;
pictureScan.BackgroundImage = Resources.icons8_heartbeat_32;
pictureScan.BackgroundImageLayout = ImageLayout.Zoom;
pictureScan.Cursor = Cursors.Hand;
pictureScan.Location = new Point(891, 11);
pictureScan.Margin = new Padding(4, 3, 4, 3);
pictureScan.Name = "pictureScan";
pictureScan.Size = new Size(32, 32);
pictureScan.TabIndex = 13;
pictureScan.TabStop = false;
pictureScan.Visible = false;
//
// Extra
//
AutoScaleDimensions = new SizeF(192F, 192F);
@@ -1343,7 +1326,6 @@ namespace GHelper
panelAPU.ResumeLayout(false);
panelAPU.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureAPUMem).EndInit();
((System.ComponentModel.ISupportInitialize)pictureScan).EndInit();
ResumeLayout(false);
PerformLayout();
}
@@ -1438,6 +1420,5 @@ namespace GHelper
private PictureBox pictureAPUMem;
private Label labelAPUMem;
private RComboBox comboAPU;
private PictureBox pictureScan;
}
}

View File

@@ -386,7 +386,6 @@ namespace GHelper
buttonServices.Click += ButtonServices_Click;
pictureLog.Click += PictureLog_Click;
pictureScan.Click += PictureScan_Click;
checkGPUFix.Visible = Program.acpi.IsNVidiaGPU();
checkGPUFix.Checked = AppConfig.IsGPUFix();
@@ -399,18 +398,6 @@ namespace GHelper
InitHibernate();
}
private void PictureScan_Click(object? sender, EventArgs e)
{
string logFile = Program.acpi.ScanRange();
new Process
{
StartInfo = new ProcessStartInfo(logFile)
{
UseShellExecute = true
}
}.Start();
}
private void ComboAPU_SelectedIndexChanged(object? sender, EventArgs e)
{
int mem = comboAPU.SelectedIndex;

View File

@@ -953,7 +953,7 @@ namespace GHelper
int chartCount = 2;
// Middle / system fan check
if (!AsusACPI.IsEmptyCurve(Program.acpi.GetFanCurve(AsusFan.Mid)) || Program.acpi.GetFan(AsusFan.Mid) >= 0)
if (!AsusACPI.IsEmptyCurve(Program.acpi.GetFanCurve(AsusFan.Mid)))
{
AppConfig.Set("mid_fan", 1);
chartCount++;

View File

@@ -15,7 +15,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.154</AssemblyVersion>
<AssemblyVersion>0.153</AssemblyVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

View File

@@ -30,7 +30,7 @@ public static class Logger
try
{
var file = File.ReadAllLines(logFile);
int skip = Math.Max(0, file.Count() - 2000);
int skip = Math.Max(0, file.Count() - 1000);
File.WriteAllLines(logFile, file.Skip(skip).ToArray());
}
catch { }

View File

@@ -500,7 +500,7 @@ namespace GHelper.Input
case "micmute":
bool muteStatus = Audio.ToggleMute();
Program.toast.RunToast(muteStatus ? "Muted" : "Unmuted", muteStatus ? ToastIcon.MicrophoneMute : ToastIcon.Microphone);
if (AppConfig.IsVivobook()) Program.acpi.DeviceSet(AsusACPI.MicMuteLed, muteStatus ? 1 : 0, "MicmuteLed");
if (AppConfig.IsVivobook()) Program.acpi.DeviceSet(AsusACPI.MICMUTE_LED, muteStatus ? 1 : 0, "MicmuteLed");
break;
case "brightness_up":
SetBrightness(+10);
@@ -628,9 +628,6 @@ namespace GHelper.Input
{
switch (EventID)
{
case 134: // FN + F12 ON OLD DEVICES
KeyProcess("m4");
return;
case 124: // M3
KeyProcess("m3");
return;
@@ -709,9 +706,6 @@ namespace GHelper.Input
else
Program.acpi.DeviceSet(AsusACPI.UniversalControl, AsusACPI.Brightness_Up, "Brightness");
break;
case 133: // Camera Toggle
ToggleCamera();
break;
case 107: // FN+F10
ToggleTouchpadEvent();
break;
@@ -790,36 +784,6 @@ namespace GHelper.Input
Program.toast.RunToast($"Screen Pad " + (toggle == 1 ? "On" : "Off"), toggle > 0 ? ToastIcon.BrightnessUp : ToastIcon.BrightnessDown);
}
public static void ToggleCamera()
{
if (!ProcessHelper.IsUserAdministrator()) return;
string CameraRegistryKeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam";
string CameraRegistryValueName = "Value";
try
{
var status = (string?)Registry.GetValue(CameraRegistryKeyPath, CameraRegistryValueName, "");
if (status == "Allow") status = "Deny";
else if (status == "Deny") status = "Allow";
else
{
Logger.WriteLine("Unknown camera status");
return;
}
Registry.SetValue(CameraRegistryKeyPath, CameraRegistryValueName, status, RegistryValueKind.String);
Program.acpi.DeviceSet(AsusACPI.CameraLed, (status == "Deny" ? 1 : 0), "Camera");
Program.toast.RunToast($"Camera " + (status == "Deny" ? "Off" : "On"));
}
catch (Exception ex)
{
Logger.WriteLine(ex.ToString());
}
}
public static void SetScreenpad(int delta)
{

View File

@@ -24,30 +24,26 @@ public sealed class KeyboardHook : IDisposable
public static void KeyPress(Keys key)
{
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
Thread.Sleep(1);
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
}
public static void KeyKeyPress(Keys key, Keys key2)
{
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
Thread.Sleep(1);
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
}
public static void KeyKeyKeyPress(Keys key, Keys key2, Keys key3, int sleep = 1)
public static void KeyKeyKeyPress(Keys key, Keys key2, Keys key3, int sleep = 0)
{
keybd_event((byte)key, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
keybd_event((byte)key3, 0, KEYEVENTF_EXTENDEDKEY, IntPtr.Zero);
Thread.Sleep(sleep);
if (sleep > 0)
{
Thread.Sleep(sleep);
}
keybd_event((byte)key3, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);
keybd_event((byte)key2, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, IntPtr.Zero);

View File

@@ -66,7 +66,7 @@ namespace GHelper.Input
}
catch (Exception ex)
{
Logger.WriteLine($"Listener exited: {ex.Message}");
Logger.WriteLine(ex.ToString());
}
}

View File

@@ -90,24 +90,18 @@ public static class AsusHid
if (devices is null) return;
foreach (var device in devices)
try
{
using (var stream = device.Open())
foreach (var data in dataList)
try
{
stream.Write(data);
Logger.WriteLine($"{log} {device.ProductID.ToString("X")}: {BitConverter.ToString(data)}");
}
catch (Exception ex)
{
Logger.WriteLine($"Error writing {log} {device.ProductID.ToString("X")}: {ex.Message} {BitConverter.ToString(data)} ");
}
}
catch (Exception ex)
{
Logger.WriteLine($"Error opening {log} {device.ProductID.ToString("X")}: {ex.Message}");
}
using (var stream = device.Open())
foreach (var data in dataList)
try
{
stream.Write(data);
Logger.WriteLine($"{log} {device.ProductID.ToString("X")}: {BitConverter.ToString(data)}");
}
catch (Exception ex)
{
Logger.WriteLine($"Error writing {log} {device.ProductID.ToString("X")}: {ex.Message} {BitConverter.ToString(data)} ");
}
}
public static void WriteAura(byte[] data)

View File

@@ -73,9 +73,6 @@ namespace GHelper.USB
private static AuraMode mode = AuraMode.AuraStatic;
private static AuraSpeed speed = AuraSpeed.Normal;
private static bool backlight = false;
private static bool initDirect = false;
public static Color Color1 = Color.White;
public static Color Color2 = Color.Black;
@@ -292,8 +289,6 @@ namespace GHelper.USB
public static void ApplyBrightness(int brightness, string log = "Backlight", bool delay = false)
{
if (brightness == 0) backlight = false;
Task.Run(async () =>
{
if (delay) await Task.Delay(TimeSpan.FromSeconds(1));
@@ -306,13 +301,6 @@ namespace GHelper.USB
if (AppConfig.IsAlly()) ApplyAura();
if (brightness > 0)
{
if (!backlight) initDirect = true;
backlight = true;
}
});
@@ -506,8 +494,6 @@ namespace GHelper.USB
public static void ApplyDirect(Color[] color, bool init = false)
{
if (!backlight) return;
const byte keySet = 167;
const byte ledCount = 178;
const ushort mapSize = 3 * ledCount;
@@ -525,9 +511,9 @@ namespace GHelper.USB
buffer[6] = 0;
buffer[7] = 0x10;
if (init || initDirect)
if (init)
{
initDirect = false;
Init();
AsusHid.WriteAura(new byte[] { AsusHid.AURA_ID, 0xBC });
}
@@ -588,8 +574,6 @@ namespace GHelper.USB
public static void ApplyDirect(Color color, bool init = false)
{
if (!backlight) return;
if (isACPI)
{
Program.acpi.TUFKeyboardRGB(0, color, 0, null);
@@ -608,9 +592,9 @@ namespace GHelper.USB
return;
}
if (init || initDirect)
if (init)
{
initDirect = false;
//Init();
AsusHid.WriteAura(new byte[] { AsusHid.AURA_ID, 0xbc, 1 });
}
@@ -737,8 +721,6 @@ namespace GHelper.USB
public static void ApplyAmbient(bool init = false)
{
if (!backlight) return;
var bound = Screen.GetBounds(Point.Empty);
bound.Y += bound.Height / 3;
bound.Height -= (int)Math.Round(bound.Height * (0.33f + 0.022f)); // cut 1/3 of the top screen + windows panel

View File

@@ -107,12 +107,13 @@ Huge thanks to [@IceStormNG](https://github.com/IceStormNG) 👑 for contributio
### ⌨️ Keybindings
- ``Fn + F5 / Fn + Shift + F5`` - Toggle Performance Modes forwards / backwards
- ``Shift + Fn + F7 / F8`` - Set Anime Matrix / Slash Lightning brightness Down / Up
- ``Ctrl + Shift + F5 / Ctrl + Shift + Alt + F5`` - Toggle Performance Modes forwards / backwards
- ``Ctrl + Shift + F12`` - Open G-Helper window
- ``Ctrl + M1 / M2`` - Screen brightness Down / Up
- ``Shift + M1 / M2`` - Backlight brightness Down / Up
- ``Fn + C`` - Fn-Lock
- ``Fn + Shift + F7 / F8`` - Matrix / Slash Lightning brightness Down / Up
- ``Fn + Shift + F7 / F8`` - Matrix brightness Down / Up
- ``Fn + Shift + F7 / F8`` - Screenpad brightness Down / Up
- ``Ctrl + Shift + F20`` - Mute Microphone
- ``Ctrl + Shift + Alt + F14`` - Eco GPU Mode