Skip to content

Commit 6e7b725

Browse files
authored
Merge pull request #4 from dend/december-2024-update
`0.0.4` Update
2 parents 8edf357 + 142ac56 commit 6e7b725

25 files changed

+734
-228
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,3 +351,6 @@ MigrationBackup/
351351

352352
# Custom files defined by me
353353
*.xml
354+
355+
# Launch settings
356+
launchSettings.json

README.md

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1-
<div align="center">
2-
<img alt="Piglet icon" src="images/logo.png" width="200" height="200" />
3-
<h1>🌊 DeckSurf SDK</h1>
4-
<p>
5-
<b>Unofficial Software Development Kit for your Stream Deck.</b>
6-
</p>
7-
<br>
8-
<br>
9-
<br>
10-
</div>
1+
![DeckSurf SDK Icon](images/logo-small.webp)
112

12-
[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://den.dev/ukraine)
3+
# 🌊 DeckSurf SDK for .NET
134

14-
For the DeckSurf tooling (_CLI and plugins_), refer to the [DeckSurf repository](https://github.com/dend/DeckSurf).
5+
_**Unofficial Software Development Kit for your Stream Deck, built in C# for the .NET platform.**_
6+
7+
>[!NOTE]
8+
>For the DeckSurf tooling (_CLI and plugins_), refer to the [DeckSurf repository](https://github.com/dend/DeckSurf).
9+
10+
![NuGet Version](https://img.shields.io/nuget/v/DeckSurf.SDK)
1511

1612
## About
1713

18-
The SDK is used to manage Stream Deck devices and create plugins for the [DeckSurf tools](https://github.com/dend/DeckSurf). It is completely independent of the Elgato software and/or libraries and can be used as a completely standalone library.
14+
The DeckSurf SDK is used to manage Stream Deck devices and create plugins for [DeckSurf tools](https://github.com/dend/DeckSurf). It is completely independent of the Elgato software and/or libraries and can be used as a standalone library.
15+
16+
## Installation
17+
18+
You can use the SDK by installing it [from NuGet](https://www.nuget.org/packages/DeckSurf.SDK):
19+
20+
```powershell
21+
dotnet add package DeckSurf.SDK
22+
```
23+
24+
## Supported devices
25+
26+
Support for the following devices is implemented:
27+
28+
- Stream Deck XL
29+
- Stream Deck Plus
30+
31+
Future support is coming for:
32+
33+
- Stream Deck Neo
34+
- Stream Deck Mini
35+
- Stream Deck MK.2
36+
- Stream Deck Original V2
37+
38+
## Documentation
39+
40+
Refer to [`https://docs.deck.surf`](https://docs.deck.surf/) for tutorials and SDK documentation.
1941

2042
## Platform compatibility
2143

images/logo-small.webp

9.23 KB
Loading

src/DeckSurf.SDK.StartBoard/DeckSurf.SDK.StartBoard.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net9.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

src/DeckSurf.SDK.StartBoard/Program.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,41 @@ namespace DeckSurf.SDK.StartBoard
1010
{
1111
class Program
1212
{
13-
1413
static void Main(string[] args)
1514
{
1615
var exitSignal = new ManualResetEvent(false);
1716
var devices = DeviceManager.GetDeviceList();
1817

18+
Console.WriteLine("The following Stream Deck devices are connected:");
19+
20+
foreach (var connectedDevice in devices)
21+
{
22+
Console.WriteLine(connectedDevice.Name);
23+
}
24+
1925
var device = ((List<ConnectedDevice>)devices)[0];
20-
//device.OnButtonPress += Device_OnButtonPress;
21-
//device.InitializeDevice();
26+
device.StartListening();
27+
device.OnButtonPress += Device_OnButtonPress;
28+
29+
byte[] testImage = File.ReadAllBytes(args[0]);
30+
31+
var image = ImageHelpers.ResizeImage(testImage, device.ScreenWidth, device.ScreenHeight, device.IsButtonImageFlipRequired);
32+
33+
device.SetScreen(image, 250, device.ScreenWidth, device.ScreenHeight);
34+
35+
var keyImage = ImageHelpers.ResizeImage(testImage, device.ButtonResolution, device.ButtonResolution, device.IsButtonImageFlipRequired);
36+
device.SetKey(1, keyImage);
2237

23-
byte[] testImage = File.ReadAllBytes("G:\\run.jpg");
24-
var image = ImageHelpers.ResizeImage(testImage, DeviceConstants.XLButtonSize, DeviceConstants.XLButtonSize);
25-
device.SetKey(1, image);
26-
//device.SetBrightness(29);
27-
//device.ClearPanel();
38+
device.SetBrightness(29);
39+
//device.ClearButtons();
2840

2941
Console.WriteLine("Done");
3042
exitSignal.WaitOne();
3143
}
3244

3345
private static void Device_OnButtonPress(object source, ButtonPressEventArgs e)
3446
{
35-
Console.WriteLine(e.Id);
47+
Console.WriteLine($"Button with ID {e.Id} was pressed. It's identified as {e.ButtonKind}. Event is {e.EventKind}. If this is a touch screen, coordinates are {e.TapCoordinates.X} and {e.TapCoordinates.Y}. Is knob rotated: {e.IsKnobRotating}. Rotation direction: {e.KnobRotationDirection}.");
3648
}
3749
}
3850
}

src/DeckSurf.SDK.sln

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.31321.278
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.12.35521.163 d17.12
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeckSurf.SDK", "DeckSurf.SDK\DeckSurf.SDK.csproj", "{F1BBE555-6029-4C52-B369-9AEFE2EDB6A9}"
77
EndProject
@@ -16,6 +16,7 @@ Global
1616
EndGlobalSection
1717
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1818
{F1BBE555-6029-4C52-B369-9AEFE2EDB6A9}.Debug|Any CPU.ActiveCfg = Debug|x64
19+
{F1BBE555-6029-4C52-B369-9AEFE2EDB6A9}.Debug|Any CPU.Build.0 = Debug|x64
1920
{F1BBE555-6029-4C52-B369-9AEFE2EDB6A9}.Debug|x64.ActiveCfg = Debug|x64
2021
{F1BBE555-6029-4C52-B369-9AEFE2EDB6A9}.Debug|x64.Build.0 = Debug|x64
2122
{F1BBE555-6029-4C52-B369-9AEFE2EDB6A9}.Release|Any CPU.ActiveCfg = Release|x64

src/DeckSurf.SDK/Core/DeviceConstants.cs

Lines changed: 0 additions & 85 deletions
This file was deleted.

src/DeckSurf.SDK/Core/DeviceManager.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
// Den Delimarsky licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using DeckSurf.SDK.Models;
6-
using DeckSurf.SDK.Models.Devices;
7-
using HidSharp;
85
using System;
96
using System.Collections.Generic;
107
using System.Linq;
8+
using DeckSurf.SDK.Models;
9+
using DeckSurf.SDK.Models.Devices;
10+
using HidSharp;
1111

1212
namespace DeckSurf.SDK.Core
1313
{
@@ -16,7 +16,9 @@ namespace DeckSurf.SDK.Core
1616
/// </summary>
1717
public class DeviceManager
1818
{
19-
private static readonly int SupportedVid = 4057;
19+
#pragma warning disable SA1010 // Opening square brackets should be spaced correctly
20+
private static readonly int[] SupportedVids = [0x0FD9];
21+
#pragma warning restore SA1010 // Opening square brackets should be spaced correctly
2022

2123
/// <summary>
2224
/// Return a list of connected Stream Deck devices supported by DeckSurf.
@@ -36,7 +38,13 @@ public static IEnumerable<ConnectedDevice> GetDeviceList()
3638
{
3739
case DeviceModel.XL:
3840
{
39-
connectedDevices.Add(new StreamDeckXL(device.VendorID, device.ProductID, device.DevicePath, device.GetFriendlyName(), (DeviceModel)device.ProductID));
41+
connectedDevices.Add(new StreamDeckXL(device.VendorID, device.ProductID, device.DevicePath, device.GetFriendlyName()));
42+
break;
43+
}
44+
45+
case DeviceModel.PLUS:
46+
{
47+
connectedDevices.Add(new StreamDeckPlus(device.VendorID, device.ProductID, device.DevicePath, device.GetFriendlyName()));
4048
break;
4149
}
4250

@@ -56,7 +64,7 @@ public static IEnumerable<ConnectedDevice> GetDeviceList()
5664
}
5765

5866
/// <summary>
59-
/// Gets a connected Stream Deck device based on a pre-defined configuration profiles.
67+
/// Gets a connected Stream Deck device based on a pre-defined configuration profile.
6068
/// </summary>
6169
/// <param name="profile">An instance representing the pre-defined configuration profile.</param>
6270
/// <returns>If the call is successful, returns a Stream Deck device.</returns>
@@ -92,7 +100,7 @@ public static ConnectedDevice SetupDevice(ConfigurationProfile profile)
92100
/// <returns>True if device is supported, false if not.</returns>
93101
public static bool IsSupported(int vid, int pid)
94102
{
95-
if (vid == SupportedVid && Enum.IsDefined(typeof(DeviceModel), (byte)pid))
103+
if (SupportedVids.Contains(vid) && Enum.IsDefined(typeof(DeviceModel), (byte)pid))
96104
{
97105
return true;
98106
}

src/DeckSurf.SDK/DeckSurf.SDK.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net5.0</TargetFramework>
4+
<TargetFramework>net9.0</TargetFramework>
55
<Platforms>x64</Platforms>
66
<Company>Den Delimarsky</Company>
77
<Authors>Den Delimarsky</Authors>
8-
<Version>0.0.3</Version>
8+
<Version>0.0.4</Version>
99
<ApplicationIcon>piglet.ico</ApplicationIcon>
1010
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1111
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1212
<GenerateDocumentationFile>true</GenerateDocumentationFile>
13-
<Copyright>Copyright © 2021 by Den Delimarsky. All rights reserved.</Copyright>
13+
<Copyright>Copyright © 2024 by Den Delimarsky. All rights reserved.</Copyright>
1414
<PackageProjectUrl>https://deck.surf</PackageProjectUrl>
1515
<PackageIcon>logo.png</PackageIcon>
1616
<PackageIconUrl />
@@ -22,9 +22,9 @@
2222
<RepositoryUrl>https://github.com/dend/decksurf-sdk</RepositoryUrl>
2323
<PackageTags>streamdeck,sdk,decksurf,hid,buttons</PackageTags>
2424
<NeutralLanguage>en-US</NeutralLanguage>
25-
<AssemblyVersion>0.0.3.0</AssemblyVersion>
26-
<FileVersion>0.0.3.0</FileVersion>
27-
<Description>Open-source package to manager your Stream Deck device from a .NET project.</Description>
25+
<AssemblyVersion>0.0.4.0</AssemblyVersion>
26+
<FileVersion>0.0.4.0</FileVersion>
27+
<Description>Open-source SDK to manage your Stream Deck device from .NET.</Description>
2828
<RepositoryType>git</RepositoryType>
2929
</PropertyGroup>
3030

@@ -62,7 +62,7 @@
6262
<PrivateAssets>all</PrivateAssets>
6363
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6464
</PackageReference>
65-
<PackageReference Include="System.Drawing.Common" Version="6.0.0-preview.4.21253.7" />
65+
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
6666
</ItemGroup>
6767

6868
</Project>

src/DeckSurf.SDK/Models/ButtonEventKind.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,14 @@ namespace DeckSurf.SDK.Models
99
/// </summary>
1010
public enum ButtonEventKind
1111
{
12+
/// <summary>
13+
/// Button is pressed.
14+
/// </summary>
1215
DOWN = 0,
16+
17+
/// <summary>
18+
/// Button is released.
19+
/// </summary>
1320
UP = 1,
1421
}
1522
}

0 commit comments

Comments
 (0)