public void SetBinding(int deviceNumber, int setNumber, InputButton button, InputTrigger trigger)
        {
            if (deviceNumber < 0 || deviceNumber >= this.devices.Count)
            {
                return;
            }

            var device = this.devices[deviceNumber];

            device.BindingSets.SetBinding(setNumber, button, trigger);
        }
예제 #2
0
 public void SetBinding(InputButton button, InputTrigger trigger)
 {
     if (trigger != null)
     {
         this.bindings[button] = new InputBinding(button, trigger);
     }
     else if (this.bindings.ContainsKey(button))
     {
         this.bindings.Remove(button);
     }
 }
예제 #3
0
        public void SetBinding(int setNumber, InputButton button, InputTrigger trigger)
        {
            if (setNumber >= this.sets.Count)
            {
                return;
            }

            var set = this.sets[setNumber];

            set.SetBinding(button, trigger);
        }
예제 #4
0
        public List <InputTrigger> GetTriggers(InputButton button)
        {
            var returnValue = new List <InputTrigger>();

            foreach (InputBindingSet set in this.sets)
            {
                InputTrigger trigger = set.GetButtonTrigger(button);
                if (trigger != null)
                {
                    returnValue.Add(trigger);
                }
            }
            return(returnValue);
        }
예제 #5
0
        private void AddGridItem(InputButton button, string buttonName)
        {
            int rowIndex = this.ControlsGridView.Rows.Add();

            this.ControlsGridView[(int)GridColumn.InputButton, rowIndex].Value = button;
            this.ControlsGridView[(int)GridColumn.ButtonName, rowIndex].Value  = buttonName;

            int columnIndex = (int)GridColumn.ButtonName + 1;

            for (int setNumber = 0; setNumber < this.devices[this.deviceNumber].BindingSets.Count; setNumber++)
            {
                InputBindingSet set = this.devices[this.deviceNumber].BindingSets[setNumber];

                InputTrigger     trigger = set.GetButtonTrigger(button);
                DataGridViewCell cell    = this.ControlsGridView[columnIndex, rowIndex];
                cell.Tag = trigger;
                this.UpdateTriggerText(cell);

                columnIndex++;
            }
        }
예제 #6
0
 public InputBinding(InputButton button, InputTrigger trigger)
 {
     this.Button  = button;
     this.Trigger = trigger;
 }
예제 #7
0
        private void DoStopEditButton(InputTrigger trigger = null)
        {
            if (!this.isEditingButton)
            {
                return;
            }

            int currentRowIndex  = this.editedCell.RowIndex;
            var currentSetNumber = this.FindSetIndexForColumn(this.editedCell);

            // If there was a trigger sent in to complete the button editing, then bind it!
            InputButton?button = this.FindInputButtonForRow(this.editedCell);

            if (trigger != null && button != null)
            {
                int setNumber = this.FindSetIndexForColumn(this.editedCell);
                this.devices.SetBinding(deviceNumber, setNumber, button.Value, trigger);
            }
            else
            {
                this.isSettingAll = false;
            }

            // Finalize editing here.
            this.editedCell      = null;
            this.isEditingButton = false;
            this.UpdateUI();

            // Move on to the next cell down (unless we were forcibly cancelled).
            // Also, if the mouse is over the controller preview, we might not move to
            // the next item.
            DataGridViewCell nextCell = null;

            if (trigger != null)
            {
                nextCell = this.GetNextInputButtonCell(currentRowIndex, currentSetNumber);
                if (nextCell != null)
                {
                    if (this.IsMouseOverPreview() && !this.isSettingAll)
                    {
                        // If the mouse if over the controller preview
                        // AND we're not "setting all", it's safe to
                        // forego moving to the next item.
                    }
                    else
                    {
                        this.ControlsGridView.CurrentCell = nextCell;
                    }
                }
            }

            // If we're in "setting all" mode, we also start editing the next item.
            if (this.isSettingAll)
            {
                if (nextCell == null)
                {
                    this.isSettingAll = false;
                }
                else
                {
                    this.DoStartEditButton(nextCell);
                }
            }
        }