Esempio n. 1
0
 public AutofireConfig(
     Config config,
     AutofireController autoFireController,
     AutoFireStickyXorAdapter stickyXorAdapter)
 {
     _config             = config;
     _autoFireController = autoFireController;
     _stickyXorAdapter   = stickyXorAdapter;
     InitializeComponent();
 }
Esempio n. 2
0
 public AutofireConfig(
     Config config,
     AutofireController autoFireController,
     AutoFireStickyXorAdapter stickyXorAdapter)
 {
     _config             = config;
     _autoFireController = autoFireController;
     _stickyXorAdapter   = stickyXorAdapter;
     InitializeComponent();
     Icon = Properties.Resources.Lightning_MultiSize;
 }
Esempio n. 3
0
        /// <summary>
        /// Set inputs in specified <see cref="Joypad"/> to specified player
        /// </summary>
        /// <param name="player">Player (one based) whom inputs must be set</param>
        /// <param name="joypad"><see cref="Joypad"/> with inputs</param>
        /// <exception cref="IndexOutOfRangeException">Raised when you specify a player less than 1 or greater than maximum allows (see SystemInfo class to get this information)</exception>
        /// <remarks>Still have some strange behaviour with multiple inputs; so this feature is still in beta</remarks>
        public static void SetInput(int player, Joypad joypad)
        {
            if (player < 1 || player > RunningSystem.MaxControllers)
            {
                throw new IndexOutOfRangeException($"{RunningSystem.DisplayName} does not support {player} controller(s)");
            }
            else
            {
                if (joypad.Inputs == 0)
                {
                    AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;
                    joypadAdaptor.ClearStickies();
                }
                else
                {
                    foreach (JoypadButton button in joypadButtonsArray)
                    {
                        if (joypad.Inputs.HasFlag(button))
                        {
                            AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;
                            if (RunningSystem == SystemInfo.GB)
                            {
                                joypadAdaptor.SetSticky($"{JoypadConverter.ConvertBack(button, RunningSystem)}", true);
                            }
                            else
                            {
                                joypadAdaptor.SetSticky($"P{player} {JoypadConverter.ConvertBack(button, RunningSystem)}", true);
                            }
                        }
                    }
                }

                //Using this break joypad usage (even in UI); have to figure out why

                /*if ((RunningSystem.AvailableButtons & JoypadButton.AnalogStick) == JoypadButton.AnalogStick)
                 * {
                 *      AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;
                 *      for (int i = 1; i <= RunningSystem.MaxControllers; i++)
                 *      {
                 *              joypadAdaptor.SetFloat($"P{i} X Axis", allJoypads[i - 1].AnalogX);
                 *              joypadAdaptor.SetFloat($"P{i} Y Axis", allJoypads[i - 1].AnalogY);
                 *      }
                 * }*/
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Set inputs in specified <see cref="Joypad"/> to specified player
        /// </summary>
        /// <param name="player">Player (one based) whom inputs must be set</param>
        /// <param name="joypad"><see cref="Joypad"/> with inputs</param>
        /// <exception cref="IndexOutOfRangeException">Raised when you specify a player less than 1 or greater than maximum allows (see SystemInfo class to get this information)</exception>
        /// <remarks>Still have some strange behaviour with multiple inputs; so this feature is still in beta</remarks>
        public static void SetInput(int player, Joypad joypad)
        {
            if (!1.RangeTo(RunningSystem.MaxControllers).Contains(player))
            {
                throw new IndexOutOfRangeException($"{RunningSystem.DisplayName} does not support {player} controller(s)");
            }
            else
            {
                if (joypad.Inputs == 0)
                {
                    AutoFireStickyXorAdapter joypadAdapter = Global.InputManager.AutofireStickyXorAdapter;
                    joypadAdapter.ClearStickies();
                }
                else
                {
                    foreach (JoypadButton button in JoypadButtonsArray)
                    {
                        if (joypad.Inputs.HasFlag(button))
                        {
                            AutoFireStickyXorAdapter joypadAdapter = Global.InputManager.AutofireStickyXorAdapter;
                            joypadAdapter.SetSticky(
                                RunningSystem == SystemInfo.GB
                                                                        ? $"{JoypadConverter.ConvertBack(button, RunningSystem)}"
                                                                        : $"P{player} {JoypadConverter.ConvertBack(button, RunningSystem)}", true);
                        }
                    }
                }

                //Using this break joypad usage (even in UI); have to figure out why
#if false
                if ((RunningSystem.AvailableButtons & JoypadButton.AnalogStick) == JoypadButton.AnalogStick)
                {
                    var joypadAdaptor = Global.AutofireStickyXORAdapter;
                    for (var i = 1; i <= RunningSystem.MaxControllers; i++)
                    {
                        joypadAdaptor.SetFloat($"P{i} X Axis", _allJoyPads[i - 1].AnalogX);
                        joypadAdaptor.SetFloat($"P{i} Y Axis", _allJoyPads[i - 1].AnalogY);
                    }
                }
#endif
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Gets all current inputs for each joypad and store
        /// them in <see cref="Joypad"/> class collection
        /// </summary>
        private static void GetAllInputs()
        {
            AutoFireStickyXorAdapter joypadAdaptor = Global.AutofireStickyXORAdapter;

            IEnumerable <string> pressedButtons = from button in joypadAdaptor.Definition.BoolButtons
                                                  where joypadAdaptor.IsPressed(button)
                                                  select button;

            foreach (Joypad j in allJoypads)
            {
                j.ClearInputs();
            }

            Parallel.ForEach <string>(pressedButtons, button =>
            {
                int player;
                if (RunningSystem == SystemInfo.GB)
                {
                    allJoypads[0].AddInput(JoypadConverter.Convert(button));
                }
                else
                {
                    if (int.TryParse(button.Substring(1, 2), out player))
                    {
                        allJoypads[player - 1].AddInput(JoypadConverter.Convert(button.Substring(3)));
                    }
                }
            });

            if ((RunningSystem.AvailableButtons & JoypadButton.AnalogStick) == JoypadButton.AnalogStick)
            {
                for (int i = 1; i <= RunningSystem.MaxControllers; i++)
                {
                    allJoypads[i - 1].AnalogX = joypadAdaptor.GetFloat($"P{i} X Axis");
                    allJoypads[i - 1].AnalogY = joypadAdaptor.GetFloat($"P{i} Y Axis");
                }
            }
        }