GetHairTriggerUp() public method

public GetHairTriggerUp ( ) : bool
return bool
Ejemplo n.º 1
0
    void Update()
    {
        if (Hand.isValid)
        {
            Hand = GetComponent <SteamVR_TrackedObject>();
        }

        device = SteamVR_Controller.Input((int)Hand.index);

        if (ball.shock)
        {
            StartCoroutine("Shock", 0.07f);
        }

        if (device.GetHairTriggerDown())
        {
            if (ball.whoHit == 1)
            {
                isSkill = true;
            }
            //Debug.Log("down");
        }

        if (device.GetHairTriggerUp())
        {
            //isSkill = false;
            //Debug.Log("up");
        }
    }
Ejemplo n.º 2
0
    public ControllerState controllerEvents()
    {
#if SteamVR_Legacy
        if (controller.GetHairTriggerDown())
        {
            return(ControllerState.TRIGGER_DOWN);
        }
        if (controller.GetHairTriggerUp())
        {
            return(ControllerState.TRIGGER_UP);
        }
        if (controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
        {
            return(ControllerState.APPLICATION_MENU);
        }
#elif SteamVR_2
        if (m_controllerPress.GetStateDown(trackedObj.inputSource))
        {
            return(ControllerState.TRIGGER_DOWN);
        }
        if (m_controllerPress.GetStateUp(trackedObj.inputSource))
        {
            return(ControllerState.TRIGGER_UP);
        }
        if (m_menuButton.GetStateDown(trackedObj.inputSource))
        {
            return(ControllerState.APPLICATION_MENU);
        }
#endif
        return(ControllerState.NONE);
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);


        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Press");
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Release");
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            triggerPress = true;
//			Debug.Log(gameObject.name + " Trigger Press");
//			if (gameObject.name == "Controller (right)") {
//				InteractionManager.right_trigger_press = true;
//			} else if (gameObject.name == "Controller (left)") {
//				InteractionManager.left_trigger_press = true;
//			}
//
            //InteractionManager.ActiveHairlineTrigger(gameObject.name);

            //if we're on controller right
//			if(gameObject.name == "Controller (right)"){
//				Debug.Log ("both at the same time!!!");
//
//				//find the interaction manager and call the function we wrote
//
//				//GameObject.Find ("InteractionManager").GetComponent<Interactions> ().HandleRightTriggerPressed ();
//			}
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            triggerPress = false;
//			if (gameObject.name == "Controller (right)") {
//				InteractionManager.right_trigger_press = false;
//			} else if (gameObject.name == "Controller (left)") {
//				InteractionManager.left_trigger_press = false;
//			}
//			Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Press");
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Release");
        }
    }
Ejemplo n.º 5
0
    void ProcessController(SteamVR_Controller.Device controller, GameObject controllerGO, bool left)
    {
        if (controller == null)
        {
            //Debug.LogError("Controller not found " + left);
            return;
        }

        // 1
        if (controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(left + " " + controller.GetAxis());
        }

        // 2
        if (controller.GetHairTriggerDown())
        {
            Debug.LogError(left + " Trigger Press");
            TriggerPull(controllerGO);
        }

        // 3
        if (controller.GetHairTriggerUp())
        {
            Debug.Log(left + " Trigger Release");
        }

        // 4
        if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(left + " Grip Press");
        }

        // 5
        if (controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(left + " Grip Release");
        }

        if (controller.GetTouch(SteamVR_Controller.ButtonMask.Touchpad))
        {
            Debug.Log("STOP TOUCHING ME!");
        }

        if (controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
        {
            TriggerSwitch(controllerGO);
        }

        if (controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
        {
            movementScript.Respawn();
        }

        //Debug.Log("Controller " + left + " has something " + controller.index + " // " + controller.transform.pos);
    }
Ejemplo n.º 6
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            GameObject go = GameObject.Find("Sphere(Clone)");

            if (go == null)
            {
                go = GameObject.Find("Cube");
            }


            //This line is the one that changes the value of photonView.isMine on the specified GameObject
            go.GetComponent <PhotonView> ().RequestOwnership();
            go.GetComponent <TransformManager> ().SetNewParent(this.transform);
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            GameObject go = GameObject.Find("Sphere(Clone)");

            if (go == null)
            {
                go = GameObject.Find("Cube");
            }

            // Make sure we have ownership before we do anything the the objects
            go.GetComponent <PhotonView> ().RequestOwnership();
            go.GetComponent <TransformManager>().DetachParent();
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Press");

            PhotonNetwork.Instantiate(spherePrefab.name, new Vector3(0, 3, 0), Quaternion.identity, 0);
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            Debug.Log(gameObject.name + " Grip Release");
        }
    }
