public virtual string ConvertMaskToName(Bitset mask, bool hasAxis = false, int axisIndex = 0)
        {
            string result = "";
            bool isFirst = true;

            for (int i = 0; i < GetButtonsCount(); i++)
            {
                if (mask.Get(i))
                {
                    if (!isFirst)
                    {
                        result += " + ";
                    }
                    else
                    {
                        isFirst = false;
                    }

                    result += GetButtonName(i);
                }
            }

            if (hasAxis)
            {
                if (!isFirst)
                {
                    result += " + ";
                }

                result += GetAxisName(axisIndex);
            }

            return result;
        }
        public Bitset Copy()
        {
            Bitset result = new Bitset(m_NumBits);
            if (m_NumBits <= 32)
            {
                result.m_SingleData = m_SingleData;
                return result;
            }

            for(int i = 0; i < m_Data.Length; i++)
            {
                result.m_Data[i] = m_Data[i];
            }

            return result;
        }
        public virtual void OnGUI()
        {
            if (m_Controller.iface == null)
            {
                shouldBeDestroyed = true;
                return;
            }

            if (m_ClickSleepTimer > 0.0f)
            {
                m_ClickSleepTimer -= Time.unscaledDeltaTime;
                if (m_ClickSleepTimer < 0.0f)
                {
                    m_CurrentMask     = null;
                    m_ClickSleepTimer = 0.0f;
                }
            }

            if (m_DestructiveActionTimer > 0.0f)
            {
                m_DestructiveActionTimer -= Time.unscaledDeltaTime;
                if (m_DestructiveActionTimer < 0.0f)
                {
                    m_DestructiveActionWait  = false;
                    m_DestructiveActionTimer = 0.0f;
                }
            }

            if (Utility.RectContainsMouse(windowRect))
            {
                InputLockManager.SetControlLock(inputLockHash);
            }
            else
            {
                InputLockManager.RemoveControlLock(inputLockHash);
            }

            windowRect = GUI.Window(1337 + m_EditorId, windowRect, DoWindow, "Fly-By-Wire Preset Editor");
            windowRect = Utility.ClampRect(windowRect, new Rect(0, 0, Screen.width, Screen.height));
        }
        public virtual void Update(FlightCtrlState state)
        {
            for (int i = 0; i < GetButtonsCount(); i++)
            {
                if (GetButtonState(i) && !buttonStates[i])
                {
                    buttonStates[i] = true;

                    if (buttonPressedCallback != null)
                    {
                        buttonPressedCallback(this, i, state);
                    }
                }
                else if (!GetButtonState(i) && buttonStates[i])
                {
                    buttonStates[i] = false;

                    if (buttonReleasedCallback != null)
                    {
                        buttonReleasedCallback(this, i, state);
                    }
                }
            }

            lastUpdateMask = GetButtonsMask();
        }
        public Bitset GetButtonsMask()
        {
            int buttonsCount = GetButtonsCount();
            Bitset mask = new Bitset(buttonsCount);

            for (int i = 0; i < buttonsCount; i++)
            {
                if (GetButtonState(i))
                {
                    mask.Set(i);
                }
            }

            return mask;
        }
        public void SetDiscreteBinding(Bitset state, DiscreteAction action)
        {
            foreach (var keyVal in discreteActionsMap)
            {
                if(keyVal.Value.Equals(state))
                {
                    discreteActionsMap.Remove(keyVal.Key);
                    break;
                }
            }

            discreteActionsMap[action] = state;
        }
 public void SetCurrentBitmask(Bitset mask)
 {
     m_CurrentMask = mask;
 }
示例#8
0
 public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action, bool isInverted)
 {
     continuousActionsMap[action] = new ContinuousActionEntry(action, state, axis, isInverted);
 }
 public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action)
 {
     continuousActionsMap[action] = new KeyValuePair<Bitset, int>(state, axis);
 }
