diff --git a/README.md b/README.md index 30d7a60..557641d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,6 @@ # Stream Deck+ Support Instead of `PluginBase`, Derive from either `KeypadBase` (if you don't support dials), `EncoderBase` (for only dials), `KeyAndEncoderBase` (for both keys and dials) - # Getting Started Introducing our new [wiki](https://github.com/BarRaider/streamdeck-tools/wiki) packed with usage instructions, examples and more. @@ -34,6 +33,10 @@ Introducing our new [wiki](https://github.com/BarRaider/streamdeck-tools/wiki) p # Change Log +### Version 6.1 +- Support for new `DialDown` and `DialUp` events. +- Removed support for deprecated `DialPress` event + ### Version 6.0 1. Merged streamdeck-client-csharp package into library to allow better logging of errors 2. Added support for SD+ SDK diff --git a/barraider-sdtools/Backend/EncoderBase.cs b/barraider-sdtools/Backend/EncoderBase.cs index 02a065e..f2c14a0 100644 --- a/barraider-sdtools/Backend/EncoderBase.cs +++ b/barraider-sdtools/Backend/EncoderBase.cs @@ -19,9 +19,14 @@ public abstract class EncoderBase : IEncoderPlugin public abstract void DialRotate(DialRotatePayload payload); /// - /// Called when the Dial is pressed or released + /// Called when the Dial is pressed /// - public abstract void DialPress(DialPressPayload payload); + public abstract void DialDown(DialPayload payload); + + /// + /// Called when the Dial is released + /// + public abstract void DialUp(DialPayload payload); /// /// Called when the touchpad (above the dials) is pressed diff --git a/barraider-sdtools/Backend/IEncoderPlugin.cs b/barraider-sdtools/Backend/IEncoderPlugin.cs index 592471a..0f217fd 100644 --- a/barraider-sdtools/Backend/IEncoderPlugin.cs +++ b/barraider-sdtools/Backend/IEncoderPlugin.cs @@ -16,9 +16,14 @@ public interface IEncoderPlugin : ICommonPluginFunctions void DialRotate(DialRotatePayload payload); /// - /// Called when the Dial is pressed or released + /// Called when the Dial is pressed /// - void DialPress(DialPressPayload payload); + void DialDown(DialPayload payload); + + /// + /// Called when the Dial is released + /// + void DialUp(DialPayload payload); /// /// Called when the touchpad (above the dials) is pressed diff --git a/barraider-sdtools/Backend/KeyAndEncoderBase.cs b/barraider-sdtools/Backend/KeyAndEncoderBase.cs index d701ea8..033ce1c 100644 --- a/barraider-sdtools/Backend/KeyAndEncoderBase.cs +++ b/barraider-sdtools/Backend/KeyAndEncoderBase.cs @@ -23,9 +23,14 @@ public abstract class KeyAndEncoderBase : IKeypadPlugin, IEncoderPlugin public abstract void DialRotate(DialRotatePayload payload); /// - /// Called when the Dial is pressed or released + /// Called when the Dial is pressed /// - public abstract void DialPress(DialPressPayload payload); + public abstract void DialDown(DialPayload payload); + + /// + /// Called when the Dial is released + /// + public abstract void DialUp(DialPayload payload); /// /// Called when the touchpad (above the dials) is pressed diff --git a/barraider-sdtools/Backend/PluginContainer.cs b/barraider-sdtools/Backend/PluginContainer.cs index 927a4c1..2f11284 100644 --- a/barraider-sdtools/Backend/PluginContainer.cs +++ b/barraider-sdtools/Backend/PluginContainer.cs @@ -47,7 +47,8 @@ public void Run(StreamDeckOptions options) connection.OnWillAppear += Connection_OnWillAppear; connection.OnWillDisappear += Connection_OnWillDisappear; connection.OnDialRotate += Connection_OnDialRotate; - connection.OnDialPress += Connection_OnDialPress; + connection.OnDialDown += Connection_OnDialDown; + connection.OnDialUp += Connection_OnDialUp; connection.OnTouchpadPress += Connection_OnTouchpadPress; // Settings changed @@ -285,7 +286,38 @@ private async void Connection_OnTouchpadPress(object sender, SDEventReceivedEven } } - private async void Connection_OnDialPress(object sender, SDEventReceivedEventArgs e) + // Dial Up + + private async void Connection_OnDialUp(object sender, SDEventReceivedEventArgs e) + { + await instancesLock.WaitAsync(); + try + { +#if DEBUG + Logger.Instance.LogMessage(TracingLevel.DEBUG, $"DialPress: Context: {e.Event.Context} Action: {e.Event.Action} Payload: {e.Event.Payload?.ToStringEx()}"); +#endif + + if (instances.ContainsKey(e.Event.Context)) + { + DialPayload payload = new DialPayload(e.Event.Payload.Coordinates, e.Event.Payload.Settings, e.Event.Payload.Controller); + if (instances[e.Event.Context] is IEncoderPlugin plugin) + { + plugin.DialUp(payload); + } + else + { + Logger.Instance.LogMessage(TracingLevel.ERROR, $"DialDown General Error: Could not convert {e.Event.Context} to IEncoderPlugin"); + } + } + } + finally + { + instancesLock.Release(); + } + } + + // Dial Down + private async void Connection_OnDialDown(object sender, SDEventReceivedEventArgs e) { await instancesLock.WaitAsync(); try @@ -296,14 +328,14 @@ private async void Connection_OnDialPress(object sender, SDEventReceivedEventArg if (instances.ContainsKey(e.Event.Context)) { - DialPressPayload payload = new DialPressPayload(e.Event.Payload.Coordinates, e.Event.Payload.Settings, e.Event.Payload.Controller, e.Event.Payload.IsDialPressed); + DialPayload payload = new DialPayload(e.Event.Payload.Coordinates, e.Event.Payload.Settings, e.Event.Payload.Controller); if (instances[e.Event.Context] is IEncoderPlugin plugin) { - plugin.DialPress(payload); + plugin.DialDown(payload); } else { - Logger.Instance.LogMessage(TracingLevel.ERROR, $"DialPress General Error: Could not convert {e.Event.Context} to IEncoderPlugin"); + Logger.Instance.LogMessage(TracingLevel.ERROR, $"DialDown General Error: Could not convert {e.Event.Context} to IEncoderPlugin"); } } } diff --git a/barraider-sdtools/Communication/SDEvents/BaseEvent.cs b/barraider-sdtools/Communication/SDEvents/BaseEvent.cs index 9798101..a6fabd7 100644 --- a/barraider-sdtools/Communication/SDEvents/BaseEvent.cs +++ b/barraider-sdtools/Communication/SDEvents/BaseEvent.cs @@ -28,6 +28,8 @@ internal static class EventTypes public const string SendToPlugin = "sendToPlugin"; public const string DialRotate = "dialRotate"; public const string DialPress = "dialPress"; + public const string DialDown = "dialDown"; + public const string DialUp = "dialUp"; public const string TouchpadPress = "touchTap"; } @@ -63,7 +65,8 @@ public abstract class BaseEvent { EventTypes.SendToPlugin, typeof(SendToPluginEvent) }, { EventTypes.DialRotate, typeof(DialRotateEvent) }, - { EventTypes.DialPress, typeof(DialPressEvent) }, + { EventTypes.DialDown, typeof(DialDownEvent) }, + { EventTypes.DialUp, typeof(DialUpEvent) }, { EventTypes.TouchpadPress, typeof(TouchpadPressEvent) }, }; diff --git a/barraider-sdtools/Communication/SDEvents/DialPressEvent.cs b/barraider-sdtools/Communication/SDEvents/DialDownEvent.cs similarity index 80% rename from barraider-sdtools/Communication/SDEvents/DialPressEvent.cs rename to barraider-sdtools/Communication/SDEvents/DialDownEvent.cs index 669f305..084e72b 100644 --- a/barraider-sdtools/Communication/SDEvents/DialPressEvent.cs +++ b/barraider-sdtools/Communication/SDEvents/DialDownEvent.cs @@ -7,9 +7,9 @@ namespace BarRaider.SdTools.Communication.SDEvents { /// - /// Payload for Dial press/unpress event + /// Payload for Dial down event /// - public class DialPressEvent : BaseEvent + public class DialDownEvent : BaseEvent { /// /// Action Name @@ -30,9 +30,9 @@ public class DialPressEvent : BaseEvent public string Device { get; private set; } /// - /// Information on dial rotation + /// Information on dial status /// [JsonProperty("payload")] - public DialPressPayload Payload { get; private set; } + public DialPayload Payload { get; private set; } } } diff --git a/barraider-sdtools/Communication/SDEvents/DialUpEvent.cs b/barraider-sdtools/Communication/SDEvents/DialUpEvent.cs new file mode 100644 index 0000000..70fde13 --- /dev/null +++ b/barraider-sdtools/Communication/SDEvents/DialUpEvent.cs @@ -0,0 +1,38 @@ +using BarRaider.SdTools.Payloads; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Text; + +namespace BarRaider.SdTools.Communication.SDEvents +{ + /// + /// Payload for Dial up event + /// + public class DialUpEvent : BaseEvent + { + /// + /// Action Name + /// + [JsonProperty("action")] + public string Action { get; private set; } + + /// + /// Unique Action UUID + /// + [JsonProperty("context")] + public string Context { get; private set; } + + /// + /// Device UUID key was pressed on + /// + [JsonProperty("device")] + public string Device { get; private set; } + + /// + /// Information on dial status + /// + [JsonProperty("payload")] + public DialPayload Payload { get; private set; } + } +} diff --git a/barraider-sdtools/Communication/StreamDeckConnection.cs b/barraider-sdtools/Communication/StreamDeckConnection.cs index 98e4c30..edafd47 100644 --- a/barraider-sdtools/Communication/StreamDeckConnection.cs +++ b/barraider-sdtools/Communication/StreamDeckConnection.cs @@ -130,9 +130,14 @@ public class StreamDeckConnection public event EventHandler> OnDialRotate; /// - /// Raised when a dial is pressed or unpressed + /// Raised when a dial is down /// - public event EventHandler> OnDialPress; + public event EventHandler> OnDialDown; + + /// + /// Raised when a dial is up + /// + public event EventHandler> OnDialUp; /// /// Raised when the tochpad is pressed @@ -394,7 +399,9 @@ private async Task ReceiveAsync() case EventTypes.PropertyInspectorDidDisappear: OnPropertyInspectorDidDisappear?.Invoke(this, new SDEventReceivedEventArgs(evt as PropertyInspectorDidDisappearEvent)); break; case EventTypes.SendToPlugin: OnSendToPlugin?.Invoke(this, new SDEventReceivedEventArgs(evt as SendToPluginEvent)); break; case EventTypes.DialRotate: OnDialRotate?.Invoke(this, new SDEventReceivedEventArgs(evt as DialRotateEvent)); break; - case EventTypes.DialPress: OnDialPress?.Invoke(this, new SDEventReceivedEventArgs(evt as DialPressEvent)); break; + case EventTypes.DialDown: OnDialDown?.Invoke(this, new SDEventReceivedEventArgs(evt as DialDownEvent)); break; + case EventTypes.DialUp: OnDialUp?.Invoke(this, new SDEventReceivedEventArgs(evt as DialUpEvent)); break; + case EventTypes.DialPress: /* Ignoring deprecated Stream Deck event;*/ break; case EventTypes.TouchpadPress: OnTouchpadPress?.Invoke(this, new SDEventReceivedEventArgs(evt as TouchpadPressEvent)); break; default: Logger.Instance.LogMessage(TracingLevel.WARN, $"{this.GetType()} Unsupported Stream Deck event: {strBuffer}"); diff --git a/barraider-sdtools/Payloads/DialPressPayload.cs b/barraider-sdtools/Payloads/DialPayload.cs similarity index 68% rename from barraider-sdtools/Payloads/DialPressPayload.cs rename to barraider-sdtools/Payloads/DialPayload.cs index 1b5ee97..abbdfb4 100644 --- a/barraider-sdtools/Payloads/DialPressPayload.cs +++ b/barraider-sdtools/Payloads/DialPayload.cs @@ -7,9 +7,9 @@ namespace BarRaider.SdTools.Payloads { /// - /// Payload received when a dial is pressed or unpressed + /// Payload received when a dial is down or up /// - public class DialPressPayload + public class DialPayload { /// /// Controller which issued the event @@ -29,30 +29,22 @@ public class DialPressPayload [JsonProperty("coordinates")] public KeyCoordinates Coordinates { get; private set; } - /// - /// Boolean whether the dial is currently pressed or not - /// - [JsonProperty("pressed")] - public bool IsDialPressed { get; private set; } - /// /// Constructor /// /// /// /// - /// - public DialPressPayload(KeyCoordinates coordinates, JObject settings, string controller, bool isDialPressed) + public DialPayload(KeyCoordinates coordinates, JObject settings, string controller) { Coordinates = coordinates; Settings = settings; Controller = controller; - IsDialPressed = isDialPressed; } /// /// Default constructor for serialization /// - public DialPressPayload() { } + public DialPayload() { } } } diff --git a/barraider-sdtools/Tools/PayloadExtensionMethods.cs b/barraider-sdtools/Tools/PayloadExtensionMethods.cs index d76068a..34a4910 100644 --- a/barraider-sdtools/Tools/PayloadExtensionMethods.cs +++ b/barraider-sdtools/Tools/PayloadExtensionMethods.cs @@ -52,13 +52,13 @@ internal static string ToStringEx(this DialRotatePayload drp) return $"Controller: {drp.Controller} Ticks: {drp.Ticks} Coordinates: ({drp.Coordinates?.Row},{drp.Coordinates?.Column}) Settings: {drp.Settings}"; } - internal static string ToStringEx(this DialPressPayload dpp) + internal static string ToStringEx(this DialPayload dpp) { if (dpp == null) { return "DialPressPayload is null!"; } - return $"Controller: {dpp.Controller} IsDialPressed: {dpp.IsDialPressed} Coordinates: ({dpp.Coordinates?.Row},{dpp.Coordinates?.Column}) Settings: {dpp.Settings}"; + return $"Controller: {dpp.Controller} Coordinates: ({dpp.Coordinates?.Row},{dpp.Coordinates?.Column}) Settings: {dpp.Settings}"; } internal static string ToStringEx(this TouchpadPressPayload tpp) diff --git a/barraider-sdtools/barraider-sdtools.csproj b/barraider-sdtools/barraider-sdtools.csproj index 7f6e3cd..5819c27 100644 --- a/barraider-sdtools/barraider-sdtools.csproj +++ b/barraider-sdtools/barraider-sdtools.csproj @@ -16,14 +16,10 @@ Feel free to contact me for more information: https://barraider.comStreamDeck Elgato Library Plugin Stream Deck Toolkit StreamDeck-Tools - 6.0.0.0 + 6.1.0.0 6.0.0.0 - 6.0 - 6.0 - 1. Merged streamdeck-client-csharp package into library to allow better logging of errors - 2. Added support for SD+ SDK -3. Increased timeout of connection to Stream Deck due to the Stream Deck taking longer than before to reply on load -4. Added error catching to prevent 3rd party plugin exception to impact communication - + 6.1.0 + 6.1.0 - Support for new DialDown and DialUp events. Removed support for deprecated DialPress event BarRaider.SdTools StreamDeckTools BRLogo_460.png diff --git a/barraider-sdtools/streamdeck-tools.xml b/barraider-sdtools/streamdeck-tools.xml index b353d09..40f7489 100644 --- a/barraider-sdtools/streamdeck-tools.xml +++ b/barraider-sdtools/streamdeck-tools.xml @@ -40,9 +40,14 @@ Called when the dial is rotated - + - Called when the Dial is pressed or released + Called when the Dial is pressed + + + + + Called when the Dial is released @@ -140,9 +145,14 @@ Called when the dial is rotated - + - Called when the Dial is pressed or released + Called when the Dial is pressed + + + + + Called when the Dial is released @@ -396,9 +406,14 @@ Called when the dial is rotated - + + + Called when the Dial is pressed + + + - Called when the Dial is pressed or released + Called when the Dial is released @@ -946,29 +961,29 @@ UUID of device that was disconnected - + - Payload for Dial press/unpress event + Payload for Dial down event - + Action Name - + Unique Action UUID - + Device UUID key was pressed on - + - Information on dial rotation + Information on dial status @@ -996,6 +1011,31 @@ Information on dial rotation + + + Payload for Dial up event + + + + + Action Name + + + + + Unique Action UUID + + + + + Device UUID key was pressed on + + + + + Information on dial status + + Payload for DidReceiveGlobalSettings Event @@ -1171,27 +1211,27 @@ Title settings - + Payload for touchpad press - + Action Name - + Unique Action UUID - + Device UUID key was pressed on - + Information on touchpad press @@ -1371,9 +1411,14 @@ Raised when a dial is rotated - + - Raised when a dial is pressed or unpressed + Raised when a dial is down + + + + + Raised when a dial is up @@ -1624,41 +1669,35 @@ - + - Payload received when a dial is pressed or unpressed + Payload received when a dial is down or up - + Controller which issued the event - + Current event settings - + Coordinates of key on the stream deck - - - Boolean whether the dial is currently pressed or not - - - + Constructor - - + Default constructor for serialization