Exemple #1
0
    // Attempts to detect input on any axis or button.
    // Returns true if input was captured. False otherwise.
    // Only creates the binding if captured input wasn't escape key/back button.
    public static bool CaptureInput(string inputFor, bool mouseMovement = true)
    {
        string axis = GetPressedAxis(mouseMovement);

        if (axis != null)
        {
            bool positive = (axis[axis.Length - 1] == '+');
            bindings[inputFor].Add(new ControlBinding(axis.Substring(0, axis.Length - 1), positive));
            bindings.Save(inputFor);
            return(true);
        }
        else
        {
            KeyCode kcode = InputWrapper.GetPressedKey();
            if (kcode != KeyCode.None)
            {
                if (kcode != KeyCode.Escape)
                {
                    bindings[inputFor].Add(new ControlBinding(kcode));
                    bindings.Save(inputFor);
                }
                return(true);
            }
        }
        return(false);
    }