This commit is contained in:
Serge
2024-03-27 18:25:56 +01:00
18 changed files with 93 additions and 18 deletions

View File

@@ -809,14 +809,14 @@ namespace GHelper.Input
public static void ToggleScreenpad()
{
int toggle = AppConfig.Is("screenpad_toggle") ? 0 : 1;
int brightness = AppConfig.Get("screenpad", 100);
int brightness = toggle == 0 ? -10 : AppConfig.Get("screenpad", 100);
Program.acpi.DeviceSet(AsusACPI.ScreenPadToggle, toggle, "ScreenpadToggle");
if (toggle > 0) Program.acpi.DeviceSet(AsusACPI.ScreenPadBrightness, Math.Max(brightness * 255 / 100, 0), "Screenpad");
Debug.WriteLine($"Screenpad toggle = {toggle}");
ApplyScreenpadAction(brightness, true);
AppConfig.Set("screenpad_toggle", toggle);
Program.toast.RunToast($"Screen Pad " + (toggle == 1 ? "On" : "Off"), toggle > 0 ? ToastIcon.BrightnessUp : ToastIcon.BrightnessDown);
}
@@ -851,6 +851,37 @@ namespace GHelper.Input
}
private static System.Threading.Timer screenpadActionTimer;
private static int screenpadBrightnessToSet;
public static void ApplyScreenpadAction(int brightness, bool doToggle = false)
{
var delay = AppConfig.Get("screenpad_delay", 1500);
//Action
Action<int> action = (b) =>
{
if (b >= 0) Program.acpi.DeviceSet(AsusACPI.ScreenPadToggle, 1, "ScreenpadOn");
Program.acpi.DeviceSet(AsusACPI.ScreenPadBrightness, Math.Max(b * 255 / 100, 0), "Screenpad");
if (b < 0) Program.acpi.DeviceSet(AsusACPI.ScreenPadToggle, 0, "ScreenpadOff");
};
if(delay <= 0 || (brightness > 0 && brightness < 100 && doToggle == false)) //instant action
{
action(brightness);
}
else //delayed action
{
//Timer Approach
if (screenpadActionTimer == null)
{
screenpadActionTimer = new System.Threading.Timer(_ => action(screenpadBrightnessToSet), null, Timeout.Infinite, Timeout.Infinite);
}
//Start Timer
screenpadBrightnessToSet = brightness;
screenpadActionTimer.Change(delay, Timeout.Infinite);
}
}
public static void SetScreenpad(int delta)
{
int brightness = AppConfig.Get("screenpad", 100);
@@ -860,7 +891,6 @@ namespace GHelper.Input
if (brightness < 0) brightness = 100;
else if (brightness >= 100) brightness = 0;
else brightness = -10;
}
else
{
@@ -869,11 +899,7 @@ namespace GHelper.Input
AppConfig.Set("screenpad", brightness);
if (brightness >= 0) Program.acpi.DeviceSet(AsusACPI.ScreenPadToggle, 1, "ScreenpadOn");
Program.acpi.DeviceSet(AsusACPI.ScreenPadBrightness, Math.Max(brightness * 255 / 100, 0), "Screenpad");
if (brightness < 0) Program.acpi.DeviceSet(AsusACPI.ScreenPadToggle, 0, "ScreenpadOff");
ApplyScreenpadAction(brightness);
string toast;
@@ -882,10 +908,8 @@ namespace GHelper.Input
else toast = brightness.ToString() + "%";
Program.toast.RunToast($"Screen Pad {toast}", delta > 0 ? ToastIcon.BrightnessUp : ToastIcon.BrightnessDown);
}
static void LaunchProcess(string command = "")
{

View File

@@ -494,6 +494,9 @@ Trotzdem fortfahren?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Laptopbildschirm</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Deckel</value>
</data>
@@ -768,10 +771,10 @@ Trotzdem fortfahren?</value>
<value>Darstellungsmodus</value>
</data>
<data name="VisualModesHDR" xml:space="preserve">
<value>Visual Modes are not available when HDR is active</value>
<value>Darstellungsmodi sind nicht verfügbar, wenn HDR aktiv ist.</value>
</data>
<data name="VisualModesScreen" xml:space="preserve">
<value>Visual Modes are not available when laptop screen is off</value>
<value>Darstellungsmodi sind nicht verfügbar, wenn Laptop-Bildschirm aus ist.</value>
</data>
<data name="VolumeDown" xml:space="preserve">
<value>Lautstärke verringern</value>

View File

@@ -494,6 +494,9 @@
<data name="LaptopScreen" xml:space="preserve">
<value>Pantalla del portátil</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>Indicadores de estado LED</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Tapa</value>
</data>
@@ -768,10 +771,10 @@
<value>Modo visual</value>
</data>
<data name="VisualModesHDR" xml:space="preserve">
<value>Visual Modes are not available when HDR is active</value>
<value>Los modos visuales no están disponibles cuando el HDR está activo</value>
</data>
<data name="VisualModesScreen" xml:space="preserve">
<value>Visual Modes are not available when laptop screen is off</value>
<value>Los modos visuales no están disponibles cuando la pantalla portátil está apagada</value>
</data>
<data name="VolumeDown" xml:space="preserve">
<value>Bajar volumen</value>

View File

@@ -494,6 +494,9 @@ Voulez-vous continuer ?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Écran</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Capot</value>
</data>

View File

@@ -494,6 +494,9 @@ Do you still want to continue?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Laptop kijelző</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Fedél</value>
</data>

View File

@@ -494,6 +494,9 @@ Apakah Anda masih ingin melanjutkan?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Layar Laptop</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Lid</value>
</data>

View File

@@ -494,6 +494,9 @@ Sei sicuro di voler continuare?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Schermo Laptop</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Lid</value>
</data>

View File

@@ -494,6 +494,9 @@
<data name="LaptopScreen" xml:space="preserve">
<value>화면</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>덮개</value>
</data>

View File

@@ -494,6 +494,9 @@ Vis tiek norite tęsti?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Ekranas</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Dangtis</value>
</data>

View File

@@ -494,6 +494,9 @@ Nadal chcesz kontynuować?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Ekran laptopa</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Pokrywa</value>
</data>

View File

@@ -494,6 +494,9 @@ Do you still want to continue?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Tela</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Tampa</value>
</data>

View File

@@ -494,6 +494,9 @@ Quer prosseguir?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Ecrã</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Tampa</value>
</data>

View File

@@ -494,6 +494,9 @@
<data name="LaptopScreen" xml:space="preserve">
<value>Ecran Laptop</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Capac</value>
</data>

View File

@@ -494,6 +494,9 @@ Yine de devam etmek istiyor musunuz?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Laptop Ekranı</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Kapak</value>
</data>

View File

@@ -494,6 +494,9 @@
<data name="LaptopScreen" xml:space="preserve">
<value>Дисплей</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Кришка</value>
</data>

View File

@@ -494,6 +494,9 @@ Do you still want to continue?</value>
<data name="LaptopScreen" xml:space="preserve">
<value>Màn hình Laptop</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>Màn gập</value>
</data>

View File

@@ -494,6 +494,9 @@
<data name="LaptopScreen" xml:space="preserve">
<value>笔记本屏幕</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED Status Indicators</value>
</data>
<data name="Lid" xml:space="preserve">
<value>盖子</value>
</data>

View File

@@ -494,6 +494,9 @@
<data name="LaptopScreen" xml:space="preserve">
<value>螢幕顯示</value>
</data>
<data name="LEDStatusIndicators" xml:space="preserve">
<value>LED狀態指示器</value>
</data>
<data name="Lid" xml:space="preserve">
<value>螢幕背蓋</value>
</data>
@@ -768,10 +771,10 @@
<value>色域模式</value>
</data>
<data name="VisualModesHDR" xml:space="preserve">
<value>Visual Modes are not available when HDR is active</value>
<value>HDR開啟時不支援色域模式</value>
</data>
<data name="VisualModesScreen" xml:space="preserve">
<value>Visual Modes are not available when laptop screen is off</value>
<value>筆電螢幕闔上時不支援色域模式</value>
</data>
<data name="VolumeDown" xml:space="preserve">
<value>音量降低</value>