Esempio n. 1
0
    // Use this for initialization
    void Start()
    {
        Instance = this;

        handL =
            VRTK_ControllerReference.GetControllerReference(SDK_BaseController.ControllerHand.Left);

        handR =
            VRTK_ControllerReference.GetControllerReference(SDK_BaseController.ControllerHand.Right);

        if (LeftController != null)
        {
            evL = LeftController.GetComponent <VRTK_ControllerEvents>();
        }
        if (RightController != null)
        {
            evR = RightController.GetComponent <VRTK_ControllerEvents>();
        }

        if (evR != null)
        {
            evR.ButtonOneReleased += new ControllerInteractionEventHandler(B1Released);
            evL.TriggerReleased   += new ControllerInteractionEventHandler(B1Released);
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Awake()
    {
        Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);

        // Update the display text
        //textMode.text = string.Format("Mode: {0}", AirSigManager.Mode.DeveloperDefined.ToString());
        // textResult.text = defaultResultText = "Pressing trigger and write symbol in the air\nReleasing trigger when finish";
        //textResult.alignment = TextAnchor.UpperCenter;
        instruction.SetActive(false);
        ToggleGestureImage("All");

        // Configure AirSig by specifying target
        developerDefined = new AirSigManager.OnDeveloperDefinedMatch(HandleOnDeveloperDefinedMatch);
        airsigManager.onDeveloperDefinedMatch += developerDefined;
        airsigManager.SetMode(AirSigManager.Mode.DeveloperDefined);
        airsigManager.SetDeveloperDefinedTarget(new List <string> {
            "Circle", "Square"
        });
        airsigManager.SetClassifier("SquareCircle", "");

        checkDbExist();

        airsigManager.SetTriggerStartKeys(
            AirSigManager.Controller.RIGHT_HAND,
            SteamVR_Controller.ButtonMask.Trigger,
            AirSigManager.PressOrTouch.PRESS);


        //        airsigManager.SetTriggerStartKeys(
        //            AirSigManager.Controller.LEFT_HAND,
        //			SteamVR_Controller.ButtonMask.Trigger,
        //            AirSigManager.PressOrTouch.PRESS);

        rc = GameObject.Find("Controller (right)").GetComponent <RightController>();
    }
Esempio n. 3
0
    void Awake()
    {
        Instance = this;
        if (Screen.width > Screen.height)
        {
            size = Screen.height;
        }
        else
        {
            size = Screen.width;
        }

        joyStickTexture         = gameObject.AddComponent <GUITexture> ();
        joyStickTexture.texture = joyStick;
        joyStickTexture.color   = inactiveColor;

        var bo = new GameObject("RightBack");

        bo.transform.localScale = Vector3.zero;
        backObj         = bo.gameObject.AddComponent <GUITexture> ();
        backObj.texture = background2D;
        backObj.color   = inactiveColor;

        rb     = gameObject.AddComponent <RightBack> ();
        rb.con = this;
        rb.tex = backObj;

        rf = gameObject.AddComponent <RightFinger> ();
        gameObject.transform.localPosition = Vector3.zero;
        gameObject.transform.localScale    = Vector3.zero;
        rf.con = this;
        rf.tex = joyStickTexture;
    }
Esempio n. 4
0
        void Start()
        {
            LeftControllerEvents  = InputAdapter.Instance.ControllerInput.ControllerEventFactory.GetFrom(LeftController);
            RightControllerEvents = InputAdapter.Instance.ControllerInput.ControllerEventFactory.GetFrom(RightController);

            if (LeftControllerEvents == null || RightController == null)
            {
                Debug.LogError("Missing ControllerEvents!");
                return;
            }

            _leftTooltipAdapter  = LeftController.GetComponent <TooltipTransformAdapterBase>();
            _rightTooltipAdapter = RightController.GetComponent <TooltipTransformAdapterBase>();

            if (_leftTooltipAdapter == null || _rightTooltipAdapter == null)
            {
                Debug.LogError("Missing TooltipTransformAdapterBase!");
                return;
            }

            _leftTooltipAdapter.Init(TooltipControllers.Left);
            _rightTooltipAdapter.Init(TooltipControllers.Right);

            StartCoroutine(ControllerEventsSubscriptionSafe());

            _tooltipObjectsLeft  = new Dictionary <TooltipButtons, GameObject>();
            _tooltipObjectsRight = new Dictionary <TooltipButtons, GameObject>();
        }
Esempio n. 5
0
    protected override void Update()
    {
        base.Update();
        leftStick  = FinchVR.LeftController.GetTouchAxes();
        rightStick = FinchVR.RightController.GetTouchAxes();

        bool rightUp   = rightStick.x >= -epsSwipe && rightStick.x <= epsSwipe && rightStick.y >= (1 - epsSwipe);
        bool rightDown = rightStick.x >= -epsSwipe && rightStick.x <= epsSwipe && rightStick.y <= -(1 - epsSwipe);
        bool leftUp    = leftStick.x >= -epsSwipe && leftStick.x <= epsSwipe && leftStick.y >= (1 - epsSwipe);
        bool leftDown  = leftStick.x >= -epsSwipe && leftStick.x <= epsSwipe && leftStick.y <= -(1 - epsSwipe);

        currentTime += Time.deltaTime;

        if (rightUp || leftUp)
        {
            if ((timesCount <= 1 && currentTime >= firstIntervalChangingHeightSec) || (timesCount > 1 && currentTime >= intervalChangingHeightSec))
            {
                StickUp.Invoke();

                if (Vibration)
                {
                    if (rightUp)
                    {
                        RightController.HapticPulse(VibrationTimeMs);
                    }
                    if (leftUp)
                    {
                        LeftController.HapticPulse(VibrationTimeMs);
                    }
                }

                currentTime = 0;
                ++timesCount;
            }
        }
        else if (rightDown || leftDown)
        {
            if ((timesCount <= 1 && currentTime >= firstIntervalChangingHeightSec) || (timesCount > 1 && currentTime >= intervalChangingHeightSec))
            {
                StickDown.Invoke();
                if (Vibration && rightDown)
                {
                    RightController.HapticPulse(VibrationTimeMs);
                }
                if (Vibration && leftDown)
                {
                    LeftController.HapticPulse(VibrationTimeMs);
                }

                currentTime = 0;
                ++timesCount;
            }
        }

        if (!(rightUp || leftUp) && !(rightDown || leftDown))
        {
            timesCount = 0;
        }
    }
Esempio n. 6
0
 void Start()
 {
     player          = GameObject.FindGameObjectWithTag("Player");
     topController   = player.transform.GetChild(1).GetComponent <TopController>();
     rightController = player.transform.GetChild(0).GetComponent <RightController>();
     leftController  = player.transform.GetChild(3).GetComponent <LeftController>();
     botController   = player.transform.GetChild(2).GetComponent <BotController>();
     editorHandler   = GameObject.Find("EditorHandler").GetComponent <EditorHandler>();
 }
Esempio n. 7
0
    public void SetFingerPos(Vector2 pos)
    {
        if (first)
        {
            first    = false;
            lastPos  = pos;
            initPos  = pos;
            isCancel = true;
            SetPos(pos);
        }
        else
        {
            //根据手指位置调整
            var diff = pos - initPos;
            var dir  = pos - lastPos;
            lastPos = pos;

            //手指在中心半径范围内 50半径 相反运动
            var mag      = diff.magnitude;
            var iner     = this.con.InnerRadius * RightController.GetRate();
            var external = this.con.ExternalRadius * RightController.GetRate();
            if (mag < iner)
            {
                initPos -= dir;
                SetPos(initPos);

                //手指在圆环外面 跟随手指移动
            }
            else if (mag > external)
            {
                var fingerDir = pos - initPos;
                var distOff   = fingerDir.normalized * external;
                initPos = pos - distOff;
                //initPos += dir;
                SetPos(initPos);
            }
            if (mag < this.con.CancelRadius * RightController.GetRate())
            {
                MyEventSystem.myEventSystem.PushEvent(new MyEvent()
                {
                    type    = MyEvent.EventType.CancelShoot,
                    boolArg = false,
                });
                isCancel = true;
            }
            else
            {
                MyEventSystem.myEventSystem.PushEvent(new MyEvent()
                {
                    type    = MyEvent.EventType.CancelShoot,
                    boolArg = true,
                });
                isCancel = false;
            }
        }
    }
Esempio n. 8
0
 private void Awake()
 {
     leftHand             = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/LeftHand");
     rightHand            = this.FindComponent <ActionBasedControllerManager>("XR Origin/Camera Offset/RightHand");
     _interactionManager  = this.FindComponent <XRInteractionManager>("XR Interaction Manager");
     locomotionSystem     = this.FindGameObject("Locomotion System");
     _mainCamera          = this.FindComponent <Camera>("XR Origin/Camera Offset/Main Camera");
     leftXRRayInteractor  = LeftController.GetComponent <XRRayInteractor>();
     rightXRRayInteractor = RightController.GetComponent <XRRayInteractor>();
 }
Esempio n. 9
0
 void Update()
 {
     if (RightController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
     {
         if (!rightMenuActive)
         {
             rightMenuActive = true;
         }
         else
         {
             rightMenuActive = false;
         }
         if ((rightMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole) || (leftMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole))
         {
             userMenu.SetActive(true);
             userMenuActive = true;
         }
         else if (!rightMenuActive && !leftMenuActive)
         {
             userMenu.SetActive(false);
             locomotionMenu.SetActive(false);
             levelMenu.SetActive(false);
             userMenuActive = false;
         }
     }
     if (LeftController.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
     {
         if (!leftMenuActive)
         {
             leftMenuActive = true;
         }
         else
         {
             leftMenuActive = false;
         }
         if ((rightMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole) || (leftMenuActive && !userMenuActive && !locomotionMenuActive && !XRoomConsole))
         {
             userMenu.SetActive(true);
             userMenuActive = true;
         }
         else if (!rightMenuActive && !leftMenuActive)
         {
             userMenu.SetActive(false);
             locomotionMenu.SetActive(false);
             levelMenu.SetActive(false);
             userMenuActive = false;
         }
     }
 }
Esempio n. 10
0
    void Start()
    {
        if (gameObject.transform.parent.CompareTag("SokobanBlock"))
        {
            unpassableBlocksTags = unpassableSokobanBlocksTags;
        }

        block = transform.parent.gameObject;
        iceBlockController = block.GetComponent <IceBlockController>();
        antiBlock          = transform.parent.GetChild(3).GetComponent <BlockRightController>();
        player             = GameObject.FindGameObjectWithTag("Player");
        playerController   = player.GetComponent <PlayerController>();
        playerMovement     = player.transform.GetChild(0).GetComponent <RightController>();
        collider           = gameObject.GetComponent <BoxCollider2D>();
    }
Esempio n. 11
0
    // Use this for initialization
    void Start()
    {
        Instance = this;

        handL =
            VRTK_ControllerReference.GetControllerReference(SDK_BaseController.ControllerHand.Left);

        handR =
            VRTK_ControllerReference.GetControllerReference(SDK_BaseController.ControllerHand.Right);

        if (LeftController != null)
        {
            evL = LeftController.GetComponent <VRTK_ControllerEvents>();
        }
        if (RightController != null)
        {
            evR = RightController.GetComponent <VRTK_ControllerEvents>();
        }

        if (evR != null)
        {
            evR.ButtonOneReleased += new ControllerInteractionEventHandler(RB1Released);
            evR.ButtonTwoReleased += new ControllerInteractionEventHandler(RB2Released);

            evL.ButtonOneReleased += new ControllerInteractionEventHandler(LB1Released);
            evL.ButtonTwoReleased += new ControllerInteractionEventHandler(LB2Released);


            evL.TriggerReleased += new ControllerInteractionEventHandler(RB1Released);
        }


        //

        Invoke("StartDemo", 0.5f); // obligé d'attendre un peu sinon la camera vrtk n'est pas chargée...

        //

        //Bezier.ControlPoints.Clear();

        foreach (Vector3 pos in TrackModel.TrackPositions) // on récupère nos boules éventuelles
        {
            Debug.Log("LOAD BALL AT " + pos);
            Vector3 newPos = pos * 30f;
            CreateBallAtPos(newPos);
        }
    }
Esempio n. 12
0
    void Start()
    {
        StartCoroutine(ReloadMovesCoroutine());
        if (EditorHandler.isBackToCheckpoint)
        {
            IsBackToCheckpoint();
        }

        editorHandler     = GameObject.FindGameObjectWithTag("EditorHandler").GetComponent <EditorHandler>();
        keyHolder         = GameObject.FindGameObjectWithTag("keyList").transform;
        keyHolderAnimator = GameObject.FindGameObjectWithTag("keyInventory").GetComponent <Animator>();

        sr              = gameObject.GetComponent <SpriteRenderer>();
        botController   = gameObject.GetComponentInChildren <BotController>();
        leftController  = gameObject.GetComponentInChildren <LeftController>();
        rightController = gameObject.GetComponentInChildren <RightController>();
        topController   = gameObject.GetComponentInChildren <TopController>();
    }
 void ReleaseDesignerOutlets()
 {
     if (SplitView != null)
     {
         SplitView.Dispose();
         SplitView = null;
     }
     if (LeftController != null)
     {
         LeftController.Dispose();
         LeftController = null;
     }
     if (RightController != null)
     {
         RightController.Dispose();
         RightController = null;
     }
 }
    protected override void Update()
    {
        base.Update();
        if (ButtonEventType == FinchButtonEventType.Right || ButtonEventType == FinchButtonEventType.Any)
        {
            detectPress(FinchChirality.Right);
        }

        if (ButtonEventType == FinchButtonEventType.Left || ButtonEventType == FinchButtonEventType.Any)
        {
            detectPress(FinchChirality.Left);
        }


        bool wasInvoked = false;

        if (ButtonEventType == FinchButtonEventType.BothAtOneTime)
        {
            if ((RightController.GetPress(button) && LeftController.GetPressDown(button)) ||
                (LeftController.GetPress(button) && RightController.GetPressDown(button)))
            {
                if (FinchDownEvent != null)
                {
                    FinchDownEvent.Invoke();
                    wasInvoked = true;
                }
                else if (FinchUpEvent != null)
                {
                    FinchUpEvent.Invoke();
                    wasInvoked = true;
                }

                if (wasInvoked && Vibration)
                {
                    RightController.HapticPulse(VibrationTimeMs);
                    LeftController.HapticPulse(VibrationTimeMs);
                }
            }
        }
    }
Esempio n. 15
0
    public override void _PhysicsProcess(float delta)
    {
        if (RightController.IsButtonPressed((int)Godot.JoystickList.VrTrigger) > 0)
        {
            if (!Shooting)
            {
                Line3D.Vertices = new Vector3[] {
                    RightController.GlobalTransform.origin,
                    RightController.GlobalTransform.origin + RightControllerDirection * ShotRange
                };
                Godot.Collections.Dictionary result = GetWorld().DirectSpaceState.IntersectRay(
                    Line3D.Vertices[0],
                    Line3D.Vertices[1]
                    );

                GD.Print("Shooting! Time: " + DateTime.Now);
                if (result.Count > 0)
                {
                    CollisionObject collider = (CollisionObject)result["collider"];
                    GD.Print(
                        ((CollisionShape)collider.ShapeOwnerGetOwner(collider.ShapeFindOwner((int)result["shape"]))).Name
                        );
                    GD.Print(result);
                    Vector3 position = (Vector3)result["position"];
                    Cube.Transform = new Transform(Basis.Identity, position);
                    Vector3 localPosition = VirtualScreen.ToLocal(position);
                    VirtualScreen.TargetPosition = new Vector2(localPosition.x, localPosition.y);
                }
                else
                {
                    GD.Print("Hit nothing! :(");
                }
                Shooting = true;
            }
        }
        else
        {
            Shooting = false;
        }
    }
    protected override void Update()
    {
        ButtonEventType = FinchButtonEventType.Any;
        base.Update();

        bool startedTouching = !bothTouching &&
                               ((LeftController.GetPress(Button) && RightController.GetPressDown(Button)) ||
                                (RightController.GetPress(Button) && LeftController.GetPressDown(Button)));
        bool eventCanBeInvoked = !alreadyInvoked && bothTouching;
        bool stoppedTouching   = bothTouching && (LeftController.GetPressUp(Button) || RightController.GetPressUp(Button));

        if (startedTouching)
        {
            bothTouching = true;
            stopWatch    = new System.Diagnostics.Stopwatch();
            stopWatch.Start();
        }
        else if (eventCanBeInvoked)
        {
            if (stopWatch.ElapsedMilliseconds >= longTapTimeMs)
            {
                stopWatch.Stop();
                alreadyInvoked = true;
                LongTapBothTouchpads.Invoke();

                if (Vibration)
                {
                    RightController.HapticPulse(VibrationTimeMs);
                    LeftController.HapticPulse(VibrationTimeMs);
                }
            }
        }
        else if (stoppedTouching)
        {
            bothTouching   = false;
            alreadyInvoked = false;
            stopWatch.Stop();
        }
    }
Esempio n. 17
0
    //Use this for initialization

    void Start()
    {
        menuActive = true;

        numCubes = 0;

        numCylinders = 0;


        cylinderNumText.text = numCylinders.ToString();

        cubeNumText.text = numCubes.ToString();


        // cubeButton.onClick.AddListener(cubePressed);

        // cylinderButton.onClick.AddListener(cylinderPressed);

        rc = rightControllerObject.GetComponent <RightController>(); //GameObject.FindGameObjectWithTag("DrawingHand").GetComponent<RightController>();

        pointer.enabled = false;
    }
    private void detectPress(FinchChirality chirality)
    {
        FinchController controller = chirality == FinchChirality.Right ? RightController : LeftController;
        FinchNodeType   nodeType   = chirality == FinchChirality.Right ? FinchNodeType.RightHand : FinchNodeType.LeftHand;
        bool            wasInvoked = false;

        if (FinchDownEvent != null && controller.GetPressDown(button))
        {
            FinchDownEvent.Invoke();
            wasInvoked = true;
        }

        if (FinchUpEvent != null && RightController.GetPressUp(button))
        {
            FinchUpEvent.Invoke();
            wasInvoked = true;
        }

        if (Vibration && wasInvoked)
        {
            FinchVR.HapticPulse(nodeType, VibrationTimeMs);
        }
    }
Esempio n. 19
0
        protected virtual void CreateControllers()
        {
            // コントローラマネージャの生成
            VRLog.Info("SteamVR Controller Manager Create");
            _ControllerManager         = gameObject.AddComponent <SteamVR_ControllerManager>();
            _ControllerManager.enabled = false;
            // コントローラの生成.
            VRLog.Info("Left Controller Create");
            Left = LeftController.Create();
            VRLog.Info("Right Controller Create");
            Right = RightController.Create();


            _ControllerManager.left  = Left.gameObject;
            _ControllerManager.right = Right.gameObject;
            _ControllerManager.UpdateTargets();
            _ControllerManager.enabled = true;

            Left.transform.SetParent(VR.Camera.Origin, true);
            Right.transform.SetParent(VR.Camera.Origin, true);

            return;
        }
Esempio n. 20
0
 protected virtual Controller CreateRightController()
 {
     return(RightController.Create());
 }
Esempio n. 21
0
    private void calculate(FinchChirality chirality)
    {
        Vector2 axis;
        float   currentTime;

        if (chirality == FinchChirality.Right)
        {
            axis              = FinchVR.RightController.GetTouchAxes();
            currentTimeRight += Time.deltaTime;
            currentTime       = currentTimeRight;
        }
        else if (chirality == FinchChirality.Left)
        {
            axis             = FinchVR.LeftController.GetTouchAxes();
            currentTimeLeft += Time.deltaTime;
            currentTime      = currentTimeLeft;
        }
        else
        {
            return;
        }

        //zero
        bool zero = axis.x <= epsZero && axis.x >= -epsZero && axis.y <= epsZero && axis.y >= -epsZero;
        //stick swipe to right-left
        bool swipeToRight = axis.x >= (1 - epsSwipe) && axis.y >= -epsSwipe && axis.y <= epsSwipe;
        bool swipeToLeft  = axis.x <= -(1 - epsSwipe) && axis.y >= -epsSwipe && axis.y <= epsSwipe;

        //stick swipe to up-down
        bool swipeToUp   = axis.x >= -epsSwipe && axis.x <= epsSwipe && axis.y >= (1 - epsSwipe);
        bool swipeToDown = axis.x >= -epsSwipe && axis.x <= epsSwipe && axis.y <= -(1 - epsSwipe);

        bool previousWasZero = chirality == FinchChirality.Right ? previousWasZeroRight : previousWasZeroLeft;

        if (zero)
        {
            if (chirality == FinchChirality.Right)
            {
                currentTimeRight     = 0;
                previousWasZeroRight = true;
            }
            else
            {
                currentTimeLeft     = 0;
                previousWasZeroLeft = true;
            }
            return;
        }

        if (currentTime >= timeToSwapSec)
        {
            currentTime = 0;
            if (chirality == FinchChirality.Right)
            {
                currentTimeRight     = 0;
                previousWasZeroRight = previousWasZero = false;
            }
            else
            {
                currentTimeLeft     = 0;
                previousWasZeroLeft = previousWasZero = false;
            }
        }

        if (previousWasZero)
        {
            bool invoked = false;
            if (swipeToRight)
            {
                SwipeRight.Invoke();
                invoked = true;
            }
            if (swipeToLeft)
            {
                SwipeLeft.Invoke();
                invoked = true;
            }
            if (swipeToUp)
            {
                SwipeUp.Invoke();
                invoked = true;
            }
            if (swipeToDown)
            {
                SwipeDown.Invoke();
                invoked = true;
            }

            if (invoked)
            {
                if (chirality == FinchChirality.Right)
                {
                    previousWasZeroRight = false;
                    currentTimeRight     = 0;
                    if (Vibration)
                    {
                        RightController.HapticPulse(VibrationTimeMs);
                    }
                }
                else
                {
                    previousWasZeroLeft = false;
                    currentTimeLeft     = 0;
                    if (Vibration)
                    {
                        LeftController.HapticPulse(VibrationTimeMs);
                    }
                }
            }
        }
    }
 public ViewResult SecondLevel(LeftController left, RightController right, FormSubmitController formSubmit)
 {
     formSubmit.Model = DateTime.Now;
     ViewData["text"] = "I am a second level controller";
     return View();
 }
Esempio n. 23
0
 /// <summary>
 /// Shut down both controllers in this pair. Must be called when the controllers are no longer needed.
 /// </summary>
 public void Shutdown()
 {
     LeftController.Shutdown();
     RightController.Shutdown();
 }
Esempio n. 24
0
 public ViewResult Left(int? number, string name, RightController right)
 {
     //Subcontroller actions have all the behavior of regular actions, including pulling things off querystrings
     ViewData["text"] = string.Format("{0}:{1}", name, number);
     return View();
 }