示例#1
0
        public void ActivateController(InputWrapper wrapper, int controllerIndex, IController.ButtonPressedCallback pressedCallback, IController.ButtonReleasedCallback releasedCallback)
        {
            foreach (var config in controllers)
            {
                if (config.wrapper == wrapper && config.controllerIndex == controllerIndex)
                {
                    config.isEnabled = true;
                    return;
                }
            }

            var controller = new ControllerConfiguration();

            controller.wrapper         = wrapper;
            controller.controllerIndex = controllerIndex;

            if (Utility.CheckXInputSupport() && wrapper == InputWrapper.XInput)
            {
#if !LINUX
                controller.iface = new XInputController(controller.controllerIndex);
#endif
            }
            else if (Utility.CheckSDLSupport() && wrapper == InputWrapper.SDL)
            {
                controller.iface = new SDLController(controller.controllerIndex);
            }

            /*else if (Utility.CheckSharpDXSupport() && wrapper == InputWrapper.DirectInput)
             * {
             #if !LINUX
             *   controller.iface = new DirectXController(controller.controllerIndex);
             #endif
             * }*/
            else if (wrapper == InputWrapper.KeyboardMouse)
            {
                controller.iface = new KeyboardMouseController();
            }
            else
            {
                // invalid configuration, bail out..
                return;
            }

            controller.SetManualDeadZones(controller.manualDeadZones);
            controller.iface.analogEvaluationCurve  = CurveFactory.Instantiate(controller.analogInputCurve);
            controller.iface.buttonPressedCallback  = pressedCallback;
            controller.iface.buttonReleasedCallback = releasedCallback;

            controller.presets       = DefaultControllerPresets.GetDefaultPresets(controller.iface);
            controller.currentPreset = 0;

            controllers.Add(controller);

            ScreenMessages.PostScreenMessage("CONTROLLER: " + controller.iface.GetControllerName(), 1.0f, ScreenMessageStyle.UPPER_CENTER);
        }
        public void ActivateController(InputWrapper wrapper, int controllerIndex, IController.ButtonPressedCallback pressedCallback, IController.ButtonReleasedCallback releasedCallback)
        {
            foreach (var config in controllers)
            {
                if (config.wrapper == wrapper && config.controllerIndex == controllerIndex)
                {
                    return;
                }
            }

            ControllerConfiguration controller = new ControllerConfiguration();

            controller.wrapper         = wrapper;
            controller.controllerIndex = controllerIndex;

            if (Utility.CheckXInputSupport() && wrapper == InputWrapper.XInput)
            {
                controller.iface = new XInputController(controller.controllerIndex);
            }
            else if (Utility.CheckSDLSupport() && wrapper == InputWrapper.SDL)
            {
                controller.iface = new SDLController(controller.controllerIndex);
            }
            else if (wrapper == InputWrapper.KeyboardMouse)
            {
                controller.iface = new KeyboardMouseController();
            }
            else
            {
                // invalid configuration, bail out..
                return;
            }

            controller.SetTreatHatsAsButtons(controller.treatHatsAsButtons);
            controller.iface.analogEvaluationCurve  = CurveFactory.Instantiate(controller.analogInputCurve);
            controller.iface.buttonPressedCallback  = new IController.ButtonPressedCallback(pressedCallback);
            controller.iface.buttonReleasedCallback = new IController.ButtonReleasedCallback(releasedCallback);

            controller.presets       = DefaultControllerPresets.GetDefaultPresets(controller.iface);
            controller.currentPreset = 0;

            controllers.Add(controller);

            ScreenMessages.PostScreenMessage("CONTROLLER: " + controller.iface.GetControllerName(), 1.0f, ScreenMessageStyle.UPPER_CENTER);
        }