示例#10
0
        public List <ContinuousAction> GetContinuousBinding(int axis, Bitset state)
        {
            List <KeyValuePair <Bitset, ContinuousAction> > matches = new List <KeyValuePair <Bitset, ContinuousAction> >();

            foreach (var continuousActionPair in continuousActionsMap)
            {
                if (continuousActionPair.Value.Value != axis)
                {
                    continue;
                }

                Bitset expectedState = continuousActionPair.Value.Key;
                bool   match         = true;

                for (int i = 0; i < state.m_NumBits; i++)
                {
                    if (expectedState.Get(i))
                    {
                        if (!state.Get(i))
                        {
                            match = false;
                            break;
                        }
                    }
                }

                if (match)
                {
                    matches.Add(new KeyValuePair <Bitset, ContinuousAction>(expectedState, continuousActionPair.Key));
                }
            }

            List <KeyValuePair <int, ContinuousAction> > matchResults = new List <KeyValuePair <int, ContinuousAction> >();

            for (int i = 0; i < matches.Count; i++)
            {
                int bits = 0;
                for (int q = 0; q < state.m_NumBits; q++)
                {
                    if (matches[i].Key.Get(q))
                    {
                        bits++;
                    }
                }

                var value = matches[i].Value;
                matchResults.Add(new KeyValuePair <int, ContinuousAction>(bits, value));
            }

            if (matches.Count == 0)
            {
                return(null);
            }

            matchResults.Sort(CompareKeys);

            int minBits = matchResults[matches.Count - 1].Key;
            List <ContinuousAction> actions = new List <ContinuousAction>();

            for (var i = 0; i < matches.Count; i++)
            {
                if (matchResults[i].Key >= minBits)
                {
                    actions.Add(matches[i].Value);
                }
            }

            return(actions);
        }