Ejemplo n.º 7
0
 void Update()
 {
     if (device.GetHairTriggerDown())
     {
         triggerDown = true;
     }
     if (device.GetHairTriggerUp())
     {
         triggerDown = false;
     }
 }
Ejemplo n.º 8
0
        //-------------------------------------------------
        // Was the standard interaction button just released? In VR, this is a trigger press. In 2D fallback, this is a mouse left-click.
        //-------------------------------------------------
        public bool GetStandardInteractionButtonUp()
        {
            if (noSteamVRFallbackCamera)
            {
                return(Input.GetMouseButtonUp(0));
            }
            else if (controller != null)
            {
                return(controller.GetHairTriggerUp());
            }

            return(false);
        }
Ejemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        if (controller.GetHairTriggerDown() && hovering)
        {
            triggerIsDown = true;
            animator.SetBool("Grab", triggerIsDown);
            //Debug.Log("grabing");
        }
        else if (controller.GetHairTriggerDown() && !hovering)
        {
            triggerIsDown = true;
            animator.SetBool("Grab", triggerIsDown);
            //Debug.Log("pointing");
        }
        else if (controller.GetHairTriggerUp())
        {
            triggerIsDown = false;
            animator.SetBool("Grab", triggerIsDown);
            animator.SetBool("Point", triggerIsDown);
            //Debug.Log("idling");
        }

        if (triggerIsDown)
        {
            timer += Time.deltaTime;
        }
        else
        {
            timer -= Time.deltaTime;
        }

        if (timer > fadeTime)
        {
            timer = fadeTime;
        }
        if (timer < 0)
        {
            timer = 0;
        }

        alpha = 1 - timer / fadeTime;

        Color tempColour = handMaterial.color;

        tempColour.a       = alpha;
        handMaterial.color = tempColour;

        // Debug.Log("alpha: " + alpha);
    }
Ejemplo n.º 10
0
        void Update()
        {
            if (_trackedObject.index == SteamVR_TrackedObject.EIndex.None)
            {
                // No device
                // TODO: Cancel events that were in progress?
                return;
            }

            SteamVR_Controller.Device device = SteamVR_Controller.Input((int)_trackedObject.index);
            triggerPosition = device.GetAxis(EVRButtonId.k_EButton_SteamVR_Trigger).x;

            // Trigger
            bool hairTriggerBegan  = device.GetHairTriggerDown();
            bool hairTriggerActive = device.GetHairTrigger();
            bool hairTriggerEnded  = device.GetHairTriggerUp();

            if (hairTriggerBegan)
            {
                DelegateFireTriggerBegan();
            }
            if (hairTriggerActive)
            {
                DelegateFireTriggerActive();
            }
            if (hairTriggerEnded)
            {
                DelegateFireTriggerEnded();
            }

            // Grip
            bool gripBegan  = device.GetPressDown(EVRButtonId.k_EButton_Grip);
            bool gripActive = device.GetPress(EVRButtonId.k_EButton_Grip);
            bool gripEnded  = device.GetPressUp(EVRButtonId.k_EButton_Grip);

            if (gripBegan)
            {
                DelegateFireGripBegan();
            }
            if (gripActive)
            {
                DelegateFireGripActive();
            }
            if (gripEnded)
            {
                DelegateFireGripEnded();
            }
        }
Ejemplo n.º 11
0
            /// <summary>
            /// Get the HTC Vive controller hair trigger up state.
            /// </summary>
            /// <returns><c>true</c>, if hair trigger up was gotten, <c>false</c> otherwise.</returns>
            public bool GetHairTriggerUp()
            {
                if (VRReplay.Instance.Mode == VRReplay.ModeType.Playback)
                {
                    return(VRReplay.Instance.QueryVRInputBool(index, "HairTriggerUp", VRDeviceInputType.HairTriggerUp));
                }
                bool state = device.GetHairTriggerUp();

                if (VRReplay.Instance.Mode == VRReplay.ModeType.Record)
                {
                    if (state)
                    {
                        VRReplay.Instance.RecordVRInputBool(index, "HairTriggerUp", VRDeviceInputType.HairTriggerUp, state);
                    }
                }
                return(state);
            }
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.tag.Equals("EditorPoint"))
     {
         if (!deviceleft.GetHairTrigger())
         {
             other.GetComponent <Renderer>().material.color = new Color(255, 0, 0);
         }
         if (deviceleft.GetHairTriggerUp())
         {
             other.GetComponent <Renderer>().material.color = new Color(255, 0, 0);
         }
         Global.modifierCollider = null;
     }
     else
     {
         Global.modifierCollider = null;
     }
 }
