コード例 #1
0
ファイル: Program.cs プロジェクト: roju/huvr
        static void Main()
        {
            Controller   controller = new Controller();
            LeapListener listener   = new LeapListener();

            controller.AddListener(listener);
            controller.SetPolicyFlags(Controller.PolicyFlag.POLICYBACKGROUNDFRAMES);

            TouchInjector.InitializeTouchInjection(256, TouchFeedback.INDIRECT); //initialize touch injection with num max touch points, indirect feedback to show hover position
            TouchActions.InitializeContacts();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new SettingsWindow());

            controller.RemoveListener(listener);
            controller.Dispose();
        }
コード例 #2
0
ファイル: LeapListener.cs プロジェクト: roju/huvr
        public override void OnFrame(Controller cntrlr)
        {
            // Get the current frame.
            Frame currentFrame = cntrlr.Frame();

            currentTime = currentFrame.Timestamp;
            timeChange  = currentTime - previousTime;


            if (timeChange > 1000) //0
            {
                Finger finger1 = currentFrame.Fingers[0];

                SettingsWindow.debugText[0] = "X: " + finger1.TipPosition.x.ToString() + "\n" +
                                              "Y: " + finger1.TipPosition.y.ToString() + "\n" +
                                              "Z: " + finger1.TipPosition.z.ToString() + "\n";



                switch (SettingsWindow.runMode)
                {
                case 0:
                    if (!currentFrame.Fingers.IsEmpty)
                    {
                        TouchActions.Run(currentFrame.Fingers);
                    }
                    break;

                case 1:
                    if (!currentFrame.Fingers.IsEmpty)
                    {
                        TouchActions.RunOne(currentFrame.Fingers);
                    }
                    break;

                case 2:
                    if (!currentFrame.Fingers.IsEmpty)
                    {
                        TouchActions.RunTwo(currentFrame.Fingers);
                    }
                    break;

                case 3:
                    if (!currentFrame.Tools.IsEmpty)
                    {
                        TouchActions.RunTool(currentFrame.Tools);
                    }
                    break;

                case 4:
                    if (!currentFrame.Fingers.IsEmpty)
                    {
                        TouchActions.RunMouse(currentFrame.Fingers);
                    }
                    break;
                }


                previousTime = currentTime;
            }
        }