예제 #1
0
 private void HandleKey(OVRInput.Button button, OVRInput.Controller controller, DirectInput.ScanCode scancode)
 {
     if (OVRInput.GetDown(button, controller))
     {
         DirectInput.Input.SendKey(scancode, false);
     }
     if (OVRInput.GetUp(button, controller))
     {
         DirectInput.Input.SendKey(scancode, true);
     }
 }
예제 #2
0
 // Get - Button
 public static bool Get(OVRInput.Button input)
 {
     InitOVRInput();
     if (_buttonKeycodeMap.ContainsKey(input))
     {
         if (Input.GetKey(_buttonKeycodeMap[input]))
         {
             return(true);
         }
     }
     return(OVRInput.Get(input));
 }
 void CheckAndOutputText(OVRInput.Button data)
 {
     // if(OVRInput.Get(bt))
     // {
     //     tm.text += bt.ToString() + "\n";
     // }
     if (OVRInput.Get(data))
     {
         tm.text += "<color=#ff0000>";
         tm.text += data.ToString() + ":" + OVRInput.Get(data).ToString() + "\n";
         tm.text += "</color>";
     }
 }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     if (this.name == "HandRight")
     {
         inputHand  = OVRInput.Button.SecondaryHandTrigger;
         controller = OVRInput.Controller.RTouch;
     }
     else if (this.name == "HandLeft")
     {
         inputHand  = OVRInput.Button.PrimaryHandTrigger;
         controller = OVRInput.Controller.LTouch;
     }
     inHand = _Weapon.gameObject.GetComponent <Weapon>().inHand;
 }
예제 #5
0
        public override void OnButtonDown(OVRInput.Button button)
        {
            base.OnButtonDown(button);
            if (!IsUsable)
            {
                return;
            }

            // 0番目のモジュールを使用
            if (button == OVRInput.Button.One)
            {
                _weaponModules[0].OnUseModule(this);
            }
        }
예제 #6
0
    // Token: 0x06005668 RID: 22120 RVA: 0x001DBC0C File Offset: 0x001DA00C
    private bool GetButton(OVRInput.Button button, OVRInput.Controller controller)
    {
        EVRButtonId buttonId;

        if (button != OVRInput.Button.One)
        {
            if (button != OVRInput.Button.Two)
            {
                if (button != OVRInput.Button.Start)
                {
                    if (button != OVRInput.Button.PrimaryIndexTrigger)
                    {
                        if (button != OVRInput.Button.PrimaryHandTrigger)
                        {
                            if (button != OVRInput.Button.PrimaryThumbstick)
                            {
                                buttonId = EVRButtonId.k_EButton_Max;
                            }
                            else
                            {
                                buttonId = EVRButtonId.k_EButton_Axis0;
                            }
                        }
                        else
                        {
                            buttonId = EVRButtonId.k_EButton_Grip;
                        }
                    }
                    else
                    {
                        buttonId = EVRButtonId.k_EButton_Axis1;
                    }
                }
                else
                {
                    buttonId = EVRButtonId.k_EButton_Max;
                }
            }
            else
            {
                buttonId = EVRButtonId.k_EButton_ApplicationMenu;
            }
        }
        else
        {
            buttonId = EVRButtonId.k_EButton_A;
        }
        return(this.GetSteamController(controller).GetPress(buttonId));
    }
예제 #7
0
    private void Awake()
    {
        collectArea          = Instantiate(collectAreaPrefab);
        abilityHandlerScript = GetComponent <AbilityHandler>();

        if (string.Equals(transform.parent.name, "LeftHandAnchor"))     // Initialize hand and index triggers
        {
            handTrigger  = OVRInput.Button.PrimaryHandTrigger;
            indexTrigger = OVRInput.Button.PrimaryIndexTrigger;
        }
        else if (string.Equals(transform.parent.name, "RightHandAnchor"))
        {
            handTrigger  = OVRInput.Button.SecondaryHandTrigger;
            indexTrigger = OVRInput.Button.SecondaryIndexTrigger;
        }
        else
        {
            Debug.LogWarning("Container GameObject isn't parented correctly with OVRCameraRig");
        }

        foreach (Transform child in transform)  // Initialize container opening transform
        {
            if (string.Equals(child.name, "ContainerOpening"))
            {
                containerOpeningTransform = child;
            }
        }
        if (!containerOpeningTransform)
        {
            Debug.LogWarning("Container GameObject doesn't have a container opening under it");
        }
        containerTransform = transform;
        collectArea.transform.localScale = smallCollectAreaLocalScale;
        collectArea.SetActive(false);
        updateCollectArea = false;

        collectedTicTacCount = 0;
        collectedTicTacs     = new List <GameObject>(); // Initialize collected tic tacs

        collectLocalPositions = new Queue <Vector3>();  // Initialize collect local positions
        collectLocalPositions.Enqueue(new Vector3(-1, -1));
        collectLocalPositions.Enqueue(new Vector3(0, -1));
        collectLocalPositions.Enqueue(new Vector3(1, -1));
        collectLocalPositions.Enqueue(new Vector3(-1, 1));
        collectLocalPositions.Enqueue(new Vector3(0, 1));
        collectLocalPositions.Enqueue(new Vector3(1, 1));

        usingAbility = false;
    }
