public int EnterInputFrame()
        {
            if (mapMouse)
            {
                Vector3 vec = Input.mousePosition;
                CrossPlatformInputManager.SetVirtualMousePositionX(vec.x);
                CrossPlatformInputManager.SetVirtualMousePositionY(vec.y);
                CrossPlatformInputManager.SetVirtualMousePositionZ(vec.z);
            }

//Only enable in Editor Mode
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
            int i;
            for (i = 0; i < numAxes; ++i)
            {
                //CrossPlatformInputManager.VirtualAxis va = _aHandles[i];
                _aHandles[i].Update(Input.GetAxisRaw(axes[i].value));
            }
            for (i = 0; i < numButtons; ++i)
            {
                if (Input.GetButtonDown(buttons[i].value))
                {
                    _bHandles[i].Pressed();
                }
                else if (Input.GetButtonUp(buttons[i].value))
                {
                    _bHandles[i].Released();
                }
            }
#endif
            return(0);
        }
Example #2
0
        void DoSetMousePosition()
        {
                        #if CROSS_PLATFORM_INPUT
            Vector3 _pos = CrossPlatformInputManager.mousePosition;

            if (!mousePosition.IsNone)
            {
                _pos = mousePosition.Value;
            }
            if (!mousePosition2d.IsNone)
            {
                _pos.x = mousePosition2d.Value.x;
                _pos.y = mousePosition2d.Value.y;
            }
            if (!mousePositionX.IsNone)
            {
                _pos.x = mousePositionX.Value;
            }
            if (!mousePositionY.IsNone)
            {
                _pos.y = mousePositionY.Value;
            }
            if (!mousePositionZ.IsNone)
            {
                _pos.z = mousePositionZ.Value;
            }

            CrossPlatformInputManager.SetVirtualMousePositionX(_pos.x);
            CrossPlatformInputManager.SetVirtualMousePositionY(_pos.y);
            CrossPlatformInputManager.SetVirtualMousePositionZ(_pos.z);
                        #endif
        }
Example #3
0
    private void Update()
    {
        float angle = 0;

        if (Input.acceleration != Vector3.zero)
        {
            switch (tiltAroundAxis)
            {
            case AxisOptions.ForwardAxis:
                angle = Mathf.Atan2(Input.acceleration.x, -Input.acceleration.z) * Mathf.Rad2Deg +
                        centreAngleOffset;
                centreAngleOffset = Mathf.LerpAngle(centreAngleOffset,
                                                    -Mathf.Atan2(Input.acceleration.x, -Input.acceleration.z) * Mathf.Rad2Deg, Time.deltaTime * 0.1f);
                break;

            case AxisOptions.SidewaysAxis:
                angle = Mathf.Atan2(Input.acceleration.z, -Input.acceleration.y) * Mathf.Rad2Deg +
                        centreAngleOffset;
                centreAngleOffset = Mathf.LerpAngle(centreAngleOffset,
                                                    -Mathf.Atan2(Input.acceleration.z, -Input.acceleration.y) * Mathf.Rad2Deg, Time.deltaTime * 0.1f);

                break;
            }
        }



        float axisValue = 0;

        if (angle > minSensetivityOffset || angle < -minSensetivityOffset)
        {
            axisValue = Mathf.InverseLerp(-fullTiltAngle, fullTiltAngle, angle) * 2 - 1;
        }

        switch (mapping.type)
        {
        case AxisMapping.MappingType.NamedAxis:
            m_SteerAxis.Update(axisValue);
            break;

        case AxisMapping.MappingType.MousePositionX:
            CrossPlatformInputManager.SetVirtualMousePositionX(axisValue * Screen.width);
            break;

        case AxisMapping.MappingType.MousePositionY:
            CrossPlatformInputManager.SetVirtualMousePositionY(axisValue * Screen.width);
            break;

        case AxisMapping.MappingType.MousePositionZ:
            CrossPlatformInputManager.SetVirtualMousePositionZ(axisValue * Screen.width);
            break;
        }
    }