Exemple #1
0
        /// <summary>
        /// This will be called each time input updates. Use this to push values into the Custom Controller axes.
        /// </summary>
        private void OnInputUpdate()
        {
            // Get the acceleration values from UnityEngine.Input and push into the controller
            Vector3 acceleration = Input.acceleration;

            controller.SetAxisValue(0, acceleration.x);
            controller.SetAxisValue(1, acceleration.y);
            controller.SetAxisValue(2, acceleration.z);
        }
        // One way to set values in the controller is to set them directly with SetAxisValue and SetButtonValue
        // If you use this method, you should make sure you call it from the InputSourceUpdateEvent because this
        // event will be called once for every update loop in which input is updated.

        private void SetControllerAxisValues()
        {
            // Set the element values directly in the controller
            for (int i = 0; i < axisValues.Length; i++)
            {
                controller.SetAxisValue(i, axisValues[i]);
            }
        }
        /**
         * Sets the headset yaw value on the controller.
         */
        private void OnInputUpdate()
        {
            Camera camera = Camera.main;

            if (camera)
            {
                float cameraYaw = Math.ClampAngle(camera.transform.localEulerAngles.y);
                float yaw       = Mathf.Clamp(cameraYaw / m_maxAngle, -1f, 1f);

                m_controller.SetAxisValue(m_elementID, yaw);
            }
        }
Exemple #4
0
    private static void OnAppleControllerInput(int id, float val1, float val2)
    {
        if (!Application.isPlaying)
        {
            return;
        }

        if (appleVirtualController == null)
        {
            return;
        }

        if (id >= 0 && id < Enum.GetNames(typeof(NCControlElementID)).Length)
        {
            //Debug.Log("Apple Controller Input! ID: " + ((NCControlElementID)id).ToString("g") + "   val1: " + val1 + "   val2: " + val2);

            NCControlElementID elemID = (NCControlElementID)id;

            switch (elemID)
            {
            case NCControlElementID.ButtonA:
                appleVirtualController.SetButtonValue(0, val2 != 0);
                break;

            case NCControlElementID.ButtonB:
                appleVirtualController.SetButtonValue(1, val2 != 0);
                break;

            case NCControlElementID.ButtonX:
                appleVirtualController.SetButtonValue(2, val2 != 0);
                break;

            case NCControlElementID.ButtonY:
                appleVirtualController.SetButtonValue(3, val2 != 0);
                break;

            case NCControlElementID.ButtonShoulderLeft:
                appleVirtualController.SetButtonValue(4, val2 != 0);
                break;

            case NCControlElementID.ButtonShoulderRight:
                appleVirtualController.SetButtonValue(5, val2 != 0);
                break;

            case NCControlElementID.ButtonTriggerLeft:
                appleVirtualController.SetButtonValue(6, val2 != 0);
                appleVirtualController.SetAxisValue(6, val1);
                break;

            case NCControlElementID.ButtonTriggerRight:
                appleVirtualController.SetButtonValue(7, val2 != 0);
                appleVirtualController.SetAxisValue(7, val2);
                break;

            case NCControlElementID.ButtonHome:
                appleVirtualController.SetButtonValue(8, val2 != 0);
                break;

            case NCControlElementID.ButtonMenu:
                appleVirtualController.SetButtonValue(9, val2 != 0);
                break;

            case NCControlElementID.ButtonOptions:
                appleVirtualController.SetButtonValue(10, val2 != 0);
                break;

            case NCControlElementID.ButtonUp:
                appleVirtualController.SetButtonValue(11, val2 != 0);
                break;

            case NCControlElementID.ButtonDown:
                appleVirtualController.SetButtonValue(12, (val2 != 0));
                break;

            case NCControlElementID.ButtonLeft:
                appleVirtualController.SetButtonValue(13, val2 != 0);
                break;

            case NCControlElementID.ButtonRight:
                appleVirtualController.SetButtonValue(14, val2 != 0);
                break;

            case NCControlElementID.ButtonThumbstickLeft:
                appleVirtualController.SetButtonValue(15, val2 != 0);
                break;

            case NCControlElementID.ButtonThumbstickRight:
                appleVirtualController.SetButtonValue(16, val2 != 0);
                break;

            case NCControlElementID.Dpad:
                appleVirtualController.SetAxisValue(0, val1);
                appleVirtualController.SetAxisValue(1, val2);
                break;

            case NCControlElementID.ThumbstickLeft:
                appleVirtualController.SetAxisValue(2, val1);
                appleVirtualController.SetAxisValue(3, val2);
                break;

            case NCControlElementID.ThumbstickRight:
                appleVirtualController.SetAxisValue(4, val1);
                appleVirtualController.SetAxisValue(5, val2);
                break;

            default:
                break;
            }
        }
    }