public static void Update()
        {
            _currentControl = KeyboardControl;
            KeyboardControl.Update();
            if (HasInput(KeyboardControl))
                return;

            _currentControl = GamePadControl;
            GamePadControl.Update();
        }
Beispiel #2
0
        /// <summary>
        /// Initialize the linked lists and load the settings. This
        /// don't initialize the plugins, so no hardware resources
        /// are locked.
        /// </summary>
        private static void BuildControlStructure()
        {
            // Get all plugins
            List <IControlPlugin> pluginInstances = PluginInstances();

            // Initialize the arrays
            _plugins = new List <IControlPlugin>();
            _input   = new List <IControlInput>();
            _output  = new List <IControlOutput>();

            // Filter the ones that are enabled
            IEnumerator <IControlPlugin> pluginIterator = pluginInstances.GetEnumerator();

            while (pluginIterator.MoveNext())
            {
                // Get the settings interface
                IControlPlugin   plugin   = pluginIterator.Current;
                IControlSettings settings = plugin.Settings;
                if (null == settings)
                {
                    Log.Error("ControlDevices: Error getting IControlSettings of {0} in {1}", ((Type)plugin).FullName,
                              plugin.LibraryName);
                    continue;
                }
                // Load the settings
                settings.Load();

                if (settings.Enabled)
                {
                    if (settings.EnableInput)
                    {
                        IControlInput input = plugin.InputInterface;
                        if (null == input)
                        {
                            Log.Error("ControlDevices: Error getting IControlInput Interface of {0} in {1}", ((Type)plugin).FullName,
                                      plugin.LibraryName);
                            continue;
                        }
                        _input.Add(input);
                    }
                    if (settings.EnableOutput)
                    {
                        IControlOutput output = plugin.OutputInterface;
                        if (null == output)
                        {
                            Log.Error("ControlDevices: Error getting IControlOutput Interface of {0} in {1}", ((Type)plugin).FullName,
                                      plugin.LibraryName);
                            continue;
                        }
                        _output.Add(output);
                    }
                }
            }
        }
Beispiel #3
0
 private static bool HasInput(IControlInput control)
 {
     return(control.KeyLeftPressing ||
            control.KeyRightPressing ||
            control.KeyUpPressing ||
            control.KeyDownPressing ||
            control.KeyJumpPressed ||
            control.KeyAttackPressed ||
            control.KeySecondaryPressed ||
            control.KeyStartPressed);
 }
Beispiel #4
0
        public static void Update()
        {
            _currentControl = KeyboardControl;
            KeyboardControl.Update();
            if (HasInput(KeyboardControl))
            {
                return;
            }

            _currentControl = GamePadControl;
            GamePadControl.Update();
        }
Beispiel #5
0
        public AddForm(Type type)
        {
            DialogResult = new DialogResult();
            this.Text    = "Добавление " + type.GetTitle();
            Instanse     = Activator.CreateInstance(type);
            Type         = type;
            Width        = 420;
            Controls.Add(new HeadAddFormControl());
            ((HeadAddFormControl)Controls[0]).Init();
            Dictionary <PropertyInfo, IControlInput> dic = GetControls(type);

            foreach (var propContrPair in dic)
            {
                IControlInput control  = propContrPair.Value;
                PropertyInfo  property = propContrPair.Key;
                control.Show(Instanse, propContrPair.Key);

                Controls.Add((UserControl)control);
            }
            Init();
        }
Beispiel #6
0
        public static bool WndProc(ref Message msg, out Action action, out char key, out Keys keyCode)
        {
            IEnumerator <IControlInput> inputIterator = _input.GetEnumerator();

            action  = null;
            key     = (char)0;
            keyCode = Keys.Escape;

            while (inputIterator.MoveNext())
            {
                // Get the settings interface
                IControlInput input = inputIterator.Current;
                if (input.UseWndProc)
                {
                    if (input.WndProc(ref msg, out action, out key, out keyCode))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
 private static bool HasInput(IControlInput control)
 {
     return control.KeyLeftPressing ||
            control.KeyRightPressing ||
            control.KeyUpPressing ||
            control.KeyDownPressing ||
            control.KeyJumpPressed ||
            control.KeyAttackPressed ||
            control.KeySecondaryPressed ||
            control.KeyStartPressed;
 }