Skip to content

Commit

Permalink
Add support for CameraShutter (seerge#3358)
Browse files Browse the repository at this point in the history
  • Loading branch information
yinyue200 authored Nov 10, 2024
1 parent df5bdfd commit 000162b
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
5 changes: 5 additions & 0 deletions app/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,10 +698,15 @@ public static bool IsForceMiniled()
{
return ContainsModel("G834JYR") || ContainsModel("G834JZR") || Is("force_miniled");
}
public static bool IsCameraShutter()
{
return ContainsModel("UX5401") || ContainsModel("UX5406");
}

public static bool SaveDimming()
{
return Is("save_dimming");
}


}
1 change: 1 addition & 0 deletions app/AsusACPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public class AsusACPI
public const int ScreenPadToggle = 0x00050031;
public const int ScreenPadBrightness = 0x00050032;

public const int CameraShutter = 0x00060078;
public const int CameraLed = 0x00060079;
public const int StatusLed = 0x000600C2;

Expand Down
54 changes: 35 additions & 19 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,33 +944,49 @@ public static void ToggleScreenRate()

public static void ToggleCamera()
{
if (!ProcessHelper.IsUserAdministrator()) return;

string CameraRegistryKeyPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\webcam";
string CameraRegistryValueName = "Value";

try
if(AppConfig.IsCameraShutter())
{
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
{
Logger.WriteLine("Unknown camera status");
return;
Program.acpi.DeviceSet(AsusACPI.CameraShutter, 0, "CameraShutterOff");
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;
Expand Down

0 comments on commit 000162b

Please sign in to comment.