Exemplo n.º 1
0
        private float ComputeJoystickAxisStateForGameplay(XB1Interface.XB1Interface.GamepadState padState, MyJoystickAxesEnum axis)
        {
            if (IsJoystickConnected() && IsJoystickAxisSupported(axis))
            {
                // Input position scaled to (-1..1).
                float position = ComputeJoystickAxisState(padState, axis);
                float distance = (((int)axis) % 2 != 0) ? position : -position; // even -> neg axis
                if (distance > m_joystickDeadzone)
                {
                    distance = (distance - m_joystickDeadzone) / (1 - m_joystickDeadzone);  // Rescale distance to (0..1) outside the deadzone.
                    return m_joystickSensitivity * (float)Math.Pow(distance, m_joystickExponent);
                }
            }

            return 0.0f;
        }
Exemplo n.º 2
0
 private bool IsGamepadLTriggerPressed(XB1Interface.XB1Interface.GamepadState pad, float threshold = 0.2f)
 {
     return pad.lt >= threshold;
 }
Exemplo n.º 3
0
        private float ComputeJoystickAxisState(XB1Interface.XB1Interface.GamepadState padState, MyJoystickAxesEnum axis)
        {
            float value = 0.0f;
            if (IsJoystickConnected() && IsJoystickAxisSupported(axis))
            {
                
                switch (axis)
                {
                        
                    case MyJoystickAxesEnum.RotationXpos:
                    case MyJoystickAxesEnum.RotationXneg: value = padState.rx; break;
                    case MyJoystickAxesEnum.RotationYpos:
                    case MyJoystickAxesEnum.RotationYneg: value = -padState.ry; break;
                    case MyJoystickAxesEnum.Xpos:
                    case MyJoystickAxesEnum.Xneg: value = padState.lx; break;
                    case MyJoystickAxesEnum.Ypos:
                    case MyJoystickAxesEnum.Yneg: value = -padState.ly; break;

                }
                 
            }
            return value;
        }