-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- update VmrAPI - add macro buttons support
- Loading branch information
Showing
30 changed files
with
594 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using PW.VoicemeeterPlugin.Models; | ||
using PW.VoicemeeterPlugin.Services; | ||
using PW.VoicemeeterPlugin.ViewModels; | ||
using SuchByte.MacroDeck.ActionButton; | ||
using SuchByte.MacroDeck.GUI; | ||
using SuchByte.MacroDeck.GUI.CustomControls; | ||
using SuchByte.MacroDeck.Logging; | ||
using SuchByte.MacroDeck.Plugins; | ||
using SuchByte.MacroDeck.Variables; | ||
|
||
using System.Diagnostics; | ||
|
||
namespace PW.VoicemeeterPlugin.Actions; | ||
|
||
public class MacroButtonAction : PluginAction | ||
{ | ||
/// <summary> | ||
/// Name of the action | ||
/// </summary> | ||
public override string Name => LocalizationManager.Instance.MacroButtonActionName; | ||
|
||
/// <summary> | ||
/// A short description what this action does | ||
/// </summary> | ||
public override string Description => LocalizationManager.Instance.MacroButtonActionDescription; | ||
|
||
/// <summary> | ||
/// Set true if the plugin can be configured. | ||
/// </summary> | ||
public override bool CanConfigure => true; | ||
|
||
/// <summary> | ||
/// Return the ActionConfigControl for this action. | ||
/// </summary> | ||
/// <returns></returns> | ||
public override ActionConfigControl GetActionConfigControl(ActionConfigurator actionConfigurator) | ||
{ | ||
return new Views.MacroButtonActionConfigView(new MacroButtonActionConfigViewModel(this)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets called when the button with this action gets pressed. | ||
/// </summary> | ||
/// <param name="clientId">Returns the client id</param> | ||
/// <param name="actionButton">Returns the pressed action button</param> | ||
public override void Trigger(string clientId, ActionButton actionButton) | ||
{ | ||
if (string.IsNullOrWhiteSpace(Configuration)) | ||
{ | ||
return; | ||
} | ||
var config = MacroButtonActionConfigModel.Deserialize(Configuration); | ||
var value = VariableManager.GetVariable(PluginInstance.Plugin, config.AsVariable()); | ||
if (value is null) | ||
{ | ||
MacroDeckLogger.Info(PluginInstance.Plugin, typeof(DeviceToggleAction), $"Please report a bug to the developer of the plugin. Expected value: {Configuration}"); | ||
return; | ||
} | ||
PluginInstance.VoicemeeterControl.SetButtonState(config.ButtonId, value.Value.Equals(bool.FalseString), config.ButtonType); | ||
//if (config.ButtonType == ButtonType.Push) | ||
//{ | ||
// var sw = Stopwatch.StartNew(); | ||
// var elapsed = sw.ElapsedMilliseconds; | ||
// while (elapsed < 100) | ||
// { | ||
// elapsed = sw.ElapsedMilliseconds; | ||
// } | ||
// PluginInstance.VoicemeeterControl.SetButtonState(config.ButtonId, value.Value.Equals(bool.FalseString)); | ||
//} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"Attribution": "szopen", | ||
"Language": "Polski", | ||
"PluginDescription": "Plugin do Macro Deck'a", | ||
"VoiceMeeterConnected": "Voicemeeter połączony", | ||
"VoiceMeeterDisconnected": "Voicemeeter rozłączony", | ||
"ToggleActionName": "Przełącz urządzenie", | ||
"ToggleActionDescription": "Przełącz opcję na pasku lub szynie", | ||
"Device": "Urządzenie", | ||
"Action": "Akcja", | ||
"AdvancedActionName": "Zaawansowane/Niestandardowe", | ||
"AdvancedActionDescription": "Zaawansowane/Niestandardowe opcje do kontrolowania Voicemeeter'a przy użyciu Voicemeeter API.\nInstrukcje znajdziesz w dokumentacji Voicemeeter.", | ||
"Commands": "Komendy (rozdzielone przez ',', ';' albo nową linią)", | ||
"LabelParameter": "Parametr", | ||
"ParameterError": "Wystąpił błąd podczas weryfikowania parametru.", | ||
"ParameterExists": "Ten parametr już istnieje.", | ||
"NoCommandsMsg": "Brak komend do wykonania", | ||
"NCommandsMsg": "{0} komend", | ||
"CommandActionName": "Wywołaj komendę", | ||
"CommandActionDescription": "Wybierz komendę z Voicemeeter'a do wykonaia", | ||
"Command": "Komenda", | ||
"CommandValue": "Wartość komendy", | ||
"CommandError": "Nastąpił błąd podczas weryfikowania komendy.", | ||
"SliderActionName": "Sterowanie suwakiem", | ||
"SliderActionDescription": "Przesuń suwak o daną wartość", | ||
"SliderValue": "Przesuń suwak o wartość", | ||
"ErrorZeroSliderValue": "Wartość nie może być równa zeru.", | ||
"MacroButtonActionName": "Use Macro Button", | ||
"MacroButtonActionDescription": "Use a Voicemeeter Macro Button", | ||
"MacroButtonButtonId": "Logical ID", | ||
"MacroButtonButtonType": "Button Type", | ||
"MacroButtonIdError": "Button Id is not valid. Valid values are 0 to 79" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Diagnostics; | ||
using System.Text.Json; | ||
|
||
namespace PW.VoicemeeterPlugin.Models; | ||
|
||
public enum ButtonType | ||
{ | ||
Push, | ||
TwoPositions, | ||
} | ||
|
||
[DebuggerDisplay("{" + nameof(GetDebuggerDisplay) + "(),nq}")] | ||
internal class MacroButtonActionConfigModel : ISerializableConfiguration | ||
{ | ||
public int ButtonId { get; set; } = -1; | ||
|
||
public ButtonType ButtonType { get; set; } | ||
|
||
public string Serialize() | ||
{ | ||
return JsonSerializer.Serialize(this); | ||
} | ||
|
||
public static MacroButtonActionConfigModel Deserialize(string config) | ||
{ | ||
return ISerializableConfiguration.Deserialize<MacroButtonActionConfigModel>(config); | ||
} | ||
|
||
public override string ToString() | ||
{ | ||
if (ButtonType == ButtonType.Push) | ||
{ | ||
return $"Button {ButtonId}: Press"; | ||
} | ||
else | ||
{ | ||
return $"Button {ButtonId}: Toggle"; | ||
} | ||
} | ||
|
||
private string GetDebuggerDisplay() | ||
{ | ||
return ToString(); | ||
} | ||
|
||
public string AsVariable() | ||
{ | ||
return GetVariable(ButtonId); | ||
} | ||
|
||
public static string GetVariable(int buttonId) | ||
{ | ||
return $"vm_macrobutton{buttonId:d2}_pressed"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace PW.VoicemeeterPlugin.Models; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.