Skip to content

Commit

Permalink
touchpad: count fingers
Browse files Browse the repository at this point in the history
  • Loading branch information
magicnat committed Feb 2, 2020
1 parent f0cbce1 commit a8fe350
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions ChuniVController/ChuniVController/TouchPad.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public enum IoType
public byte ioTarget { get; set; }

private ChuniIoMessage message;
private int fingers = 0;
public TouchPad()
{
InitializeComponent();
Expand All @@ -43,18 +44,26 @@ public TouchPad()

private void Press()
{
if (localColoring) LedStrip.Fill = activeColor;
message.Target = ioTarget;
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderPress : ChuniMessageTypes.IrBlocked);
io.Send(message);
fingers++;
if (fingers == 1) // send only the first finger
{
if (localColoring) LedStrip.Fill = activeColor;
message.Target = ioTarget;
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderPress : ChuniMessageTypes.IrBlocked);
io.Send(message);
}
}

private void Release()
{
if (localColoring) LedStrip.Fill = idleColor;
message.Target = ioTarget;
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderRelease : ChuniMessageTypes.IrUnblocked);
io.Send(message);
fingers--;
if (fingers == 0) // send only if no more fingers touched
{
if (localColoring) LedStrip.Fill = idleColor;
message.Target = ioTarget;
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderRelease : ChuniMessageTypes.IrUnblocked);
io.Send(message);
}
}

protected override void OnMouseEnter(MouseEventArgs e)
Expand Down

0 comments on commit a8fe350

Please sign in to comment.