Ejemplo n.º 1
0
        internal Tuple <ActionFloat, float> GetAction(MouseAxis axis)
        {
            Tuple <ActionFloat, float> value;

            axisActionMap.TryGetValue(axis, out value);
            return(value);
        }
Ejemplo n.º 2
0
        public float DidInputHappen <T>(T previous, T current)
        {
            if (typeof(T) == typeof(MouseState))
            {
                var buttonPreviousState =
                    (ButtonState)ReflectionHelpers.GetPropertyValue(previous, MouseButton + "Button");
                var buttonCurrentState =
                    (ButtonState)ReflectionHelpers.GetPropertyValue(current, MouseButton + "Button");

                if (buttonPreviousState.Equals(ButtonState.Released) && buttonCurrentState.Equals(ButtonState.Pressed))
                {
                    _start = (int)ReflectionHelpers.GetPropertyValue(current, MouseAxis.ToString());
                    //DragStartPosition = ReflectionHelpers.GetPropertyValue(current, MouseAxis.ToString());
                    DragStartX = (int)ReflectionHelpers.GetPropertyValue(current, "X");
                    DragStartY = (int)ReflectionHelpers.GetPropertyValue(current, "Y");
                }
                else if (buttonPreviousState.Equals(ButtonState.Pressed) && buttonCurrentState.Equals(ButtonState.Released))
                {
                    int temp = _start;
                    _start = _current = 0;
                    return((int)ReflectionHelpers.GetPropertyValue(current, MouseAxis.ToString()) - temp);
                }
                else
                {
                    _current = (int)ReflectionHelpers.GetPropertyValue(current, MouseAxis.ToString());
                }
            }
            return(0f);
        }
Ejemplo n.º 3
0
    public static float GetMouseAxis(MouseAxis axis)
    {
#if UNITY_WEBGL
        float axisValue = 0f;

        if (axis == MouseAxis.x)
        {
            axisValue = (Input.mousePosition.x - lastMousePosition.x) / Screen.width / Time.deltaTime;
        }
        else if (axis == MouseAxis.y)
        {
            axisValue = (Input.mousePosition.y - lastMousePosition.y) / Screen.height / Time.deltaTime;
        }

        lastMousePosition = Input.mousePosition;

        return(axisValue);
#else
        var axisValue = 0f;
        if (axis == MouseAxis.x)
        {
            axisValue = Input.GetAxis("Mouse X");
        }
        else if (axis == MouseAxis.y)
        {
            axisValue = Input.GetAxis("Mouse Y");
        }

        return(axisValue);
#endif
    }
Ejemplo n.º 4
0
 public AxisMapping(int primaryPositive, int primaryNegative, int secondaryPositive, int secondaryNegative, MouseAxis mouseAxis, bool invertMouse)
 {
     PrimaryPositive   = primaryPositive;
     PrimaryNegative   = primaryNegative;
     SecondaryPositive = secondaryPositive;
     SecondaryNegative = secondaryNegative;
     MouseAxis         = mouseAxis;
     InvertMouse       = invertMouse;
 }
Ejemplo n.º 5
0
        public void AddBinding(MouseAxis bindX, MouseAxis bindY)
        {
            var x = new MouseAxisControl(bindX, this);
            var y = new MouseAxisControl(bindY, this);

            axisControls.Add(new AxisControlPair {
                X = x, Y = y
            });
        }
Ejemplo n.º 6
0
        public void SetKey(string uniqueKeyName, MouseAxis mouseAxis)
        {
            int i = GetUniqueIndex(uniqueKeyName);

            inputs[i].Type = KeyType.MouseAxis;
            inputs[i].Axis = (AxisCode)mouseAxis;

            hUtility.SaveBinings(inputs);
        }
