Skip to content

Commit 06a69df

Browse files
authored
Merge pull request #64 from BarRaider/stream-deck-plus-sdk
Stream Deck+ SDK support
2 parents 69cb52a + 0622f5f commit 06a69df

27 files changed

Lines changed: 1710 additions & 253 deletions
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
using BarRaider.SdTools.Payloads;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace BarRaider.SdTools
7+
{
8+
/// <summary>
9+
/// Main abstract class your plugin should derive from for dials (not keys)
10+
/// For keys use the KeyBase or KeyAndEncoderBase
11+
/// Holds implementation for all the basic functions
12+
/// If you're missing an event, you can register to it from the Connection.StreamDeckConnection object
13+
/// </summary>
14+
public abstract class EncoderBase : IEncoderPlugin
15+
{
16+
/// <summary>
17+
/// Called when the dial is rotated
18+
/// </summary>
19+
public abstract void DialRotate(DialRotatePayload payload);
20+
21+
/// <summary>
22+
/// Called when the Dial is pressed or released
23+
/// </summary>
24+
public abstract void DialPress(DialPressPayload payload);
25+
26+
/// <summary>
27+
/// Called when the touchpad (above the dials) is pressed
28+
/// </summary>
29+
public abstract void TouchPress(TouchpadPressPayload payload);
30+
31+
/// <summary>
32+
/// Called when the PropertyInspector has new settings
33+
/// </summary>
34+
/// <param name="payload"></param>
35+
public abstract void ReceivedSettings(ReceivedSettingsPayload payload);
36+
37+
/// <summary>
38+
/// Called when GetGlobalSettings is called.
39+
/// </summary>
40+
/// <param name="payload"></param>
41+
public abstract void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload);
42+
43+
/// <summary>
44+
/// Called every second
45+
/// Logic for displaying title/image can go here
46+
/// </summary>
47+
public abstract void OnTick();
48+
49+
/// <summary>
50+
/// Abstract method Called when the plugin is disposed
51+
/// </summary>
52+
public abstract void Dispose();
53+
54+
/// <summary>
55+
/// Main iDisposable Dispose function
56+
/// </summary>
57+
public void Destroy()
58+
{
59+
Dispose();
60+
if (Connection != null)
61+
{
62+
Connection.Dispose();
63+
}
64+
}
65+
66+
/// <summary>
67+
/// Connection object which handles your communication with the Stream Deck app
68+
/// </summary>
69+
protected ISDConnection Connection { get; private set; }
70+
71+
/// <summary>
72+
/// Constructor for PluginBase. Receives the communication and plugin settings
73+
/// Note that the settings object is not used by the base and should be consumed by the deriving class.
74+
/// Usually, a private class inside the deriving class is created which stores the settings
75+
/// Example for settings usage:
76+
/// * if (payload.Settings == null || payload.Settings.Count == 0)
77+
/// * {
78+
/// * // Create default settings
79+
/// * }
80+
/// * else
81+
/// * {
82+
/// this.settings = payload.Settings.ToObject();
83+
/// * }
84+
///
85+
/// </summary>
86+
/// <param name="connection">Communication module with Stream Deck</param>
87+
/// <param name="payload">Plugin settings - NOTE: Not used in base class, should be consumed by deriving class</param>
88+
#pragma warning disable IDE0060 // Remove unused parameter
89+
public EncoderBase(ISDConnection connection, InitialPayload payload)
90+
#pragma warning restore IDE0060 // Remove unused parameter
91+
{
92+
Connection = connection;
93+
}
94+
}
95+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace BarRaider.SdTools
6+
{
7+
public interface ICommonPluginFunctions : IDisposable
8+
{
9+
/// <summary>
10+
/// Called when the PropertyInspector has new settings
11+
/// </summary>
12+
/// <param name="payload"></param>
13+
void ReceivedSettings(ReceivedSettingsPayload payload);
14+
15+
/// <summary>
16+
/// Called when GetGlobalSettings is called.
17+
/// </summary>
18+
/// <param name="payload"></param>
19+
void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload);
20+
21+
/// <summary>
22+
/// Called every second
23+
/// Logic for displaying title/image can go here
24+
/// </summary>
25+
void OnTick();
26+
27+
/// <summary>
28+
/// Internal function used by StreamDeckTools to prevent memory leaks
29+
/// </summary>
30+
void Destroy();
31+
}
32+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using BarRaider.SdTools.Payloads;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Text;
5+
6+
namespace BarRaider.SdTools
7+
{
8+
/// <summary>
9+
/// Interface used to capture dial/encoder events
10+
/// </summary>
11+
public interface IEncoderPlugin : ICommonPluginFunctions
12+
{
13+
/// <summary>
14+
/// Called when the dial is rotated
15+
/// </summary>
16+
void DialRotate(DialRotatePayload payload);
17+
18+
/// <summary>
19+
/// Called when the Dial is pressed or released
20+
/// </summary>
21+
void DialPress(DialPressPayload payload);
22+
23+
/// <summary>
24+
/// Called when the touchpad (above the dials) is pressed
25+
/// </summary>
26+
void TouchPress(TouchpadPressPayload payload);
27+
}
28+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace BarRaider.SdTools
6+
{
7+
/// <summary>
8+
/// Interface used to capture key events
9+
/// </summary>
10+
public interface IKeypadPlugin : ICommonPluginFunctions
11+
{
12+
void KeyPressed(KeyPayload payload);
13+
14+
/// <summary>
15+
/// Called when a Stream Deck key is released
16+
/// </summary>
17+
void KeyReleased(KeyPayload payload);
18+
}
19+
}

barraider-sdtools/Backend/ISDConnection.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,20 @@ public interface ISDConnection : IDisposable
185185
/// <returns></returns>
186186
Task SetStateAsync(uint state);
187187

188+
/// <summary>
189+
/// Sets the values of touchpad layouts items
190+
/// </summary>
191+
/// <param name="dictKeyValue">Dictionary holding the layout item keys and values you want to change</param>
192+
/// <returns></returns>
193+
Task SetFeedbackAsync(Dictionary<string, string> dictKeyValue);
194+
195+
/// <summary>
196+
/// Sets the value of a single touchpad layout item
197+
/// </summary>
198+
/// <param name="dictKeyValues"></param>
199+
/// <returns></returns>
200+
Task SetFeedbackAsync(string layoutItemKey, string value);
201+
188202
#endregion
189203

190204
/// <summary>
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using BarRaider.SdTools.Payloads;
7+
using Newtonsoft.Json.Linq;
8+
9+
namespace BarRaider.SdTools
10+
{
11+
12+
/// <summary>
13+
/// Main abstract class your plugin should derive from for keys (not dials)
14+
/// For dials use the EncoderBase or KeyAndEncoderBase
15+
/// Holds implementation for all the basic functions
16+
/// If you're missing an event, you can register to it from the Connection.StreamDeckConnection object
17+
/// </summary>
18+
public abstract class KeyAndEncoderBase : IKeypadPlugin, IEncoderPlugin
19+
{
20+
/// <summary>
21+
/// Called when the dial is rotated
22+
/// </summary>
23+
public abstract void DialRotate(DialRotatePayload payload);
24+
25+
/// <summary>
26+
/// Called when the Dial is pressed or released
27+
/// </summary>
28+
public abstract void DialPress(DialPressPayload payload);
29+
30+
/// <summary>
31+
/// Called when the touchpad (above the dials) is pressed
32+
/// </summary>
33+
public abstract void TouchPress(TouchpadPressPayload payload);
34+
35+
/// <summary>
36+
/// Called when a Stream Deck key is pressed
37+
/// </summary>
38+
public abstract void KeyPressed(KeyPayload payload);
39+
40+
/// <summary>
41+
/// Called when a Stream Deck key is released
42+
/// </summary>
43+
public abstract void KeyReleased(KeyPayload payload);
44+
45+
/// <summary>
46+
/// Called when the PropertyInspector has new settings
47+
/// </summary>
48+
/// <param name="payload"></param>
49+
public abstract void ReceivedSettings(ReceivedSettingsPayload payload);
50+
51+
/// <summary>
52+
/// Called when GetGlobalSettings is called.
53+
/// </summary>
54+
/// <param name="payload"></param>
55+
public abstract void ReceivedGlobalSettings(ReceivedGlobalSettingsPayload payload);
56+
57+
/// <summary>
58+
/// Called every second
59+
/// Logic for displaying title/image can go here
60+
/// </summary>
61+
public abstract void OnTick();
62+
63+
/// <summary>
64+
/// Abstract method Called when the plugin is disposed
65+
/// </summary>
66+
public abstract void Dispose();
67+
68+
/// <summary>
69+
/// Main iDisposable Dispose function
70+
/// </summary>
71+
public void Destroy()
72+
{
73+
Dispose();
74+
if (Connection != null)
75+
{
76+
Connection.Dispose();
77+
}
78+
}
79+
80+
/// <summary>
81+
/// Connection object which handles your communication with the Stream Deck app
82+
/// </summary>
83+
protected ISDConnection Connection { get; private set; }
84+
85+
/// <summary>
86+
/// Constructor for PluginBase. Receives the communication and plugin settings
87+
/// Note that the settings object is not used by the base and should be consumed by the deriving class.
88+
/// Usually, a private class inside the deriving class is created which stores the settings
89+
/// Example for settings usage:
90+
/// * if (payload.Settings == null || payload.Settings.Count == 0)
91+
/// * {
92+
/// * // Create default settings
93+
/// * }
94+
/// * else
95+
/// * {
96+
/// this.settings = payload.Settings.ToObject();
97+
/// * }
98+
///
99+
/// </summary>
100+
/// <param name="connection">Communication module with Stream Deck</param>
101+
/// <param name="payload">Plugin settings - NOTE: Not used in base class, should be consumed by deriving class</param>
102+
#pragma warning disable IDE0060 // Remove unused parameter
103+
public KeyAndEncoderBase(ISDConnection connection, InitialPayload payload)
104+
#pragma warning restore IDE0060 // Remove unused parameter
105+
{
106+
Connection = connection;
107+
}
108+
}
109+
}

0 commit comments

Comments
 (0)