public void Execute(CancellationToken threadCancellationToken) { Common.PlaySoundFile(SoundFile, Volume); if (!PluginManager.DisableKeyboardAPI) { OSKeyPress.Execute(threadCancellationToken); } if (PluginManager.PlugSupportActivated && PluginManager.HasPlugin()) { PluginManager.DoEvent( DCSFPProfile.SelectedProfile.Description, StreamDeckPanelInstance.HIDInstance, StreamDeckCommon.ConvertEnum(_streamDeckPanel.TypeOfPanel), (int)StreamDeckButtonName, true, OSKeyPress.KeyPressSequence); } }
public void DoPress() { if (ActionForPress == null) { /* * Must do this here as there are no ActionTypeKey for this button, otherwise Plugin would never get any event. * Otherwise it is sent from ActionTypeKey together with key configs associated with the button. */ if (PluginManager.PlugSupportActivated && PluginManager.HasPlugin()) { PluginManager.DoEvent( DCSFPProfile.SelectedProfile.Description, StreamDeckPanelInstance.HIDInstance, StreamDeckCommon.ConvertEnum(_streamDeckPanel.TypeOfPanel), (int)StreamDeckButtonName, true, null); } return; } while (ActionForPress.IsRunning()) { _cancellationTokenSource?.Cancel(); } if (ActionForPress.IsRepeatable()) { _cancellationTokenSource = new CancellationTokenSource(); var threadCancellationToken = _cancellationTokenSource.Token; Debug.WriteLine("Creating Key Press Thread for Streamdeck"); _keyPressedThread = new Thread(() => ThreadedPress(threadCancellationToken)); _keyPressedThread.Start(); } else { ActionForPress.Execute(CancellationToken.None); } }