Ejemplo n.º 13
0
    // Updates the state of each controller
    void updateControllers()
    {
        for (int i = 0; i < 1; i++)
        {
            ControllerScript          script = controllerStates[i].gameObject.GetComponent <ControllerScript>();
            SteamVR_Controller.Device device = script.Controller;
            if (device == null)
            {
                continue;
            }

            Vector3 pos = controllerStates[i].gameObject.transform.position;
            int     grabbedVertIndex = controllerStates[i].grabbedVertIndex;
            bool    isGrabbing       = controllerStates[i].isGrabbing;

            // Counterintuitively.. getHairTriggerDown() only returns true on the first frame that the trigger is pulled.
            // This is good though because that's actually what we want.
            if (device.GetHairTriggerDown())
            {
                int     nearestVertIndex = nearestVertexTo(pos);
                Vector3 nearestVertPos   = transform.TransformPoint(mesh.vertices[nearestVertIndex]);
                double  dist             = (pos - nearestVertPos).magnitude;

                if (dist < minSelectionDist)
                {
                    isGrabbing       = true;
                    grabbedVertIndex = nearestVertIndex;
                }
            }

            if (device.GetHairTriggerUp())
            {
                isGrabbing = false;
            }


            controllerStates[i].isGrabbing       = isGrabbing;
            controllerStates[i].pos              = transform.InverseTransformPoint(pos);
            controllerStates[i].grabbedVertIndex = grabbedVertIndex;
            controllerStates[i].script           = script;
            controllerStates[i].device           = device;
        }
    }
Ejemplo n.º 14
0
        /// <summary>
        /// Get the Steam VR hair trigger up state.
        /// </summary>
        /// <returns>Trigger up state.</returns>
        public bool GetHairTriggerUp()
        {
            if (CurrentInputMode == RVInputMode.Playback)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.HasCurrentFrame() ?
                                             CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, "HairTriggerUp") : null;
                return(inputInfo == null ? false : inputInfo.HairTriggerUpState);
            }
            bool stateValue = m_DeviceImpl.GetHairTriggerUp();

            if (CurrentInputMode == RVInputMode.Record)
            {
                SteamVRInputInfo inputInfo = CurrentRecording.CurrentFrame.GetInputInfo(DeviceIndex, "HairTriggerUp");
                if (inputInfo == null)
                {
                    inputInfo = new SteamVRInputInfo();
                }
                inputInfo.HairTriggerUpState = stateValue;
                CurrentRecording.CurrentFrame.AddInputInfo(DeviceIndex, "HairTriggerUp", inputInfo);
            }
            return(stateValue);
        }
Ejemplo n.º 15
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        // Getting the Touchpad Axis
        checkSwipe();
        showMode();

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Press");
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Release");
            GameObject lc = GameObject.Find("Controller (left)");
            GameObject rc = GameObject.Find("Controller (right)");

            lc.GetComponentInChildren <Canvas> ().enabled = !lc.GetComponentInChildren <Canvas> ().enabled;
            rc.GetComponentInChildren <Canvas> ().enabled = !rc.GetComponentInChildren <Canvas> ().enabled;
        }
        Debug.Log("SC: " + swipeCounter);
    }
