Skip to content

Commit a8fe350

Browse files
committed
touchpad: count fingers
1 parent f0cbce1 commit a8fe350

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

ChuniVController/ChuniVController/TouchPad.xaml.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public enum IoType
3434
public byte ioTarget { get; set; }
3535

3636
private ChuniIoMessage message;
37+
private int fingers = 0;
3738
public TouchPad()
3839
{
3940
InitializeComponent();
@@ -43,18 +44,26 @@ public TouchPad()
4344

4445
private void Press()
4546
{
46-
if (localColoring) LedStrip.Fill = activeColor;
47-
message.Target = ioTarget;
48-
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderPress : ChuniMessageTypes.IrBlocked);
49-
io.Send(message);
47+
fingers++;
48+
if (fingers == 1) // send only the first finger
49+
{
50+
if (localColoring) LedStrip.Fill = activeColor;
51+
message.Target = ioTarget;
52+
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderPress : ChuniMessageTypes.IrBlocked);
53+
io.Send(message);
54+
}
5055
}
5156

5257
private void Release()
5358
{
54-
if (localColoring) LedStrip.Fill = idleColor;
55-
message.Target = ioTarget;
56-
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderRelease : ChuniMessageTypes.IrUnblocked);
57-
io.Send(message);
59+
fingers--;
60+
if (fingers == 0) // send only if no more fingers touched
61+
{
62+
if (localColoring) LedStrip.Fill = idleColor;
63+
message.Target = ioTarget;
64+
message.Type = (byte)(ioType == IoType.Slider ? ChuniMessageTypes.SliderRelease : ChuniMessageTypes.IrUnblocked);
65+
io.Send(message);
66+
}
5867
}
5968

6069
protected override void OnMouseEnter(MouseEventArgs e)

0 commit comments

Comments
 (0)