public IInputMap Clone()
        {
            GamepadMap clone = new GamepadMap();

            clone.buttons.AddRange(buttons);
            clone.axes.AddRange(axes);

            return(clone);
        }
        public bool SetFrom(IInputMap that)
        {
            GamepadMap gpCast = that as GamepadMap;

            if (gpCast == null)
            {
                Debug.LogError("Type incompatibility when trying to call SetFrom on a gamepad input map");
                return(false);
            }

            SetEmpty();
            buttons.AddRange(gpCast.buttons);
            axes.AddRange(gpCast.axes);

            return(true);
        }
            public void Add(IInputMap map)
            {
                KeyboardMap kbMap = map as KeyboardMap;

                if (kbMap != null)
                {
                    kbMaps.Add(kbMap);
                }

                GamepadMap gpButtonMap = map as GamepadMap;

                if (gpButtonMap != null)
                {
                    gpButtonMaps.Add(gpButtonMap);
                }

                JoystickMap jsButtonMap = map as JoystickMap;

                if (jsButtonMap != null)
                {
                    jsMaps.Add(jsButtonMap);
                }
            }
        public bool HasConflict(IInputMap other, InputAction.Properties properties)
        {
            GamepadMap otherGpMap = other as GamepadMap;

            if (otherGpMap == null || otherGpMap.IsEmpty)
            {
                return(false);
            }

            bool allowSameFrameMultiInput = properties.allowSameFrameMultiInput;

            if (allowSameFrameMultiInput)
            {
                if (buttons.Count > 0 && otherGpMap.buttons.Count > 0)
                {
                    // Check if they match exactly, or if one map is a sub-set of the other
                    var smallerButtonMap = buttons.Count < otherGpMap.buttons.Count ? buttons : otherGpMap.buttons;
                    var largerButtonMap  = buttons.Count < otherGpMap.buttons.Count ? otherGpMap.buttons : buttons;

                    int sameInputCount = 0;
                    foreach (var button in smallerButtonMap)
                    {
                        if (largerButtonMap.Contains(button))
                        {
                            ++sameInputCount;
                        }
                    }

                    if (sameInputCount == smallerButtonMap.Count)
                    {
                        return(true);
                    }
                }
            }
            else
            {
                foreach (var button in buttons)
                {
                    foreach (var otherButton in otherGpMap.buttons)
                    {
                        if (button == otherButton)
                        {
                            return(true);
                        }
                    }
                }
            }

            foreach (var axis in axes)
            {
                foreach (var otherAxis in otherGpMap.axes)
                {
                    if (axis.axis == otherAxis.axis && (axis.dir == otherAxis.dir || axis.dir == GamepadDevice.AxisDir.Any || otherAxis.dir == GamepadDevice.AxisDir.Any))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }