CCT.NUI.HandTracking.Mouse.MouseController.handSource_NewDataAvailable C# (CSharp) Method

handSource_NewDataAvailable() private method

private handSource_NewDataAvailable ( HandCollection handData ) : void
handData HandCollection
return void
        void handSource_NewDataAvailable(HandCollection handData)
        {
            if (!this.Enabled || handData.Count == 0)
            {
                return;
            }

            if(this.cursorMode.HasPoint(handData))
            {
                var pointOnScreen = this.MapToScreen(this.cursorMode.GetPoint(handData));

                double newX = pointOnScreen.X;
                double newY = pointOnScreen.Y;

                if (lastPointOnScreen.HasValue)
                {
                    var distance = Point.Distance2D(pointOnScreen, lastPointOnScreen.Value);
                    if (distance < 100)
                    {
                        newX = lastPointOnScreen.Value.X + (newX - lastPointOnScreen.Value.X) * (distance / 100);
                        newY = lastPointOnScreen.Value.Y + (newY - lastPointOnScreen.Value.Y) * (distance / 100);
                    }
                    if (distance < 10)
                    {
                        newX = lastPointOnScreen.Value.X;
                        newY = lastPointOnScreen.Value.Y; 
                    }
                }

                UserInput.SetCursorPositionAbsolute((int)newX, (int)newY);
                lastPointOnScreen = new Point((float)newX, (float)newY, 0);

                this.clickMode.Process(handData);
            }
        }