Skip to content

Commit f786a7a

Browse files
committed
v6.1 - DialUp & DialDown support
- Support for new `DialDown` and `DialUp` events. - Removed support for deprecated `DialPress` event
1 parent 6054509 commit f786a7a

13 files changed

Lines changed: 199 additions & 74 deletions

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# Stream Deck+ Support
1010
Instead of `PluginBase`, Derive from either `KeypadBase` (if you don't support dials), `EncoderBase` (for only dials), `KeyAndEncoderBase` (for both keys and dials)
1111

12-
1312
# Getting Started
1413
Introducing our new [wiki](https://github.com/BarRaider/streamdeck-tools/wiki) packed with usage instructions, examples and more.
1514

@@ -34,6 +33,10 @@ Introducing our new [wiki](https://github.com/BarRaider/streamdeck-tools/wiki) p
3433

3534
# Change Log
3635

36+
### Version 6.1
37+
- Support for new `DialDown` and `DialUp` events.
38+
- Removed support for deprecated `DialPress` event
39+
3740
### Version 6.0
3841
1. Merged streamdeck-client-csharp package into library to allow better logging of errors
3942
2. Added support for SD+ SDK

barraider-sdtools/Backend/EncoderBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,14 @@ public abstract class EncoderBase : IEncoderPlugin
1919
public abstract void DialRotate(DialRotatePayload payload);
2020

2121
/// <summary>
22-
/// Called when the Dial is pressed or released
22+
/// Called when the Dial is pressed
2323
/// </summary>
24-
public abstract void DialPress(DialPressPayload payload);
24+
public abstract void DialDown(DialPayload payload);
25+
26+
/// <summary>
27+
/// Called when the Dial is released
28+
/// </summary>
29+
public abstract void DialUp(DialPayload payload);
2530

2631
/// <summary>
2732
/// Called when the touchpad (above the dials) is pressed

barraider-sdtools/Backend/IEncoderPlugin.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@ public interface IEncoderPlugin : ICommonPluginFunctions
1616
void DialRotate(DialRotatePayload payload);
1717

1818
/// <summary>
19-
/// Called when the Dial is pressed or released
19+
/// Called when the Dial is pressed
2020
/// </summary>
21-
void DialPress(DialPressPayload payload);
21+
void DialDown(DialPayload payload);
22+
23+
/// <summary>
24+
/// Called when the Dial is released
25+
/// </summary>
26+
void DialUp(DialPayload payload);
2227

2328
/// <summary>
2429
/// Called when the touchpad (above the dials) is pressed

barraider-sdtools/Backend/KeyAndEncoderBase.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@ public abstract class KeyAndEncoderBase : IKeypadPlugin, IEncoderPlugin
2323
public abstract void DialRotate(DialRotatePayload payload);
2424

2525
/// <summary>
26-
/// Called when the Dial is pressed or released
26+
/// Called when the Dial is pressed
2727
/// </summary>
28-
public abstract void DialPress(DialPressPayload payload);
28+
public abstract void DialDown(DialPayload payload);
29+
30+
/// <summary>
31+
/// Called when the Dial is released
32+
/// </summary>
33+
public abstract void DialUp(DialPayload payload);
2934

3035
/// <summary>
3136
/// Called when the touchpad (above the dials) is pressed

barraider-sdtools/Backend/PluginContainer.cs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public void Run(StreamDeckOptions options)
4747
connection.OnWillAppear += Connection_OnWillAppear;
4848
connection.OnWillDisappear += Connection_OnWillDisappear;
4949
connection.OnDialRotate += Connection_OnDialRotate;
50-
connection.OnDialPress += Connection_OnDialPress;
50+
connection.OnDialDown += Connection_OnDialDown;
51+
connection.OnDialUp += Connection_OnDialUp;
5152
connection.OnTouchpadPress += Connection_OnTouchpadPress;
5253

5354
// Settings changed
@@ -285,7 +286,38 @@ private async void Connection_OnTouchpadPress(object sender, SDEventReceivedEven
285286
}
286287
}
287288

288-
private async void Connection_OnDialPress(object sender, SDEventReceivedEventArgs<DialPressEvent> e)
289+
// Dial Up
290+
291+
private async void Connection_OnDialUp(object sender, SDEventReceivedEventArgs<DialUpEvent> e)
292+
{
293+
await instancesLock.WaitAsync();
294+
try
295+
{
296+
#if DEBUG
297+
Logger.Instance.LogMessage(TracingLevel.DEBUG, $"DialPress: Context: {e.Event.Context} Action: {e.Event.Action} Payload: {e.Event.Payload?.ToStringEx()}");
298+
#endif
299+
300+
if (instances.ContainsKey(e.Event.Context))
301+
{
302+
DialPayload payload = new DialPayload(e.Event.Payload.Coordinates, e.Event.Payload.Settings, e.Event.Payload.Controller);
303+
if (instances[e.Event.Context] is IEncoderPlugin plugin)
304+
{
305+
plugin.DialUp(payload);
306+
}
307+
else
308+
{
309+
Logger.Instance.LogMessage(TracingLevel.ERROR, $"DialDown General Error: Could not convert {e.Event.Context} to IEncoderPlugin");
310+
}
311+
}
312+
}
313+
finally
314+
{
315+
instancesLock.Release();
316+
}
317+
}
318+
319+
// Dial Down
320+
private async void Connection_OnDialDown(object sender, SDEventReceivedEventArgs<DialDownEvent> e)
289321
{
290322
await instancesLock.WaitAsync();
291323
try
@@ -296,14 +328,14 @@ private async void Connection_OnDialPress(object sender, SDEventReceivedEventArg
296328

297329
if (instances.ContainsKey(e.Event.Context))
298330
{
299-
DialPressPayload payload = new DialPressPayload(e.Event.Payload.Coordinates, e.Event.Payload.Settings, e.Event.Payload.Controller, e.Event.Payload.IsDialPressed);
331+
DialPayload payload = new DialPayload(e.Event.Payload.Coordinates, e.Event.Payload.Settings, e.Event.Payload.Controller);
300332
if (instances[e.Event.Context] is IEncoderPlugin plugin)
301333
{
302-
plugin.DialPress(payload);
334+
plugin.DialDown(payload);
303335
}
304336
else
305337
{
306-
Logger.Instance.LogMessage(TracingLevel.ERROR, $"DialPress General Error: Could not convert {e.Event.Context} to IEncoderPlugin");
338+
Logger.Instance.LogMessage(TracingLevel.ERROR, $"DialDown General Error: Could not convert {e.Event.Context} to IEncoderPlugin");
307339
}
308340
}
309341
}

barraider-sdtools/Communication/SDEvents/BaseEvent.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ internal static class EventTypes
2828
public const string SendToPlugin = "sendToPlugin";
2929
public const string DialRotate = "dialRotate";
3030
public const string DialPress = "dialPress";
31+
public const string DialDown = "dialDown";
32+
public const string DialUp = "dialUp";
3133
public const string TouchpadPress = "touchTap";
3234
}
3335

@@ -63,7 +65,8 @@ public abstract class BaseEvent
6365
{ EventTypes.SendToPlugin, typeof(SendToPluginEvent) },
6466

6567
{ EventTypes.DialRotate, typeof(DialRotateEvent) },
66-
{ EventTypes.DialPress, typeof(DialPressEvent) },
68+
{ EventTypes.DialDown, typeof(DialDownEvent) },
69+
{ EventTypes.DialUp, typeof(DialUpEvent) },
6770
{ EventTypes.TouchpadPress, typeof(TouchpadPressEvent) },
6871
};
6972

barraider-sdtools/Communication/SDEvents/DialPressEvent.cs renamed to barraider-sdtools/Communication/SDEvents/DialDownEvent.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
namespace BarRaider.SdTools.Communication.SDEvents
88
{
99
/// <summary>
10-
/// Payload for Dial press/unpress event
10+
/// Payload for Dial down event
1111
/// </summary>
12-
public class DialPressEvent : BaseEvent
12+
public class DialDownEvent : BaseEvent
1313
{
1414
/// <summary>
1515
/// Action Name
@@ -30,9 +30,9 @@ public class DialPressEvent : BaseEvent
3030
public string Device { get; private set; }
3131

3232
/// <summary>
33-
/// Information on dial rotation
33+
/// Information on dial status
3434
/// </summary>
3535
[JsonProperty("payload")]
36-
public DialPressPayload Payload { get; private set; }
36+
public DialPayload Payload { get; private set; }
3737
}
3838
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using BarRaider.SdTools.Payloads;
2+
using Newtonsoft.Json;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Text;
6+
7+
namespace BarRaider.SdTools.Communication.SDEvents
8+
{
9+
/// <summary>
10+
/// Payload for Dial up event
11+
/// </summary>
12+
public class DialUpEvent : BaseEvent
13+
{
14+
/// <summary>
15+
/// Action Name
16+
/// </summary>
17+
[JsonProperty("action")]
18+
public string Action { get; private set; }
19+
20+
/// <summary>
21+
/// Unique Action UUID
22+
/// </summary>
23+
[JsonProperty("context")]
24+
public string Context { get; private set; }
25+
26+
/// <summary>
27+
/// Device UUID key was pressed on
28+
/// </summary>
29+
[JsonProperty("device")]
30+
public string Device { get; private set; }
31+
32+
/// <summary>
33+
/// Information on dial status
34+
/// </summary>
35+
[JsonProperty("payload")]
36+
public DialPayload Payload { get; private set; }
37+
}
38+
}

barraider-sdtools/Communication/StreamDeckConnection.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,14 @@ public class StreamDeckConnection
130130
public event EventHandler<SDEventReceivedEventArgs<DialRotateEvent>> OnDialRotate;
131131

132132
/// <summary>
133-
/// Raised when a dial is pressed or unpressed
133+
/// Raised when a dial is down
134134
/// </summary>
135-
public event EventHandler<SDEventReceivedEventArgs<DialPressEvent>> OnDialPress;
135+
public event EventHandler<SDEventReceivedEventArgs<DialDownEvent>> OnDialDown;
136+
137+
/// <summary>
138+
/// Raised when a dial is up
139+
/// </summary>
140+
public event EventHandler<SDEventReceivedEventArgs<DialUpEvent>> OnDialUp;
136141

137142
/// <summary>
138143
/// Raised when the tochpad is pressed
@@ -394,7 +399,9 @@ private async Task<WebSocketCloseStatus> ReceiveAsync()
394399
case EventTypes.PropertyInspectorDidDisappear: OnPropertyInspectorDidDisappear?.Invoke(this, new SDEventReceivedEventArgs<PropertyInspectorDidDisappearEvent>(evt as PropertyInspectorDidDisappearEvent)); break;
395400
case EventTypes.SendToPlugin: OnSendToPlugin?.Invoke(this, new SDEventReceivedEventArgs<SendToPluginEvent>(evt as SendToPluginEvent)); break;
396401
case EventTypes.DialRotate: OnDialRotate?.Invoke(this, new SDEventReceivedEventArgs<DialRotateEvent>(evt as DialRotateEvent)); break;
397-
case EventTypes.DialPress: OnDialPress?.Invoke(this, new SDEventReceivedEventArgs<DialPressEvent>(evt as DialPressEvent)); break;
402+
case EventTypes.DialDown: OnDialDown?.Invoke(this, new SDEventReceivedEventArgs<DialDownEvent>(evt as DialDownEvent)); break;
403+
case EventTypes.DialUp: OnDialUp?.Invoke(this, new SDEventReceivedEventArgs<DialUpEvent>(evt as DialUpEvent)); break;
404+
case EventTypes.DialPress: /* Ignoring deprecated Stream Deck event;*/ break;
398405
case EventTypes.TouchpadPress: OnTouchpadPress?.Invoke(this, new SDEventReceivedEventArgs<TouchpadPressEvent>(evt as TouchpadPressEvent)); break;
399406
default:
400407
Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} Unsupported Stream Deck event: {strBuffer}");

barraider-sdtools/Payloads/DialPressPayload.cs renamed to barraider-sdtools/Payloads/DialPayload.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
namespace BarRaider.SdTools.Payloads
88
{
99
/// <summary>
10-
/// Payload received when a dial is pressed or unpressed
10+
/// Payload received when a dial is down or up
1111
/// </summary>
12-
public class DialPressPayload
12+
public class DialPayload
1313
{
1414
/// <summary>
1515
/// Controller which issued the event
@@ -29,30 +29,22 @@ public class DialPressPayload
2929
[JsonProperty("coordinates")]
3030
public KeyCoordinates Coordinates { get; private set; }
3131

32-
/// <summary>
33-
/// Boolean whether the dial is currently pressed or not
34-
/// </summary>
35-
[JsonProperty("pressed")]
36-
public bool IsDialPressed { get; private set; }
37-
3832
/// <summary>
3933
/// Constructor
4034
/// </summary>
4135
/// <param name="coordinates"></param>
4236
/// <param name="settings"></param>
4337
/// <param name="controller"></param>
44-
/// <param name="isDialPressed"></param>
45-
public DialPressPayload(KeyCoordinates coordinates, JObject settings, string controller, bool isDialPressed)
38+
public DialPayload(KeyCoordinates coordinates, JObject settings, string controller)
4639
{
4740
Coordinates = coordinates;
4841
Settings = settings;
4942
Controller = controller;
50-
IsDialPressed = isDialPressed;
5143
}
5244

5345
/// <summary>
5446
/// Default constructor for serialization
5547
/// </summary>
56-
public DialPressPayload() { }
48+
public DialPayload() { }
5749
}
5850
}

0 commit comments

Comments
 (0)