mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Add support for CameraShutter (#3358)
This commit is contained in:
@@ -698,10 +698,15 @@ public static class AppConfig
|
|||||||
{
|
{
|
||||||
return ContainsModel("G834JYR") || ContainsModel("G834JZR") || Is("force_miniled");
|
return ContainsModel("G834JYR") || ContainsModel("G834JZR") || Is("force_miniled");
|
||||||
}
|
}
|
||||||
|
public static bool IsCameraShutter()
|
||||||
|
{
|
||||||
|
return ContainsModel("UX5401") || ContainsModel("UX5406");
|
||||||
|
}
|
||||||
|
|
||||||
public static bool SaveDimming()
|
public static bool SaveDimming()
|
||||||
{
|
{
|
||||||
return Is("save_dimming");
|
return Is("save_dimming");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,6 +129,7 @@ public class AsusACPI
|
|||||||
public const int ScreenPadToggle = 0x00050031;
|
public const int ScreenPadToggle = 0x00050031;
|
||||||
public const int ScreenPadBrightness = 0x00050032;
|
public const int ScreenPadBrightness = 0x00050032;
|
||||||
|
|
||||||
|
public const int CameraShutter = 0x00060078;
|
||||||
public const int CameraLed = 0x00060079;
|
public const int CameraLed = 0x00060079;
|
||||||
public const int StatusLed = 0x000600C2;
|
public const int StatusLed = 0x000600C2;
|
||||||
|
|
||||||
|
|||||||
@@ -944,33 +944,49 @@ namespace GHelper.Input
|
|||||||
|
|
||||||
public static void ToggleCamera()
|
public static void ToggleCamera()
|
||||||
{
|
{
|
||||||
if (!ProcessHelper.IsUserAdministrator()) return;
|
if(AppConfig.IsCameraShutter())
|
||||||
|
|
||||||
string CameraRegistryKeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam";
|
|
||||||
string CameraRegistryValueName = "Value";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
var status = (string?)Registry.GetValue(CameraRegistryKeyPath, CameraRegistryValueName, "");
|
if(Program.acpi.DeviceGet(AsusACPI.CameraShutter)==0)
|
||||||
|
{
|
||||||
|
Program.acpi.DeviceSet(AsusACPI.CameraShutter, 1, "CameraShutterOn");
|
||||||
|
Program.toast.RunToast($"Camera Off");
|
||||||
|
|
||||||
if (status == "Allow") status = "Deny";
|
}
|
||||||
else if (status == "Deny") status = "Allow";
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.WriteLine("Unknown camera status");
|
Program.acpi.DeviceSet(AsusACPI.CameraShutter, 0, "CameraShutterOff");
|
||||||
return;
|
Program.toast.RunToast($"Camera On");
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
else
|
||||||
{
|
{
|
||||||
Logger.WriteLine(ex.ToString());
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static System.Threading.Timer screenpadActionTimer;
|
private static System.Threading.Timer screenpadActionTimer;
|
||||||
|
|||||||
Reference in New Issue
Block a user