// ----------------------------
        static protected void SetupAxisBinding(AxisBinding binding, string axisName)
        {
            binding.Clear();

            if (!string.IsNullOrEmpty(axisName))
            {
                binding.Enable();
                binding.AddTarget().SetSingleAxis(axisName, false);
            }
        }
Example #2
0
            // ---------------
            public void Execute()
            {
                if (this.binding == null)
                {
                    return;
                }

                CFGUI.CreateUndo(this.undoLabel, this.undoObject);

                DigitalBinding       digiBinding   = (this.binding as DigitalBinding);
                AxisBinding          analogBinding = (this.binding as AxisBinding);
                EmuTouchBinding      touchBinding  = (this.binding as EmuTouchBinding);
                MousePositionBinding mouseBinding  = (this.binding as MousePositionBinding);

                //JoystickNameBinding		joyNameBinding	= (this.binding as JoystickNameBinding);

                // Digi binding...

                if (digiBinding != null)
                {
                    if (this.digiKey != KeyCode.None)
                    {
                        digiBinding.Enable();

                        if (this.digiKeyElemId < 0)
                        {
                            digiBinding.AddKey(this.digiKey);
                        }
                        else
                        {
                            digiBinding.ReplaceKey(this.digiKeyElemId, this.digiKey);
                        }
                    }

                    if (!string.IsNullOrEmpty(this.digiAxisName))
                    {
                        digiBinding.Enable();

                        DigitalBinding.AxisElem elem = null;


                        if (this.digiAxisElemId < 0)
                        {
                            elem = digiBinding.AddAxis();
                        }
                        else
                        {
                            elem = digiBinding.GetAxisElem(this.digiAxisElemId);
                        }

                        if (elem != null)
                        {
                            elem.SetAxis(this.digiAxisName, this.digiBindToPositiveAxis);
                        }
                    }
                }


                // Analog Binding...

                else if (analogBinding != null)
                {
                    if (!string.IsNullOrEmpty(this.analogAxisName))
                    {
                        analogBinding.Enable();

                        AxisBinding.TargetElem elem = null;

                        if (this.analogElemId < 0)
                        {
                            elem = analogBinding.AddTarget();
                        }
                        else
                        {
                            elem = analogBinding.GetTarget(this.analogElemId);
                        }

                        if (elem != null)
                        {
                            if (this.analogSeparate)
                            {
                                elem.SetSeparateAxis(this.analogAxisName, this.analogPositiveSide, !this.analogFlip);
                            }
                            else
                            {
                                elem.SetSingleAxis(this.analogAxisName, this.analogFlip);
                            }
                        }
                    }
                }

                // Touch Binding...

                else if (touchBinding != null)
                {
                    touchBinding.Enable();
                }

                // Mouse Binding...

                else if (mouseBinding != null)
                {
                    mouseBinding.Enable();
                }


                CFGUI.EndUndo(this.undoObject);

                if (this.onRefreshCallback != null)
                {
                    this.onRefreshCallback();
                }
            }