Skip to content

Commit

Permalink
Now only (re)mutes on mouse up if it was already muted on mouse down.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kibsgaard committed Apr 26, 2020
1 parent 6737987 commit d32af6e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions SimplePTT/MicController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class MicController : IDisposable

private readonly Timer timer;
private readonly Object muteLock;
private DateTime mouseDownTime = new DateTime();
private bool wasMutedOnMouseDown;
private TargetMicrophoneState targetMicrophoneState;
private Guid? selectedDeviceGuid;
private IDisposable muteChangedSubscription;
Expand Down Expand Up @@ -193,13 +195,12 @@ private void KeyboardHook_KeyUp(object sender, KeyEventArgs keyEvt)
DeferMute();
}

private DateTime mouseDownTime = new DateTime();
private void MouseHook_ButtonDown(object sender, MouseEventArgs mouseEvt)
{
if (IsValidMouseButton(mouseEvt.Button))
{
mouseDownTime = DateTime.Now;

wasMutedOnMouseDown = IsMuted;
Unmute();
}
}
Expand All @@ -211,7 +212,8 @@ private void MouseHook_ButtonUp(object sender, MouseEventArgs mouseEvt)
if(DateTime.Now - mouseDownTime > TimeSpan.FromMilliseconds(200))
mouseHook.ConsumeMouseKey = true;

DeferMute();
if(wasMutedOnMouseDown)
DeferMute();
}
}

Expand Down

0 comments on commit d32af6e

Please sign in to comment.