From cb3d9155e6227c6c80c2ec8d4d89f5856f90308d Mon Sep 17 00:00:00 2001 From: Martin Renner Date: Thu, 2 May 2024 18:03:46 +0200 Subject: [PATCH] Fix for SD+ dial press not working since Stream Deck v6.5 The event "dialPress" was replaced by "dialDown" and "dialUp". Since Stream Deck v6.5 the old "dialPress" is removed from the API. --- .../Connectivity/IStreamDeckConnection.cs | 9 +++++++-- .../Net/StreamDeckWebSocketConnection.cs | 17 +++++++++++++---- .../Connectivity/StreamDeckActionRegistry.cs | 3 ++- src/SharpDeck/Events/Received/DialPayload.cs | 5 ----- src/SharpDeck/StreamDeckAction.cs | 12 ++++++++++-- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/SharpDeck/Connectivity/IStreamDeckConnection.cs b/src/SharpDeck/Connectivity/IStreamDeckConnection.cs index e27968c..e6479f1 100644 --- a/src/SharpDeck/Connectivity/IStreamDeckConnection.cs +++ b/src/SharpDeck/Connectivity/IStreamDeckConnection.cs @@ -38,9 +38,14 @@ public interface IStreamDeckConnection : IDisposable event EventHandler DeviceDidDisconnect; /// - /// Occurs when a dial is pressed, or released. + /// Occurs when a dial is pressed. /// - event EventHandler> DialPress; + event EventHandler> DialDown; + + /// + /// Occurs when a dial is released. + /// + event EventHandler> DialUp; /// /// Occurs when a dial rotates. diff --git a/src/SharpDeck/Connectivity/Net/StreamDeckWebSocketConnection.cs b/src/SharpDeck/Connectivity/Net/StreamDeckWebSocketConnection.cs index 9f2d3f0..f1db4c3 100644 --- a/src/SharpDeck/Connectivity/Net/StreamDeckWebSocketConnection.cs +++ b/src/SharpDeck/Connectivity/Net/StreamDeckWebSocketConnection.cs @@ -55,9 +55,14 @@ internal sealed class StreamDeckWebSocketConnection : IStreamDeckConnection public event EventHandler DeviceDidDisconnect; /// - /// Occurs when a dial is pressed, or released. + /// Occurs when a dial is pressed. /// - public event EventHandler> DialPress; + public event EventHandler> DialDown; + + /// + /// Occurs when a dial is released. + /// + public event EventHandler> DialUp; /// /// Occurs when a dial rotates. @@ -441,8 +446,12 @@ private void Raise(string @event, JObject args) break; // action specific - case "dialPress": - this.DialPress?.Invoke(this, args.ToObject>()); + case "dialDown": + this.DialDown?.Invoke(this, args.ToObject>()); + break; + + case "dialUp": + this.DialUp?.Invoke(this, args.ToObject>()); break; case "dialRotate": diff --git a/src/SharpDeck/Connectivity/StreamDeckActionRegistry.cs b/src/SharpDeck/Connectivity/StreamDeckActionRegistry.cs index bfc2c35..05ea8ea 100644 --- a/src/SharpDeck/Connectivity/StreamDeckActionRegistry.cs +++ b/src/SharpDeck/Connectivity/StreamDeckActionRegistry.cs @@ -42,7 +42,8 @@ public StreamDeckActionRegistry(IStreamDeckConnection connection, IDynamicProfil connection.WillAppear += this.Action_WillAppear; // action propagation - connection.DialPress += (_, e) => this.InvokeOnAction(e, a => a.OnDialPress); + connection.DialDown += (_, e) => this.InvokeOnAction(e, a => a.OnDialDown); + connection.DialUp += (_, e) => this.InvokeOnAction(e, a => a.OnDialUp); connection.DialRotate += (_, e) => this.InvokeOnAction(e, a => a.OnDialRotate); connection.DidReceiveSettings += (_, e) => this.InvokeOnAction(e, a => a.OnDidReceiveSettings); connection.KeyDown += (_, e) => this.InvokeOnAction(e, a => a.OnKeyDown); diff --git a/src/SharpDeck/Events/Received/DialPayload.cs b/src/SharpDeck/Events/Received/DialPayload.cs index e34e890..9028739 100644 --- a/src/SharpDeck/Events/Received/DialPayload.cs +++ b/src/SharpDeck/Events/Received/DialPayload.cs @@ -14,10 +14,5 @@ public class DialPayload : SettingsPayload /// Gets or sets the coordinates of a triggered action. /// public Coordinates Coordinates { get; set; } - - /// - /// Gets or sets a value indicating whether the dial is pressed. - /// - public bool Pressed { get; set; } } } diff --git a/src/SharpDeck/StreamDeckAction.cs b/src/SharpDeck/StreamDeckAction.cs index 32a20e2..4d455ae 100644 --- a/src/SharpDeck/StreamDeckAction.cs +++ b/src/SharpDeck/StreamDeckAction.cs @@ -154,11 +154,19 @@ internal void Initialize(ActionEventArgs args, IStreamDeckCon } /// - /// Occurs when is received for this instance. + /// Occurs when is received for this instance. /// /// The instance containing the event data. /// The task of handling the event. - protected internal virtual Task OnDialPress(ActionEventArgs args) + protected internal virtual Task OnDialDown(ActionEventArgs args) + => Task.CompletedTask; + + /// + /// Occurs when is received for this instance. + /// + /// The instance containing the event data. + /// The task of handling the event. + protected internal virtual Task OnDialUp(ActionEventArgs args) => Task.CompletedTask; ///