Ejemplo n.º 16
0
        void FixedUpdate()
        {
            device = SteamVR_Controller.Input((int)trackedObj.index);

            if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                Vector2 touchpad = (device.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0));
                print("Pressing Touchpad" + touchpad.y);

                if (this.flg == 0 && touchpad.y > 0.3f) // start write
                {
                    print("Moving Up");
                    this.flg = 1;
                    this.tag = 0;
                    print("start to write");
                    SB.Length = 0;
                    SB.AppendLine("{");
                    //SB.AppendLine("\"word\" : \"" + this.wordList[wordID] + "\",");

                    SB.AppendLine("\"word\" : \"" + "10" + "\",");
                    SB.AppendLine("\"fps\" : " + (int)Math.Ceiling(1.0 / Time.fixedDeltaTime) + ",");
                    SB.AppendLine("\"name\" : \"" + this.Name + "\",");
                    SB.AppendLine("\"id\" : " + this.uid + ",");
                    SB.AppendLine("\"data\" : [");
                }

                else if (touchpad.y < -0.3f) // clear
                {
                    print("Moving Down");
                    this.flg = 0;
                    clearall();
                }

                //if (touchpad.x > 0.7f)
                //{
                //    print("Moving Right");

                //}

                //else if (touchpad.x < -0.7f)
                //{
                //    print("Moving left");
                //}
            }

            if (this.flg == 1 && device.GetHairTriggerUp()) // send to server
            {
                Debug.Log(gameObject.name + " Trigger Release");

                this.flg = 0;
                print("Stop to write and save data");
                SB = new StringBuilder(SB.ToString().TrimEnd('\n'));
                SB = new StringBuilder(SB.ToString().TrimEnd(','));
                SB.Append("\n");
                SB.AppendLine("\t]");
                SB.AppendLine("}");

                // TODO
                var    temp         = new Program();
                string value        = "";
                Thread socketThread = new Thread(() =>
                {
                    value = temp.Modelprocess(SB.ToString(), myCallback); // Publish the return value
                });
                socketThread.Start();
            }

            if (this.flg1 < 2 && Input.GetKey(KeyCode.Space))
            {
                this.flg1 = 0;
                clearall();
            }

            //if (this.flg1 == 0 && Input.GetKey(KeyCode.A)) {
            //    this.flg1 = 1;
            //    if (wordID > 0)
            //        this.wordID = this.wordID - 1;
            //    target.GetComponent<TextMesh>().text = this.wordID+ ". " + wordList[wordID];
            //    clearall();
            //    //print("In left " + wordID + " " + this.wordList[wordID]);
            //}

            //if (this.flg1 == 0 && Input.GetKey(KeyCode.D)) {
            //    this.flg1 = 1;
            //    if (this.wordID < this.wordList.Count-1)
            //        this.wordID = this.wordID + 1;
            //    target.GetComponent<TextMesh>().text = this.wordID + ". " + wordList[wordID];
            //    clearall();
            //    //print("In right " + wordID + " " + this.wordList[wordID]);
            //}

            if (this.flg == 0 && Input.GetKey(KeyCode.W))
            {
                this.flg  = 1;
                this.flg1 = 2;
                this.tag  = 0;
                print("start to write");
                SB.Length = 0;
                SB.AppendLine("{");
                //SB.AppendLine("\"word\" : \"" + this.wordList[wordID] + "\",");

                SB.AppendLine("\"word\" : \"" + "10" + "\",");
                SB.AppendLine("\"fps\" : " + (int)Math.Ceiling(1.0 / Time.fixedDeltaTime) + ",");
                SB.AppendLine("\"name\" : \"" + this.Name + "\",");
                SB.AppendLine("\"id\" : " + this.uid + ",");
                SB.AppendLine("\"data\" : [");
            }

            if (this.flg == 1 && Input.GetKey(KeyCode.S))
            {
                this.flg  = 0;
                this.flg1 = 0;
                print("Stop to write and save data");
                SB = new StringBuilder(SB.ToString().TrimEnd('\n'));
                SB = new StringBuilder(SB.ToString().TrimEnd(','));
                SB.Append("\n");
                SB.AppendLine("\t]");
                SB.AppendLine("}");

                // TODO
                var    temp         = new Program();
                string value        = "";
                Thread socketThread = new Thread(() =>
                {
                    value = temp.Modelprocess(SB.ToString(), myCallback); // Publish the return value
                });
                socketThread.Start();
                //    print(socketThread.IsAlive);
                //    socketThread.Join(10000);
                //    print(socketThread.IsAlive);
                //target.GetComponent<TextMesh>().text = value;

                //string ptr = this.path + @"\" + this.uid + @"\" + this.wordList[this.wordID] + ".json";

                //if (!File.Exists(ptr)) {
                //    Debug.LogError("Oops!! " + ptr + " is not exist!!!!!");
                //}
                //else {
                //    File.WriteAllText(ptr, SB.ToString(), Encoding.UTF8);

                //}
            }

            if (this.flg == 1)
            {
                for (int i = 0; i < _pinchDetectors.Length; i++)
                {
                    var detector  = _pinchDetectors[i];
                    var drawState = _drawStates[i];


                    if (detector.IsHolding)
                    {
                        List <Finger> fingers = frame.Hands[0].Fingers;

                        Vector3 tipPosition  = fingers[1].TipPosition.ToVector3();
                        Vector3 tipDirection = fingers[1].Direction.ToVector3();
                        Vector3 tipVelocity  = fingers[1].TipVelocity.ToVector3();

                        var epochStart = new System.DateTime(1970, 1, 1, 8, 0, 0, System.DateTimeKind.Utc);
                        var timestamp  = (System.DateTime.UtcNow - epochStart).TotalSeconds;

                        /*
                         * print("detector ");
                         * print(detector.Position.x + ", " + detector.Position.y + ", " + detector.Position.z);
                         * print("tipPosition");
                         * print(tipPosition.x + ", " + tipPosition.y + ", " + tipPosition.z);
                         */
                        string qq = "\t{ \"face\" : [" + Camera.main.transform.forward.x + ", " + Camera.main.transform.forward.y + ", " + Camera.main.transform.forward.z + "], " +
                                    "\"head\" : [" + Camera.main.transform.position.x + ", " + Camera.main.transform.position.y + ", " + Camera.main.transform.position.z + "], " +
                                    "\"time\" : " + timestamp +
                                    ", \"position\" : [" + detector.Position.x + ", " + detector.Position.y + ", " + detector.Position.z + "] " +
                                    ", \"direction\" : [" + tipDirection.x + ", " + tipDirection.y + ", " + tipDirection.z + "] " +
                                    ", \"velocity\" : [" + tipVelocity.x + ", " + tipVelocity.y + ", " + tipVelocity.z + "] " +
                                    ", \"tag\" : " + this.tag +
                                    "},\n";

                        SB.Append(qq);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        private void Update()
        {
            controllerIndex = (uint)trackedController.index;
            //Only continue if the controller index has been set to a sensible number
            //SteamVR seems to put the index to the uint max value if it can't find the controller
            if (controllerIndex >= uint.MaxValue)
            {
                return;
            }

            device = SteamVR_Controller.Input((int)controllerIndex);

            Vector2 currentTriggerAxis  = device.GetAxis(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger);
            Vector2 currentTouchpadAxis = device.GetAxis();

            //Trigger Pressed
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerPressed(SetButtonEvent(ref triggerPressed, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Press, true, currentTriggerAxis.x, ref triggerPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerReleased(SetButtonEvent(ref triggerPressed, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Press, false, 0f, ref triggerPressed);
            }

            //Trigger Touched
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerTouchStart(SetButtonEvent(ref triggerTouched, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Touch, true, currentTriggerAxis.x, ref triggerTouched);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                OnTriggerTouchEnd(SetButtonEvent(ref triggerTouched, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Touch, false, 0f, ref triggerTouched);
            }

            //Trigger Hairline
            if (device.GetHairTriggerDown())
            {
                OnTriggerHairlineStart(SetButtonEvent(ref triggerHairlinePressed, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Hairline, true, currentTriggerAxis.x, ref triggerHairlinePressed);
            }
            else if (device.GetHairTriggerUp())
            {
                OnTriggerHairlineEnd(SetButtonEvent(ref triggerHairlinePressed, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Hairline, false, 0f, ref triggerHairlinePressed);
            }

            //Trigger Clicked
            if (!triggerClicked && currentTriggerAxis.x == 1f)
            {
                OnTriggerClicked(SetButtonEvent(ref triggerClicked, true, currentTriggerAxis.x));
                EmitAlias(ButtonAlias.Trigger_Click, true, currentTriggerAxis.x, ref triggerClicked);
            }
            else if (triggerClicked && currentTriggerAxis.x < 1f)
            {
                OnTriggerUnclicked(SetButtonEvent(ref triggerClicked, false, 0f));
                EmitAlias(ButtonAlias.Trigger_Click, false, 0f, ref triggerClicked);
            }

            //Trigger Axis
            if (Vector2ShallowEquals(triggerAxis, currentTriggerAxis))
            {
                triggerAxisChanged = false;
            }
            else
            {
                OnTriggerAxisChanged(SetButtonEvent(ref triggerAxisChanged, true, currentTriggerAxis.x));
            }

            //ApplicationMenu
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                OnApplicationMenuPressed(SetButtonEvent(ref applicationMenuPressed, true, 1f));
                EmitAlias(ButtonAlias.Application_Menu, true, 1f, ref applicationMenuPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                OnApplicationMenuReleased(SetButtonEvent(ref applicationMenuPressed, false, 0f));
                EmitAlias(ButtonAlias.Application_Menu, false, 0f, ref applicationMenuPressed);
            }

            //Grip
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                OnGripPressed(SetButtonEvent(ref gripPressed, true, 1f));
                EmitAlias(ButtonAlias.Grip, true, 1f, ref gripPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                OnGripReleased(SetButtonEvent(ref gripPressed, false, 0f));
                EmitAlias(ButtonAlias.Grip, false, 0f, ref gripPressed);
            }

            //Touchpad Pressed
            if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadPressed(SetButtonEvent(ref touchpadPressed, true, 1f));
                EmitAlias(ButtonAlias.Touchpad_Press, true, 1f, ref touchpadPressed);
            }
            else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadReleased(SetButtonEvent(ref touchpadPressed, false, 0f));
                EmitAlias(ButtonAlias.Touchpad_Press, false, 0f, ref touchpadPressed);
            }

            //Touchpad Touched
            if (device.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadTouchStart(SetButtonEvent(ref touchpadTouched, true, 1f));
                EmitAlias(ButtonAlias.Touchpad_Touch, true, 1f, ref touchpadTouched);
            }
            else if (device.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                OnTouchpadTouchEnd(SetButtonEvent(ref touchpadTouched, false, 0f));
                EmitAlias(ButtonAlias.Touchpad_Touch, false, 0f, ref touchpadTouched);
            }

            if (Vector2ShallowEquals(touchpadAxis, currentTouchpadAxis))
            {
                touchpadAxisChanged = false;
            }
            else
            {
                OnTouchpadAxisChanged(SetButtonEvent(ref touchpadTouched, true, 1f));
                touchpadAxisChanged = true;
            }

            // Save current touch and trigger settings to detect next change.
            touchpadAxis     = new Vector2(currentTouchpadAxis.x, currentTouchpadAxis.y);
            triggerAxis      = new Vector2(currentTriggerAxis.x, currentTriggerAxis.y);
            hairTriggerDelta = device.hairTriggerDelta;
        }
Ejemplo n.º 18
0
    private void checkRight()
    {
        if (withWeapon == false)
        {
            if (cdTime <= 0f)
            {
                //add new ball
                cdTime     = coolDown;
                withWeapon = true;
                CmdsetAct();
                RumbleTime(2000f, 0.1f);
                CmdCreateBall(transform.GetChild(3).position, localPlayer.gameObject.GetComponent <NetworkIdentity>());
            }
            else
            {
                cdTime = cdTime - Time.deltaTime;
                if (steamDevice.GetHairTriggerDown())
                {
                    //RumbleTime(4000f, 0.2f);
                }
            }
        }
        else
        {
            vel = steamDevice.velocity;
            if (steamDevice.GetHairTriggerUp())
            {
                //CmdreleaseBall(totalSpeed * 8f);
                if (ballInHand.GetComponent <ballController>().hasAuthority)
                {
                    ballInHand.GetComponent <ballController>().follow = false;



                    Rigidbody rb = ballInHand.GetComponent <Rigidbody>();
                    rb.isKinematic = false;
                    Vector3 vv = totalSpeed / totalNum * speedFac;
                    if (vv.magnitude > 15)
                    {
                        vv = 15 * Vector3.Normalize(vv);
                    }
                    rb.velocity        = vv;
                    rb.angularVelocity = Vector3.zero;
                    ballInHand         = null;
                    withWeapon         = false;
                }
                //RumbleTime(4000, 0.1f);
                //Instantiate(ballPrefab,transform.GetChild(3).position, Quaternion.identity);
                counter = 0;
            }



            //get the velocity

            //Rigidbody rb = GetComponent<Rigidbody>();
            // if (vel.magnitude > 1.8 && vel.magnitude < 20) {
            //  counter++;
            // }
            // else counter = 0;
        }
    }
Ejemplo n.º 19
0
        //EMPTY
        #region PUBLIC_METHODS
        #endregion PUBLIC_METHODS


        #region PRIVATE_METHODS
        /// <summary>
        /// Handle the Left Controller input and put them in the Events
        /// </summary>
        public void CheckControllerInput(VRInputsEvents clickEvents, VRInputsEvents touchEvents, VRInputsBoolean clickBools, VRInputsBoolean touchBools, SteamVR_Controller.Device controller, Vector2Variable thumbOrientation)
        {
            BoolVariable tempClick;
            BoolVariable tempTouch;

            #region TRIGGER
            tempClick = clickBools.Get("TriggerIsDown");
            tempTouch = touchBools.Get("TriggerIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetHairTriggerDown())
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetHairTriggerUp())
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("TriggerUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Trigger))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("TriggerStopTouching");
                _tempEvent.Raise();
            }
            #endregion TRIGGER

            #region TOUCHPAD
            thumbOrientation.SetValue(controller.GetAxis());

            tempClick = clickBools.Get("ThumbIsDown");
            tempTouch = touchBools.Get("ThumbIsTouching");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(true);
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("ThumbUp");
                _tempEvent.Raise();
            }
            // Check Touch Events if user is not clicking
            else if (!tempClick.Value && !tempTouch.Value && controller.GetTouchDown(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(true);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStartTouching");
                _tempEvent.Raise();
            }
            else if (tempTouch.Value && controller.GetTouchUp(SteamVR_Controller.ButtonMask.Touchpad))
            {
                tempTouch.SetValue(false);
                _tempEvent = (GameEvent)touchEvents.Get("ThumbStopTouching");
                _tempEvent.Raise();
            }
            #endregion TOUCHPAD

            #region GRIP
            tempClick = clickBools.Get("GripIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("GripDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("GripUp");
                _tempEvent.Raise();
            }
            #endregion GRIP

            #region MENU
            tempClick = clickBools.Get("MenuIsDown");

            // Check Click Events
            if (!tempClick.Value && controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(true);
                _tempEvent = (GameEvent)clickEvents.Get("MenuDown");
                _tempEvent.Raise();
            }
            else if (tempClick.Value && controller.GetPressUp(SteamVR_Controller.ButtonMask.ApplicationMenu))
            {
                tempClick.SetValue(false);
                _tempEvent = (GameEvent)clickEvents.Get("MenuUp");
                _tempEvent.Raise();
            }
            #endregion MENU
        }
Ejemplo n.º 20
0
    // Update is called once per frame
    void Update()
    {
        Controller = SteamVR_Controller.Input((int)trackedObj.index);


//		Controller.TriggerHapticPulse (700);
//		if(Controller.GetPressDown(SteamVR_Controller.ButtonMask.ApplicationMenu)){
//
//			Debug.Log("Yeah boiiiiiiii");
//		}

        // Getting the Touchpad Axis
        if (gameObject.name == "Controller (left)")
        {
            checkSwipe();
            showMode();
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Debug.Log(gameObject.name + " Trigger Release");
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Press");
            //anim.StopPlayback();
            //anim.enabled = false;
            //anim.isActiveAndEnabled = false;
            //anim.
            //anim.stop
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
            //Debug.Log(gameObject.name + " Grip Release");


            lc.GetComponentInChildren <Canvas> ().enabled = !lc.GetComponentInChildren <Canvas> ().enabled;
            rc.GetComponentInChildren <Canvas> ().enabled = !rc.GetComponentInChildren <Canvas> ().enabled;

            displayMenus = lc.GetComponentInChildren <Canvas> ().enabled;

            if (!displayMenus)
            {
                swipeCountPrev = swipeCounter;
                swipeCounter   = 100;
            }
            else
            {
                swipeCounter = swipeCountPrev;
            }

            manager.GetComponent <prefabDisplay>().showPrefabs = displayMenus;
        }
        //Debug.Log ("SC: " + swipeCounter);
    }
Ejemplo n.º 21
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (Global.mode == 3 && Global.isTips == 0)
     {
         if (deviceleft.GetHairTrigger())
         {
             if (Global.handGripObj != null)
             {
                 if (!Global.selectObjDict.Contains(Global.handGripObj))
                 {
                     Global.selectObjDict.Add(Global.handGripObj);
                 }
                 foreach (GameObject g in Global.selectObjDict)
                 {
                     g.transform.parent = Global.handGripObj.transform;
                 }
                 if (device.GetHairTrigger())
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = Global.handGripObj.GetComponent <Rigidbody>();
                 }
                 if (device.GetHairTriggerUp())
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = null;
                 }
                 if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
                 {
                     float xx = device.GetState().rAxis0.x;
                     float yy = device.GetState().rAxis0.y;
                     if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                     {
                         Global.handGripObj.AddComponent <CombineMesh>();
                         Global.selectObjDict.Clear();
                     }
                 }
             }
             else
             {
                 foreach (GameObject g in Global.selectObjDict)
                 {
                     g.transform.parent = Global.sceneSet[Global.sceneSet.Count - 1].transform;
                 }
                 FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                 fixedjoint.connectedBody = null;
             }
             foreach (GameObject g in Global.selectObjDict)
             {
                 g.GetComponent <Renderer>().material.color = new Color(200, 255, 0);
             }
         }
         else
         {
             foreach (GameObject g in Global.selectObjDict)
             {
                 g.GetComponent <Renderer>().material.color = new Color(255, 255, 255);
             }
             foreach (GameObject g in Global.selectObjDict)
             {
                 g.transform.parent = Global.sceneSet[Global.sceneSet.Count - 1].transform;
             }
             Global.selectObjDict.Clear();
             if (device.GetPress(SteamVR_Controller.ButtonMask.Trigger))
             {
                 if (Global.handGripObj != null)
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = Global.handGripObj.GetComponent <Rigidbody>();
                 }
                 else if (Global.handGripObj == null)
                 {
                     FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                     fixedjoint.connectedBody = null;
                 }
             }
             if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
             {
                 FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                 fixedjoint.connectedBody = null;
             }
             if (device.GetPressDown(SteamVR_Controller.ButtonMask.Touchpad))
             {
                 float xx = device.GetState().rAxis0.x;
                 float yy = device.GetState().rAxis0.y;
                 // Debug.Log(xx+","+yy);
                 if (xx < 1 && xx > 0.5 && yy < 0.5 && yy > -0.5)
                 {
                     if (Global.handGripObj != null)
                     {
                         GameObject copyobj    = Copy(Global.handGripObj);
                         FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                         fixedjoint.connectedBody = copyobj.GetComponent <Rigidbody>();
                     }
                     else if (Global.handGripObj == null)
                     {
                         FixedJoint fixedjoint = handjoint.GetComponent <FixedJoint>();
                         fixedjoint.connectedBody = null;
                     }
                 }
                 else if (xx < -0.5 && xx > -1 && yy < 0.5 && yy > -0.5)
                 {
                 }
                 if (xx < 0.5 && xx > -0.5 && yy < 1 && yy > 0.5)
                 {
                     SacleIncrease(Global.handGripObj);
                 }
                 if (xx < 0.5 && xx > -0.5 && yy < -0.5 && yy > -1)
                 {
                     SacleDecrease(Global.handGripObj);
                 }
             }
         }
     }
 }
Ejemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {
        float    alpha    = 1f;
        Gradient gradient = new Gradient();

        gradient.SetKeys(
            new GradientColorKey[] { new GradientColorKey(Color.green, 0f), new GradientColorKey(Color.green, 1f) },
            new GradientAlphaKey[] { new GradientAlphaKey(alpha, 0f), new GradientAlphaKey(alpha, 1f) }
            );
        lr.colorGradient = gradient;

        Controller = SteamVR_Controller.Input((int)trackedObj.index);

        positions [0] = transform.position;                //new Vector3 (-2f,0.2f,0f);
        positions [1] = transform.position;                //new Vector3 (0f,0.2f,0f);
        //positions [2] = new Vector3 (2f,-2f,0f);
        lr.positionCount = positions.Length;
        lr.SetPositions(positions);

        Raycasting();

        // Getting the Touchpad Axis
        if (Controller.GetAxis() != Vector2.zero)
        {
            Debug.Log(gameObject.name + Controller.GetAxis());

            if (transform.childCount > 2 && transform.GetChild(2).tag == "Light")
            {
                lt.intensity = Controller.GetAxis().x + 1;
            }
//			Transform go = gameObject.transform.GetChild (1);
//			go.parent = null;
//			go.transform.localScale = Vector3.one;
        }

        // Getting the Trigger press
        if (Controller.GetHairTriggerDown())
        {
            Debug.Log(gameObject.name + " Trigger Press");
        }

        // Getting the Trigger Release
        if (Controller.GetHairTriggerUp())
        {
            Transform go = gameObject.transform.GetChild(2);
            go.GetComponent <PhotonView> ().RequestOwnership();
            go.GetComponent <TransformManager>().MakeVisible();
            go.GetComponent <TransformManager> ().DetachParent();
            //
            //go.parent = null;
            //go.transform.localScale = Vector3.one;
        }

        // Getting the Grip Press
        if (Controller.GetPressDown(SteamVR_Controller.ButtonMask.Grip))
        {
//			Debug.Log(gameObject.name + " Grip Press");
//			float alpha = 1f;
//			Gradient gradient = new Gradient ();
//			gradient.SetKeys (
//				new GradientColorKey[] { new GradientColorKey (Color.yellow, 0f), new GradientColorKey (Color.yellow, 1f) },
//				new GradientAlphaKey[] { new GradientAlphaKey (alpha, 0f), new GradientAlphaKey (alpha, 1f) }
//			);
//			lr.colorGradient = gradient;
//
//			//set some positions
//
//			positions [0] = transform.position;//new Vector3 (-2f,0.2f,0f);
////			var localDirection = transform.InverseTransformPoint (transform.forward);
//			//var localDirection = transform.InverseTransformDirection(transform.forward);
//			positions [1] = transform.TransformDirection(transform.forward);//hit.collider.gameObject.transform.position;//new Vector3 (0f,0.2f,0f);
//			//positions [2] = new Vector3 (2f,-2f,0f);
//			Debug.Log("fwd on yellow is: " + Vector3.forward);
//			lr.positionCount = positions.Length;
//			lr.SetPositions (positions);
//			reset = false;
        }

        // Getting the Grip Release
        if (Controller.GetPressUp(SteamVR_Controller.ButtonMask.Grip))
        {
//			Debug.Log(gameObject.name + " Grip Release");
//			reset = true;
        }
    }