Ejemplo n.º 7
0
    /// <summary>
    /// Create a new instance of <see cref="MouseInput"/> that handles specified mouse axis.
    /// </summary>
    /// <param name="axis">Mouse axis.</param>
    public MouseInput(MouseAxis axis)
    {
        if (axis==MouseAxis.None)
        {
            Debug.LogError("axis can't be MouseAxis.None");
        }

        mAxis   = axis;
        mButton = MouseButton.None;
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Create a new instance of <see cref="MouseInput"/> that handles specified mouse button.
    /// </summary>
    /// <param name="button">Mouse button.</param>
    public MouseInput(MouseButton button)
    {
        if (button==MouseButton.None)
        {
            Debug.LogError("button can't be MouseButton.None");
        }

        mAxis   = MouseAxis.None;
        mButton = button;
    }
Ejemplo n.º 9
0
 public string GetName(MouseAxis.Axis axis)
 {
     switch (axis)
     {
         case MouseAxis.Axis.ScrollWheel:    return "ScrollWheel";
         case MouseAxis.Axis.MouseX:         return "Mouse X";
         case MouseAxis.Axis.MouseY:         return "Mouse Y";
     }
     return "None";
 }
Ejemplo n.º 10
0
        public static float CheckAxis(MouseAxis axis)
        {
            if (axis == MouseAxis.Wheel)
            {
                return(StrideInputManager.MouseWheelDelta);
            }

            Vector2 axisData = StrideInputManager.MouseDelta;

            return(axis == MouseAxis.X ? axisData.X : axisData.Y);
        }
Ejemplo n.º 11
0
 //update the backing data for an axis's MouseAxis value
 private void HandleMouseAxisChanged(string axisName, MouseAxis value, Dropdown dropdown)
 {
     if (InputMap.AxisMappings.TryGetValue(axisName, out var axisMapping))
     {
         axisMapping.MouseAxis           = value;
         InputMap.AxisMappings[axisName] = axisMapping; //since it's a value type, we need to insert our modified copy back
     }
     else
     {
         Debug.LogWarning($"Couldn't find a mapping for axis \"{axisName}\"");
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        ///   Checks if any axis has just been moved.
        /// </summary>
        /// <returns>
        ///   True if any axies have just been moved and false otherwise.
        /// </returns>
        public bool AnyJustMoved()
        {
            for (MouseAxis b = 0; b < MouseAxis.COUNT; b++)
            {
                if (m_current.GetAxis(b) != m_last.GetAxis(b))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 13
0
        public MouseInput(MouseAxis axis, MouseButton button, KeyModifier modifiers = KeyModifier.NoModifier)
        {
            if ((axis == MouseAxis.None) == (button == MouseButton.None))
            {
                Debug.LogError("Either axis or button must be None, not both or neither");
            }

            mAxis      = axis;
            mButton    = button;
            mModifiers = modifiers;

            mCachedToString = null;
        }
Ejemplo n.º 14
0
    /// <summary>
    /// Create a new instance of <see cref="MouseInput"/> that handles specified mouse button.
    /// </summary>
    /// <param name="button">Mouse button.</param>
    /// <param name="modifiers">Key modifiers.</param>
    public MouseInput(MouseButton button, KeyModifier modifiers =KeyModifier.NoModifier)
    {
        if (button == MouseButton.None)
        {
            Debug.LogError("button can't be MouseButton.None");
        }

        mAxis      = MouseAxis.None;
        mButton    = button;
        mModifiers = modifiers;

        mCachedToString = null;
    }
Ejemplo n.º 15
0
    /// <summary>
    /// Create a new instance of <see cref="MouseInput"/> that handles specified mouse axis.
    /// </summary>
    /// <param name="axis">Mouse axis.</param>
    /// <param name="modifiers">Key modifiers.</param>
    public MouseInput(MouseAxis axis, KeyModifier modifiers = KeyModifier.NoModifier)
    {
        if (axis == MouseAxis.None)
        {
            Debug.LogError("axis can't be MouseAxis.None");
        }

        mAxis      = axis;
        mButton    = MouseButton.None;
        mModifiers = modifiers;

        mCachedToString = null;
    }
Ejemplo n.º 16
0
    /// <summary>
    /// Create a new instance of <see cref="MouseInput"/> that handles specified mouse axis.
    /// </summary>
    /// <param name="axis">Mouse axis.</param>
    /// <param name="modifiers">Key modifiers.</param>
    public MouseInput(MouseAxis axis, KeyModifier modifiers = KeyModifier.NoModifier)
    {
        if (axis == MouseAxis.None)
        {
            Debug.LogError("axis can't be MouseAxis.None");
        }

        mAxis      = axis;
        mButton    = MouseButton.None;
        mModifiers = modifiers;

        mCachedToString = null;
    }
Ejemplo n.º 17
0
    /// <summary>
    /// Create a new instance of <see cref="MouseInput"/> that handles specified mouse button.
    /// </summary>
    /// <param name="button">Mouse button.</param>
    /// <param name="modifiers">Key modifiers.</param>
    public MouseInput(MouseButton button, KeyModifier modifiers = KeyModifier.NoModifier)
    {
        if (button == MouseButton.None)
        {
            Debug.LogError("button can't be MouseButton.None");
        }

        mAxis      = MouseAxis.None;
        mButton    = button;
        mModifiers = modifiers;

        mCachedToString = null;
    }
Ejemplo n.º 18
0
 /// <summary>
 /// Remove an existing listener from it's axis.
 /// </summary>
 /// <param name="axis">The axis to remove a listener from.</param>
 /// <param name="listener">The listener to remove.</param>
 public void RemoveListener(MouseAxis axis, MouseAxisListener listener)
 {
     if (axisHandlers != null)
     {
         for (int i = 0, axisHandlerCount = axisHandlers.Count; i < axisHandlerCount; i++)
         {
             if (axisHandlers[i].Axis == axis)
             {
                 axisHandlers[i].RemoveListener(listener);
                 return;
             }
         }
     }
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Remove every single listener from a single
 /// axis of the mouse.
 /// </summary>
 /// <param name="axis"></param>
 public void RemoveAllListeners(MouseAxis axis)
 {
     if (axisHandlers != null)
     {
         for (int i = 0, axisHandlerCount = axisHandlers.Count; i < axisHandlerCount; i++)
         {
             if (axisHandlers[i].Axis == axis)
             {
                 axisHandlers.RemoveAt(i);
                 break;
             }
         }
     }
 }
Ejemplo n.º 20
0
 public void MapMouseAxisAction(MouseAxis axis, AxisAction proc)
 {
     if (_axisMouseMap.ContainsKey(axis))
     {
         var map = _axisMouseMap[axis];
         map.Action += proc;
     }
     else
     {
         _axisMouseMap.Add(axis, new MouseAxisMapping {
             Axis = axis, Action = proc
         });
     }
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Constructs an InputAction which tracks relative mouse movement.
 /// </summary>
 /// <param name="playerIndex">The index of the player using this input.</param>
 /// <param name="buttonAction">What state the button should be in to activate.</param>
 /// <param name="axis">The axis of movement to be tracked.</param>
 /// <param name="sensitivity">
 /// How sensitive the mouse is.
 /// A sensitivity of 4.0 and movement of 2 pixels will have a Degree of 0.5.</param>
 /// <param name="deadZoneMin">The minimum Degree which will not be sensed.</param>
 /// <param name="deadZoneMax">The maximum Degree which will not be sensed.</param>
 public MouseMovementInputAction(
     PlayerIndex playerIndex,
     ButtonAction buttonAction,
     MouseAxis axis,
     float sensitivity,
     float deadZoneMin,
     float deadZoneMax)
     : base(playerIndex, buttonAction)
 {
     mMouseAxis = axis;
     mSensitivity = sensitivity;
     mDeadZoneMax = deadZoneMax;
     mDeadZoneMin = deadZoneMin;
     previousX = Microsoft.Xna.Framework.Input.Mouse.GetState().X;
     previousY = Microsoft.Xna.Framework.Input.Mouse.GetState().Y;
 }
Ejemplo n.º 22
0
        private float GetMouseAxis(MouseAxis axis, bool applySensitivity)
        {
            switch (axis)
            {
            case MouseAxis.Horizontal:
                return(GetMouseMovement().x *(applySensitivity ? MouseXSensitivity : 1));

            case MouseAxis.Vertical:
                return(GetMouseMovement().y *(applySensitivity ? MouseYSensitivity : 1));

            case MouseAxis.Scroll:
                return(UnityEngine.Input.mouseScrollDelta.y * (applySensitivity ? MouseScrollSensitivity : 1));

            default:
                return(0);
            }
        }
        public void mouseAxisEvent(MouseAxis id, int val)
        {
            float prevVal = 0;

            if (id == MouseAxis.X)
            {
                prevVal = mouseX;
                mouseX  = val;
            }
            else
            {
                prevVal = mouseY;
                mouseY  = val;
            }

            fireEvent(new MouseAxisEvent(id, false, val, prevVal));
        }
Ejemplo n.º 24
0
        /// <summary>
        /// returns mouse axis value.
        /// </summary>
        public static float Get(MouseAxis a)
        {
            switch (a)
            {
            case MouseAxis.X:
                return(MouseAxesValues.X);

            case MouseAxis.Y:
                return(MouseAxesValues.Y);

            case MouseAxis.Wheel:
                return(MouseAxesValues.Wheel);

            default:
                Exception ex = new AxisException("MouseAxis is null", new NullReferenceException());
                Log.Exception(ex);
                throw ex;
            }
        }
        public MouseAxisSource(MouseAxis axis)
        {
            this.axis = axis;

            switch (axis)
            {
                case MouseAxis.Horizontal:
                    axisName = "Mouse X";
                    description = "Mouse Horizontal";
                    break;

                case MouseAxis.Vertical:
                    axisName = "Mouse Y";
                    description = "Mouse Vertical";
                    break;

                default:
                    throw new Exception("Unexpected axis value.");
            }
        }
Ejemplo n.º 26
0
        public MouseAxisSource(MouseAxis axis)
        {
            this.axis = axis;

            switch (axis)
            {
            case MouseAxis.Horizontal:
                axisName    = "Mouse X";
                description = "Mouse Horizontal";
                break;

            case MouseAxis.Vertical:
                axisName    = "Mouse Y";
                description = "Mouse Vertical";
                break;

            default:
                throw new Exception("Unexpected axis value.");
            }
        }
Ejemplo n.º 27
0
        public MouseInput(MouseAxis axis, float inputModifier = 1.0f)
        {
            this.axis = axis;
            modifier  = inputModifier;

            switch (axis)
            {
            case MouseAxis.MouseRight:
            case MouseAxis.MouseDown:
                Game.GameInstance.Form.MouseMove += Form_MouseMove;
                break;

            case MouseAxis.MouseWheelUp:
                Game.GameInstance.Form.MouseWheel += Form_MouseWheel;
                break;

            default:
                Logger.LogWarning("Unknown mouse axis");
                break;
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Add a new axis event listener to the specific mouse
        /// axis.
        /// </summary>
        /// <param name="axis">The axis to listen to.</param>
        /// <param name="listener">The listener to notify.</param>
        public void AddListener(MouseAxis axis, MouseAxisListener listener)
        {
            if (axisHandlers != null)
            {
                for (int i = 0, axisHandlerCount = axisHandlers.Count; i < axisHandlerCount; i++)
                {
                    if (axisHandlers[i].Axis == axis)
                    {
                        axisHandlers[i].AddListener(listener);
                        return;
                    }
                }
            }
            else
            {
                axisHandlers = new List <MouseAxisHandler>();
            }

            MouseAxisHandler axisHandler = new MouseAxisHandler(axis);

            axisHandler.AddListener(listener);
            axisHandlers.Add(axisHandler);
        }
Ejemplo n.º 29
0
 protected void BindAxisDelta(MouseAxis axis, ActionFloat action, float sensibilite)
 {
     axisActionMap.Add(axis, new Tuple <ActionFloat, float>(action, sensibilite));
 }
Ejemplo n.º 30
0
 public void AddBinding(MouseAxis bind)
 {
     AddBinding(new MouseAxisControl(bind, this));
 }
Ejemplo n.º 31
0
        public override void OnInspectorGUI()
        {
            EditorGUILayout.BeginVertical(hStyles.TitleBox());

            EditorGUILayout.LabelField("Complete Control", hStyles.TitleText());
            EditorGUILayout.LabelField("by Hard Shell Studios", hStyles.TitleSubText());
            if (GUILayout.Button("Developed by www.HaydnComley.com", hStyles.TitleCorner()))
            {
                System.Diagnostics.Process.Start("http://www.haydncomley.com");
            }

            EditorGUILayout.EndVertical();

            myTarget = (hScheme)target;
            InitFadeBoxes(myTarget);

            if (!TestUnitySettings())
            {
                EditorGUILayout.BeginVertical(hStyles.InputParent());

                EditorGUILayout.LabelField("Unity Bindings Need Update", hStyles.TitleSubText());
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                EditorGUILayout.Space();
                if (GUILayout.Button("Overwrite Current Unity Bindings"))
                {
                    ImportUnityBindings();
                }
                EditorGUILayout.EndVertical();
            }

            if (myTarget.inputs != null)
            {
                // Iterate through all inputs showing their details.
                for (int i = 0; i < myTarget.inputs.Length; i++)
                {
                    // Get the current input.
                    hInputDetails currentInput = myTarget.inputs[i];
                    EditorGUILayout.BeginVertical(hStyles.InputParent());

                    #region Input Title Bar
                    // Top Bar
                    EditorGUILayout.BeginHorizontal();

                    //      Button that allows expansion to reveal more details
                    if (GUILayout.Button(hStyles.GetFadeText(currentInput), hStyles.GetFadeStyle(currentInput)))
                    {
                        showFields[i].target = !showFields[i].value;
                    }

                    if (i != 0)
                    {
                        if (GUILayout.Button(hStyles.Up(), hStyles.MoveButton()))
                        {
                            SwitchInputDetails(i, i - 1);
                        }
                    }

                    if (i != myTarget.inputs.Length - 1)
                    {
                        if (GUILayout.Button(hStyles.Down(), hStyles.MoveButton()))
                        {
                            SwitchInputDetails(i, i + 1);
                        }
                    }

                    if (GUILayout.Button(hStyles.DuplicateButton(), hStyles.MoveButton()))
                    {
                        DuplicateInput(i);
                    }

                    //      Remove Button
                    if (GUILayout.Button("X", hStyles.RemoveCross()))
                    {
                        Remove(i);
                    }

                    EditorGUILayout.EndHorizontal();
                    // End of top bar

                    #endregion

                    // If opened it shows these details
                    //if (i < showFields.Length && EditorGUILayout.BeginFadeGroup(showFields[i].faded))
                    {
                        EditorGUILayout.BeginVertical(hStyles.DetailGroup());

                        myTarget.inputs[i].Name       = EditorGUILayout.TextField("Name", myTarget.inputs[i].Name);
                        myTarget.inputs[i].UniqueName = EditorGUILayout.TextField("Unique Name", myTarget.inputs[i].UniqueName);
                        myTarget.inputs[i].Type       = (KeyType)EditorGUILayout.EnumPopup("Type", myTarget.inputs[i].Type);

                        #region KeyPress display in editor
                        if (myTarget.inputs[i].Type == KeyType.KeyPress)
                        {
                            EditorGUILayout.LabelField("+ Positive");

                            EditorGUILayout.BeginHorizontal();
                            myTarget.inputs[i].Positive.Primary = (KeyCode)EditorGUILayout.EnumPopup("Primary", myTarget.inputs[i].Positive.Primary);
                            if (GUILayout.Button("X", hStyles.RemoveInput()))
                            {
                                myTarget.inputs[i].Positive.Primary = KeyCode.None;
                            }
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.BeginHorizontal();
                            myTarget.inputs[i].Positive.Secondary = (KeyCode)EditorGUILayout.EnumPopup("Secondary", myTarget.inputs[i].Positive.Secondary);
                            if (GUILayout.Button("X", hStyles.RemoveInput()))
                            {
                                myTarget.inputs[i].Positive.Secondary = KeyCode.None;
                            }
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.LabelField("- Negative");
                            EditorGUILayout.BeginHorizontal();
                            myTarget.inputs[i].Negative.Primary = (KeyCode)EditorGUILayout.EnumPopup("Primary", myTarget.inputs[i].Negative.Primary);
                            if (GUILayout.Button("X", hStyles.RemoveInput()))
                            {
                                myTarget.inputs[i].Negative.Primary = KeyCode.None;
                            }
                            EditorGUILayout.EndHorizontal();

                            EditorGUILayout.BeginHorizontal();
                            myTarget.inputs[i].Negative.Secondary = (KeyCode)EditorGUILayout.EnumPopup("Secondary", myTarget.inputs[i].Negative.Secondary);
                            if (GUILayout.Button("X", hStyles.RemoveInput()))
                            {
                                myTarget.inputs[i].Negative.Secondary = KeyCode.None;
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                        #endregion
                        #region MouseAxis display in editor
                        else if (myTarget.inputs[i].Type == KeyType.MouseAxis)
                        {
                            // Display the 3 Axis for the mice and map it to the 28 availbale axis inputs.
                            MouseAxis tempAxis = (MouseAxis)(((int)myTarget.inputs[i].Axis) > 3 ? 0 : (int)myTarget.inputs[i].Axis);
                            myTarget.inputs[i].Axis = (AxisCode)EditorGUILayout.EnumPopup("Axis", tempAxis);
                        }
                        #endregion
                        #region ControllerAxis display in editor
                        else if (myTarget.inputs[i].Type == KeyType.ControllerAxis)
                        {
                            myTarget.inputs[i].targetController = (TargetController)EditorGUILayout.EnumPopup("Controller", myTarget.inputs[i].targetController);
                            myTarget.inputs[i].Axis             = (AxisCode)EditorGUILayout.EnumPopup("Axis", myTarget.inputs[i].Axis);
                        }
                        #endregion

                        myTarget.inputs[i].Invert      = EditorGUILayout.Toggle("Invert", myTarget.inputs[i].Invert);
                        myTarget.inputs[i].Sensitivity = EditorGUILayout.FloatField("Sensitivity", myTarget.inputs[i].Sensitivity);

                        EditorGUILayout.EndVertical();
                        //   EditorGUILayout.EndFadeGroup();
                    }
                    // End of details.
                    EditorGUILayout.EndVertical();
                }
            }

            EditorGUILayout.Space();

            #region Controls Panel
            EditorGUILayout.BeginVertical(hStyles.InputParent());

            EditorGUILayout.LabelField("Control Panel", hStyles.TitleSubText());
            // Totally efficient way of making a gap.
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            // Add An Input
            if (GUILayout.Button("Add Input"))
            {
                myTarget.inputs = AddInput(myTarget.inputs);
            }

            // Rebind Remove Key.
            myTarget.rebindRemoveKey = (KeyCode)EditorGUILayout.EnumPopup(new GUIContent("Rebind Remove",
                                                                                         "When trying to rebind keys at runtime, this specific one will act as none. E.g. Normally 'Escape' or 'Delete'"),
                                                                          myTarget.rebindRemoveKey);

            // Force reset of bindings.
            myTarget.forceResetInEditor = EditorGUILayout.Toggle("Reset Editor Bindings on play.", myTarget.forceResetInEditor);

            if (GUILayout.Button("Goto Keybindings Save File"))
            {
                System.Diagnostics.Process.Start(hUtility.GetSavePath().Replace(hUtility.SaveName, ""));
            }

            if (GUILayout.Button("Import"))
            {
                System.Diagnostics.Process.Start(hUtility.GetSavePath().Replace(hUtility.SaveName, ""));
            }

            EditorGUILayout.EndVertical();
            #endregion
        }
Ejemplo n.º 32
0
 /// <summary>
 ///   Check if the given axis was just released.
 /// </summary>
 /// <param name="ax">
 ///   The axis to check.
 /// </param>
 /// <returns>
 ///   True if the given axis was just released and false otherwise.
 /// </returns>
 public bool AxisJustReleased(MouseAxis ax)
 {
     return(!m_current.AxisIsPressed(ax) && m_last.AxisIsPressed(ax));
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 /// <param name="third">Third input.</param>
 public static KeyMapping SetKey(string name, MouseAxis primary, KeyCode secondary, KeyCode third)
 {
     return SetKey(name, ArgToInput(primary), ArgToInput(secondary), ArgToInput(third));
 }
Ejemplo n.º 34
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 public static KeyMapping SetKey(string name, MouseAxis primary, MouseAxis secondary)
 {
     return SetKey(name, ArgToInput(primary), ArgToInput(secondary));
 }
Ejemplo n.º 35
0
 /// <summary>
 /// Convert argument to <see cref="CustomInput"/>.
 /// </summary>
 /// <returns>Converted CustomInput.</returns>
 /// <param name="arg">Some kind of argument.</param>
 private static CustomInput ArgToInput(MouseAxis arg)
 {
     return new MouseInput(arg);
 }
Ejemplo n.º 36
0
 public void UnMapMouseAxisAction(MouseAxis axis)
 {
     _axisMouseMap.Remove(axis);
 }
Ejemplo n.º 37
0
 /// <summary>
 ///   Check if the given axis was just pressed.
 /// </summary>
 /// <param name="ax">
 ///   The index of the axis.
 /// </param>
 /// <returns>
 ///   True if the given axis was just pressed and false otherwise.
 /// </returns>
 public bool AxisJustPressed(MouseAxis ax)
 {
     return(m_current.AxisIsPressed(ax) && !m_last.AxisIsPressed(ax));
 }
Ejemplo n.º 38
0
 protected void SetUp()
 {
     mouse = new FakeMouse();
     instance = new MouseAxis(mouse);
 }
Ejemplo n.º 39
0
 public static void SetKey(string uniqueKeyName, MouseAxis mouseAxis)
 {
     hManager.Active().SetKey(uniqueKeyName, mouseAxis);
 }
Ejemplo n.º 40
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 /// <param name="third">Third input.</param>
 public static KeyMapping setKey(string name, MouseAxis primary, CustomInput secondary, MouseButton third)
 {
     return setKey(name, argToInput(primary), argToInput(secondary), argToInput(third));
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 /// <param name="third">Third input.</param>
 public static KeyMapping setKey(string name, MouseButton primary, MouseAxis secondary, KeyCode third)
 {
     return setKey(name, argToInput(primary), argToInput(secondary), argToInput(third));
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 /// <param name="third">Third input.</param>
 public static KeyMapping SetKey(string name, CustomInput primary, MouseAxis secondary, CustomInput third)
 {
     return SetKey(name, ArgToInput(primary), ArgToInput(secondary), ArgToInput(third));
 }
        protected void RelateMapWithMouseAxis(Maps map, Dictionary<MouseAxis, HashSet<Maps>> mapsPerMouseAxis, MouseAxis axis)
        {
            if (!mapsPerMouseAxis.ContainsKey(axis))
                mapsPerMouseAxis.Add(axis, new HashSet<Maps>());

            mapsPerMouseAxis[axis].Add(map);
        }
Ejemplo n.º 44
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 /// <param name="third">Third input.</param>
 public static KeyMapping SetKey(string name, MouseButton primary, MouseButton secondary, MouseAxis third)
 {
     return SetKey(name, ArgToInput(primary), ArgToInput(secondary), ArgToInput(third));
 }
Ejemplo n.º 45
0
        internal static void Load(MachineInfo machineInfo)
        {
            try
            {
                AxisManager.MachineAxes.Clear();
                ControlManager.Blocks.Clear();

                // read mod version
                if (!machineInfo.MachineData.HasKey("ac-version"))
                {
                    return;
                }
                var version = new Version(machineInfo.MachineData.ReadString("ac-version").TrimStart('v'));

                // version alert
                if (version < Assembly.GetExecutingAssembly().GetName().Version)
                {
                    Debug.Log("[ACM]: " + machineInfo.Name + " was saved with mod version " + version + ".\n\tIt may not be compatible with some newer features.");
                }

                // return if no input axes are present
                if (!machineInfo.MachineData.HasKey("ac-axislist"))
                {
                    return;
                }
                var axes = machineInfo.MachineData.ReadStringArray("ac-axislist");

                // load all axes
                foreach (var name in axes)
                {
                    InputAxis axis = null;
                    if (!machineInfo.MachineData.HasKey("axis-" + name + "-type"))
                    {
                        continue;
                    }
                    var type = machineInfo.MachineData.ReadString("axis-" + name + "-type");
                    if (type == AxisType.Chain.ToString())
                    {
                        axis = new ChainAxis(name);
                    }
                    if (type == AxisType.Controller.ToString())
                    {
                        axis = new ControllerAxis(name);
                    }
                    if (type == AxisType.Custom.ToString())
                    {
                        axis = new CustomAxis(name);
                    }
                    if (type == AxisType.Standard.ToString() || // backwards compatibility
                        type == AxisType.Inertial.ToString() || // backwards compatibility
                        type == AxisType.Key.ToString())
                    {
                        axis = new KeyAxis(name);
                    }
                    if (type == AxisType.Mouse.ToString())
                    {
                        axis = new MouseAxis(name);
                    }
                    if (axis != null)
                    {
                        axis?.Load(machineInfo);
                        AxisManager.AddMachineAxis(axis);
                    }
                }

                // refresh chain axis links
                foreach (var entry in AxisManager.MachineAxes)
                {
                    if (entry.Value.Type == AxisType.Chain)
                    {
                        (entry.Value as ChainAxis).RefreshLinks();
                    }
                }

                // resolve from foreign controllers
                AxisManager.ResolveMachineAxes();

                // load all controls
                foreach (BlockInfo blockInfo in machineInfo.Blocks)
                {
                    if (!blockInfo.BlockData.HasKey("ac-controllist"))
                    {
                        continue;
                    }
                    var control_list  = ControlManager.GetBlockControls(blockInfo.ID, blockInfo.Guid);
                    var control_names = blockInfo.BlockData.ReadStringArray("ac-controllist");
                    foreach (string name in control_names)
                    {
                        foreach (Control c in control_list)
                        {
                            if (name == c.Name)
                            {
                                c.Load(blockInfo);
                            }
                        }
                    }
                }

                ACM.Instance.LoadedMachine = true;
            }
            catch (Exception e)
            {
                Debug.Log("[ACM]: Error loading machine's controls:");
                Debug.LogException(e);
            }
        }
Ejemplo n.º 46
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 public static KeyMapping setKey(string name, MouseAxis primary, KeyCode secondary)
 {
     return setKey(name, argToInput(primary), argToInput(secondary));
 }
Ejemplo n.º 47
0
 /// <summary>
 /// Create new <see cref="KeyMapping"/> with specified name and inputs.
 /// </summary>
 /// <returns>Created KeyMapping.</returns>
 /// <param name="name">KeyMapping name.</param>
 /// <param name="primary">Primary input.</param>
 /// <param name="secondary">Secondary input.</param>
 /// <param name="third">Third input.</param>
 public static KeyMapping setKey(string name, CustomInput primary, KeyCode secondary, MouseAxis third)
 {
     return setKey(name, argToInput(primary), argToInput(secondary), argToInput(third));
 }
Ejemplo n.º 48
0
 public AxisMapping(KeyCode primaryPositive, KeyCode primaryNegative, KeyCode secondaryPositive, KeyCode secondaryNegative, MouseAxis mouseAxis, bool invertMouse) :
     this((int)primaryPositive, (int)primaryNegative, (int)secondaryPositive, (int)secondaryNegative, mouseAxis, invertMouse)
 {
 }
 public AbsoluteMousePositionOutput(MouseAxis axis = MouseAxis.X)
 {
     this.Axis = axis;
 }