public GestureMap() { _controller = new Leap.Controller(); _controller.EnableGesture(Leap.Gesture.GestureType.TYPE_SWIPE); _controller.EnableGesture(Leap.Gesture.GestureType.TYPE_CIRCLE); _controller.EnableGesture(Leap.Gesture.GestureType.TYPE_SCREEN_TAP); _controller.AddListener(this); }
/* Policy setting requests * A request to change a policy is subject to user approval and a policy can be changed by the user at any time * (using the Leap Motion settings dialog). * The desired policy flags must be set every time an application runs. * Policy changes are completed asynchronously and, because they are subject to user approval or system compatibility checks, may not complete successfully. * Call Controller::isPolicySet() after a suitable interval to test whether the change was accepted. */ public static void SetPolicy(Leap.Controller controller, out Leap.Controller controllerOut, PolicyFlag policy, bool set) { controllerOut = controller; if (set) { controller.SetPolicy((Leap.Controller.PolicyFlag)policy); } else { controller.ClearPolicy((Leap.Controller.PolicyFlag)policy); } }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { listener = new LeapListener(); controller = new Leap.Controller(); controller.AddListener(listener); listener.OnFrameUpdate += listener_OnFrameUpdate; listener.OnDeviceStatusUpdate += listener_OnDeviceStatusUpdate; listener.OnCircleGesture += listener_OnCircleGesture; listener.OnKeyTapGesture += listener_OnKeyTapGesture; listener.OnScreenTapGesture += listener_OnScreenTapGesture; listener.OnSwipeGesture += listener_OnSwipeGesture; }
/// <summary> /// Invoked when this page is about to be displayed in a Frame. /// </summary> /// <param name="e">Event data that describes how this page was reached. The Parameter /// property is typically used to configure the page.</param> protected override void OnNavigatedTo(NavigationEventArgs e) { listener = new LeapListener(); controller = new Leap.Controller(); controller.AddListener(listener); listener.OnFrameUpdate += listener_OnFrameUpdate; listener.OnDeviceStatusUpdate +=listener_OnDeviceStatusUpdate; listener.OnCircleGesture += listener_OnCircleGesture; listener.OnKeyTapGesture += listener_OnKeyTapGesture; listener.OnScreenTapGesture += listener_OnScreenTapGesture; listener.OnSwipeGesture += listener_OnSwipeGesture; }
public void Terminate() { if (m_initialized) { if (m_controller != null) { m_controller.StopConnection(); m_controller.Dispose(); m_controller = null; } m_initialized = false; } }
public bool Initialize() { if (!m_initialized) { m_controller = new Leap.Controller(); m_controller.StartConnection(); m_controller.PolicyChange += OnControllerPolicyChange; m_controller.Device += OnControllerConnected; m_controller.DeviceLost += OnControllerDisconnected; m_initialized = true; } return(m_initialized); }
private bool setupLeapMotion() { controller = new Leap.Controller(); for (int i = 0; !controller.IsConnected && i < 5; ++i) System.Threading.Thread.Sleep(100); // if Leap is not available, quit if (!controller.IsConnected) return isLeapConnected = false; isLeapConnected = true; listener = new LeapListener(); listener.ShowWindow = showWindow; controller.AddListener(listener); return true; }
private void ThisAddIn_Shutdown(object sender, System.EventArgs e) { Console.WriteLine("AddIn stop."); MessageFilter.Revoke(); if (_leapCtrl != null) { if (_leap != null) { _leapCtrl.RemoveListener(_leap); _leap.Dispose(); _leap = null; } _leapCtrl.Dispose(); _leapCtrl = null; } }
public handController(gameController game, GameObject sph1, GameObject sph2, GameObject sph3, GameObject sph4, UnityEngine.UI.Text xt, UnityEngine.UI.Text yt, UnityEngine.UI.Text zt, UnityEngine.UI.Text wt) { menu = GameObject.Find("menu"); leapspace = GameObject.Find("LeapSpace"); controller = new Leap.Controller(); camera = GameObject.Find("CenterEyeAnchor").GetComponent <Camera>(); gamer = game; debug1 = DrawLine(Vector3.zero, Vector3.zero, Color.white, 0.05f); debug2 = DrawLine(Vector3.zero, Vector3.zero, Color.white, 0.05f); sphereswitch = sph1; sphererand = sph2; sphereexpand = sph3; spheresmall = sph4; txt1 = xt; txt2 = yt; txt3 = zt; txt4 = wt; getctr = this; }
private void ThisAddIn_Startup(object sender, System.EventArgs e) { try { _leapCtrl = new Leap.Controller(); _leap = new LeapListener(); _leap.GestureOccur += new EventHandler(gesture_Occur); Console.WriteLine("AddIn start."); MessageFilter.Register(); this.Application.SlideShowBegin += StartPresentationEvent; this.Application.SlideShowEnd += StopPresentationEvent; } catch (Exception ex) { Console.WriteLine("AddIn faild to start : " + ex.Message); } }
private void btn_Connection_Click(object sender, EventArgs e) { if (aSocket.IsConnected() == false) { System.Net.IPAddress ip = System.Net.IPAddress.Parse("127.0.0.1"); if (System.Net.IPAddress.TryParse(tb_Ip.Text, out ip)) { aSocket = new NXTRemoteLib.Sockets.SocketWrapper(); aSocket.Connected += OnSocketConnected; aSocket.Shutdown += OnSocketClosed; aSocket.ServerClosedConnection += OnSocketClosed; aSocket.ConnectToServer(tb_Ip.Text, Int32.Parse(tb_Port.Text)); leapListener = new Objects.NXTLeapListener(); leapController = new Leap.Controller(); leapListener.Initialized += OnLeapLog; leapListener.Connected += OnLeapLog; leapListener.Disconnected += OnLeapLog; leapListener.Exited += OnLeapLog; leapListener.Framed += OnLeapLog; leapListener.CircleGesture += OnLeapCircleGesture; leapListener.ReturnHand += OnLeapHand; leapController.AddListener(leapListener); } else { System.Windows.Forms.MessageBox.Show("Adresse ip incorrect."); } } else { aSocket.SendData(NXTRemoteLib.Controllers.XML.SendOrder("0", "0", "0", "false")); aSocket.ShutdownClient(); } }
//NOTE: I'm giving all inputs of mutable data (like Leap.Controller) also as an output of the method, to avoid timing ambiguity in VL public static void SetGestureEnabled(Leap.Controller controller, out Leap.Controller controllerOut, GestureType gestureType, bool set) { controllerOut = controller; controller.EnableGesture((Leap.Gesture.GestureType)gestureType, set); }
public override void OnApplicationStart() { DependenciesHandler.ExtractDependencies(); MelonLoader.MelonPreferences.CreateCategory("LME", "Leap Motion extension"); MelonLoader.MelonPreferences.CreateEntry("LME", "Enabled", false, "Enable Leap Motion extension"); MelonLoader.MelonPreferences.CreateEntry("LME", "VR", false, "Enable HMD mode for Leap Motion"); MelonLoader.MelonPreferences.CreateEntry("LME", "SDK3", false, "Send SDK3 parameters"); MelonLoader.MelonPreferences.CreateEntry("LME", "HeadRoot", false, "Use head as root point"); MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetY", c_defaultRootOffsetY, "Avatar root point offset for Y axis"); MelonLoader.MelonPreferences.CreateEntry("LME", "RootOffsetZ", c_defaultRootOffsetZ, "Avatar root point offset for Z axis"); MelonLoader.MelonPreferences.CreateEntry("LME", "FingersOnly", false, "Fingers tracking only"); m_leapController = new Leap.Controller(); m_gesturesData = new GestureMatcher.GesturesData(); // Methods search m_heightMethod = MethodsResolver.GetHeightMethod(); if (m_heightMethod != null) { MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_heightMethod.Name + " -> VRCTrackingManager.GetPlayerHeight"); } else { MelonLoader.MelonLogger.Warning("Can't resolve height method, fallback to zero float"); m_heightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat)); } m_eyeHeightMethod = MethodsResolver.GetEyeHeightMethod(); if (m_eyeHeightMethod != null) { MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_eyeHeightMethod.Name + " -> VRCTrackingManager.GetPlayerEyeHeight (Desktop)"); } else { MelonLoader.MelonLogger.Warning("Can't resolve eye height method for desktop, fallback to zero float"); m_eyeHeightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat)); } m_vrEyeHeightMethod = MethodsResolver.GetVREyeHeightMethod(); if (m_vrEyeHeightMethod != null) { MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_vrEyeHeightMethod.Name + " -> VRCTrackingManager.GetPlayerEyeHeight (VR)"); } else { MelonLoader.MelonLogger.Warning("Can't resolve eye height method for VR, fallback to zero float"); m_vrEyeHeightMethod = typeof(LeapMotionExtention).GetMethod(nameof(ZeroFloat)); } m_vrCheckMethod = MethodsResolver.GetVRCheckMethod(); if (m_vrCheckMethod != null) { MelonLoader.MelonDebug.Msg("VRCTrackingManager." + m_vrCheckMethod.Name + " -> VRCTrackingManager.IsInVRMode"); } else { MelonLoader.MelonLogger.Warning("Can't resolve vr check method, fallback to false boolean"); m_vrCheckMethod = typeof(LeapMotionExtention).GetMethod(nameof(FalseBoolean)); } // Patches var l_patchMethod = new Harmony.HarmonyMethod(typeof(LeapMotionExtention), nameof(VRCIM_ControllersType)); typeof(VRCInputManager).GetMethods().Where(x => x.Name.StartsWith("Method_Public_Static_Boolean_EnumNPublicSealedvaKeMoCoGaViOcViDaWaUnique_") ).ToList().ForEach(m => Harmony.Patch(m, l_patchMethod)); OnPreferencesSaved(); }
private static void LeapEnable(bool bEnable) { lock (controllerLock) { bool bEnabled = (leapController != null); if (bEnable == bEnabled) return; if (bEnable) { leapController = new Leap.Controller(); } else { leapController.Dispose(); leapController = null; } } }
public static bool IsPolicySet(Leap.Controller controller, out Leap.Controller controllerOut, PolicyFlag policy) { controllerOut = controller; return(controller.IsPolicySet((Leap.Controller.PolicyFlag)policy)); }
private bool IsLeapMotionTrackingBone(HumanBodyBones bone) { Leap.Controller lc = IKDataSourceManager.Instance.LeapController; Leap.Frame frame = lc.Frame(); List <Leap.Hand> hands = frame.Hands; bool leftHandTracked = false; bool rightHandTracked = false; int numHands = hands.Count; for (int i = 0; i < numHands; ++i) { if (hands[i].IsLeft) { leftHandTracked = true; } else if (hands[i].IsRight) { rightHandTracked = true; } } switch (bone) { // Left hand bones case HumanBodyBones.LeftHand: case HumanBodyBones.LeftIndexDistal: case HumanBodyBones.LeftIndexIntermediate: case HumanBodyBones.LeftIndexProximal: case HumanBodyBones.LeftLittleDistal: case HumanBodyBones.LeftLittleIntermediate: case HumanBodyBones.LeftLittleProximal: case HumanBodyBones.LeftLowerArm: case HumanBodyBones.LeftMiddleDistal: case HumanBodyBones.LeftMiddleIntermediate: case HumanBodyBones.LeftMiddleProximal: case HumanBodyBones.LeftRingDistal: case HumanBodyBones.LeftRingIntermediate: case HumanBodyBones.LeftRingProximal: case HumanBodyBones.LeftThumbDistal: case HumanBodyBones.LeftThumbIntermediate: case HumanBodyBones.LeftThumbProximal: return(leftHandTracked); // Right hand bones case HumanBodyBones.RightHand: case HumanBodyBones.RightIndexDistal: case HumanBodyBones.RightIndexIntermediate: case HumanBodyBones.RightIndexProximal: case HumanBodyBones.RightLittleDistal: case HumanBodyBones.RightLittleIntermediate: case HumanBodyBones.RightLittleProximal: case HumanBodyBones.RightLowerArm: case HumanBodyBones.RightMiddleDistal: case HumanBodyBones.RightMiddleIntermediate: case HumanBodyBones.RightMiddleProximal: case HumanBodyBones.RightRingDistal: case HumanBodyBones.RightRingIntermediate: case HumanBodyBones.RightRingProximal: case HumanBodyBones.RightThumbDistal: case HumanBodyBones.RightThumbIntermediate: case HumanBodyBones.RightThumbProximal: return(rightHandTracked); // Leap only tracks hands default: Debug.LogWarningFormat("IKTarget IsLeapMotionTrackingBone: Invalid bone for Leap Motion: {0} - returning false", bone); return(false); } }
static void Main( string[] args ) { // Game window Game game; // Leap Motion Controller Leap.Listener LeapListener; Leap.Controller LeapController; // Game scene Scene_GameClass Scene_Game; // We want to initialize this after the game is initialized // Initialize { // Game Window game = new Game( "Tragic Magic", // Window Title 1920, 1080, // Window size 60, // Target FPS false // Fullscreen ); game.SetWindowAutoFullscreen( true ); // VSync & auto max resolution // Leap Motion Controller LeapListener = new Leap.Listener(); LeapController = new Leap.Controller(); LeapController.AddListener( LeapListener ); // Initialize player sessions game.AddSession( "LightWizard" ); game.AddSession( "DarkWizard" ); // Setup controls game.Session( "DarkWizard" ).Controller = new ControllerXbox360(); game.Session( "LightWizard" ).Controller = new ControllerXbox360(); // Keyboard / IPAC Controls // Movement game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Up.AddKey( Key.W ); // Up for Player 1 game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Down.AddKey( Key.S ); // Down for Player 1 game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Left.AddKey( Key.A ); // Left for Player 1 game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Right.AddKey( Key.D ); // Right for Player 1 game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Start.AddKey( Key.Space ); //Ready Up button(?) / Start game.Session( "LightWizard" ).GetController<ControllerXbox360>().Up.AddKey( Key.Up ); // Up for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().Down.AddKey( Key.Down ); // Down for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().Left.AddKey( Key.Left ); // Left for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().Right.AddKey( Key.Right ); // Right for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().Start.AddKey( Key.Num0 ); //Ready Up button(?) //Start // Elements // Keyboard game.Session( "DarkWizard" ).GetController<ControllerXbox360>().RB.AddKey( Key.E ); // Cast Spell game.Session( "DarkWizard" ).GetController<ControllerXbox360>().B.AddKey( Key.Num1 ); // Fire Element Key for Player 1 game.Session( "DarkWizard" ).GetController<ControllerXbox360>().A.AddKey( Key.Num3 ); // Earth Element Key for Player 1 game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Y.AddKey( Key.Num2 ); // Lightning Element Key for Player 1 game.Session( "DarkWizard" ).GetController<ControllerXbox360>().X.AddKey( Key.Num4 ); // Water Element Key for Player 1 game.Session( "LightWizard" ).GetController<ControllerXbox360>().RB.AddKey( Key.PageDown ); // Cast spell game.Session( "LightWizard" ).GetController<ControllerXbox360>().B.AddKey( Key.Num7 ); // Fire Element Key for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().A.AddKey( Key.Num9 ); // Earth Element Key for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().Y.AddKey( Key.Num8 ); // Lightning Element Key for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().X.AddKey( Key.Num0 ); // Water Element Key for Player 2 // Xbox / Playstation Controller Controls game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Up.AddAxisButton( AxisButton.PovYMinus, 0 ); // Up for Player 1 / DPAD UP game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Down.AddAxisButton( AxisButton.PovYPlus, 0 ); // Down for Player 1 / DPAD DOWN game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Left.AddAxisButton( AxisButton.PovXMinus, 0 ); // Left for Player 1 / DPAD LEFT game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Right.AddAxisButton( AxisButton.PovXPlus, 0 ); // Right for Player 1 / DPAD RIGHT game.Session( "DarkWizard" ).GetController<ControllerXbox360>().B.AddButton( 1, 0 ); // Fire Element Key for Player 1 / RIGHT FACE BUTTON game.Session( "DarkWizard" ).GetController<ControllerXbox360>().A.AddButton( 0, 0 ); // Earth Element Key for Player 1 / DOWN FACE BUTTON game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Y.AddButton( 3, 0 ); // Lightning Element Key for Player 1 / UP FACE BUTTON game.Session( "DarkWizard" ).GetController<ControllerXbox360>().X.AddButton( 2, 0 ); // Water Element Key for Player 1 / RIGHT FACE BUTTON game.Session( "DarkWizard" ).GetController<ControllerXbox360>().Start.AddButton( 7, 0 ); //Ready Up button(?) game.Session( "DarkWizard" ).GetController<ControllerXbox360>().LeftStick.AddAxis( JoyAxis.X, JoyAxis.Y, 0 ); //Left Stick Movement game.Session( "DarkWizard" ).GetController<ControllerXbox360>().RightStick.AddAxis( JoyAxis.U, JoyAxis.R, 0 ); //Right Stick Movement game.Session( "LightWizard" ).GetController<ControllerXbox360>().Up.AddAxisButton( AxisButton.PovYMinus, 1 ); // Up for Player 2 / DPAD UP game.Session( "LightWizard" ).GetController<ControllerXbox360>().Down.AddAxisButton( AxisButton.PovYPlus, 1 ); // Down for Player 2 / DPAD DOWN game.Session( "LightWizard" ).GetController<ControllerXbox360>().Left.AddAxisButton( AxisButton.PovXMinus, 1 ); // Left for Player 2 / DPAD LEFT game.Session( "LightWizard" ).GetController<ControllerXbox360>().Right.AddAxisButton( AxisButton.PovXPlus, 1 ); // Right for Player 2 / DPAD RIGHT game.Session( "LightWizard" ).GetController<ControllerXbox360>().B.AddButton( 1, 1 ); // Fire Element Key for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().A.AddButton( 0, 1 ); // Earth Element Key for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().Y.AddButton( 3, 1 ); // Lightning Element Key for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().X.AddButton( 2, 1 ); // Water Element Key for Player 2 game.Session( "LightWizard" ).GetController<ControllerXbox360>().Start.AddButton( 7, 1 ); //Ready Up button(?) game.Session( "LightWizard" ).GetController<ControllerXbox360>().LeftStick.AddAxis( JoyAxis.X, JoyAxis.Y, 1 ); //Left Stick Movement game.Session( "LightWizard" ).GetController<ControllerXbox360>().RightStick.AddAxis( JoyAxis.U, JoyAxis.R, 1 ); //Right Stick Movement // Initialize Scene Scene_Game = new Scene_GameClass(); { Scene_Game.LeapController = LeapController; } Scene_Game.Initialize( game ); game.FirstScene = Scene_Game; // Test tweeting interface TweetinviClass test = new TweetinviClass(); } // Update { // Start the game application game.Start(); } // Cleanup { // Dispose of the Leap Motion Controller LeapController.RemoveListener( LeapListener ); LeapController.Dispose(); LeapListener.Dispose(); } }
public override void OnFrame(Leap.Controller controller) { observer.OnNext(controller.Frame()); }
public override void OnFrame(Leap.Controller controller) { Leap.Frame frame = controller.Frame(); Leap.InteractionBox interactionBox = frame.InteractionBox; _pointerPosition = interactionBox.NormalizePoint(frame.Pointables.Frontmost.TipPosition); _standardGestures = frame.Gestures(); foreach (Leap.Gesture gesture in _standardGestures) { if (gesture.State.Equals(Leap.Gesture.GestureState.STATESTOP)) { if (gesture.Type.Equals(Leap.Gesture.GestureType.TYPESWIPE)) { Print("Finger Swipe Detected"); Leap.SwipeGesture swipe = new Leap.SwipeGesture(gesture); Events.FingerSwipeEvent swipeEvent = new Events.FingerSwipeEvent(swipe); OnFingerSwipeDetected(swipeEvent); } if (gesture.Type.Equals(Leap.Gesture.GestureType.TYPE_CIRCLE)) { Print("Circle Gesture Detected"); Leap.CircleGesture circle = new Leap.CircleGesture(gesture); Events.CircleEvent circleEvent = new Events.CircleEvent(circle); OnCircleDetected(circleEvent); } if (gesture.Type.Equals(Leap.Gesture.GestureType.TYPE_SCREEN_TAP)) { Print("Screen Tap Detected"); Leap.ScreenTapGesture screenTap = new Leap.ScreenTapGesture(gesture); Events.ScreenTapEvent screenTapEvent = new Events.ScreenTapEvent(screenTap); OnScreenTapDetected(screenTapEvent); } } } Gestures.HandSwipe handSwipe = Gestures.HandSwipe.IsHandSwipe(frame); if (handSwipe != null) { if (handSwipe.State.Equals(Gestures.GestureState.END)) { Print("Hand Swipe Detected"); Events.HandSwipeEvent swipeEvent = new Events.HandSwipeEvent(handSwipe); OnHandSwipeDetected(swipeEvent); } } Gestures.ZoomIn zoomIn = Gestures.ZoomIn.IsZoomIn(frame); if (zoomIn != null) { if (zoomIn.State.Equals(Gestures.GestureState.END)) { Print("ZoomIn Detected"); Events.ZoomInEvent zoomInEvent = new Events.ZoomInEvent(zoomIn); OnZoomInDetected(zoomInEvent); } } Gestures.ZoomOut zoomOut = Gestures.ZoomOut.IsZoomOut(frame); if (zoomOut != null) { if (zoomOut.State.Equals(Gestures.GestureState.END)) { Print("ZoomOut Detected"); Events.ZoomOutEvent zoomOutEvent = new Events.ZoomOutEvent(zoomOut); OnZoomOutDetected(zoomOutEvent); } } }