예제 #8
0
 //Checks which hand is used
 void checkInput()
 {
     //Checks if weapon is in right or left hand; sets the inputs accordingly.
     if (this.transform.parent.name == "HandRight")
     {
         this.inputHand          = OVRInput.Button.SecondaryIndexTrigger;
         this.positionCorrection = positionCorrectionR;
         inRightHand             = true;
     }
     else if (this.transform.parent.name == "HandLeft")
     {
         this.inputHand          = OVRInput.Button.PrimaryIndexTrigger;
         this.positionCorrection = positionCorrectionL;
         inRightHand             = false;
     }
 }
예제 #9
0
        private static bool IsKeyJustPressed(OVRInput.Button key)
        {
            if (!PreviousStates.ContainsKey(key))
            {
                PreviousStates.Add(key, false);
            }

            if (OVRInput.Get(key, OVRInput.Controller.Touch) && !PreviousStates[key])
            {
                return(PreviousStates[key] = true);
            }
            else
            {
                return(PreviousStates[key] = false);
            }
        }
예제 #10
0
        private int GetButtonIndex(OVRInput.Button button)
        {
            switch (button)
            {
            case OVRInput.Button.One:
                return((int)VRInputDevice.VRControl.Action1);

            case OVRInput.Button.Two:
                return((int)VRInputDevice.VRControl.Action2);

            case OVRInput.Button.PrimaryThumbstick:
                return((int)VRInputDevice.VRControl.LeftStickButton);
            }

            // Not all buttons are currently mapped
            return(-1);
        }
예제 #11
0
 void OnButtonDown(OVRInput.Button button)
 {
     if (button == OVRInput.Button.Three && waitingToStart)
     {
         ActivateTutorial(false);
         SetUpNextRound();
         NextItem();
     }
     else if (button == OVRInput.Button.PrimaryThumbstickLeft && !waitingToStart)
     {
         CheckIfCorrect(rounds[roundIndex].yesKeys);
     }
     else if (button == OVRInput.Button.PrimaryThumbstickRight && !waitingToStart)
     {
         CheckIfCorrect(rounds[roundIndex].noKeys);
     }
 }
예제 #12
0
 public void TriggerSkill(ISkill skill, OVRInput.Button button, OVRInput.Controller controller)
 {
     if (OVRInput.GetDown(button, controller))
     {
         Debug.Log("Pressed Trigger");
         skill.InvokeSkill(true, controller);
     }
     if (OVRInput.GetUp(button, controller))
     {
         Debug.Log("Released Trigger");
         skill.InvokeSkill(false, controller);
     }
     if (OVRInput.Get(button, controller))
     {
         skill.InvokeSkill(true, controller);
     }
 }
예제 #13
0
    void OnButtonDown(OVRInput.Button button)
    {
        //Debug.LogError("Getting input from button " + button);

        if (!fadeAnimator.GetCurrentAnimatorStateInfo(0).IsName("Fade"))
        {
            fadeAnimator.SetTrigger("Fade");

            if (button == OVRInput.Button.One)
            {
                NextPerspective();
            }
            else
            {
                PreviousPerspective();
            }
        }
    }
예제 #14
0
 private void OnButtonDown(OVRInput.Button key)
 {
     if (key == OVRInput.Button.SecondaryThumbstickLeft && !acknowledgementPanel.activeInHierarchy)
     {
         ChangeID(-1);
     }
     else if (key == OVRInput.Button.SecondaryThumbstickRight && !acknowledgementPanel.activeInHierarchy)
     {
         ChangeID(1);
     }
     else if (key == OVRInput.Button.One)
     {
         SubmitID();
     }
     else if (key == OVRInput.Button.Two && acknowledgementPanel.activeInHierarchy)
     {
         Cancel();
     }
 }
