Example #1
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);
                 *      }
                 * }*/
            }
        }
Example #2
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
            }
        }
Example #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(string.Format("{0} does not support {1} controller(s)", RunningSystem.DisplayName, player));
            }
            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(string.Format("{0}", JoypadConverter.ConvertBack(button, RunningSystem)), true);
                            }
                            else
                            {
                                joypadAdaptor.SetSticky(string.Format("P{0} {1}", 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(string.Format("P{0} X Axis", i), allJoypads[i - 1].AnalogX);
                        joypadAdaptor.SetFloat(string.Format("P{0} Y Axis", i), allJoypads[i - 1].AnalogY);
                    }
                }*/
            }
        }