Add a simple adjustment
Overview
To create a simple adjustment, add to the plugin project a class inherited from the PluginDynamicAdjustment
class. To alter the command appearance and behavior, change the properties and overwrite the virtual methods of this class.
As an example, let's add a simple adjustment to the Demo plugin that increases or decreases the counter based on the number of ticks with which the encoder is rotated.
The full source code for this topic is at DemoPlugin/Step04
You can find the CounterAdjustment
class here: CounterAdjustment.cs
Steps
-
Open the Demo plugin solution in Visual Studio.
-
In the Solution Explorer, right-click on the DemoPlugin project and select Add > Class.
-
Enter CounterAdjustment.cs as the file name and click Add. The
CounterAdjustment
class opens for editing. -
Inherit the
CounterAdjustment
class from thePluginDynamicAdjustment
class: -
Add a private counter field and set it to
0
: -
Create an empty, parameterless constructor and set the command display name, description, and group name in the parent constructor parameters. To indicate that the adjustment has a reset functionality, set the parameter
hasReset
totrue
: -
Overwrite the
ApplyAdjustment
method that is called every time a user rotates the encoder to which this adjustment is assigned: -
Overwrite the
RunCommand
method that is called every time a user presses the encoder to which this command is assigned: -
Plugin Service can draw the current adjustment value near the encoder. To enable that functionality, overwrite the
GetAdjustmentValue
method: -
To inform Plugin Service that the adjustment value has changed, call the
AdjustmentValueChanged
method:protected override void ApplyAdjustment(String actionParameter, Int32 diff) { this._counter += diff; // Increase or decrease the counter by the number of ticks. this.AdjustmentValueChanged(); // Notify the Plugin service that the adjustment value has changed. } protected override void RunCommand(String actionParameter) { this._counter = 0; // Reset the counter. this.AdjustmentValueChanged(); // Notify the Plugin service that the adjustment value has changed. }
-
Start debugging and wait until the Software is loaded.
-
Open the configuration UI.
-
Switch the Adapt to App to OFF Options+ or Dynamic mode to OFF in Loupedeck Software.
-
In the applications dropdown list, select Demo.
-
On the left pane, under Rotation Adjustments, expand the Demo node, then expand the
Adjustments
group and ensure that the Counter adjustment is there. -
Drag and drop the Counter command to any encoder.
-
Connect a console to your computer. The console shows the Counter command on the encoder screen.
-
Rotate the encoder to change the counter value.
-
Press the encoder to reset the counter value to
0
.