예제 #15
0
        // Find the current active controller, based on last time a certain button was hit. Needs to know the previous active controller.
        public static OVRInput.Controller GetControllerForButton(OVRInput.Button joyPadClickButton, OVRInput.Controller oldController)
        {
            OVRInput.Controller controller = OVRInput.GetConnectedControllers();

            if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch)
            {
                if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.RTouch) || oldController == OVRInput.Controller.None)
                {
                    return(OVRInput.Controller.RTouch);
                }
            }

            if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch)
            {
                if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.LTouch) || oldController == OVRInput.Controller.None)
                {
                    return(OVRInput.Controller.LTouch);
                }
            }

            if ((controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote)
            {
                if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.RTrackedRemote) || oldController == OVRInput.Controller.None)
                {
                    return(OVRInput.Controller.RTrackedRemote);
                }
            }

            if ((controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote)
            {
                if (OVRInput.Get(joyPadClickButton, OVRInput.Controller.LTrackedRemote) || oldController == OVRInput.Controller.None)
                {
                    return(OVRInput.Controller.LTrackedRemote);
                }
            }

            if ((controller & oldController) != oldController)
            {
                return(OVRInput.Controller.None);
            }

            return(oldController);
        }
예제 #16
0
    private OVRInput.Button middleTrigger;  //middle finger trigger

    void Start()
    {
        //default all to false
        isGrabbing = false;
        isHolding  = false;
        hitDivider = false;

        //determining which hand this instance is tracking
        if (this.name == "hand_left")
        {
            pointerTrigger = OVRInput.Button.PrimaryIndexTrigger;
            middleTrigger  = OVRInput.Button.PrimaryHandTrigger;
        }
        else
        {
            pointerTrigger = OVRInput.Button.SecondaryIndexTrigger;
            middleTrigger  = OVRInput.Button.SecondaryHandTrigger;
        }
    }
예제 #17
0
        // Thanks to Psychloor!
        // https://github.com/Psychloor/DoubleTapRunner/blob/master/DoubleTapSpeed/Utilities.cs#L30
        public static bool HasDoubleClicked(OVRInput.Button keyCode, float threshold)
        {
            if (!OVRInput.GetDown(keyCode, OVRInput.Controller.Touch))
            {
                return(false);
            }
            if (!lastTime.ContainsKey(keyCode))
            {
                lastTime.Add(keyCode, Time.time);
            }

            if (Time.time - lastTime[keyCode] <= threshold)
            {
                lastTime[keyCode] = threshold * 2;
                return(true);
            }

            lastTime[keyCode] = Time.time;
            return(false);
        }
예제 #18
0
    void Awake()
    {
        if (inputModule != null)
        {
            inputModule.OnSelectionRayHit += RayHitSomething;
            triggerButton = inputModule.joyPadClickButton;
        }

        OVRInput.Controller controller = OVRInput.GetConnectedControllers();

        if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch)
        {
            activeController = OVRInput.Controller.RTouch;
        }

        if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch)
        {
            activeController = OVRInput.Controller.LTouch;
        }
    }
예제 #19
0
    void Awake()
    {
        if (inputModule != null)
        {
            inputModule.OnSelectionRayHit += RayHitSomething;
            joyPadClickButton              = inputModule.joyPadClickButton;
        }

        OVRInput.Controller controller = OVRInput.GetConnectedControllers();

        if ((controller & OVRInput.Controller.RTouch) == OVRInput.Controller.RTouch)
        {
            activeController = OVRInput.Controller.RTouch;
        }

        if ((controller & OVRInput.Controller.LTouch) == OVRInput.Controller.LTouch)
        {
            activeController = OVRInput.Controller.LTouch;
        }

        if ((controller & OVRInput.Controller.RTrackedRemote) == OVRInput.Controller.RTrackedRemote)
        {
            activeController = OVRInput.Controller.RTrackedRemote;
        }

        if ((controller & OVRInput.Controller.LTrackedRemote) == OVRInput.Controller.LTrackedRemote)
        {
            activeController = OVRInput.Controller.LTrackedRemote;
        }

        //set defaultPos
        DefaultPos = new Vector3(0, 0, 0);
        DefaultPos = transform.position;

        //set active state of point for the raycast from centre eye
        //if(testPoint != null)
        //    testPoint.SetActive(!isController);

        lineReference = lineRenderer;
        testPoint.SetActive(false);
    }
