public async Task DaisyChainCommands(int Delay, SwitchButton[] buttons, CancellationToken token) { SwitchCommand.Configure(SwitchConfigureParameter.mainLoopSleepTime, Delay); var commands = buttons.Select(SwitchCommand.Click).ToArray(); var chain = commands.SelectMany(x => x).ToArray(); await Connection.SendAsync(chain, Config.ConnectionType, token).ConfigureAwait(false); SwitchCommand.Configure(SwitchConfigureParameter.mainLoopSleepTime, 0); }
public async Task DaisyChainCommands(int delay, IEnumerable <SwitchButton> buttons, CancellationToken token) { SwitchCommand.Configure(SwitchConfigureParameter.mainLoopSleepTime, delay, UseCRLF); var commands = buttons.Select(z => SwitchCommand.Click(z, UseCRLF)).ToArray(); var chain = commands.SelectMany(x => x).ToArray(); await Connection.SendAsync(chain, token).ConfigureAwait(false); SwitchCommand.Configure(SwitchConfigureParameter.mainLoopSleepTime, 0, UseCRLF); }
public async Task PressAndHold(SwitchButton b, int hold, int delay, CancellationToken token) { // Set hold delay var delaycgf = SwitchCommand.Configure(SwitchConfigureParameter.buttonClickSleepTime, hold); await Connection.SendAsync(delaycgf, Config.ConnectionType, token).ConfigureAwait(false); // Press the button await Click(b, delay, token).ConfigureAwait(false); // Reset delay delaycgf = SwitchCommand.Configure(SwitchConfigureParameter.buttonClickSleepTime, 50); // 50 ms await Connection.SendAsync(delaycgf, Config.ConnectionType, token).ConfigureAwait(false); }
public async Task BootLanMode(int hold, CancellationToken token) { // Set hold delay var delaycgf = SwitchCommand.Configure(SwitchConfigureParameter.buttonClickSleepTime, hold); await Connection.SendAsync(delaycgf, token).ConfigureAwait(false); // Hold the buttons await Connection.SendAsync(SwitchCommand.Hold(SwitchButton.L), token).ConfigureAwait(false); await Connection.SendAsync(SwitchCommand.Hold(SwitchButton.R), token).ConfigureAwait(false); await Connection.SendAsync(SwitchCommand.Hold(SwitchButton.LSTICK), token).ConfigureAwait(false); // Reset delay delaycgf = SwitchCommand.Configure(SwitchConfigureParameter.buttonClickSleepTime, 50); // 50 ms await Connection.SendAsync(delaycgf, token).ConfigureAwait(false); // Release the buttons await Connection.SendAsync(SwitchCommand.Release(SwitchButton.L), token).ConfigureAwait(false); await Connection.SendAsync(SwitchCommand.Release(SwitchButton.R), token).ConfigureAwait(false); await Connection.SendAsync(SwitchCommand.Release(SwitchButton.LSTICK), token).ConfigureAwait(false); }
public async Task EchoCommands(bool value, CancellationToken token) { var cmd = SwitchCommand.Configure(SwitchConfigureParameter.echoCommands, value ? 1 : 0); await Connection.SendAsync(cmd, Config.ConnectionType, token).ConfigureAwait(false); }