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

December 2024 Release #9

Open
wants to merge 3 commits 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
6 changes: 3 additions & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ jobs:
- uses: actions/checkout@v2

- name: Setup .NET Core SDK
uses: actions/setup-dotnet@v1.8.1
uses: actions/setup-dotnet@v4
with:
dotnet-version: 5.0.x
dotnet-version: 9.0.x

- name: Restore
run: dotnet restore

- name: Build
run: dotnet build --configuration Release --no-restore
run: dotnet build --configuration Release --no-restore
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://den.dev/ukraine)

## How It Works
## Setup & operation

To get started, it's necessary to create a new profile, with a set of commands that will be associated with a button on the Stream Deck. To do that, you can use the `write` command in the Piglet CLI.
### Creating a new profile

To get started, it's necessary to **create a new profile**, with a set of commands that will be associated with a button on the Stream Deck. To do that, you can use the `write` command in the Piglet CLI.

```bash
Usage:
Expand Down Expand Up @@ -47,7 +49,15 @@ The following arguments are used, and are required:
| `--action-args` or `-a` | Arguments to pass to the command being executed. This string is specific to each command. |
| `--profile` or `-p` | The name of the profile to be used. If no profile with a given name exists, a new one will be created. |

The created profile will be located in `%LOCALAPPDATA%\DenDev\{PROFILE_NAME}`. The settings are stored in a `profile.json` file within the profile folder.
The created profile will be located in `%LOCALAPPDATA%\Den.Dev\DeckSurf\{PROFILE_NAME}`. The settings are stored in a `profile.json` file within the profile folder.

### Listing existing devices

To list existing devices, run:

```powershell
deck list
```

## FAQ

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using DeckSurf.SDK.Core;
using DeckSurf.SDK.Interfaces;
using DeckSurf.SDK.Interfaces;
using DeckSurf.SDK.Models;
using DeckSurf.SDK.Util;
using System.Diagnostics;
Expand All @@ -23,11 +22,11 @@ public void ExecuteOnActivation(CommandMapping mappedCommand, ConnectedDevice ma
{
try
{
var icon = ImageHelpers.GetFileIcon(mappedCommand.CommandArguments, DeviceConstants.XLButtonSize, DeviceConstants.XLButtonSize, SIIGBF.SIIGBF_ICONONLY | SIIGBF.SIIGBF_CROPTOSQUARE);
var icon = ImageHelpers.GetFileIcon(mappedCommand.CommandArguments, mappedDevice.ButtonResolution, mappedDevice.ButtonResolution, SIIGBF.SIIGBF_ICONONLY | SIIGBF.SIIGBF_CROPTOSQUARE);
var byteContent = ImageHelpers.GetImageBuffer(icon);

// TODO: Make sure that this works beyond the XL model.
var resizedByteContent = ImageHelpers.ResizeImage(byteContent, DeviceConstants.XLButtonSize, DeviceConstants.XLButtonSize);
var resizedByteContent = ImageHelpers.ResizeImage(byteContent, mappedDevice.ButtonResolution, mappedDevice.ButtonResolution, mappedDevice.IsButtonImageFlipRequired);
mappedDevice.SetKey(mappedCommand.ButtonIndex, resizedByteContent);
}
catch
Expand Down
2 changes: 1 addition & 1 deletion src/DeckSurf/DeckSurf.Plugin.Barn/Commands/ShowCPUUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void ExecuteOnActivation(CommandMapping mappedCommand, ConnectedDevice ma
cpuUsageTimer.Elapsed += (s, e) =>
{
var randomIconFromText = IconGenerator.GenerateTestImageFromText(GetCPUUsage().ToString() + "%", new Font("Bahnschrift", 94), Color.Red, Color.Black);
var resizeImage = ImageHelpers.ResizeImage(ImageHelpers.GetImageBuffer(randomIconFromText), DeviceConstants.XLButtonSize, DeviceConstants.XLButtonSize);
var resizeImage = ImageHelpers.ResizeImage(ImageHelpers.GetImageBuffer(randomIconFromText), mappedDevice.ButtonResolution, mappedDevice.ButtonResolution, mappedDevice.IsButtonImageFlipRequired);

mappedDevice.SetKey(mappedCommand.ButtonIndex, resizeImage);
};
Expand Down
11 changes: 6 additions & 5 deletions src/DeckSurf/DeckSurf.Plugin.Barn/Commands/SnakeGame.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
using DeckSurf.SDK.Core;
using DeckSurf.SDK.Interfaces;
using DeckSurf.SDK.Interfaces;
using DeckSurf.SDK.Models;
using DeckSurf.SDK.Util;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Timers;

namespace DeckSurf.Plugin.Barn.Commands
Expand Down Expand Up @@ -72,13 +73,13 @@ public void ExecuteOnAction(CommandMapping mappedCommand, ConnectedDevice mapped

public void ExecuteOnActivation(CommandMapping mappedCommand, ConnectedDevice mappedDevice)
{
mappedDevice.ClearPanel();
mappedDevice.ClearButtons();

UpdateSnakeRendering(mappedDevice);
Timer timer = new(1000);
timer.Elapsed += (s, e) =>
{
mappedDevice.SetKey(UpdateSnakePosition(_direction), DeviceConstants.XLDefaultBlackButton);
mappedDevice.SetKey(UpdateSnakePosition(_direction), ImageHelpers.CreateBlankImage(mappedDevice.ButtonResolution, Color.Black));
UpdateSnakeRendering(mappedDevice);
};
timer.Start();
Expand Down Expand Up @@ -121,7 +122,7 @@ private void UpdateSnakeRendering(ConnectedDevice mappedDevice)
{
foreach (var snakeNode in _snake)
{
mappedDevice.SetKey(snakeNode, DeviceConstants.XLDefaultWhiteButton);
mappedDevice.SetKey(snakeNode, ImageHelpers.CreateBlankImage(mappedDevice.ButtonResolution, Color.White));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/DeckSurf/DeckSurf.Plugin.Barn/DeckSurf.Plugin.Barn.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
Expand All @@ -18,8 +18,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DeckSurf.SDK" Version="0.0.3" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="6.0.0-preview.6.21352.12" />
<PackageReference Include="DeckSurf.SDK" Version="0.0.5" />
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="9.0.0" />
</ItemGroup>

</Project>
10 changes: 5 additions & 5 deletions src/DeckSurf/DeckSurf/DeckSurf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Platforms>x64</Platforms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ApplicationIcon>piglet.ico</ApplicationIcon>
<Authors>Den Delimarsky</Authors>
<Version>0.0.1</Version>
<Copyright>2021 by Den Delimarsky. All rights reserved.</Copyright>
<Version>0.0.2</Version>
<Copyright>Copyright © 2024 by Den Delimarsky. All rights reserved.</Copyright>
<AssemblyName>deck</AssemblyName>
</PropertyGroup>

Expand All @@ -21,8 +21,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Autofac" Version="6.2.0" />
<PackageReference Include="DeckSurf.SDK" Version="0.0.3" />
<PackageReference Include="Autofac" Version="8.2.0" />
<PackageReference Include="DeckSurf.SDK" Version="0.0.5" />
<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />
</ItemGroup>

Expand Down
26 changes: 13 additions & 13 deletions src/DeckSurf/DeckSurf/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private static Task<int> SetupCommandLine(string[] args)
};

writeCommand.AddOption(new Option<int>(
aliases: new[] { "--device-index", "-d" },
aliases: ["--device-index", "-d"],
getDefaultValue: () => -1,
description: "Index of the connected device, to which a key setting should be written.")
{
Expand All @@ -43,7 +43,7 @@ private static Task<int> SetupCommandLine(string[] args)
});

writeCommand.AddOption(new Option<int>(
aliases: new[] { "--key-index", "-k" },
aliases: ["--key-index", "-k"],
getDefaultValue: () => -1,
description: "Index of the key that needs to be written.")
{
Expand All @@ -52,7 +52,7 @@ private static Task<int> SetupCommandLine(string[] args)
});

writeCommand.AddOption(new Option<string>(
aliases: new[] { "--plugin", "-l" },
aliases: ["--plugin", "-l"],
getDefaultValue: () => string.Empty,
description: "Plugin that contains the relevant command.")
{
Expand All @@ -61,7 +61,7 @@ private static Task<int> SetupCommandLine(string[] args)
});

writeCommand.AddOption(new Option<string>(
aliases: new[] { "--command", "-c" },
aliases: ["--command", "-c"],
getDefaultValue: () => string.Empty,
description: "Command to be executed.")
{
Expand All @@ -70,7 +70,7 @@ private static Task<int> SetupCommandLine(string[] args)
});

writeCommand.AddOption(new Option<string>(
aliases: new[] { "--image-path", "-i" },
aliases: ["--image-path", "-i"],
getDefaultValue: () => string.Empty,
description: "Path to the default image for the button.")
{
Expand All @@ -79,7 +79,7 @@ private static Task<int> SetupCommandLine(string[] args)
});

writeCommand.AddOption(new Option<string>(
aliases: new[] { "--action-args", "-g" },
aliases: ["--action-args", "-g"],
getDefaultValue: () => string.Empty,
description: "Arguments for the defined action.")
{
Expand All @@ -88,7 +88,7 @@ private static Task<int> SetupCommandLine(string[] args)
});

writeCommand.AddOption(new Option<string>(
aliases: new[] { "--profile", "-p" },
aliases: ["--profile", "-p"],
getDefaultValue: () => string.Empty,
description: "The profile to which the command should be added.")
{
Expand All @@ -114,7 +114,7 @@ private static Task<int> SetupCommandLine(string[] args)
Handler = CommandHandler.Create<string>(HandleListenCommand)
};
listenCommand.AddOption(new Option<string>(
aliases: new[] { "--profile", "-p" },
aliases: ["--profile", "-p"],
getDefaultValue: () => string.Empty,
description: "The profile associated with the current device.")
{
Expand Down Expand Up @@ -155,9 +155,9 @@ private static void HandleListenCommand(string profile)

device.OnButtonPress += (s, e) =>
{
Console.WriteLine($"Button {e.Id} pressed. Event type: {e.Kind}");
Console.WriteLine($"Button {e.Id} pressed. Event type: {e.EventKind}");

if (e.Kind == ButtonEventKind.DOWN)
if (e.EventKind == ButtonEventKind.DOWN)
{
var buttonEntry = workingProfile.ButtonMap.FirstOrDefault(x => x.ButtonIndex == e.Id);
if (buttonEntry != null)
Expand Down Expand Up @@ -188,7 +188,7 @@ private static void HandleListenCommand(string profile)
}
_commands = new Dictionary<string, IEnumerable<IDSCommand>>(commandMap);

device.InitializeDevice();
device.StartListening();

foreach(var mappedButton in workingProfile.ButtonMap)
{
Expand Down Expand Up @@ -229,11 +229,11 @@ private static void ExecuteButtonAction(CommandMapping buttonEntry, ConnectedDev
private static void HandleListCommand()
{
var devices = DeviceManager.GetDeviceList();
Console.WriteLine($"{"| Device Name",-21} {"| VID",-10} {"| PID",-10}");
Console.WriteLine($"{"| Device Name",-21} {"| VID",-10} {"| PID",-10} {"| Serial Number",-10}");
Console.WriteLine("===========================================");
foreach (var device in devices)
{
Console.WriteLine($"{"| " + device.Name,-21} {"| " + device.VId,-10} {"| " + device.PId,-10}");
Console.WriteLine($"{"| " + device.Name,-21} {"| " + device.VId,-10} {"| " + $"0x{((int)device.Model):X}",-10} {"| " + device.Serial ,-10}");
}
}

Expand Down
Loading