예제 #20
0
    void HandleOVRStateForButton(OVRInput.Button button, ref InputState state)
    {
        switch (state)
        {
        case InputState.Down: {
            if (OVRInput.Get(button, ovrHand))
            {
                state = InputState.Holding;
            }
            break;
        }

        case InputState.Holding: {
            if (!OVRInput.Get(button, ovrHand))
            {
                state = InputState.Released;
            }
            break;
        }

        case InputState.Released: {
            if (OVRInput.GetDown(button, ovrHand))
            {
                state = InputState.Down;
            }
            else
            {
                state = InputState.Up;
            }
            break;
        }

        case InputState.Up: {
            if (OVRInput.GetDown(button, ovrHand))
            {
                state = InputState.Down;
            }
            break;
        }
        }
    }
예제 #21
0
        public override void OnButtonDown(OVRInput.Button button)
        {
            base.OnButtonDown(button);

            if (!_isSettedArrow)
            {
                return;
            }

            // 0番目のモジュールを使用
            if (button == OVRInput.Button.One)
            {
                _weaponModules[0].OnUseModule(this);

                _isSettedArrow = false;
                _arrowBody.SetActive(false);

                // 矢を元の位置に戻す
                UpdateArrow(_arrowPosition);
            }
        }
예제 #22
0
    private void Awake()
    {
        containerScript = GetComponent <Container>();
        orbsAlive       = 0;
        mintOrbs        = new Queue <GameObject>();

        if (string.Equals(transform.parent.name, "LeftHandAnchor"))     // Initialize hand and index triggers
        {
            handTrigger  = OVRInput.Button.PrimaryHandTrigger;
            indexTrigger = OVRInput.Button.PrimaryIndexTrigger;
        }
        else if (string.Equals(transform.parent.name, "RightHandAnchor"))
        {
            handTrigger  = OVRInput.Button.SecondaryHandTrigger;
            indexTrigger = OVRInput.Button.SecondaryIndexTrigger;
        }
        else
        {
            Debug.LogWarning("Container GameObject isn't parented correctly with OVRCameraRig");
        }
    }
예제 #23
0
        public bool InputActive(VRDevice vrDevice, VRInput input, VRInputAction action)
        {
            if (vrDevice == VRDevice.None || input == VRInput.None)
            {
                //Debug.LogError("Checking if no input device is active.");
                return(false);
            }

            if (platform == Platform.OVR)
            {
                OVRInput.Button button          = (OVRInput.Button)VRInputToOVRButton[input];
                OVRInput.Button buttonAlternate = (OVRInput.Button)VRInputToOVRButtonAlternate[input];

                OVRInput.Controller controller = OVRInput.Controller.LTouch;

                if (vrDevice == VRDevice.LeftController)
                {
                    controller = OVRInput.Controller.LTouch;
                }
                else
                if (vrDevice == VRDevice.RightController)
                {
                    controller = OVRInput.Controller.RTouch;
                }


                if (action == VRInputAction.Pressed)
                {
                    return(OVRInput.GetDown(button, controller) || OVRInput.GetDown(buttonAlternate, controller));
                }
                else if (action == VRInputAction.Held)
                {
                    return(OVRInput.Get(button, controller) || OVRInput.Get(buttonAlternate, controller));
                }
                else //implicitly if (action == VRInputAction.Released)
                {
                    return(OVRInput.GetUp(button, controller) || OVRInput.GetUp(buttonAlternate, controller));
                }
            }
        }
    bool ShouldToggleMenu()
    {
        OVRInput.Button     showButton       = OVRInput.Button.Start;
        OVRInput.Controller activeController = OVRInput.GetActiveController();

        if ((activeController == OVRInput.Controller.Remote) ||
            (activeController == OVRInput.Controller.Touchpad)
            )
        {
            showButton = OVRInput.Button.Two;
        }

        if (OVRInput.GetDown(showButton) ||
            (IsMenuActive() && Input.GetKeyDown(hideKey)) ||
            (!IsMenuActive() && Input.GetKeyDown(showKey))
            )
        {
            return(true);
        }

        return(false);
    }
예제 #25
0
 void OnButtonDown(OVRInput.Button key)
 {
     if (key == OVRInput.Button.PrimaryThumbstickLeft)
     {
         stepIndex = stepIndex.DecrementClamped(slider.minValue);
         UpdateUI();
         if (heldDownEnumerator != null)
         {
             StopCoroutine(heldDownEnumerator);
         }
         heldDownEnumerator = StartCoroutine(UpdateHold(false));
     }
     else if (key == OVRInput.Button.PrimaryThumbstickRight)
     {
         stepIndex = stepIndex.IncrementClamped(slider.maxValue);
         UpdateUI();
         if (heldDownEnumerator != null)
         {
             StopCoroutine(heldDownEnumerator);
         }
         heldDownEnumerator = StartCoroutine(UpdateHold(true));
     }
 }
