From 765cd8bba84028aa42e3a09d04328dda25ffd167 Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Thu, 9 May 2024 15:12:23 +0200 Subject: [PATCH 1/4] Replace sharpadbclient --- Directory.Packages.props | 4 +- MacroDeck/MacroDeck.cs | 4 +- MacroDeck/MacroDeck.csproj | 4 +- MacroDeck/Server/ADBServerHelper.cs | 86 ++++++++++++++--------------- 4 files changed, 46 insertions(+), 52 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 66583a5..4ae7caa 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,6 +3,7 @@ true + @@ -11,10 +12,9 @@ - - + diff --git a/MacroDeck/MacroDeck.cs b/MacroDeck/MacroDeck.cs index b0d9a6a..d21720a 100644 --- a/MacroDeck/MacroDeck.cs +++ b/MacroDeck/MacroDeck.cs @@ -103,7 +103,7 @@ public class MacroDeck : NativeWindow SearchNetworkInterfaces(); MacroDeckServer.Start(StartParameters.Port <= 0 ? Configuration.HostPort : StartParameters.Port); BroadcastServer.Start(); - ADBServerHelper.Initialize(); + AdbServerHelper.Initialize(); ProfileManager.AddVariableChangedListener(); ProfileManager.AddWindowFocusChangedListener(); @@ -318,7 +318,7 @@ public class MacroDeck : NativeWindow public static void Exit() { - ADBServerHelper.Kill(); + AdbServerHelper.Kill(); Environment.Exit(0); } } \ No newline at end of file diff --git a/MacroDeck/MacroDeck.csproj b/MacroDeck/MacroDeck.csproj index 586bafa..c81899c 100644 --- a/MacroDeck/MacroDeck.csproj +++ b/MacroDeck/MacroDeck.csproj @@ -21,7 +21,7 @@ AnyCPU;x64 true WinExe - disable + annotations @@ -40,6 +40,7 @@ + @@ -48,7 +49,6 @@ - diff --git a/MacroDeck/Server/ADBServerHelper.cs b/MacroDeck/Server/ADBServerHelper.cs index 0b6f272..46200f3 100644 --- a/MacroDeck/Server/ADBServerHelper.cs +++ b/MacroDeck/Server/ADBServerHelper.cs @@ -1,7 +1,8 @@ using System.Diagnostics; using System.IO; using System.Net; -using SharpAdbClient; +using AdvancedSharpAdbClient; +using AdvancedSharpAdbClient.Models; using SuchByte.MacroDeck.Enums; using SuchByte.MacroDeck.Logging; using SuchByte.MacroDeck.Startup; @@ -15,24 +16,16 @@ public class AdbDeviceConnectionStateChangedEventArgs : EventArgs public AdbDeviceConnectionState ConnectionState { get; set; } } - -public class ADBServerHelper +public class AdbServerHelper { + private static AdbServer? _adbServer; - private static IAdbServer? _adbServer; + private static AdbClient? _adbClient; - private static IAdbClient? _adbClient; - - private static string _adbFolderName = "Android Debug Bridge"; - - private static string _adbPath = Path.Combine(ApplicationPaths.MainDirectoryPath, _adbFolderName, "adb.exe"); - - public static EventHandler? OnDeviceConnectionStateChanged; - - public static bool ServerRunning => _adbServer != null && _adbClient != null && _adbServer.GetStatus().IsRunning; - - public static List Devices => _adbClient?.GetDevices() ?? new List(); + private const string AdbFolderName = "Android Debug Bridge"; + private static readonly string AdbPath = Path.Combine(ApplicationPaths.MainDirectoryPath, AdbFolderName, "adb.exe"); + public static void Kill() { try @@ -52,56 +45,51 @@ public class ADBServerHelper public static void Initialize() { - if (!File.Exists(_adbPath)) + if (!File.Exists(AdbPath)) { - MacroDeckLogger.Warning(typeof(ADBServerHelper), $"Cannot start adb server at {_adbPath}: File not found"); + MacroDeckLogger.Warning(typeof(AdbServerHelper), $"Cannot start adb server at {AdbPath}: File not found"); return; } - MacroDeckLogger.Info(typeof(ADBServerHelper), $"Starting ADB server using {_adbPath}"); + MacroDeckLogger.Info(typeof(AdbServerHelper), $"Starting ADB server using {AdbPath}"); - _adbClient = new AdbClient(); - _adbServer = new AdbServer(_adbClient, Factories.AdbCommandLineClientFactory); - var result = _adbServer.StartServer(_adbPath, true); + _adbServer = new AdbServer(); + var result = _adbServer.StartServer(AdbPath, true); if (result != StartServerResult.Started) { - MacroDeckLogger.Info(typeof(ADBServerHelper), "Unable to start ADB server"); + MacroDeckLogger.Info(typeof(AdbServerHelper), "Unable to start ADB server"); } - Task.Run(() => + var adbServerEndpoint = _adbServer.EndPoint.ToString(); + if (adbServerEndpoint is null) { - var monitor = new DeviceMonitor(new AdbSocket(new IPEndPoint(IPAddress.Loopback, AdbClient.AdbServerPort))); - monitor.DeviceConnected += Monitor_DeviceConnected; - monitor.DeviceDisconnected += Monitor_DeviceDisconnected; - monitor.Start(); - }); - - + MacroDeckLogger.Info(typeof(AdbServerHelper), "Endpoint was null"); + return; + } + + _adbClient = new AdbClient(); + _adbClient.Connect(adbServerEndpoint); + foreach (var device in _adbClient.GetDevices()) { - MacroDeckLogger.Info(typeof(ADBServerHelper), $"Found {device.Name}"); + MacroDeckLogger.Info(typeof(AdbServerHelper), $"Found {device.Name}"); StartReverseForward(device); } + + var monitor = new DeviceMonitor(new AdbSocket(AdbClient.AdbServerEndPoint)); + monitor.DeviceConnected += Monitor_DeviceConnected; + monitor.DeviceDisconnected += Monitor_DeviceDisconnected; + Task.Run(async () => await monitor.StartAsync()); } private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e) { - MacroDeckLogger.Info(typeof(ADBServerHelper), $"{e.Device.Name} disconnected"); - OnDeviceConnectionStateChanged?.Invoke(null, new AdbDeviceConnectionStateChangedEventArgs - { - Device = e.Device, - ConnectionState = AdbDeviceConnectionState.DISCONNECTED - }); + MacroDeckLogger.Info(typeof(AdbServerHelper), $"{e.Device.Name} disconnected"); } private static void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e) { - MacroDeckLogger.Info(typeof(ADBServerHelper), $"{e.Device.Name} connected"); - OnDeviceConnectionStateChanged?.Invoke(null, new AdbDeviceConnectionStateChangedEventArgs - { - Device = e.Device, - ConnectionState = AdbDeviceConnectionState.CONNECTED - }); + MacroDeckLogger.Info(typeof(AdbServerHelper), $"{e.Device.Name} connected"); StartReverseForward(e.Device); } @@ -109,12 +97,18 @@ public class ADBServerHelper { try { - _adbClient?.CreateReverseForward(device, $"tcp:{MacroDeck.Configuration.HostPort}", $"tcp:{MacroDeck.Configuration.HostPort}", true); + _adbClient?.CreateReverseForward( + device, + $"tcp:{MacroDeck.Configuration.HostPort}", + $"tcp:{MacroDeck.Configuration.HostPort}", + true); + + MacroDeckLogger.Info(typeof(AdbServerHelper), $"Started reverse forward on {device.Name}"); } catch (Exception ex) { - MacroDeckLogger.Warning(typeof(ADBServerHelper), $"Unable to start reverse forward on {device?.Name}: {ex.Message}"); + MacroDeckLogger.Warning(typeof(AdbServerHelper), + $"Unable to start reverse forward on {device.Name}: {ex.Message}"); } - MacroDeckLogger.Info(typeof(ADBServerHelper), $"Started reverse forward on {device?.Name}"); } } \ No newline at end of file From e285edf32b8d1a08420c7dcd3f48480bce215760 Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Fri, 10 May 2024 10:24:56 +0200 Subject: [PATCH 2/4] Improve adb reconnect --- MacroDeck/Configuration/MainConfiguration.cs | 6 + MacroDeck/MacroDeck.cs | 7 +- MacroDeck/Program.cs | 8 +- MacroDeck/Server/ADBServerHelper.cs | 209 +++++++++++++++---- 4 files changed, 180 insertions(+), 50 deletions(-) diff --git a/MacroDeck/Configuration/MainConfiguration.cs b/MacroDeck/Configuration/MainConfiguration.cs index 87451f0..c0b44d7 100644 --- a/MacroDeck/Configuration/MainConfiguration.cs +++ b/MacroDeck/Configuration/MainConfiguration.cs @@ -40,6 +40,12 @@ public class MainConfiguration [JsonProperty("Update.InstallBeta")] public bool UpdateBetaVersions { get; set; } + [JsonProperty("Connection.Adb.Enabled")] + public bool EnableAdbServer { get; set; } = true; + + [JsonProperty("Connection.Adb.AutoStartApp")] + public bool EnableAdbAutoStartApp { get; set; } = true; + [JsonProperty("Connection.Ssl.Enabled")] public bool EnableSsl { get; set; } diff --git a/MacroDeck/MacroDeck.cs b/MacroDeck/MacroDeck.cs index d21720a..0fe9cb0 100644 --- a/MacroDeck/MacroDeck.cs +++ b/MacroDeck/MacroDeck.cs @@ -103,7 +103,7 @@ public class MacroDeck : NativeWindow SearchNetworkInterfaces(); MacroDeckServer.Start(StartParameters.Port <= 0 ? Configuration.HostPort : StartParameters.Port); BroadcastServer.Start(); - AdbServerHelper.Initialize(); + Task.Run(async () => await AdbServerHelper.Initialize()); ProfileManager.AddVariableChangedListener(); ProfileManager.AddWindowFocusChangedListener(); @@ -114,7 +114,7 @@ public class MacroDeck : NativeWindow TrayIcon.SetupTrayIcon(TrayIconContextMenu, ShowMainWindow, () => RestartMacroDeck(string.Join(" ", StartParameters)), - Exit); + Exit); using (_mainWindow = new MainWindow()) { @@ -243,7 +243,7 @@ public class MacroDeck : NativeWindow using var msgBox = new GUI.CustomControls.MessageBox(); if (msgBox.ShowDialog(LanguageManager.Strings.MacroDeckNeedsARestart, LanguageManager.Strings.MacroDeckMustBeRestartedForTheChanges, MessageBoxButtons.YesNo) == DialogResult.Yes) { - MacroDeck.RestartMacroDeck(); + RestartMacroDeck(); } } @@ -318,7 +318,6 @@ public class MacroDeck : NativeWindow public static void Exit() { - AdbServerHelper.Kill(); Environment.Exit(0); } } \ No newline at end of file diff --git a/MacroDeck/Program.cs b/MacroDeck/Program.cs index d443520..0db40b7 100644 --- a/MacroDeck/Program.cs +++ b/MacroDeck/Program.cs @@ -4,6 +4,7 @@ using SuchByte.MacroDeck.Startup; using System.Diagnostics; using System.Threading; using System.Windows.Forms; +using SuchByte.MacroDeck.Server; namespace SuchByte.MacroDeck; @@ -19,6 +20,7 @@ internal class Program // Register exception event handlers Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += ApplicationThreadException; + AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit; AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; @@ -29,7 +31,11 @@ internal class Program MacroDeck.Start(startParameters); } - + + private static async void CurrentDomainOnProcessExit(object? sender, EventArgs e) + { + } + private static void CheckRunningInstance(int ignoredPid) { var proc = Process.GetCurrentProcess(); diff --git a/MacroDeck/Server/ADBServerHelper.cs b/MacroDeck/Server/ADBServerHelper.cs index 46200f3..ef8ba41 100644 --- a/MacroDeck/Server/ADBServerHelper.cs +++ b/MacroDeck/Server/ADBServerHelper.cs @@ -1,50 +1,29 @@ -using System.Diagnostics; +using System.Collections.Concurrent; using System.IO; -using System.Net; using AdvancedSharpAdbClient; +using AdvancedSharpAdbClient.DeviceCommands; using AdvancedSharpAdbClient.Models; -using SuchByte.MacroDeck.Enums; +using AdvancedSharpAdbClient.Receivers; using SuchByte.MacroDeck.Logging; using SuchByte.MacroDeck.Startup; namespace SuchByte.MacroDeck.Server; -public class AdbDeviceConnectionStateChangedEventArgs : EventArgs -{ - public DeviceData Device { get; set; } - - public AdbDeviceConnectionState ConnectionState { get; set; } -} - public class AdbServerHelper { private static AdbServer? _adbServer; - private static AdbClient? _adbClient; - private const string AdbFolderName = "Android Debug Bridge"; private static readonly string AdbPath = Path.Combine(ApplicationPaths.MainDirectoryPath, AdbFolderName, "adb.exe"); - public static void Kill() + public static async Task Initialize() { - try + if (!MacroDeck.Configuration.EnableAdbServer) { - _adbClient?.KillAdb(); - var processes = Process.GetProcessesByName("adb").ToArray(); - foreach (var process in processes) - { - process.Kill(); - } + return; } - catch (Exception ex) - { - MacroDeckLogger.Warning($"Failed to kill adb\n{ex}"); - } - } - - public static void Initialize() - { + if (!File.Exists(AdbPath)) { MacroDeckLogger.Warning(typeof(AdbServerHelper), $"Cannot start adb server at {AdbPath}: File not found"); @@ -54,32 +33,100 @@ public class AdbServerHelper MacroDeckLogger.Info(typeof(AdbServerHelper), $"Starting ADB server using {AdbPath}"); _adbServer = new AdbServer(); - var result = _adbServer.StartServer(AdbPath, true); + var result = await _adbServer.StartServerAsync(AdbPath, true); if (result != StartServerResult.Started) { MacroDeckLogger.Info(typeof(AdbServerHelper), "Unable to start ADB server"); } - - var adbServerEndpoint = _adbServer.EndPoint.ToString(); - if (adbServerEndpoint is null) + + var adbClient = await GetAdbClient(); + if (adbClient is null) { - MacroDeckLogger.Info(typeof(AdbServerHelper), "Endpoint was null"); return; } - - _adbClient = new AdbClient(); - _adbClient.Connect(adbServerEndpoint); - - foreach (var device in _adbClient.GetDevices()) + + var devices = await adbClient.GetDevicesAsync(); + var onlineDevices = devices.Where(x => x.State == DeviceState.Online); + foreach (var device in onlineDevices) { - MacroDeckLogger.Info(typeof(AdbServerHelper), $"Found {device.Name}"); - StartReverseForward(device); + await RunForDevice(device.Serial, async (adbDeviceClient, deviceData) => + { + await StartMacroDeckClient(adbDeviceClient, deviceData); + await StartReverseForward(adbDeviceClient, deviceData); + }); } var monitor = new DeviceMonitor(new AdbSocket(AdbClient.AdbServerEndPoint)); monitor.DeviceConnected += Monitor_DeviceConnected; monitor.DeviceDisconnected += Monitor_DeviceDisconnected; - Task.Run(async () => await monitor.StartAsync()); + await monitor.StartAsync(); + } + + public static async Task Exit() + { + var adbClient = await GetAdbClient(); + if (adbClient is null) + { + return; + } + + var devices = await adbClient.GetDevicesAsync(); + var onlineDevices = devices.Where(x => x.State == DeviceState.Online); + foreach (var device in onlineDevices) + { + await RunForDevice(device.Serial, async (adbDeviceClient, deviceData) => + { + await ExitMacroDeckClient(adbDeviceClient, deviceData); + }); + } + } + + private static async Task RunForDevice(string serial, Func action) + { + var adbDeviceClient = await GetAdbClient(); + if (adbDeviceClient is null) + { + return; + } + var deviceData = await GetDevice(adbDeviceClient, serial); + if (!deviceData.HasValue) + { + return; + } + + await action(adbDeviceClient, deviceData.Value); + } + + private static async Task GetDevice(AdbClient adbDeviceClient, string serial) + { + var devices = await adbDeviceClient.GetDevicesAsync(); + return devices.FirstOrDefault(x => x.Serial.Equals(serial)); + } + + private static async Task GetAdbClient() + { + var serverEndpoint = GetAdbServerEndpoint(); + if (serverEndpoint is null) + { + return null; + } + + var adbClient = new AdbClient(); + await adbClient.ConnectAsync(serverEndpoint); + return adbClient; + } + + private static string? GetAdbServerEndpoint() + { + var adbServerEndpoint = _adbServer?.EndPoint.ToString(); + if (adbServerEndpoint is not null) + { + return adbServerEndpoint; + } + + MacroDeckLogger.Info(typeof(AdbServerHelper), "Endpoint was null"); + return null; + } private static void Monitor_DeviceDisconnected(object sender, DeviceDataEventArgs e) @@ -87,17 +134,89 @@ public class AdbServerHelper MacroDeckLogger.Info(typeof(AdbServerHelper), $"{e.Device.Name} disconnected"); } - private static void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e) + private static async void Monitor_DeviceConnected(object sender, DeviceDataEventArgs e) { + if (e.Device.Serial.StartsWith("127.0.0.1")) + { + return; + } + + await Task.Delay(TimeSpan.FromSeconds(1)); MacroDeckLogger.Info(typeof(AdbServerHelper), $"{e.Device.Name} connected"); - StartReverseForward(e.Device); + await RunForDevice(e.Device.Serial, async (adbDeviceClient, deviceData) => + { + await StartMacroDeckClient(adbDeviceClient, deviceData); + await StartReverseForward(adbDeviceClient, deviceData); + }); } - private static void StartReverseForward(DeviceData device) + private static async Task IsDeviceOnline(DeviceData device) { + var timeoutTask = Task.Delay(TimeSpan.FromSeconds(20)); + + await Task.WhenAny([timeoutTask, WaitForDeviceOnline()]); + + if (device.State == DeviceState.Online) + { + return true; + } + + MacroDeckLogger.Info(typeof(AdbServerHelper), $"Device {device.Serial} is still not online - {device.State}"); + return false; + + async Task WaitForDeviceOnline() + { + while (device.State != DeviceState.Online) + { + await Task.Delay(100); + } + } + } + + private static async Task ExitMacroDeckClient(AdbClient adbDeviceClient, DeviceData device) + { + var deviceIsOnline = await IsDeviceOnline(device); + if (!deviceIsOnline) + { + return; + } + + await adbDeviceClient.ExecuteRemoteCommandAsync("am force-stop com.suchbyte.macrodeck", + device, + new ConsoleOutputReceiver()); + await adbDeviceClient.SendKeyEventAsync(device, "KEYCODE_SLEEP"); + } + + private static async Task StartMacroDeckClient(AdbClient adbDeviceClient, DeviceData device) + { + if (!MacroDeck.Configuration.EnableAdbAutoStartApp) + { + return; + } + + var deviceIsOnline = await IsDeviceOnline(device); + if (!deviceIsOnline) + { + return; + } + + await adbDeviceClient.SendKeyEventAsync(device, "KEYCODE_WAKEUP"); + await adbDeviceClient.ExecuteRemoteCommandAsync("am start -n com.suchbyte.macrodeck/.MainActivity", + device, + new ConsoleOutputReceiver()); + } + + private static async Task StartReverseForward(AdbClient adbDeviceClient, DeviceData device) + { + var deviceIsOnline = await IsDeviceOnline(device); + if (!deviceIsOnline) + { + return; + } + try { - _adbClient?.CreateReverseForward( + await adbDeviceClient.CreateReverseForwardAsync( device, $"tcp:{MacroDeck.Configuration.HostPort}", $"tcp:{MacroDeck.Configuration.HostPort}", From b0fc380dfad764cb0dc16bca01a33f65eceb3093 Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Fri, 10 May 2024 11:22:02 +0200 Subject: [PATCH 3/4] Add Quick Setup Qr Code --- Directory.Packages.props | 1 + .../QrCode/QuickConnectQrCodeData.cs | 20 ++ MacroDeck/GUI/MainWindow.Designer.cs | 205 +++++++----------- MacroDeck/GUI/MainWindow.cs | 32 +-- MacroDeck/GUI/MainWindow.resx | 62 +++++- MacroDeck/MacroDeck.csproj | 1 + MacroDeck/Services/QrCodeService.cs | 60 +++++ 7 files changed, 227 insertions(+), 154 deletions(-) create mode 100644 MacroDeck/DataTypes/QrCode/QuickConnectQrCodeData.cs create mode 100644 MacroDeck/Services/QrCodeService.cs diff --git a/Directory.Packages.props b/Directory.Packages.props index 4ae7caa..6840d23 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -12,6 +12,7 @@ + diff --git a/MacroDeck/DataTypes/QrCode/QuickConnectQrCodeData.cs b/MacroDeck/DataTypes/QrCode/QuickConnectQrCodeData.cs new file mode 100644 index 0000000..fdf8f8d --- /dev/null +++ b/MacroDeck/DataTypes/QrCode/QuickConnectQrCodeData.cs @@ -0,0 +1,20 @@ +namespace SuchByte.MacroDeck.DataTypes.QrCode; + +public class QuickConnectQrCodeData +{ + public string InstanceName { get; set; } + + public List NetworkInterfaces { get; set; } + + public int Port { get; set; } + + public bool Ssl { get; set; } + + public QuickConnectQrCodeData(string instanceName, List networkInterfaces, int port, bool ssl) + { + InstanceName = instanceName; + NetworkInterfaces = networkInterfaces; + Port = port; + Ssl = ssl; + } +} \ No newline at end of file diff --git a/MacroDeck/GUI/MainWindow.Designer.cs b/MacroDeck/GUI/MainWindow.Designer.cs index 30725f7..760ad93 100644 --- a/MacroDeck/GUI/MainWindow.Designer.cs +++ b/MacroDeck/GUI/MainWindow.Designer.cs @@ -59,6 +59,7 @@ namespace SuchByte.MacroDeck.GUI lblVersion = new Label(); contentPanel = new BufferedPanel(); contentButtonPanel = new FlowLayoutPanel(); + btnNotifications = new NotificationButton(); btnDeck = new ContentSelectorButton(); panel1 = new Panel(); btnExtensions = new ContentSelectorButton(); @@ -67,12 +68,9 @@ namespace SuchByte.MacroDeck.GUI panel2 = new Panel(); btnSettings = new ContentSelectorButton(); lblNumClientsConnected = new Label(); - label1 = new Label(); - lblPort = new Label(); - lblIpAddressHostname = new Label(); navigation = new RoundedPanel(); - btnNotifications = new NotificationButton(); - hosts = new RoundedComboBox(); + qrCodeBox = new PictureBox(); + label1 = new Label(); contentButtonPanel.SuspendLayout(); ((ISupportInitialize)btnDeck).BeginInit(); ((ISupportInitialize)btnExtensions).BeginInit(); @@ -80,6 +78,7 @@ namespace SuchByte.MacroDeck.GUI ((ISupportInitialize)btnVariables).BeginInit(); ((ISupportInitialize)btnSettings).BeginInit(); navigation.SuspendLayout(); + ((ISupportInitialize)qrCodeBox).BeginInit(); SuspendLayout(); // // lblSafeMode @@ -89,29 +88,31 @@ namespace SuchByte.MacroDeck.GUI // // lblVersion // - lblVersion.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + lblVersion.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + lblVersion.Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); lblVersion.ForeColor = Color.White; - lblVersion.Location = new Point(2, 603); + lblVersion.Location = new Point(1046, 613); lblVersion.Margin = new Padding(9, 0, 9, 0); lblVersion.Name = "lblVersion"; - lblVersion.Size = new Size(328, 30); + lblVersion.Size = new Size(154, 20); lblVersion.TabIndex = 3; lblVersion.Text = "2.0.0"; - lblVersion.TextAlign = ContentAlignment.MiddleLeft; + lblVersion.TextAlign = ContentAlignment.MiddleRight; lblVersion.UseMnemonic = false; // // contentPanel // contentPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - contentPanel.Location = new Point(69, 94); + contentPanel.Location = new Point(65, 42); contentPanel.Margin = new Padding(9, 4, 9, 4); contentPanel.Name = "contentPanel"; - contentPanel.Size = new Size(1131, 509); + contentPanel.Size = new Size(981, 591); contentPanel.TabIndex = 4; // // contentButtonPanel // contentButtonPanel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + contentButtonPanel.Controls.Add(btnNotifications); contentButtonPanel.Controls.Add(btnDeck); contentButtonPanel.Controls.Add(panel1); contentButtonPanel.Controls.Add(btnExtensions); @@ -119,21 +120,45 @@ namespace SuchByte.MacroDeck.GUI contentButtonPanel.Controls.Add(btnVariables); contentButtonPanel.Controls.Add(panel2); contentButtonPanel.FlowDirection = FlowDirection.TopDown; - contentButtonPanel.Location = new Point(8, 9); + contentButtonPanel.Location = new Point(8, 7); contentButtonPanel.Margin = new Padding(0); contentButtonPanel.Name = "contentButtonPanel"; - contentButtonPanel.Size = new Size(45, 470); + contentButtonPanel.Size = new Size(45, 528); contentButtonPanel.TabIndex = 5; // + // btnNotifications + // + btnNotifications.BorderRadius = 8; + btnNotifications.Cursor = Cursors.Hand; + btnNotifications.FlatAppearance.BorderSize = 0; + btnNotifications.FlatStyle = FlatStyle.Flat; + btnNotifications.Font = new Font("Tahoma", 8F); + btnNotifications.ForeColor = Color.White; + btnNotifications.HoverColor = Color.Empty; + btnNotifications.Icon = Properties.Resources.Bell; + btnNotifications.Location = new Point(0, 4); + btnNotifications.Margin = new Padding(0, 4, 0, 4); + btnNotifications.Name = "btnNotifications"; + btnNotifications.NotificationCount = 0; + btnNotifications.Progress = 0; + btnNotifications.ProgressColor = Color.FromArgb(0, 103, 205); + btnNotifications.Size = new Size(44, 44); + btnNotifications.TabIndex = 16; + btnNotifications.UseVisualStyleBackColor = true; + btnNotifications.UseWindowsAccentColor = false; + btnNotifications.Visible = false; + btnNotifications.WriteProgress = true; + btnNotifications.Click += BtnNotifications_Click; + // // btnDeck // btnDeck.BackColor = Color.Transparent; btnDeck.BackgroundImage = Properties.Resources.deck; btnDeck.BackgroundImageLayout = ImageLayout.Stretch; btnDeck.Cursor = Cursors.Hand; - btnDeck.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnDeck.Font = new Font("Tahoma", 9.75F); btnDeck.ForeColor = Color.White; - btnDeck.Location = new Point(0, 0); + btnDeck.Location = new Point(0, 52); btnDeck.Margin = new Padding(0, 0, 0, 6); btnDeck.Name = "btnDeck"; btnDeck.Selected = false; @@ -145,7 +170,7 @@ namespace SuchByte.MacroDeck.GUI // panel1 // panel1.BackColor = Color.Silver; - panel1.Location = new Point(0, 54); + panel1.Location = new Point(0, 106); panel1.Margin = new Padding(0, 4, 0, 4); panel1.Name = "panel1"; panel1.Size = new Size(66, 3); @@ -157,9 +182,9 @@ namespace SuchByte.MacroDeck.GUI btnExtensions.BackgroundImage = Properties.Resources.Package_Manager_icon; btnExtensions.BackgroundImageLayout = ImageLayout.Stretch; btnExtensions.Cursor = Cursors.Hand; - btnExtensions.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnExtensions.Font = new Font("Tahoma", 9.75F); btnExtensions.ForeColor = Color.White; - btnExtensions.Location = new Point(0, 67); + btnExtensions.Location = new Point(0, 119); btnExtensions.Margin = new Padding(0, 6, 0, 6); btnExtensions.Name = "btnExtensions"; btnExtensions.Selected = false; @@ -174,9 +199,9 @@ namespace SuchByte.MacroDeck.GUI btnDeviceManager.BackgroundImage = Properties.Resources.device_manager; btnDeviceManager.BackgroundImageLayout = ImageLayout.Stretch; btnDeviceManager.Cursor = Cursors.Hand; - btnDeviceManager.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnDeviceManager.Font = new Font("Tahoma", 9.75F); btnDeviceManager.ForeColor = Color.White; - btnDeviceManager.Location = new Point(0, 123); + btnDeviceManager.Location = new Point(0, 175); btnDeviceManager.Margin = new Padding(0, 6, 0, 6); btnDeviceManager.Name = "btnDeviceManager"; btnDeviceManager.Selected = false; @@ -191,9 +216,9 @@ namespace SuchByte.MacroDeck.GUI btnVariables.BackgroundImage = Properties.Resources.variables; btnVariables.BackgroundImageLayout = ImageLayout.Stretch; btnVariables.Cursor = Cursors.Hand; - btnVariables.Font = new Font("Tahoma", 12.75F, FontStyle.Regular, GraphicsUnit.Point); + btnVariables.Font = new Font("Tahoma", 12.75F); btnVariables.ForeColor = Color.White; - btnVariables.Location = new Point(0, 179); + btnVariables.Location = new Point(0, 231); btnVariables.Margin = new Padding(0, 6, 0, 6); btnVariables.Name = "btnVariables"; btnVariables.Selected = false; @@ -206,7 +231,7 @@ namespace SuchByte.MacroDeck.GUI // panel2 // panel2.BackColor = Color.Silver; - panel2.Location = new Point(0, 233); + panel2.Location = new Point(0, 285); panel2.Margin = new Padding(0, 4, 0, 4); panel2.Name = "panel2"; panel2.Size = new Size(66, 3); @@ -219,9 +244,9 @@ namespace SuchByte.MacroDeck.GUI btnSettings.BackgroundImage = Properties.Resources.settings; btnSettings.BackgroundImageLayout = ImageLayout.Stretch; btnSettings.Cursor = Cursors.Hand; - btnSettings.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnSettings.Font = new Font("Tahoma", 9.75F); btnSettings.ForeColor = Color.White; - btnSettings.Location = new Point(8, 511); + btnSettings.Location = new Point(8, 541); btnSettings.Margin = new Padding(12, 6, 12, 6); btnSettings.Name = "btnSettings"; btnSettings.Selected = false; @@ -233,59 +258,17 @@ namespace SuchByte.MacroDeck.GUI // lblNumClientsConnected // lblNumClientsConnected.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - lblNumClientsConnected.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point); + lblNumClientsConnected.Font = new Font("Tahoma", 8.25F, FontStyle.Regular, GraphicsUnit.Point, 0); lblNumClientsConnected.ForeColor = Color.White; - lblNumClientsConnected.Location = new Point(936, 606); + lblNumClientsConnected.Location = new Point(1046, 593); lblNumClientsConnected.Margin = new Padding(9, 0, 9, 0); lblNumClientsConnected.Name = "lblNumClientsConnected"; - lblNumClientsConnected.Size = new Size(264, 27); + lblNumClientsConnected.Size = new Size(154, 20); lblNumClientsConnected.TabIndex = 8; lblNumClientsConnected.Text = "0 clients connected"; lblNumClientsConnected.TextAlign = ContentAlignment.MiddleRight; lblNumClientsConnected.UseMnemonic = false; // - // label1 - // - label1.Anchor = AnchorStyles.Top | AnchorStyles.Right; - label1.AutoSize = true; - label1.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); - label1.Location = new Point(1094, 44); - label1.Margin = new Padding(9, 0, 9, 0); - label1.Name = "label1"; - label1.Size = new Size(15, 19); - label1.TabIndex = 10; - label1.Text = ":"; - label1.UseMnemonic = false; - // - // lblPort - // - lblPort.Anchor = AnchorStyles.Top | AnchorStyles.Right; - lblPort.BackColor = Color.FromArgb(45, 45, 45); - lblPort.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); - lblPort.ForeColor = Color.White; - lblPort.Location = new Point(1127, 37); - lblPort.Margin = new Padding(9, 0, 9, 0); - lblPort.Name = "lblPort"; - lblPort.Size = new Size(69, 32); - lblPort.TabIndex = 11; - lblPort.Text = "8191"; - lblPort.TextAlign = ContentAlignment.MiddleLeft; - lblPort.UseMnemonic = false; - // - // lblIpAddressHostname - // - lblIpAddressHostname.Anchor = AnchorStyles.Top | AnchorStyles.Right; - lblIpAddressHostname.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point); - lblIpAddressHostname.ForeColor = Color.White; - lblIpAddressHostname.Location = new Point(225, 42); - lblIpAddressHostname.Margin = new Padding(9, 0, 9, 0); - lblIpAddressHostname.Name = "lblIpAddressHostname"; - lblIpAddressHostname.Size = new Size(468, 27); - lblIpAddressHostname.TabIndex = 13; - lblIpAddressHostname.Text = "IP address/hostname : Port"; - lblIpAddressHostname.TextAlign = ContentAlignment.MiddleRight; - lblIpAddressHostname.UseMnemonic = false; - // // navigation // navigation.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left; @@ -295,50 +278,32 @@ namespace SuchByte.MacroDeck.GUI navigation.Location = new Point(0, 42); navigation.Margin = new Padding(0); navigation.Name = "navigation"; - navigation.Size = new Size(60, 561); + navigation.Size = new Size(60, 591); navigation.TabIndex = 15; // - // btnNotifications + // qrCodeBox // - btnNotifications.BorderRadius = 8; - btnNotifications.Cursor = Cursors.Hand; - btnNotifications.FlatAppearance.BorderSize = 0; - btnNotifications.FlatStyle = FlatStyle.Flat; - btnNotifications.Font = new Font("Tahoma", 8F, FontStyle.Regular, GraphicsUnit.Point); - btnNotifications.ForeColor = Color.White; - btnNotifications.HoverColor = Color.Empty; - btnNotifications.Icon = Properties.Resources.Bell; - btnNotifications.Location = new Point(69, 42); - btnNotifications.Margin = new Padding(4); - btnNotifications.Name = "btnNotifications"; - btnNotifications.NotificationCount = 0; - btnNotifications.Padding = new Padding(0, 4, 4, 0); - btnNotifications.Progress = 0; - btnNotifications.ProgressColor = Color.FromArgb(0, 103, 205); - btnNotifications.Size = new Size(44, 44); - btnNotifications.TabIndex = 16; - btnNotifications.UseVisualStyleBackColor = true; - btnNotifications.UseWindowsAccentColor = false; - btnNotifications.Visible = false; - btnNotifications.WriteProgress = true; - btnNotifications.Click += BtnNotifications_Click; + qrCodeBox.Anchor = AnchorStyles.Top | AnchorStyles.Right; + qrCodeBox.BackgroundImageLayout = ImageLayout.Stretch; + qrCodeBox.Location = new Point(1058, 66); + qrCodeBox.Name = "qrCodeBox"; + qrCodeBox.Size = new Size(130, 130); + qrCodeBox.TabIndex = 17; + qrCodeBox.TabStop = false; // - // hosts + // label1 // - hosts.Anchor = AnchorStyles.Top | AnchorStyles.Right; - hosts.BackColor = Color.FromArgb(65, 65, 65); - hosts.DropDownStyle = ComboBoxStyle.DropDownList; - hosts.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point); - hosts.Icon = null; - hosts.Location = new Point(706, 41); - hosts.Margin = new Padding(4); - hosts.Name = "hosts"; - hosts.Padding = new Padding(12, 3, 12, 3); - hosts.SelectedIndex = -1; - hosts.SelectedItem = null; - hosts.Size = new Size(375, 28); - hosts.TabIndex = 17; - hosts.SelectedIndexChanged += Hosts_SelectedIndexChanged; + label1.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + label1.Font = new Font("Tahoma", 9.75F, FontStyle.Bold, GraphicsUnit.Point, 0); + label1.ForeColor = Color.White; + label1.Location = new Point(1046, 42); + label1.Margin = new Padding(9, 0, 9, 0); + label1.Name = "label1"; + label1.Size = new Size(154, 20); + label1.TabIndex = 18; + label1.Text = "Quick Setup"; + label1.TextAlign = ContentAlignment.MiddleCenter; + label1.UseMnemonic = false; // // MainWindow // @@ -346,12 +311,9 @@ namespace SuchByte.MacroDeck.GUI AutoScaleMode = AutoScaleMode.Dpi; BackColor = Color.FromArgb(45, 45, 45); ClientSize = new Size(1200, 635); - Controls.Add(hosts); - Controls.Add(btnNotifications); - Controls.Add(navigation); - Controls.Add(lblIpAddressHostname); - Controls.Add(lblPort); Controls.Add(label1); + Controls.Add(qrCodeBox); + Controls.Add(navigation); Controls.Add(lblNumClientsConnected); Controls.Add(contentPanel); Controls.Add(lblVersion); @@ -366,12 +328,9 @@ namespace SuchByte.MacroDeck.GUI Controls.SetChildIndex(lblVersion, 0); Controls.SetChildIndex(contentPanel, 0); Controls.SetChildIndex(lblNumClientsConnected, 0); - Controls.SetChildIndex(label1, 0); - Controls.SetChildIndex(lblPort, 0); - Controls.SetChildIndex(lblIpAddressHostname, 0); Controls.SetChildIndex(navigation, 0); - Controls.SetChildIndex(btnNotifications, 0); - Controls.SetChildIndex(hosts, 0); + Controls.SetChildIndex(qrCodeBox, 0); + Controls.SetChildIndex(label1, 0); contentButtonPanel.ResumeLayout(false); ((ISupportInitialize)btnDeck).EndInit(); ((ISupportInitialize)btnExtensions).EndInit(); @@ -379,8 +338,8 @@ namespace SuchByte.MacroDeck.GUI ((ISupportInitialize)btnVariables).EndInit(); ((ISupportInitialize)btnSettings).EndInit(); navigation.ResumeLayout(false); + ((ISupportInitialize)qrCodeBox).EndInit(); ResumeLayout(false); - PerformLayout(); } #endregion @@ -393,13 +352,11 @@ namespace SuchByte.MacroDeck.GUI private ContentSelectorButton btnDeviceManager; private Label lblNumClientsConnected; private ContentSelectorButton btnVariables; - private Label label1; - private Label lblPort; - private Label lblIpAddressHostname; private Panel panel1; private Panel panel2; private RoundedPanel navigation; private NotificationButton btnNotifications; - private RoundedComboBox hosts; + private PictureBox qrCodeBox; + private Label label1; } } \ No newline at end of file diff --git a/MacroDeck/GUI/MainWindow.cs b/MacroDeck/GUI/MainWindow.cs index 579cb54..3de19ee 100644 --- a/MacroDeck/GUI/MainWindow.cs +++ b/MacroDeck/GUI/MainWindow.cs @@ -58,7 +58,6 @@ public partial class MainWindow : Form private void UpdateTranslation() { - lblIpAddressHostname.Text = LanguageManager.Strings.IpAddressHostNamePort; } private void LanguageChanged(object? sender, EventArgs e) @@ -115,7 +114,6 @@ public partial class MainWindow : Form { Application.DoEvents(); RefreshPluginsLabels(); - LoadHosts(); if (MacroDeck.SafeMode) { @@ -138,6 +136,8 @@ public partial class MainWindow : Form using var updateAvailableDialog = new UpdateAvailableDialog(updateApiVersionInfo); updateAvailableDialog.ShowDialog(); } + + this.qrCodeBox.BackgroundImage = QrCodeService.Instance.GetQuickSetupQrCode(); } private void MainWindow_Load(object? sender, EventArgs e) @@ -158,26 +158,6 @@ public partial class MainWindow : Form CenterToScreen(); } - private void LoadHosts() - { - hosts.SelectedIndexChanged -= Hosts_SelectedIndexChanged; - foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces()) - { - var ipAddress = networkInterface - .GetIPProperties() - .UnicastAddresses - .FirstOrDefault(x => x.Address.AddressFamily == AddressFamily.InterNetwork) - ?.Address - .ToString(); - if (!string.IsNullOrWhiteSpace(ipAddress)) - { - hosts.Items.Add(ipAddress); - } - } - hosts.Text = MacroDeck.Configuration.HostAddress; - hosts.SelectedIndexChanged += Hosts_SelectedIndexChanged; - } - private void NotificationsChanged(object? sender, EventArgs e) { btnNotifications.NotificationCount = NotificationManager.Notifications.Count; @@ -254,7 +234,7 @@ public partial class MainWindow : Form { _notificationsList = new NotificationsList { - Location = btnNotifications.Location with { Y = btnNotifications.Location.Y + btnNotifications.Height } + Location = btnNotifications.Location with { Y = btnNotifications.Location.Y + btnNotifications.Height, X = btnNotifications.Location.X + btnNotifications.Size.Width + 20 } }; _notificationsList.OnCloseRequested += (_, _) => { @@ -272,10 +252,4 @@ public partial class MainWindow : Form _notificationsList.BringToFront(); } } - - private void Hosts_SelectedIndexChanged(object? sender, EventArgs e) - { - MacroDeck.Configuration.HostAddress = hosts.Text; - MacroDeck.Configuration.Save(ApplicationPaths.MainConfigFilePath); - } } \ No newline at end of file diff --git a/MacroDeck/GUI/MainWindow.resx b/MacroDeck/GUI/MainWindow.resx index f55fe35..d8e4a5c 100644 --- a/MacroDeck/GUI/MainWindow.resx +++ b/MacroDeck/GUI/MainWindow.resx @@ -1,4 +1,64 @@ - + + + diff --git a/MacroDeck/MacroDeck.csproj b/MacroDeck/MacroDeck.csproj index c81899c..4a1b743 100644 --- a/MacroDeck/MacroDeck.csproj +++ b/MacroDeck/MacroDeck.csproj @@ -49,6 +49,7 @@ + diff --git a/MacroDeck/Services/QrCodeService.cs b/MacroDeck/Services/QrCodeService.cs new file mode 100644 index 0000000..bceb859 --- /dev/null +++ b/MacroDeck/Services/QrCodeService.cs @@ -0,0 +1,60 @@ +using System.IO; +using System.Net.NetworkInformation; +using System.Net.Sockets; +using System.Text.Json; +using QRCoder; +using SuchByte.MacroDeck.DataTypes.QrCode; +using SuchByte.MacroDeck.Logging; + +namespace SuchByte.MacroDeck.Services; + +public class QrCodeService +{ + public static readonly QrCodeService Instance = new(); + + private byte[]? _quickSetupQrCode; + + public Image GetQuickSetupQrCode() + { + if (_quickSetupQrCode is not null) + { + return FromSavedBytes(); + } + + var networkInterfaces = new List(); + try + { + networkInterfaces.AddRange(NetworkInterface.GetAllNetworkInterfaces() + .Select(adapter => adapter.GetIPProperties() + .UnicastAddresses.FirstOrDefault(x => x.Address.AddressFamily == AddressFamily.InterNetwork) + ?.Address.ToString()) + .Where(address => !string.IsNullOrWhiteSpace(address) && address != "127.0.0.1")); + } + catch (Exception ex) + { + MacroDeckLogger.Warning($"Error while searching for network interfaces\n{ex.Message}"); + } + + var data = new QuickConnectQrCodeData(Environment.MachineName, + networkInterfaces, + MacroDeck.Configuration.HostPort, + MacroDeck.Configuration.EnableSsl); + + var dataJson = JsonSerializer.Serialize(data); + var dataBase64 = Convert.ToBase64String(Encoding.UTF8.GetBytes(dataJson)); + var qrCodeLink = $"https://macro-deck.app/quick-setup/{dataBase64}"; + + using var qrGenerator = new QRCodeGenerator(); + using var qrCodeData = qrGenerator.CreateQrCode(qrCodeLink, QRCodeGenerator.ECCLevel.L); + using var qrCode = new BitmapByteQRCode(qrCodeData); + + _quickSetupQrCode = qrCode.GetGraphic(20); + return FromSavedBytes(); + + Image FromSavedBytes() + { + using var ms = new MemoryStream(_quickSetupQrCode); + return Image.FromStream(ms); + } + } +} \ No newline at end of file From 7ea37584c899967bcfa78e0f276079ebe629a416 Mon Sep 17 00:00:00 2001 From: Manuel Mayer Date: Fri, 10 May 2024 11:54:47 +0200 Subject: [PATCH 4/4] Add adb settings --- .../MainWindowViews/SettingsView.Designer.cs | 109 +++++++++++++----- MacroDeck/GUI/MainWindowViews/SettingsView.cs | 16 +++ .../GUI/MainWindowViews/SettingsView.resx | 64 +++++++++- MacroDeck/MacroDeck.cs | 2 +- MacroDeck/Program.cs | 6 +- ...{ADBServerHelper.cs => AdbServerHelper.cs} | 48 +------- 6 files changed, 162 insertions(+), 83 deletions(-) rename MacroDeck/Server/{ADBServerHelper.cs => AdbServerHelper.cs} (80%) diff --git a/MacroDeck/GUI/MainWindowViews/SettingsView.Designer.cs b/MacroDeck/GUI/MainWindowViews/SettingsView.Designer.cs index 07bc634..24c1558 100644 --- a/MacroDeck/GUI/MainWindowViews/SettingsView.Designer.cs +++ b/MacroDeck/GUI/MainWindowViews/SettingsView.Designer.cs @@ -45,6 +45,9 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents lblBehaviour = new Label(); lblGeneral = new Label(); tabConnection = new TabPage(); + checkAutoStartUsb = new CheckBox(); + checkEnableAdb = new CheckBox(); + label5 = new Label(); btnApplySslConfiguration = new ButtonPrimary(); btnBrowseCertificatePath = new ButtonPrimary(); label4 = new Label(); @@ -104,7 +107,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents verticalTabControl.Controls.Add(tabUpdater); verticalTabControl.Controls.Add(tabBackups); verticalTabControl.Controls.Add(tabAbout); - verticalTabControl.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + verticalTabControl.Font = new Font("Tahoma", 12F); verticalTabControl.ImageList = tabIcons; verticalTabControl.ItemSize = new Size(44, 200); verticalTabControl.Location = new Point(3, 3); @@ -124,7 +127,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents tabGeneral.Controls.Add(checkStartWindows); tabGeneral.Controls.Add(lblBehaviour); tabGeneral.Controls.Add(lblGeneral); - tabGeneral.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + tabGeneral.Font = new Font("Tahoma", 12F); tabGeneral.ForeColor = Color.White; tabGeneral.Location = new Point(204, 4); tabGeneral.Name = "tabGeneral"; @@ -138,7 +141,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents language.BackColor = Color.FromArgb(65, 65, 65); language.Cursor = Cursors.Hand; language.DropDownStyle = ComboBoxStyle.DropDownList; - language.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + language.Font = new Font("Tahoma", 12F); language.ForeColor = Color.White; language.Icon = null; language.Location = new Point(12, 222); @@ -153,7 +156,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // lblLanguage // lblLanguage.AutoSize = true; - lblLanguage.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point); + lblLanguage.Font = new Font("Tahoma", 14.25F); lblLanguage.ForeColor = Color.Gray; lblLanguage.Location = new Point(3, 198); lblLanguage.Name = "lblLanguage"; @@ -177,7 +180,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // lblBehaviour // lblBehaviour.AutoSize = true; - lblBehaviour.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point); + lblBehaviour.Font = new Font("Tahoma", 14.25F); lblBehaviour.ForeColor = Color.Gray; lblBehaviour.Location = new Point(3, 63); lblBehaviour.Name = "lblBehaviour"; @@ -189,7 +192,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // lblGeneral // lblGeneral.AutoSize = true; - lblGeneral.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point); + lblGeneral.Font = new Font("Tahoma", 15.75F); lblGeneral.Location = new Point(3, 0); lblGeneral.Name = "lblGeneral"; lblGeneral.Size = new Size(84, 25); @@ -200,6 +203,9 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // tabConnection // tabConnection.BackColor = Color.FromArgb(45, 45, 45); + tabConnection.Controls.Add(checkAutoStartUsb); + tabConnection.Controls.Add(checkEnableAdb); + tabConnection.Controls.Add(label5); tabConnection.Controls.Add(btnApplySslConfiguration); tabConnection.Controls.Add(btnBrowseCertificatePath); tabConnection.Controls.Add(label4); @@ -212,7 +218,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents tabConnection.Controls.Add(port); tabConnection.Controls.Add(lblPort); tabConnection.Controls.Add(lblConnection); - tabConnection.Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point); + tabConnection.Font = new Font("Tahoma", 9F); tabConnection.ForeColor = Color.White; tabConnection.Location = new Point(204, 4); tabConnection.Name = "tabConnection"; @@ -220,13 +226,49 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents tabConnection.TabIndex = 3; tabConnection.Text = "Connection"; // + // checkAutoStartUsb + // + checkAutoStartUsb.AutoSize = true; + checkAutoStartUsb.Font = new Font("Tahoma", 12F); + checkAutoStartUsb.Location = new Point(14, 395); + checkAutoStartUsb.Name = "checkAutoStartUsb"; + checkAutoStartUsb.Size = new Size(532, 23); + checkAutoStartUsb.TabIndex = 27; + checkAutoStartUsb.Text = "Automatically wake screen and start Macro Deck Client when connected"; + checkAutoStartUsb.UseMnemonic = false; + checkAutoStartUsb.UseVisualStyleBackColor = true; + // + // checkEnableAdb + // + checkEnableAdb.AutoSize = true; + checkEnableAdb.Font = new Font("Tahoma", 12F); + checkEnableAdb.Location = new Point(14, 366); + checkEnableAdb.Name = "checkEnableAdb"; + checkEnableAdb.Size = new Size(520, 23); + checkEnableAdb.TabIndex = 26; + checkEnableAdb.Text = "Enable Android Debug Bridge (Required for Android USB connection)"; + checkEnableAdb.UseMnemonic = false; + checkEnableAdb.UseVisualStyleBackColor = true; + // + // label5 + // + label5.AutoSize = true; + label5.Font = new Font("Tahoma", 14.25F); + label5.ForeColor = Color.Gray; + label5.Location = new Point(5, 340); + label5.Name = "label5"; + label5.Size = new Size(44, 23); + label5.TabIndex = 25; + label5.Text = "USB"; + label5.UseMnemonic = false; + // // btnApplySslConfiguration // btnApplySslConfiguration.BorderRadius = 8; btnApplySslConfiguration.Cursor = Cursors.Hand; btnApplySslConfiguration.FlatAppearance.BorderSize = 0; btnApplySslConfiguration.FlatStyle = FlatStyle.Flat; - btnApplySslConfiguration.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnApplySslConfiguration.Font = new Font("Tahoma", 9.75F); btnApplySslConfiguration.ForeColor = Color.White; btnApplySslConfiguration.HoverColor = Color.FromArgb(0, 89, 184); btnApplySslConfiguration.Icon = null; @@ -249,7 +291,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents btnBrowseCertificatePath.Cursor = Cursors.Hand; btnBrowseCertificatePath.FlatAppearance.BorderSize = 0; btnBrowseCertificatePath.FlatStyle = FlatStyle.Flat; - btnBrowseCertificatePath.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnBrowseCertificatePath.Font = new Font("Tahoma", 9.75F); btnBrowseCertificatePath.ForeColor = Color.White; btnBrowseCertificatePath.HoverColor = Color.FromArgb(0, 89, 184); btnBrowseCertificatePath.Icon = null; @@ -268,7 +310,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // // label4 // - label4.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point); + label4.Font = new Font("Tahoma", 11.25F); label4.Location = new Point(17, 258); label4.Name = "label4"; label4.Size = new Size(159, 30); @@ -280,7 +322,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // certificatePassword // certificatePassword.BackColor = Color.FromArgb(65, 65, 65); - certificatePassword.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + certificatePassword.Font = new Font("Tahoma", 12F); certificatePassword.Icon = null; certificatePassword.Location = new Point(182, 258); certificatePassword.MaxCharacters = 32767; @@ -299,7 +341,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // // label3 // - label3.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point); + label3.Font = new Font("Tahoma", 11.25F); label3.Location = new Point(17, 222); label3.Name = "label3"; label3.Size = new Size(159, 30); @@ -311,7 +353,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // certificatePath // certificatePath.BackColor = Color.FromArgb(65, 65, 65); - certificatePath.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + certificatePath.Font = new Font("Tahoma", 12F); certificatePath.Icon = null; certificatePath.Location = new Point(182, 222); certificatePath.MaxCharacters = 32767; @@ -331,7 +373,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // checkEnableSsl // checkEnableSsl.AutoSize = true; - checkEnableSsl.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + checkEnableSsl.Font = new Font("Tahoma", 12F); checkEnableSsl.Location = new Point(12, 193); checkEnableSsl.Name = "checkEnableSsl"; checkEnableSsl.Size = new Size(106, 23); @@ -343,7 +385,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // labelSsl // labelSsl.AutoSize = true; - labelSsl.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point); + labelSsl.Font = new Font("Tahoma", 14.25F); labelSsl.ForeColor = Color.Gray; labelSsl.Location = new Point(3, 167); labelSsl.Name = "labelSsl"; @@ -358,7 +400,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents btnChangePort.Cursor = Cursors.Hand; btnChangePort.FlatAppearance.BorderSize = 0; btnChangePort.FlatStyle = FlatStyle.Flat; - btnChangePort.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnChangePort.Font = new Font("Tahoma", 9.75F); btnChangePort.ForeColor = Color.White; btnChangePort.HoverColor = Color.FromArgb(0, 89, 184); btnChangePort.Icon = null; @@ -379,7 +421,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // port.BackColor = Color.FromArgb(65, 65, 65); port.BorderStyle = BorderStyle.FixedSingle; - port.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point); + port.Font = new Font("Tahoma", 11.25F); port.ForeColor = Color.White; port.Location = new Point(13, 89); port.Maximum = new decimal(new int[] { 65535, 0, 0, 0 }); @@ -391,7 +433,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // lblPort // lblPort.AutoSize = true; - lblPort.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point); + lblPort.Font = new Font("Tahoma", 14.25F); lblPort.ForeColor = Color.Gray; lblPort.Location = new Point(3, 63); lblPort.Name = "lblPort"; @@ -403,7 +445,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // lblConnection // lblConnection.AutoSize = true; - lblConnection.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point); + lblConnection.Font = new Font("Tahoma", 15.75F); lblConnection.Location = new Point(3, 0); lblConnection.Name = "lblConnection"; lblConnection.Size = new Size(116, 25); @@ -421,7 +463,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents tabUpdater.Controls.Add(lblInstalledVersion); tabUpdater.Controls.Add(lblInstalledVersionLabel); tabUpdater.Controls.Add(lblUpdates); - tabUpdater.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + tabUpdater.Font = new Font("Tahoma", 12F); tabUpdater.ForeColor = Color.White; tabUpdater.Location = new Point(204, 4); tabUpdater.Name = "tabUpdater"; @@ -432,7 +474,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // label2 // label2.AutoSize = true; - label2.Font = new Font("Tahoma", 14.25F, FontStyle.Regular, GraphicsUnit.Point); + label2.Font = new Font("Tahoma", 14.25F); label2.ForeColor = Color.Gray; label2.Location = new Point(3, 63); label2.Name = "label2"; @@ -469,7 +511,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents btnCheckUpdates.Cursor = Cursors.Hand; btnCheckUpdates.FlatAppearance.BorderSize = 0; btnCheckUpdates.FlatStyle = FlatStyle.Flat; - btnCheckUpdates.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnCheckUpdates.Font = new Font("Tahoma", 9.75F); btnCheckUpdates.ForeColor = Color.White; btnCheckUpdates.HoverColor = Color.FromArgb(0, 89, 184); btnCheckUpdates.Icon = null; @@ -509,7 +551,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // lblUpdates // lblUpdates.AutoSize = true; - lblUpdates.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point); + lblUpdates.Font = new Font("Tahoma", 15.75F); lblUpdates.Location = new Point(3, 0); lblUpdates.Name = "lblUpdates"; lblUpdates.Size = new Size(88, 25); @@ -537,7 +579,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents btnCreateBackup.Cursor = Cursors.Hand; btnCreateBackup.FlatAppearance.BorderSize = 0; btnCreateBackup.FlatStyle = FlatStyle.Flat; - btnCreateBackup.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnCreateBackup.Font = new Font("Tahoma", 9.75F); btnCreateBackup.ForeColor = Color.White; btnCreateBackup.HoverColor = Color.FromArgb(0, 89, 184); btnCreateBackup.Icon = null; @@ -565,7 +607,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // lblBackups // lblBackups.AutoSize = true; - lblBackups.Font = new Font("Tahoma", 15.75F, FontStyle.Regular, GraphicsUnit.Point); + lblBackups.Font = new Font("Tahoma", 15.75F); lblBackups.Location = new Point(3, 0); lblBackups.Name = "lblBackups"; lblBackups.Size = new Size(89, 25); @@ -589,7 +631,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents tabAbout.Controls.Add(lblDeveloped); tabAbout.Controls.Add(lblMacroDeck); tabAbout.Controls.Add(pictureBox1); - tabAbout.Font = new Font("Tahoma", 12F, FontStyle.Regular, GraphicsUnit.Point); + tabAbout.Font = new Font("Tahoma", 12F); tabAbout.ForeColor = Color.White; tabAbout.Location = new Point(204, 4); tabAbout.Name = "tabAbout"; @@ -613,7 +655,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // // label1 // - label1.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point); + label1.Font = new Font("Tahoma", 11.25F); label1.Location = new Point(219, 226); label1.Name = "label1"; label1.Size = new Size(485, 18); @@ -624,7 +666,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // // lblTranslationBy // - lblTranslationBy.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point); + lblTranslationBy.Font = new Font("Tahoma", 11.25F); lblTranslationBy.Location = new Point(219, 164); lblTranslationBy.Name = "lblTranslationBy"; lblTranslationBy.Size = new Size(485, 18); @@ -639,7 +681,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents btnLicenses.Cursor = Cursors.Hand; btnLicenses.FlatAppearance.BorderSize = 0; btnLicenses.FlatStyle = FlatStyle.Flat; - btnLicenses.Font = new Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point); + btnLicenses.Font = new Font("Tahoma", 9.75F); btnLicenses.ForeColor = Color.White; btnLicenses.HoverColor = Color.FromArgb(0, 89, 184); btnLicenses.Icon = null; @@ -718,7 +760,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // // lblDeveloped // - lblDeveloped.Font = new Font("Tahoma", 11.25F, FontStyle.Regular, GraphicsUnit.Point); + lblDeveloped.Font = new Font("Tahoma", 11.25F); lblDeveloped.Location = new Point(219, 206); lblDeveloped.Name = "lblDeveloped"; lblDeveloped.Size = new Size(485, 18); @@ -729,7 +771,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents // // lblMacroDeck // - lblMacroDeck.Font = new Font("Tahoma", 21.75F, FontStyle.Regular, GraphicsUnit.Point); + lblMacroDeck.Font = new Font("Tahoma", 21.75F); lblMacroDeck.ForeColor = Color.LightGray; lblMacroDeck.Location = new Point(3, 3); lblMacroDeck.Name = "lblMacroDeck"; @@ -766,7 +808,7 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents AutoScaleMode = AutoScaleMode.Dpi; BackColor = Color.FromArgb(45, 45, 45); Controls.Add(verticalTabControl); - Font = new Font("Tahoma", 9F, FontStyle.Regular, GraphicsUnit.Point); + Font = new Font("Tahoma", 9F); Name = "SettingsView"; Size = new Size(1137, 540); Load += Settings_Load; @@ -835,5 +877,8 @@ namespace SuchByte.MacroDeck.GUI.MainWindowContents private RoundedTextBox certificatePath; private CheckBox checkEnableSsl; private Label labelSsl; + private CheckBox checkEnableAdb; + private Label label5; + private CheckBox checkAutoStartUsb; } } diff --git a/MacroDeck/GUI/MainWindowViews/SettingsView.cs b/MacroDeck/GUI/MainWindowViews/SettingsView.cs index 16bc1c6..437c3fc 100644 --- a/MacroDeck/GUI/MainWindowViews/SettingsView.cs +++ b/MacroDeck/GUI/MainWindowViews/SettingsView.cs @@ -104,6 +104,22 @@ public partial class SettingsView : UserControl checkEnableSsl.Checked = MacroDeck.Configuration.EnableSsl; certificatePath.Text = MacroDeck.Configuration.SslCertificatePath; certificatePassword.Text = MacroDeck.Configuration.SslCertificatePassword; + checkEnableAdb.Checked = MacroDeck.Configuration.EnableAdbServer; + checkAutoStartUsb.Checked = MacroDeck.Configuration.EnableAdbAutoStartApp; + checkEnableAdb.CheckedChanged += CheckEnableAdb_CheckedChanged; + checkAutoStartUsb.CheckedChanged += CheckAutoStartUsb_CheckedChanged; + } + + private void CheckAutoStartUsb_CheckedChanged(object? sender, EventArgs e) + { + MacroDeck.Configuration.EnableAdbAutoStartApp = checkAutoStartUsb.Checked; + MacroDeck.Configuration.Save(ApplicationPaths.MainConfigFilePath); + } + + private void CheckEnableAdb_CheckedChanged(object? sender, EventArgs e) + { + MacroDeck.Configuration.EnableAdbServer = checkEnableAdb.Checked; + MacroDeck.Configuration.Save(ApplicationPaths.MainConfigFilePath); } private void LoadAutoStart() diff --git a/MacroDeck/GUI/MainWindowViews/SettingsView.resx b/MacroDeck/GUI/MainWindowViews/SettingsView.resx index 9887363..a3501ac 100644 --- a/MacroDeck/GUI/MainWindowViews/SettingsView.resx +++ b/MacroDeck/GUI/MainWindowViews/SettingsView.resx @@ -1,4 +1,64 @@ - + + + @@ -65,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAfg4AAAJNU0Z0AUkBTAIBAQUB - AAGQAQABkAEAATABAAEwAQAE/wEFAQAI/wFCAU0BdgcAAXYDAAEoAwABwAMAAWADAAEBAQABBAYAASQY + AAGoAQABqAEAATABAAEwAQAE/wEFAQAI/wFCAU0BdgcAAXYDAAEoAwABwAMAAWADAAEBAQABBAYAASQY AAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAA4ADAAH/AgAB/wMAAv8BAAH/AwAB/wEAAf8B AAL/AgAD//8A/wD/AA0AAQ8C/10AAQ8D/1wAAQ8D/wHwWwABDwT/AfBaAAEPBf9aAAEPAv8B8AEPAf9a AAEPAv8B8FwAAQ8C/wHwXQAD/10AA/9dAAP/XQAD/10AAQ8C/wHwXAABDwL/AfBcAAEPAv8B8FoAAQ8B diff --git a/MacroDeck/MacroDeck.cs b/MacroDeck/MacroDeck.cs index 0fe9cb0..12d16b5 100644 --- a/MacroDeck/MacroDeck.cs +++ b/MacroDeck/MacroDeck.cs @@ -318,6 +318,6 @@ public class MacroDeck : NativeWindow public static void Exit() { - Environment.Exit(0); + Application.Exit(); } } \ No newline at end of file diff --git a/MacroDeck/Program.cs b/MacroDeck/Program.cs index 0db40b7..1e6eac1 100644 --- a/MacroDeck/Program.cs +++ b/MacroDeck/Program.cs @@ -20,7 +20,7 @@ internal class Program // Register exception event handlers Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += ApplicationThreadException; - AppDomain.CurrentDomain.ProcessExit += CurrentDomainOnProcessExit; + AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException; @@ -32,10 +32,6 @@ internal class Program MacroDeck.Start(startParameters); } - private static async void CurrentDomainOnProcessExit(object? sender, EventArgs e) - { - } - private static void CheckRunningInstance(int ignoredPid) { var proc = Process.GetCurrentProcess(); diff --git a/MacroDeck/Server/ADBServerHelper.cs b/MacroDeck/Server/AdbServerHelper.cs similarity index 80% rename from MacroDeck/Server/ADBServerHelper.cs rename to MacroDeck/Server/AdbServerHelper.cs index ef8ba41..d01fac0 100644 --- a/MacroDeck/Server/ADBServerHelper.cs +++ b/MacroDeck/Server/AdbServerHelper.cs @@ -1,5 +1,4 @@ -using System.Collections.Concurrent; -using System.IO; +using System.IO; using AdvancedSharpAdbClient; using AdvancedSharpAdbClient.DeviceCommands; using AdvancedSharpAdbClient.Models; @@ -39,62 +38,26 @@ public class AdbServerHelper MacroDeckLogger.Info(typeof(AdbServerHelper), "Unable to start ADB server"); } - var adbClient = await GetAdbClient(); - if (adbClient is null) - { - return; - } - - var devices = await adbClient.GetDevicesAsync(); - var onlineDevices = devices.Where(x => x.State == DeviceState.Online); - foreach (var device in onlineDevices) - { - await RunForDevice(device.Serial, async (adbDeviceClient, deviceData) => - { - await StartMacroDeckClient(adbDeviceClient, deviceData); - await StartReverseForward(adbDeviceClient, deviceData); - }); - } - var monitor = new DeviceMonitor(new AdbSocket(AdbClient.AdbServerEndPoint)); monitor.DeviceConnected += Monitor_DeviceConnected; monitor.DeviceDisconnected += Monitor_DeviceDisconnected; await monitor.StartAsync(); } - public static async Task Exit() + private static async Task RunForDevice(string serial, Func action) { var adbClient = await GetAdbClient(); if (adbClient is null) { return; } - - var devices = await adbClient.GetDevicesAsync(); - var onlineDevices = devices.Where(x => x.State == DeviceState.Online); - foreach (var device in onlineDevices) - { - await RunForDevice(device.Serial, async (adbDeviceClient, deviceData) => - { - await ExitMacroDeckClient(adbDeviceClient, deviceData); - }); - } - } - - private static async Task RunForDevice(string serial, Func action) - { - var adbDeviceClient = await GetAdbClient(); - if (adbDeviceClient is null) - { - return; - } - var deviceData = await GetDevice(adbDeviceClient, serial); - if (!deviceData.HasValue) + var device = await GetDevice(adbClient, serial); + if (!device.HasValue) { return; } - await action(adbDeviceClient, deviceData.Value); + await action(adbClient, device.Value); } private static async Task GetDevice(AdbClient adbDeviceClient, string serial) @@ -141,7 +104,6 @@ public class AdbServerHelper return; } - await Task.Delay(TimeSpan.FromSeconds(1)); MacroDeckLogger.Info(typeof(AdbServerHelper), $"{e.Device.Name} connected"); await RunForDevice(e.Device.Serial, async (adbDeviceClient, deviceData) => {