Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for SD+ dial press not working since Stream Deck v6.5 #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/SharpDeck/Connectivity/IStreamDeckConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,14 @@ public interface IStreamDeckConnection : IDisposable
event EventHandler<DeviceEventArgs> DeviceDidDisconnect;

/// <summary>
/// Occurs when a dial is pressed, or released.
/// Occurs when a dial is pressed.
/// </summary>
event EventHandler<ActionEventArgs<DialPayload>> DialPress;
event EventHandler<ActionEventArgs<DialPayload>> DialDown;

/// <summary>
/// Occurs when a dial is released.
/// </summary>
event EventHandler<ActionEventArgs<DialPayload>> DialUp;

/// <summary>
/// Occurs when a dial rotates.
Expand Down
17 changes: 13 additions & 4 deletions src/SharpDeck/Connectivity/Net/StreamDeckWebSocketConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ internal sealed class StreamDeckWebSocketConnection : IStreamDeckConnection
public event EventHandler<DeviceEventArgs> DeviceDidDisconnect;

/// <summary>
/// Occurs when a dial is pressed, or released.
/// Occurs when a dial is pressed.
/// </summary>
public event EventHandler<ActionEventArgs<DialPayload>> DialPress;
public event EventHandler<ActionEventArgs<DialPayload>> DialDown;

/// <summary>
/// Occurs when a dial is released.
/// </summary>
public event EventHandler<ActionEventArgs<DialPayload>> DialUp;

/// <summary>
/// Occurs when a dial rotates.
Expand Down Expand Up @@ -441,8 +446,12 @@ private void Raise(string @event, JObject args)
break;

// action specific
case "dialPress":
this.DialPress?.Invoke(this, args.ToObject<ActionEventArgs<DialPayload>>());
case "dialDown":
this.DialDown?.Invoke(this, args.ToObject<ActionEventArgs<DialPayload>>());
break;

case "dialUp":
this.DialUp?.Invoke(this, args.ToObject<ActionEventArgs<DialPayload>>());
break;

case "dialRotate":
Expand Down
3 changes: 2 additions & 1 deletion src/SharpDeck/Connectivity/StreamDeckActionRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 0 additions & 5 deletions src/SharpDeck/Events/Received/DialPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,5 @@ public class DialPayload : SettingsPayload
/// Gets or sets the coordinates of a triggered action.
/// </summary>
public Coordinates Coordinates { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the dial is pressed.
/// </summary>
public bool Pressed { get; set; }
}
}
12 changes: 10 additions & 2 deletions src/SharpDeck/StreamDeckAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,19 @@ internal void Initialize(ActionEventArgs<AppearancePayload> args, IStreamDeckCon
}

/// <summary>
/// Occurs when <see cref="IStreamDeckConnection.DialPress"/> is received for this instance.
/// Occurs when <see cref="IStreamDeckConnection.DialDown"/> is received for this instance.
/// </summary>
/// <param name="args">The <see cref="ActionEventArgs{DialPayload}" /> instance containing the event data.</param>
/// <returns>The task of handling the event.</returns>
protected internal virtual Task OnDialPress(ActionEventArgs<DialPayload> args)
protected internal virtual Task OnDialDown(ActionEventArgs<DialPayload> args)
=> Task.CompletedTask;

/// <summary>
/// Occurs when <see cref="IStreamDeckConnection.DialUp"/> is received for this instance.
/// </summary>
/// <param name="args">The <see cref="ActionEventArgs{DialPayload}" /> instance containing the event data.</param>
/// <returns>The task of handling the event.</returns>
protected internal virtual Task OnDialUp(ActionEventArgs<DialPayload> args)
=> Task.CompletedTask;

/// <summary>
Expand Down