예제 #26
0
파일: Ball.cs 프로젝트: AeroRogue/Portfolio
    // Update is called once per frame
    void Update()
    {
        if (this.transform.parent == null)
        {
        }
        else if (this.transform.parent.name == "HandRight")
        {
            grabButton = OVRInput.Button.SecondaryHandTrigger;
            controller = OVRInput.Controller.RTouch;
        }
        else if (this.transform.parent.name == "HandLeft")
        {
            grabButton = OVRInput.Button.PrimaryHandTrigger;
            controller = OVRInput.Controller.LTouch;
        }

        if (!_Thrown & this.transform.parent != null)
        {
            this.transform.position = new Vector3(this.transform.parent.position.x, this.transform.position.y, this.transform.parent.position.z);
            if (ranOnce)
            {
                ToggleBounciness(1f);
            }
            ranOnce = true;
            if (!_Thrown & this.transform.position.y >= (this.transform.parent.position.y - 0.05f))
            {
                this.transform.position = new Vector3(this.transform.parent.position.x, (this.transform.parent.position.y - 0.09f), this.transform.parent.position.z);
            }

            if (!_Thrown & (this.transform.parent.parent.parent.localRotation.eulerAngles.x <180f& this.transform.parent.parent.parent.localRotation.eulerAngles.x> 150f))
            {
                ReadyToThrow();
            }

            if (OVRInput.Get(grabButton))
            {
                ReadyToThrow();
            }

            else if (inHand & OVRInput.GetUp(grabButton))
            {
                throwObject();
            }
        }

        if (this.transform.parent == null)
        {
            if (_Thrown)
            {
                timer -= Time.deltaTime;
                if (timer <= 0f)
                {
                    _Thrown = false;
                    ToggleBounciness(0.95f);
                    timer = 1f;
                }
                Debug.Log(timer);
            }
        }
        else
        {
            if (ranOnce)
            {
                ranOnce = false;
                ToggleBounciness(0.95f);
            }
            lastRotation    = currentRotation;
            currentRotation = this.transform.rotation;
        }

        if (this.transform.position.y <= -1)
        {
            this.transform.position = new Vector3(this.transform.position.x, 0.125f, this.transform.position.z);
        }

        timerPos -= Time.deltaTime;
        if (timerPos <= 0f)
        {
            thrownLocation = this.transform.position;
            timerPos       = 0.25f;
        }
    }
예제 #27
0
    void UpdateHand(int handNumber, OVRInput.Controller controller, OVRInput.Button indexTrigger, OVRInput.Button handTrigger, float strength, Vector3 velocity)
    {
        // We've got something in our hand.
        if (grab[handNumber])
        {
            Rigidbody rb = grab[handNumber].GetComponent <Rigidbody>();
            // Grabbed things are kinematic, so use these Move functions.
            rb.MovePosition(hand[handNumber].transform.position);
            rb.MoveRotation(hand[handNumber].transform.rotation);
        }

        // Try to grab something
        if (OVRInput.GetDown(handTrigger) && !grab[handNumber])
        {
            // Find all colliders within 10cm.
            Collider[] colliders = Physics.OverlapSphere(hand[handNumber].transform.position, 0.1f);
            for (int i = 0; i < colliders.Length; ++i)
            {
                Rigidbody rb = colliders[i].gameObject.GetComponent <Rigidbody>();
                // Only grab objects with a rigib body.
                if (rb)
                {
                    Grab(handNumber, rb.gameObject);
                    break;  // We only want one object, so break out.
                }
            }
        }

        // Drop the thing we are holding.
        if (OVRInput.GetUp(handTrigger) && grab[handNumber])
        {
            Drop(handNumber, OVRInput.GetLocalControllerVelocity(controller) * 1.5f + velocity);
        }
    }
 public UsageMapping(ControllerButtonUsage usage, OVRInput.Button button)
 {
     Usage  = usage;
     Touch  = OVRInput.Touch.None;
     Button = button;
 }
예제 #29
0
 public override void OnButtonDown(OVRInput.Button button)
 {
     base.OnButtonDown(button);
 }
예제 #30
0
 bool IInputController.IsUp(ControllerType controllerType, ButtonType buttonType)
 {
     OVRInput.Controller touchType = GetOculusTouchType(controllerType);
     OVRInput.Button     button    = GetOculusButtonType(buttonType);
     return(OVRInput.GetUp(button, touchType));
 }