Closed TripleNico closed 3 years ago
Hi @TripleNico, thank you for your feedback and your idea.
I really want to keep the interfaces as slim and clean as possible to directly adding a property sadly wasn't an option for me, but I like the idea to make things simpler for developers using this library. I think the solution I came up with is simple enough to help developers without compromising the simple IMacroBoard interface.
Here is how it works:
The IMacroBoard interface has not changed, but OpenMacroboard hast now some extension methods that allows developers to "attach" features to a board, for example with the extension method .WithButtonPressEffect()
using var deck = StreamDeck.OpenDevice().WithButtonPressEffect();
// just use the deck as usual - if you press buttons a fake button push is shown
Behind the curtain this works by wrapping the macroboard in an adapter (some sort of middle-ware) for this reason it's important that you don't interact with the original deck reference or the illusion will break.
var original = StreamDeck.OpenDevice();
using var deckWithFeature = original.WithButtonPressEffect();
// do not use 'original' here or unexpected things might happen.
There is also an option to configure the exact behaviour (size, offset, background color).
var config = new ButtonPressEffectConfig()
{
// Try to experiment with these properties
Scale = 0.5,
OriginX = 0.5,
OriginY = 0.5,
};
using var deck = StreamDeck.OpenDevice().WithButtonPressEffect(config);
// You can even change the configuration later and it will take effect
config.Scale = 0.9;
Another similar "attachable" feature that was implemented in the last version might interest you, called .WithDisconnectReplay()
. This allows the user to disconnect the stream deck and if it's reconnected the last known state for brightness and the key images are automatically sent again, so the stream deck shows the correct state again.
using var deck = StreamDeck.OpenDevice().WithDisconnectReplay(config);
You can also combine multiple features if you want like so:
using var deck =
StreamDeck
.OpenDevice()
.WithButtonPressEffect()
.WithDisconnectReplay();
Let me know what you think.
@wischi-chr Thanks for your effort, this looks very promising and i like the approach you took! Currently i have no StreamDeck available so unfortunately i can't test it right now. But when i have one available i will certainly will look into this! 👍
If you want to check it out you can give the virtual board a try (https://github.com/OpenMacroBoard/OpenMacroBoard.SDK) - Example in the getting started section.
First of all, my compliments about your library. It is really easy to use and well documented, keep up the good work!
If you have some time left it would be great is you can add a Property that enables "Make image smaller on button down". What do i mean? Well lets say the image is 100,100 when i push the button i would like to see that the image would be downsized to let's say 80,80 and when i release the button it returns to it's original size 100,100
This way the push action of a button is more like a software button. I noticed this behaviour if you use the stock StreamDeck software.