示例#11
0
 public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action)
 {
     continuousActionsMap[action] = new KeyValuePair <Bitset, int>(state, axis);
 }
        public virtual void DoWindow(int window)
        {
            GUI.DragWindow(new Rect(0, 0, 10000, 20));

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("X", GUILayout.Height(16)) || m_Controller == null || m_Controller.iface == null)
            {
                shouldBeDestroyed = true;
                if (m_Controller != null)
                {
                    m_Controller.presetEditorOpen = false;
                    AdvancedFlyByWire.Instance.SaveState(null);
                }

                return;
            }

            GUILayout.EndHorizontal();

            var currentPreset = m_Controller.GetCurrentPreset();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Preset: ");

            currentPreset.name = GUILayout.TextField(currentPreset.name, GUILayout.Width(256));

            if (m_Controller.currentPreset > 0)
            {
                if (GUILayout.Button("<"))
                {
                    m_Controller.currentPreset--;
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button("<");
                GUI.enabled = true;
            }

            if (m_Controller.currentPreset < m_Controller.presets.Count - 1)
            {
                if (GUILayout.Button(">"))
                {
                    m_Controller.currentPreset++;
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button(">");
                GUI.enabled = true;
            }

            if (GUILayout.Button("New"))
            {
                m_Controller.presets.Add(new ControllerPreset());
                m_Controller.currentPreset = m_Controller.presets.Count - 1;
            }

            string destructiveRemoveLabel = "Delete";
            if (m_DestructiveActionWait)
            {
                destructiveRemoveLabel = "Sure?";
            }

            if (m_Controller.presets.Count <= 1 || m_Controller.currentPreset == 0)
            {
                GUI.enabled = false;
            }

            if (GUILayout.Button(destructiveRemoveLabel))
            {
                if(m_DestructiveActionWait)
                {
                    if(m_Controller.presets.Count > 1)
                    {
                        m_Controller.presets.RemoveAt(m_Controller.currentPreset);
                        m_Controller.currentPreset--;
                        if (m_Controller.currentPreset < 0)
                        {
                            m_Controller.currentPreset = 0;
                        }

                        m_DestructiveActionWait = false;
                        m_DestructiveActionTimer = 0.0f;
                    }
                }
                else
                {
                    m_DestructiveActionWait = true;
                    m_DestructiveActionTimer = 2.0f;
                }
            }

            GUI.enabled = true;
            GUILayout.EndHorizontal();

            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);

            GUILayout.Label("Continuous actions");

            foreach (var action in (ContinuousAction[])Enum.GetValues(typeof(ContinuousAction)))
            {
                if (action == ContinuousAction.None)
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(Stringify.ContinuousActionToString(action));
                GUILayout.FlexibleSpace();

                string label = "";

                var axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action);
                if (m_CurrentlyEditingContinuousAction == action)
                {
                    label = "Press desired combination";

                    var buttonsMask = m_Controller.iface.GetButtonsMask();

                    for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++)
                    {
                        if (Math.Abs(m_Controller.iface.GetAxisState(i) - axisSnapshot[i]) > 0.1 && m_ClickSleepTimer == 0.0f)
                        {
                            currentPreset.SetContinuousBinding(i, buttonsMask, action, false);
                            m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                        }
                    }
                }

                axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action);
                if (m_CurrentlyEditingContinuousAction != action)
                {
                    if (axisBitsetPair.Value == null)
                    {
                        label = "Click to assign";
                    }
                    else
                    {
                        label = m_Controller.iface.ConvertMaskToName(axisBitsetPair.Value, true, axisBitsetPair.Key);
                    }
                }

                if (GUILayout.Button(label, GUILayout.Width(220)))
                {
                    if (m_CurrentlyEditingContinuousAction != action)
                    {
                        m_CurrentlyEditingContinuousAction = action;
                        m_CurrentlyEditingDiscreteAction = DiscreteAction.None;
                        m_ClickSleepTimer = 0.25f;

                        for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++)
                        {
                            axisSnapshot[i] = m_Controller.iface.GetAxisState(i);
                        }
                    }

                    m_CurrentMask = null;
                }

                GUILayout.Space(8);

                var inverted = GUILayout.Toggle(currentPreset.IsContinuousBindingInverted(action), "");
                currentPreset.SetContinuousBindingInverted(action, inverted);
                GUILayout.Label("Invert");

                GUILayout.Space(8);

                if (GUILayout.Button("X"))
                {
                    currentPreset.UnsetContinuousBinding(action);
                    m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                    m_CurrentlyEditingDiscreteAction = DiscreteAction.None;
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.Label("Discrete actions");

            foreach (var action in (DiscreteAction[])Enum.GetValues(typeof(DiscreteAction)))
            {
                if (action == DiscreteAction.None)
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(Stringify.DiscreteActionToString(action));
                GUILayout.FlexibleSpace();

                string label = "";

                var bitset = currentPreset.GetBitsetForDiscreteBinding(action);
                if (m_CurrentlyEditingDiscreteAction == action)
                {
                    label = "Press desired combination";

                    if (m_CurrentMask != null && m_ClickSleepTimer == 0.0f)
                    {
                        currentPreset.SetDiscreteBinding(m_CurrentMask, action);
                        m_CurrentMask = null;
                        m_CurrentlyEditingDiscreteAction = DiscreteAction.None;
                    }
                }

                bitset = currentPreset.GetBitsetForDiscreteBinding(action);
                if (m_CurrentlyEditingDiscreteAction != action)
                {
                    if (bitset == null)
                    {
                        label = "Click to assign";
                    }
                    else
                    {
                        label = m_Controller.iface.ConvertMaskToName(bitset);
                    }
                }

                if (GUILayout.Button(label, GUILayout.Width(256)))
                {
                    if (m_CurrentlyEditingDiscreteAction != action)
                    {
                        m_CurrentlyEditingDiscreteAction = action;
                        m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                        m_ClickSleepTimer = 0.25f;
                    }

                    m_CurrentMask = null;
                }

                if (GUILayout.Button("X"))
                {
                    currentPreset.UnsetDiscreteBinding(action);
                    m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                    m_CurrentlyEditingDiscreteAction = DiscreteAction.None;
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
        }
 public void SetCurrentBitmask(Bitset mask)
 {
     m_CurrentMask = mask;
 }
        public virtual void OnGUI()
        {
            if (m_Controller.iface == null)
            {
                shouldBeDestroyed = true;
                return;
            }

            if (m_ClickSleepTimer > 0.0f)
            {
                m_ClickSleepTimer -= Time.unscaledDeltaTime;
                if (m_ClickSleepTimer < 0.0f)
                {
                    m_CurrentMask = null;
                    m_ClickSleepTimer = 0.0f;
                }
            }

            if (m_DestructiveActionTimer > 0.0f)
            {
                m_DestructiveActionTimer -= Time.unscaledDeltaTime;
                if (m_DestructiveActionTimer < 0.0f)
                {
                    m_DestructiveActionWait = false;
                    m_DestructiveActionTimer = 0.0f;
                }
            }

            if (Utility.RectContainsMouse(windowRect))
            {
                InputLockManager.SetControlLock(inputLockHash);
            }
            else
            {
                InputLockManager.RemoveControlLock(inputLockHash);
            }

            windowRect = GUI.Window(1337 + m_EditorId, windowRect, DoWindow, "Fly-By-Wire Preset Editor");
            windowRect = Utility.ClampRect(windowRect, new Rect(0, 0, Screen.width, Screen.height));
        }
示例#15
0
        }                                // Required for XML serialization

        public DiscreteActionEntry(DiscreteAction action, Bitset bitset)
        {
            this.Action = action;
            this.Bitset = bitset;
        }
示例#16
0
        public List <DiscreteAction> GetDiscreteBinding(Bitset state)
        {
            List <KeyValuePair <Bitset, DiscreteAction> > matches = new List <KeyValuePair <Bitset, DiscreteAction> >();

            foreach (var discreteActionEntry in discreteActionsMap.Values)
            {
                bool match = true;
                for (int i = 0; i < state.m_NumBits; i++)
                {
                    if (discreteActionEntry.Bitset.Get(i))
                    {
                        if (!state.Get(i))
                        {
                            match = false;
                            break;
                        }
                    }
                }

                if (match)
                {
                    matches.Add(new KeyValuePair <Bitset, DiscreteAction>(discreteActionEntry.Bitset, discreteActionEntry.Action));
                }
            }

            List <KeyValuePair <int, DiscreteAction> > matchResults = new List <KeyValuePair <int, DiscreteAction> >();

            for (int i = 0; i < matches.Count; i++)
            {
                int bits = 0;
                for (int q = 0; q < state.m_NumBits; q++)
                {
                    if (matches[i].Key.Get(q))
                    {
                        bits++;
                    }
                }

                var value = matches[i].Value;
                matchResults.Add(new KeyValuePair <int, DiscreteAction>(bits, value));
            }

            if (matches.Count == 0)
            {
                return(null);
            }

            matchResults.Sort(CompareKeys2);

            int minBits = matchResults[matches.Count - 1].Key;
            List <DiscreteAction> actions = new List <DiscreteAction>();

            for (var i = 0; i < matches.Count; i++)
            {
                if (matchResults[i].Key >= minBits)
                {
                    actions.Add(matchResults[i].Value);
                }
            }

            return(actions);
        }
        public List<ContinuousAction> GetContinuousBinding(int axis, Bitset state)
        {
            List<KeyValuePair<Bitset, ContinuousAction>> matches = new List<KeyValuePair<Bitset, ContinuousAction>>();

            foreach (var continuousActionPair in continuousActionsMap)
            {
                if(continuousActionPair.Value.Value != axis)
                {
                    continue;
                }

                Bitset expectedState = continuousActionPair.Value.Key;
                bool match = true;

                for (int i = 0; i < state.m_NumBits; i++)
                {
                    if (expectedState.Get(i))
                    {
                        if (!state.Get(i))
                        {
                            match = false;
                            break;
                        }
                    }
                }

                if (match)
                {
                    matches.Add(new KeyValuePair<Bitset, ContinuousAction>(expectedState, continuousActionPair.Key));
                }
            }

            if (matches.Count == 0)
            {
                return null;
            }

            List<KeyValuePair<int, ContinuousAction>> matchResults = new List<KeyValuePair<int, ContinuousAction>>();
            for (int i = 0; i < matches.Count; i++)
            {
                int bits = 0;
                for (int q = 0; q < matches[i].Key.m_NumBits; q++)
                {
                    if(matches[i].Key.Get(q))
                    {
                        bits++;
                    }
                }

                var value = matches[i].Value;
                matchResults.Add(new KeyValuePair<int, ContinuousAction>(bits, value));
            }

            matchResults.Sort(CompareKeys);

            int minBits = matchResults[0].Key;
            List<ContinuousAction> actions = new List<ContinuousAction>();

            for (var i = 0; i < matchResults.Count; i++)
            {
                if (matchResults[i].Key >= minBits)
                {
                    actions.Add(matchResults[i].Value);
                }
            }

            return actions;
        }
示例#18
0
        public List <ContinuousAction> GetContinuousBinding(int axis, Bitset state)
        {
            List <KeyValuePair <Bitset, ContinuousAction> > matches = new List <KeyValuePair <Bitset, ContinuousAction> >();

            foreach (var continuousActionEntry in continuousActionsMap.Values)
            {
                if (continuousActionEntry.Bitset == null || continuousActionEntry.Axis != axis)
                {
                    continue;
                }

                bool match = true;
                for (int i = 0; i < state.m_NumBits; i++)
                {
                    if (continuousActionEntry.Bitset.Get(i))
                    {
                        if (!state.Get(i))
                        {
                            match = false;
                            break;
                        }
                    }
                }

                if (match)
                {
                    matches.Add(new KeyValuePair <Bitset, ContinuousAction>(continuousActionEntry.Bitset, continuousActionEntry.Action));
                }
            }

            if (matches.Count == 0)
            {
                return(null);
            }

            List <KeyValuePair <int, ContinuousAction> > matchResults = new List <KeyValuePair <int, ContinuousAction> >();

            for (int i = 0; i < matches.Count; i++)
            {
                int bits = 0;
                for (int q = 0; q < matches[i].Key.m_NumBits; q++)
                {
                    if (matches[i].Key.Get(q))
                    {
                        bits++;
                    }
                }

                var value = matches[i].Value;
                matchResults.Add(new KeyValuePair <int, ContinuousAction>(bits, value));
            }

            matchResults.Sort(CompareKeys);

            int minBits = matchResults[0].Key;
            List <ContinuousAction> actions = new List <ContinuousAction>();

            for (var i = 0; i < matchResults.Count; i++)
            {
                if (matchResults[i].Key >= minBits)
                {
                    actions.Add(matchResults[i].Value);
                }
            }

            return(actions);
        }
        public List<DiscreteAction> GetDiscreteBinding(Bitset state)
        {
            List<KeyValuePair<Bitset, DiscreteAction>> matches = new List<KeyValuePair<Bitset, DiscreteAction>>();

            foreach (var maskActionPair in discreteActionsMap)
            {
                Bitset expectedState = maskActionPair.Value;
                bool match = true;

                for (int i = 0; i < state.m_NumBits; i++)
                {
                    if (expectedState.Get(i))
                    {
                        if (!state.Get(i))
                        {
                            match = false;
                            break;
                        }
                    }
                }

                if(match)
                {
                    matches.Add(new KeyValuePair<Bitset, DiscreteAction>(maskActionPair.Value, maskActionPair.Key));
                }
            }

            List<KeyValuePair<int, DiscreteAction>> matchResults = new List<KeyValuePair<int, DiscreteAction>>();
            for (int i = 0; i < matches.Count; i++)
            {
                int bits = 0;
                for (int q = 0; q < state.m_NumBits; q++)
                {
                    if (matches[i].Key.Get(q))
                    {
                        bits++;
                    }
                }

                var value = matches[i].Value;
                matchResults.Add(new KeyValuePair<int, DiscreteAction>(bits, value));
            }

            if (matches.Count == 0)
            {
                return null;
            }

            matchResults.Sort(CompareKeys2);

            int minBits = matchResults[matches.Count - 1].Key;
            List<DiscreteAction> actions = new List<DiscreteAction>();

            for (var i = 0; i < matches.Count; i++)
            {
                if (matchResults[i].Key >= minBits)
                {
                    actions.Add(matchResults[i].Value);
                }
            }

            return actions;
        }
        public virtual void DoWindow(int window)
        {
            GUI.DragWindow(new Rect(0, 0, 10000, 20));

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            if (GUILayout.Button("X", GUILayout.Height(16)) || m_Controller == null || m_Controller.iface == null)
            {
                shouldBeDestroyed = true;
                if (m_Controller != null)
                {
                    m_Controller.presetEditorOpen = false;
                }
            }

            GUILayout.EndHorizontal();

            var currentPreset = m_Controller.GetCurrentPreset();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Preset: ");

            currentPreset.name = GUILayout.TextField(currentPreset.name, GUILayout.Width(256));

            if (m_Controller.currentPreset > 0)
            {
                if (GUILayout.Button("<"))
                {
                    m_Controller.currentPreset--;
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button("<");
                GUI.enabled = true;
            }

            if (m_Controller.currentPreset < m_Controller.presets.Count - 1)
            {
                if (GUILayout.Button(">"))
                {
                    m_Controller.currentPreset++;
                }
            }
            else
            {
                GUI.enabled = false;
                GUILayout.Button(">");
                GUI.enabled = true;
            }

            if (GUILayout.Button("New"))
            {
                m_Controller.presets.Add(new ControllerPreset());
                m_Controller.currentPreset = m_Controller.presets.Count - 1;
            }

            string destructiveRemoveLabel = "Delete";

            if (m_DestructiveActionWait)
            {
                destructiveRemoveLabel = "Sure?";
            }

            if (m_Controller.presets.Count <= 1)
            {
                GUI.enabled = false;
            }

            if (GUILayout.Button(destructiveRemoveLabel))
            {
                if (m_DestructiveActionWait)
                {
                    if (m_Controller.presets.Count > 1)
                    {
                        m_Controller.presets.RemoveAt(m_Controller.currentPreset);
                        m_Controller.currentPreset--;
                        if (m_Controller.currentPreset < 0)
                        {
                            m_Controller.currentPreset = 0;
                        }

                        m_DestructiveActionWait  = false;
                        m_DestructiveActionTimer = 0.0f;
                    }
                }
                else
                {
                    m_DestructiveActionWait  = true;
                    m_DestructiveActionTimer = 2.0f;
                }
            }

            GUI.enabled = true;
            GUILayout.EndHorizontal();

            m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);

            GUILayout.Label("Continuous actions");

            foreach (var action in (ContinuousAction[])Enum.GetValues(typeof(ContinuousAction)))
            {
                if (action == ContinuousAction.None)
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(Stringify.ContinuousActionToString(action));
                GUILayout.FlexibleSpace();

                string label = "";

                var axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action);
                if (m_CurrentlyEditingContinuousAction == action)
                {
                    label = "Press desired combination";

                    for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++)
                    {
                        if (Math.Abs(m_Controller.iface.GetAxisState(i) - axisSnapshot[i]) > 0.1 && m_ClickSleepTimer == 0.0f)
                        {
                            currentPreset.SetContinuousBinding(i, m_Controller.iface.GetButtonsMask(), action);
                            m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                        }
                    }
                }

                axisBitsetPair = currentPreset.GetBitsetForContinuousBinding(action);
                if (m_CurrentlyEditingContinuousAction != action)
                {
                    if (axisBitsetPair.Value == null)
                    {
                        label = "Click to assign";
                    }
                    else
                    {
                        label = m_Controller.iface.ConvertMaskToName(axisBitsetPair.Value, true, axisBitsetPair.Key);
                    }
                }

                if (GUILayout.Button(label, GUILayout.Width(256)))
                {
                    if (m_CurrentlyEditingContinuousAction != action)
                    {
                        m_CurrentlyEditingContinuousAction = action;
                        m_CurrentlyEditingDiscreteAction   = DiscreteAction.None;
                        m_ClickSleepTimer = 0.25f;

                        for (int i = 0; i < m_Controller.iface.GetAxesCount(); i++)
                        {
                            axisSnapshot[i] = m_Controller.iface.GetAxisState(i);
                        }
                    }

                    m_CurrentMask = null;
                }

                if (GUILayout.Button("X"))
                {
                    currentPreset.UnsetContinuousBinding(action);
                    m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                    m_CurrentlyEditingDiscreteAction   = DiscreteAction.None;
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.Label("Discrete actions");

            foreach (var action in (DiscreteAction[])Enum.GetValues(typeof(DiscreteAction)))
            {
                if (action == DiscreteAction.None)
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                GUILayout.Label(Stringify.DiscreteActionToString(action));
                GUILayout.FlexibleSpace();

                string label = "";

                var bitset = currentPreset.GetBitsetForDiscreteBinding(action);
                if (m_CurrentlyEditingDiscreteAction == action)
                {
                    label = "Press desired combination";

                    if (m_CurrentMask != null && m_ClickSleepTimer == 0.0f)
                    {
                        currentPreset.SetDiscreteBinding(m_CurrentMask, action);
                        m_CurrentMask = null;
                        m_CurrentlyEditingDiscreteAction = DiscreteAction.None;
                    }
                }

                bitset = currentPreset.GetBitsetForDiscreteBinding(action);
                if (m_CurrentlyEditingDiscreteAction != action)
                {
                    if (bitset == null)
                    {
                        label = "Click to assign";
                    }
                    else
                    {
                        label = m_Controller.iface.ConvertMaskToName(bitset);
                    }
                }

                if (GUILayout.Button(label, GUILayout.Width(256)))
                {
                    if (m_CurrentlyEditingDiscreteAction != action)
                    {
                        m_CurrentlyEditingDiscreteAction   = action;
                        m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                        m_ClickSleepTimer = 0.25f;
                    }

                    m_CurrentMask = null;
                }

                if (GUILayout.Button("X"))
                {
                    currentPreset.UnsetDiscreteBinding(action);
                    m_CurrentlyEditingContinuousAction = ContinuousAction.None;
                    m_CurrentlyEditingDiscreteAction   = DiscreteAction.None;
                }

                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
        }
 public void SetContinuousBinding(int axis, Bitset state, ContinuousAction action, bool isInverted)
 {
     //Debug.Log("SetContBind: " + action.ToString() + " to axis " + axis + " and bitset " + state.ToString());
     continuousActionsMap[action] = new KeyValuePair<Bitset, int>(state, axis);
     if (isInverted)
     {
         continuousActionsInvMap[action] = true;
     }
     //TODO: Remove from map if false and containsKey? Saves a little space when serializing.
 }