Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop-50' into develop-50-issu…
Browse files Browse the repository at this point in the history
…e-643
  • Loading branch information
gregsn committed Apr 3, 2015
2 parents 945d869 + b144542 commit 26bf85f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
22 changes: 14 additions & 8 deletions common/src/core/Utils/IO/TouchNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,45 @@ public class TouchNotification
public readonly Point Position;
public readonly Size ClientArea;
public readonly int Id;
public readonly bool Primary;
public readonly Size ContactArea;

public TouchNotification(TouchNotificationKind kind, Point position, Size clientArea, int id, Size contactArea)
public TouchNotification(TouchNotificationKind kind, Point position, Size clientArea, int id, bool primary, Size contactArea)
{
Kind = kind;
Position = position;
ClientArea = clientArea;
Id = id;
Primary = primary;
ContactArea = contactArea;
}

public bool IsTouchDown { get { return Kind == TouchNotificationKind.TouchDown; } }
public bool IsTouchUp { get { return Kind == TouchNotificationKind.TouchUp; } }
public bool IsTouchMove { get { return Kind == TouchNotificationKind.TouchMove; } }
}

public class TouchDownNotification : TouchNotification
{
public TouchDownNotification(Point position, Size clientArea, int id, Size contactArea)
: base(TouchNotificationKind.TouchDown, position, clientArea, id, contactArea)
public TouchDownNotification(Point position, Size clientArea, int id, bool primary, Size contactArea)
: base(TouchNotificationKind.TouchDown, position, clientArea, id, primary, contactArea)
{
}
}

public class TouchMoveNotification : TouchNotification
{
public TouchMoveNotification(Point position, Size clientArea, int id, Size contactArea)
: base(TouchNotificationKind.TouchMove, position, clientArea, id, contactArea)
public TouchMoveNotification(Point position, Size clientArea, int id, bool primary, Size contactArea)
: base(TouchNotificationKind.TouchMove, position, clientArea, id, primary, contactArea)
{
}
}

public class TouchUpNotification : TouchNotification
{
public TouchUpNotification(Point position, Size clientArea, int id, Size contactArea)
: base(TouchNotificationKind.TouchUp, position, clientArea, id, contactArea)
public TouchUpNotification(Point position, Size clientArea, int id, bool primary, Size contactArea)
: base(TouchNotificationKind.TouchUp, position, clientArea, id, primary, contactArea)
{
}
}
}
}
18 changes: 15 additions & 3 deletions vvvv45/src/nodes/plugins/System/TouchNodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,17 @@ private IEnumerable<TouchNotification> GenerateTouchNotifications(WMEventArgs e)
User32.ScreenToClient(e.HWnd, ref position);
var clientArea = new Size(cr.Width, cr.Height);
var id = touchPoint.dwID;
var primary = (touchPoint.dwFlags & Const.TOUCHEVENTF_PRIMARY) > 0;
var contactArea = (touchPoint.dwMask & Const.TOUCHINPUTMASKF_CONTACTAREA) > 0
? new Size(touchPoint.cxContact / 100, touchPoint.cyContact / 100)
: Size.Empty;

if ((touchPoint.dwFlags & Const.TOUCHEVENTF_DOWN) > 0)
yield return new TouchDownNotification(position, clientArea, id, contactArea);
yield return new TouchDownNotification(position, clientArea, id, primary, contactArea);
if ((touchPoint.dwFlags & Const.TOUCHEVENTF_MOVE) > 0)
yield return new TouchMoveNotification(position, clientArea, id, contactArea);
yield return new TouchMoveNotification(position, clientArea, id, primary, contactArea);
if ((touchPoint.dwFlags & Const.TOUCHEVENTF_UP) > 0)
yield return new TouchUpNotification(position, clientArea, id, contactArea);
yield return new TouchUpNotification(position, clientArea, id, primary, contactArea);
}
}
}
Expand Down Expand Up @@ -149,6 +150,8 @@ public class TouchEventsSplitNode : IPluginEvaluate, IDisposable
public ISpread<Vector2D> PositionOut;
[Output("Id")]
public ISpread<int> IdOut;
[Output("Primary")]
public ISpread<bool> PrimaryOut;
[Output("Contact Area")]
public ISpread<Vector2D> ContactAreaOut;

Expand Down Expand Up @@ -177,6 +180,7 @@ public void Evaluate(int spreadMax)
FEventTypeOut.SliceCount = notifications.Count;
PositionOut.SliceCount = notifications.Count;
IdOut.SliceCount = notifications.Count;
PrimaryOut.SliceCount = notifications.Count;
ContactAreaOut.SliceCount = notifications.Count;

for (int i = 0; i < notifications.Count; i++)
Expand All @@ -187,6 +191,7 @@ public void Evaluate(int spreadMax)
var clientArea = new Vector2D(n.ClientArea.Width, n.ClientArea.Height);
PositionOut[i] = VMath.Map(position, Vector2D.Zero, clientArea, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float);
IdOut[i] = n.Id;
PrimaryOut[i] = n.Primary;
ContactAreaOut[i] = new Vector2D(n.ContactArea.Width, n.ContactArea.Height);
}
}
Expand Down Expand Up @@ -228,6 +233,8 @@ public class TouchStatesSplitNode : IPluginEvaluate, IPartImportsSatisfiedNotifi
public ISpread<Vector2D> PositionOut;
[Output("Id")]
public ISpread<int> IdOut;
[Output("Primary")]
public ISpread<bool> PrimaryOut;
[Output("Contact Area")]
public ISpread<Vector2D> ContactAreaOut;
[Output("Is New")]
Expand All @@ -240,6 +247,7 @@ public void OnImportsSatisfied()
{
PositionOut.SliceCount = 0;
IdOut.SliceCount = 0;
PrimaryOut.SliceCount = 0;
ContactAreaOut.SliceCount = 0;
IsNewOut.SliceCount = 0;
FSubscription = new Subscription<TouchDevice, TouchNotification>(
Expand All @@ -254,13 +262,15 @@ public void OnImportsSatisfied()
var normalizedPosition = VMath.Map(position, Vector2D.Zero, clientArea, new Vector2D(-1, 1), new Vector2D(1, -1), TMapMode.Float);
var contactArea = new Vector2D(n.ContactArea.Width, n.ContactArea.Height);
var index = IdOut.IndexOf(n.Id);
var primary = n.Primary;
switch (n.Kind)
{
case TouchNotificationKind.TouchDown:
if (index < 0)
{
IdOut.Add(n.Id);
PositionOut.Add(normalizedPosition);
PrimaryOut.Add(primary);
ContactAreaOut.Add(contactArea);
IsNewOut.Add(true);
}
Expand All @@ -270,6 +280,7 @@ public void OnImportsSatisfied()
{
IdOut.RemoveAt(index);
PositionOut.RemoveAt(index);
PrimaryOut.RemoveAt(index);
ContactAreaOut.RemoveAt(index);
IsNewOut.RemoveAt(index);
}
Expand All @@ -278,6 +289,7 @@ public void OnImportsSatisfied()
if (index >= 0)
{
PositionOut[index] = normalizedPosition;
PrimaryOut[index] = primary;
ContactAreaOut[index] = contactArea;
IsNewOut[index] = false;
}
Expand Down

0 comments on commit 26bf85f

Please sign in to comment.