Skip to content

Commit

Permalink
v1.4 - Bugfix in Advanced Press/Long-Press plugin
Browse files Browse the repository at this point in the history
No longer triggers the Short Press when trying to enable the long press
  • Loading branch information
BarRaider committed Apr 5, 2019
1 parent 501072c commit 53ceaad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions VoiceMeeter/VMAdvancedPress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static PluginSettings CreateDefaultSettings()
public string TitleParam { get; set; }

[JsonProperty(PropertyName = "titlePrefix")]
public string TitlePrefix{ get; set; }
public string TitlePrefix { get; set; }
}

#region Private members
Expand All @@ -48,6 +48,7 @@ public static PluginSettings CreateDefaultSettings()

private PluginSettings settings;
private bool keyPressed = false;
private bool longKeyPressed = false;
private DateTime keyPressStart;

#endregion
Expand All @@ -69,6 +70,7 @@ public VMAdvancedPress(SDConnection connection, InitialPayload payload) : base(c

public void LongKeyPressed()
{
longKeyPressed = true;
if (!String.IsNullOrEmpty(settings.LongPressValue))
{
VMManager.Instance.SetParameters(settings.LongPressValue);
Expand All @@ -90,23 +92,24 @@ public async override void KeyPressed(KeyPayload payload)
{
// Used for long press
keyPressed = true;
longKeyPressed = false;
keyPressStart = DateTime.Now;

if (!VMManager.Instance.IsConnected)
{
await Connection.ShowAlert();
return;
}

if (!String.IsNullOrEmpty(settings.SetValue))
{
VMManager.Instance.SetParameters(settings.SetValue);
}
}

public override void KeyReleased(KeyPayload payload)
{
keyPressed = false;

if (!longKeyPressed && !String.IsNullOrEmpty(settings.SetValue))
{
VMManager.Instance.SetParameters(settings.SetValue);
}
}

public async override void OnTick()
Expand All @@ -119,7 +122,7 @@ public async override void OnTick()

// Stream Deck calls this function every second,
// so this is the best place to determine if we need to call the long keypress
if (!String.IsNullOrEmpty(settings.LongPressValue) && keyPressed && (DateTime.Now - keyPressStart).TotalSeconds > LONG_KEYPRESS_LENGTH)
if (!String.IsNullOrEmpty(settings.LongPressValue) && keyPressed && (DateTime.Now - keyPressStart).TotalSeconds >= LONG_KEYPRESS_LENGTH)
{
LongKeyPressed();
}
Expand Down
2 changes: 1 addition & 1 deletion VoiceMeeter/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"Name": "VoiceMeeter Integration",
"Icon": "Images/pluginIcon",
"URL": "https://barraider.github.io/",
"Version": "1.3",
"Version": "1.4",
"CodePath": "com.barraider.voicemeeter.exe",
"Category": "BarRaider",
"CategoryIcon": "Images/categoryIcon",
Expand Down

0 comments on commit 53ceaad

Please sign in to comment.