Exemplo n.º 1
0
        static GamePadState ReadState(PlayerIndex index, GamePadDeadZone deadZone)
        {
            const float DeadZoneSize = 0.27f;
            IntPtr      device       = GetDevice(index);
            PadConfig   c            = GetConfig(index);

            if (device == IntPtr.Zero || c == null)
            {
                return(GamePadState.InitializedState);
            }

            var leftStick             = c.LeftStick.ReadAxisPair(device);
            var rightStick            = c.RightStick.ReadAxisPair(device);
            GamePadThumbSticks sticks = new GamePadThumbSticks(new Vector2(leftStick.X, leftStick.Y), new Vector2(rightStick.X, rightStick.Y));

            sticks.ApplyDeadZone(deadZone, DeadZoneSize);
            GamePadTriggers triggers    = new GamePadTriggers(c.LeftTrigger.ReadFloat(device), c.RightTrigger.ReadFloat(device));
            Buttons         buttonState = ReadButtons(device, c, DeadZoneSize);

            buttonState |= StickToButtons(sticks.Left, Buttons.LeftThumbstickLeft, Buttons.LeftThumbstickRight, Buttons.LeftThumbstickUp, Buttons.LeftThumbstickDown, DeadZoneSize);
            buttonState |= StickToButtons(sticks.Right, Buttons.RightThumbstickLeft, Buttons.RightThumbstickRight, Buttons.RightThumbstickUp, Buttons.RightThumbstickDown, DeadZoneSize);
            buttonState |= TriggerToButton(triggers.Left, Buttons.LeftTrigger, DeadZoneSize);
            buttonState |= TriggerToButton(triggers.Right, Buttons.RightTrigger, DeadZoneSize);
            GamePadButtons buttons = new GamePadButtons(buttonState);
            GamePadDPad    dpad    = new GamePadDPad(buttons.buttons);

            GamePadState g = new GamePadState(sticks, triggers, buttons, dpad);

            return(g);
        }
Exemplo n.º 2
0
        static Buttons ReadButtons(IntPtr device, PadConfig c, float deadZoneSize, Vector2 leftStick, Vector2 rightStick)
        {
            Buttons b = ReadButtons(device, c, deadZoneSize);

            b |= StickToButtons(leftStick, deadZoneSize);
            b |= StickToButtons(rightStick, deadZoneSize);

            return(b);
        }
Exemplo n.º 3
0
 public InputManager(Game game, ActiveDevice device = ActiveDevice.Keyboard | ActiveDevice.Pad, int lever = 500)
 {
     Game = game;
     DirectInput = new SharpDX.DirectInput.DirectInput();
     LeverDead = lever;
     MouseState = new MouseState();
     var ms = MSInput::Mouse.GetState();
     MouseState.X = ms.X;
     MouseState.Y = ms.Y;
     ControlState = new ControlState();
     GamePlayControlState = new ControlState();
     keyConfig = KeyboardConfig.GetDefault();
     padConfig = PadConfig.GetDefault();
     InitDevices(device);
     GetPushedKey();//������
 }
Exemplo n.º 4
0
        //Inits SDL and grabs the sticks
        static void Init()
        {
            running = true;
            try {
                Joystick.Init();
                sdl = true;
            }
            catch (Exception exc) {
            }

            for (int i = 0; i < 4; i++)
            {
                PadConfig pc = settings[i];
                if (pc != null)
                {
                    devices[i] = Sdl.SDL_JoystickOpen(pc.ID);
                }
            }
        }
Exemplo n.º 5
0
        private static GamePadState ReadState(PlayerIndex index, GamePadDeadZone deadZone)
        {
            IntPtr    device = SdlGamePad.GetDevice(index);
            PadConfig config = SdlGamePad.GetConfig(index);

            if (device == IntPtr.Zero || config == null)
            {
                return(GamePadState.InitializedState);
            }
            Vector2            vector2_1   = config.LeftStick.ReadAxisPair(device);
            Vector2            vector2_2   = config.RightStick.ReadAxisPair(device);
            GamePadThumbSticks thumbSticks = new GamePadThumbSticks(new Vector2(vector2_1.X, vector2_1.Y), new Vector2(vector2_2.X, vector2_2.Y));

            thumbSticks.ApplyDeadZone(deadZone, 0.27f);
            GamePadTriggers triggers = new GamePadTriggers(config.LeftTrigger.ReadFloat(device), config.RightTrigger.ReadFloat(device));
            GamePadButtons  buttons  = new GamePadButtons(SdlGamePad.ReadButtons(device, config, 0.27f) | SdlGamePad.StickToButtons(thumbSticks.Left, Buttons.LeftThumbstickLeft, Buttons.LeftThumbstickRight, Buttons.LeftThumbstickUp, Buttons.LeftThumbstickDown, 0.27f) | SdlGamePad.StickToButtons(thumbSticks.Right, Buttons.RightThumbstickLeft, Buttons.RightThumbstickRight, Buttons.RightThumbstickUp, Buttons.RightThumbstickDown, 0.27f) | SdlGamePad.TriggerToButton(triggers.Left, Buttons.LeftTrigger, 0.27f) | SdlGamePad.TriggerToButton(triggers.Right, Buttons.RightTrigger, 0.27f));
            GamePadDPad     dPad     = new GamePadDPad(buttons.buttons);

            return(new GamePadState(thumbSticks, triggers, buttons, dPad));
        }
Exemplo n.º 6
0
 private static void Init()
 {
     SdlGamePad.running = true;
     try
     {
         Joystick.Init();
         SdlGamePad.sdl = true;
     }
     catch (Exception ex)
     {
     }
     for (int index = 0; index < 4; ++index)
     {
         PadConfig padConfig = SdlGamePad.settings[index];
         if (padConfig != null)
         {
             SdlGamePad.devices[index] = Sdl.SDL_JoystickOpen(padConfig.Index);
         }
     }
 }
Exemplo n.º 7
0
        //
        // Summary:
        //     Retrieves the capabilities of an Xbox 360 Controller.
        //
        // Parameters:
        //   playerIndex:
        //     Index of the controller to query.
        public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
        {
            IntPtr    d = GetDevice(playerIndex);
            PadConfig c = GetConfig(playerIndex);

            if (c == null || ((c.JoystickName == null || c.JoystickName == string.Empty) && d == IntPtr.Zero))
            {
                return(new GamePadCapabilities());
            }

            return(new GamePadCapabilities()
            {
                IsConnected = d != IntPtr.Zero,
                HasAButton = c.Button_A.Type != InputType.None,
                HasBButton = c.Button_B.Type != InputType.None,
                HasXButton = c.Button_X.Type != InputType.None,
                HasYButton = c.Button_Y.Type != InputType.None,
                HasBackButton = c.Button_Back.Type != InputType.None,
                HasStartButton = c.Button_Start.Type != InputType.None,
                HasDPadDownButton = c.Dpad.Down.Type != InputType.None,
                HasDPadLeftButton = c.Dpad.Left.Type != InputType.None,
                HasDPadRightButton = c.Dpad.Right.Type != InputType.None,
                HasDPadUpButton = c.Dpad.Up.Type != InputType.None,
                HasLeftShoulderButton = c.Button_LB.Type != InputType.None,
                HasRightShoulderButton = c.Button_RB.Type != InputType.None,
                HasLeftStickButton = c.LeftStick.Press.Type != InputType.None,
                HasRightStickButton = c.RightStick.Press.Type != InputType.None,
                HasLeftTrigger = c.LeftTrigger.Type != InputType.None,
                HasRightTrigger = c.RightTrigger.Type != InputType.None,
                HasLeftXThumbStick = c.LeftStick.X.Type != InputType.None,
                HasLeftYThumbStick = c.LeftStick.Y.Type != InputType.None,
                HasRightXThumbStick = c.RightStick.X.Type != InputType.None,
                HasRightYThumbStick = c.RightStick.Y.Type != InputType.None,

                HasLeftVibrationMotor = false,
                HasRightVibrationMotor = false,
                HasVoiceSupport = false,
                HasBigButton = false
            });
        }
Exemplo n.º 8
0
        //Inits SDL and grabs the sticks
        static void Init()
        {
            running = true;
            try
            {
                Joystick.Init();
                sdl = true;
            }
            catch (Exception)
            {
            }
            for (int i = 0; i < 4; i++)
            {
                PadConfig pc = settings[i];
#if !PORTABLE
                if (pc != null)
                {
                    devices[i] = Sdl.SDL_JoystickOpen(pc.Index);
                }
#endif
            }
        }
Exemplo n.º 9
0
        static GamePadState ReadState(PlayerIndex index, GamePadDeadZone deadZone)
        {
            const float DeadZoneSize = 0.27f;
            IntPtr      device       = GetDevice(index);
            PadConfig   c            = GetConfig(index);

            if (device == IntPtr.Zero || c == null)
            {
                return(GamePadState.InitializedState);
            }

            GamePadThumbSticks sticks = new GamePadThumbSticks(new Vector2(c.LeftStick.ReadAxisPair(device)), new Vector2(c.RightStick.ReadAxisPair(device)));

            sticks.ApplyDeadZone(deadZone, DeadZoneSize);
            GamePadTriggers triggers = new GamePadTriggers(c.LeftTrigger.ReadFloat(device), c.RightTrigger.ReadFloat(device));
            GamePadButtons  buttons  = new GamePadButtons(ReadButtons(device, c, DeadZoneSize));
            GamePadDPad     dpad     = new GamePadDPad(buttons.buttons);

            GamePadState g = new GamePadState(sticks, triggers, buttons, dpad);

            return(g);
        }
Exemplo n.º 10
0
		static void AutoConfig()
		{
			Init();
			if (!sdl) return;
#if DEBUG
			Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
#endif			
			// Limit to the first 4 sticks to avoid crashes
			int numSticks = Math.Min (4,Sdl.SDL_NumJoysticks());
			for (int x = 0; x < numSticks; x++)
			{

				PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), x);
				devices[x] = Sdl.SDL_JoystickOpen(pc.Index);

				pc.Button_A.ID = 0;
				pc.Button_A.Type = InputType.Button;

				pc.Button_B.ID = 1;
				pc.Button_B.Type = InputType.Button;

				pc.Button_X.ID = 2;
				pc.Button_X.Type = InputType.Button;

				pc.Button_Y.ID = 3;
				pc.Button_Y.Type = InputType.Button;

				pc.Button_LB.ID = 4;
				pc.Button_LB.Type = InputType.Button;

				pc.Button_RB.ID = 5;
				pc.Button_RB.Type = InputType.Button;

				pc.Button_Back.ID = 6;
				pc.Button_Back.Type = InputType.Button;

				pc.Button_Start.ID = 7;
				pc.Button_Start.Type = InputType.Button;

				pc.LeftStick.Press.ID = 8;
				pc.LeftStick.Press.Type = InputType.Button;

				pc.RightStick.Press.ID = 9;
				pc.RightStick.Press.Type = InputType.Button;

				pc.LeftStick.X.Negative.ID = 0;
				pc.LeftStick.X.Negative.Type = InputType.Axis;
				pc.LeftStick.X.Negative.Negative = true;

				pc.LeftStick.X.Positive.ID = 0;
				pc.LeftStick.X.Positive.Type = InputType.Axis;
				pc.LeftStick.X.Positive.Negative = false;

				pc.LeftStick.Y.Negative.ID = 1;
				pc.LeftStick.Y.Negative.Type = InputType.Axis;
				pc.LeftStick.Y.Negative.Negative = true;

				pc.LeftStick.Y.Positive.ID = 1;
				pc.LeftStick.Y.Positive.Type = InputType.Axis;
				pc.LeftStick.Y.Positive.Negative = false;

				pc.RightStick.Y.Negative.ID = 3;
				pc.RightStick.Y.Negative.Type = InputType.Axis;
				pc.RightStick.Y.Negative.Negative = true;

				pc.RightStick.Y.Positive.ID = 3;
				pc.RightStick.Y.Positive.Type = InputType.Axis;
				pc.RightStick.Y.Positive.Negative = false;

				pc.RightStick.X.Negative.ID = 4;
				pc.RightStick.X.Negative.Type = InputType.Axis;
				pc.RightStick.X.Negative.Negative = true;

				pc.RightStick.X.Positive.ID = 4;
				pc.RightStick.X.Positive.Type = InputType.Axis;
				pc.RightStick.X.Positive.Negative = false;

				pc.Dpad.Up.ID = 0;
				pc.Dpad.Up.Type = InputType.PovUp;

				pc.Dpad.Down.ID = 0;
				pc.Dpad.Down.Type = InputType.PovDown;

				pc.Dpad.Left.ID = 0;
				pc.Dpad.Left.Type = InputType.PovLeft;

				pc.Dpad.Right.ID = 0;
				pc.Dpad.Right.Type = InputType.PovRight;

				pc.LeftTrigger.ID = 2;
				pc.LeftTrigger.Type = InputType.Axis;
				pc.LeftTrigger.Negative = false;

				pc.RightTrigger.ID = 2;
				pc.RightTrigger.Type = InputType.Axis;
				pc.RightTrigger.Negative = true;

				// Suggestion: Xbox Guide button <=> BigButton
				//pc.BigButton.ID = 8;
				//pc.BigButton.Type = InputType.Button;

#if DEBUG
				int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
				Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);

				int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
				Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);

				int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
				Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);
#endif

				settings[x] = pc;
			}
		}
Exemplo n.º 11
0
        static Buttons ReadButtons(IntPtr device, PadConfig c, float deadZoneSize)
        {
            short DeadZone = (short)(deadZoneSize * short.MaxValue);
            Buttons b = (Buttons)0;

            if (c.Button_A.ReadBool(device, DeadZone))
                b |= Buttons.A;
            if (c.Button_B.ReadBool(device, DeadZone))
                b |= Buttons.B;
            if (c.Button_X.ReadBool(device, DeadZone))
                b |= Buttons.X;
            if (c.Button_Y.ReadBool(device, DeadZone))
                b |= Buttons.Y;

            if (c.Button_LB.ReadBool(device, DeadZone))
                b |= Buttons.LeftShoulder;
            if (c.Button_RB.ReadBool(device, DeadZone))
                b |= Buttons.RightShoulder;

            if (c.Button_Back.ReadBool(device, DeadZone))
                b |= Buttons.Back;
            if (c.Button_Start.ReadBool(device, DeadZone))
                b |= Buttons.Start;

            if (c.LeftStick.Press.ReadBool(device, DeadZone))
                b |= Buttons.LeftStick;
            if (c.RightStick.Press.ReadBool(device, DeadZone))
                b |= Buttons.RightStick;

            if (c.Dpad.Up.ReadBool(device, DeadZone))
                b |= Buttons.DPadUp;
            if (c.Dpad.Down.ReadBool(device, DeadZone))
                b |= Buttons.DPadDown;
            if (c.Dpad.Left.ReadBool(device, DeadZone))
                b |= Buttons.DPadLeft;
            if (c.Dpad.Right.ReadBool(device, DeadZone))
                b |= Buttons.DPadRight;

            return b;
        }
Exemplo n.º 12
0
        static void AutoConfig()
        {
            Init();
            if (!sdl)
            {
                return;
            }
#if DEBUG
            Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
#endif
            // Limit to the first 4 sticks to avoid crashes
            int numSticks = Math.Min(4, Sdl.SDL_NumJoysticks());
            for (int x = 0; x < numSticks; x++)
            {
                PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), x);
                devices[x] = Sdl.SDL_JoystickOpen(pc.Index);

                pc.Button_A.ID   = 0;
                pc.Button_A.Type = InputType.Button;

                pc.Button_B.ID   = 1;
                pc.Button_B.Type = InputType.Button;

                pc.Button_X.ID   = 2;
                pc.Button_X.Type = InputType.Button;

                pc.Button_Y.ID   = 3;
                pc.Button_Y.Type = InputType.Button;

                pc.Button_LB.ID   = 4;
                pc.Button_LB.Type = InputType.Button;

                pc.Button_RB.ID   = 5;
                pc.Button_RB.Type = InputType.Button;

                pc.Button_Back.ID   = 6;
                pc.Button_Back.Type = InputType.Button;

                pc.Button_Start.ID   = 7;
                pc.Button_Start.Type = InputType.Button;

                pc.LeftStick.Press.ID   = 8;
                pc.LeftStick.Press.Type = InputType.Button;

                pc.RightStick.Press.ID   = 9;
                pc.RightStick.Press.Type = InputType.Button;

                pc.LeftStick.X.Negative.ID       = 0;
                pc.LeftStick.X.Negative.Type     = InputType.Axis;
                pc.LeftStick.X.Negative.Negative = true;

                pc.LeftStick.X.Positive.ID       = 0;
                pc.LeftStick.X.Positive.Type     = InputType.Axis;
                pc.LeftStick.X.Positive.Negative = false;

                pc.LeftStick.Y.Negative.ID       = 1;
                pc.LeftStick.Y.Negative.Type     = InputType.Axis;
                pc.LeftStick.Y.Negative.Negative = true;

                pc.LeftStick.Y.Positive.ID       = 1;
                pc.LeftStick.Y.Positive.Type     = InputType.Axis;
                pc.LeftStick.Y.Positive.Negative = false;

                pc.RightStick.Y.Negative.ID       = 3;
                pc.RightStick.Y.Negative.Type     = InputType.Axis;
                pc.RightStick.Y.Negative.Negative = true;

                pc.RightStick.Y.Positive.ID       = 3;
                pc.RightStick.Y.Positive.Type     = InputType.Axis;
                pc.RightStick.Y.Positive.Negative = false;

                pc.RightStick.X.Negative.ID       = 4;
                pc.RightStick.X.Negative.Type     = InputType.Axis;
                pc.RightStick.X.Negative.Negative = true;

                pc.RightStick.X.Positive.ID       = 4;
                pc.RightStick.X.Positive.Type     = InputType.Axis;
                pc.RightStick.X.Positive.Negative = false;

                pc.Dpad.Up.ID   = 0;
                pc.Dpad.Up.Type = InputType.PovUp;

                pc.Dpad.Down.ID   = 0;
                pc.Dpad.Down.Type = InputType.PovDown;

                pc.Dpad.Left.ID   = 0;
                pc.Dpad.Left.Type = InputType.PovLeft;

                pc.Dpad.Right.ID   = 0;
                pc.Dpad.Right.Type = InputType.PovRight;

                pc.LeftTrigger.ID       = 2;
                pc.LeftTrigger.Type     = InputType.Axis;
                pc.LeftTrigger.Negative = false;

                pc.RightTrigger.ID       = 2;
                pc.RightTrigger.Type     = InputType.Axis;
                pc.RightTrigger.Negative = true;

                // Suggestion: Xbox Guide button <=> BigButton
                //pc.BigButton.ID = 8;
                //pc.BigButton.Type = InputType.Button;

#if DEBUG
                int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
                Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);

                int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
                Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);

                int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
                Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);
#endif

                settings[x] = pc;
            }
        }
Exemplo n.º 13
0
 private static void AutoConfig()
 {
   SdlGamePad.Init();
   if (!SdlGamePad.sdl)
     return;
   int num = Math.Min(4, Sdl.SDL_NumJoysticks());
   for (int index = 0; index < num; ++index)
   {
     PadConfig padConfig = new PadConfig(Sdl.SDL_JoystickName(index), index);
     SdlGamePad.devices[index] = Sdl.SDL_JoystickOpen(padConfig.Index);
     padConfig.Button_A.ID = 1;
     padConfig.Button_A.Type = InputType.Button;
     padConfig.Button_B.ID = 2;
     padConfig.Button_B.Type = InputType.Button;
     padConfig.Button_X.ID = 0;
     padConfig.Button_X.Type = InputType.Button;
     padConfig.Button_Y.ID = 3;
     padConfig.Button_Y.Type = InputType.Button;
     padConfig.Button_LB.ID = 4;
     padConfig.Button_LB.Type = InputType.Button;
     padConfig.Button_RB.ID = 5;
     padConfig.Button_RB.Type = InputType.Button;
     padConfig.Button_Back.ID = 8;
     padConfig.Button_Back.Type = InputType.Button;
     padConfig.Button_Start.ID = 9;
     padConfig.Button_Start.Type = InputType.Button;
     padConfig.LeftStick.Press.ID = 10;
     padConfig.LeftStick.Press.Type = InputType.Button;
     padConfig.RightStick.Press.ID = 11;
     padConfig.RightStick.Press.Type = InputType.Button;
     padConfig.LeftStick.X.Negative.ID = 0;
     padConfig.LeftStick.X.Negative.Type = InputType.Axis;
     padConfig.LeftStick.X.Negative.Negative = true;
     padConfig.LeftStick.X.Positive.ID = 0;
     padConfig.LeftStick.X.Positive.Type = InputType.Axis;
     padConfig.LeftStick.X.Positive.Negative = false;
     padConfig.LeftStick.Y.Negative.ID = 1;
     padConfig.LeftStick.Y.Negative.Type = InputType.Axis;
     padConfig.LeftStick.Y.Negative.Negative = true;
     padConfig.LeftStick.Y.Positive.ID = 1;
     padConfig.LeftStick.Y.Positive.Type = InputType.Axis;
     padConfig.LeftStick.Y.Positive.Negative = false;
     padConfig.RightStick.X.Negative.ID = 2;
     padConfig.RightStick.X.Negative.Type = InputType.Axis;
     padConfig.RightStick.X.Negative.Negative = true;
     padConfig.RightStick.X.Positive.ID = 2;
     padConfig.RightStick.X.Positive.Type = InputType.Axis;
     padConfig.RightStick.X.Positive.Negative = false;
     padConfig.RightStick.Y.Negative.ID = 3;
     padConfig.RightStick.Y.Negative.Type = InputType.Axis;
     padConfig.RightStick.Y.Negative.Negative = true;
     padConfig.RightStick.Y.Positive.ID = 3;
     padConfig.RightStick.Y.Positive.Type = InputType.Axis;
     padConfig.RightStick.Y.Positive.Negative = false;
     padConfig.Dpad.Up.ID = 0;
     padConfig.Dpad.Up.Type = InputType.PovUp;
     padConfig.Dpad.Down.ID = 0;
     padConfig.Dpad.Down.Type = InputType.PovDown;
     padConfig.Dpad.Left.ID = 0;
     padConfig.Dpad.Left.Type = InputType.PovLeft;
     padConfig.Dpad.Right.ID = 0;
     padConfig.Dpad.Right.Type = InputType.PovRight;
     padConfig.LeftTrigger.ID = 6;
     padConfig.LeftTrigger.Type = InputType.Button;
     padConfig.RightTrigger.ID = 7;
     padConfig.RightTrigger.Type = InputType.Button;
     SdlGamePad.settings[index] = padConfig;
   }
 }
Exemplo n.º 14
0
        private static void AutoConfig()
        {
            SdlGamePad.Init();
            if (!SdlGamePad.sdl)
            {
                return;
            }
            int num = Math.Min(4, Sdl.SDL_NumJoysticks());

            for (int index = 0; index < num; ++index)
            {
                PadConfig padConfig = new PadConfig(Sdl.SDL_JoystickName(index), index);
                SdlGamePad.devices[index]                = Sdl.SDL_JoystickOpen(padConfig.Index);
                padConfig.Button_A.ID                    = 1;
                padConfig.Button_A.Type                  = InputType.Button;
                padConfig.Button_B.ID                    = 2;
                padConfig.Button_B.Type                  = InputType.Button;
                padConfig.Button_X.ID                    = 0;
                padConfig.Button_X.Type                  = InputType.Button;
                padConfig.Button_Y.ID                    = 3;
                padConfig.Button_Y.Type                  = InputType.Button;
                padConfig.Button_LB.ID                   = 4;
                padConfig.Button_LB.Type                 = InputType.Button;
                padConfig.Button_RB.ID                   = 5;
                padConfig.Button_RB.Type                 = InputType.Button;
                padConfig.Button_Back.ID                 = 8;
                padConfig.Button_Back.Type               = InputType.Button;
                padConfig.Button_Start.ID                = 9;
                padConfig.Button_Start.Type              = InputType.Button;
                padConfig.LeftStick.Press.ID             = 10;
                padConfig.LeftStick.Press.Type           = InputType.Button;
                padConfig.RightStick.Press.ID            = 11;
                padConfig.RightStick.Press.Type          = InputType.Button;
                padConfig.LeftStick.X.Negative.ID        = 0;
                padConfig.LeftStick.X.Negative.Type      = InputType.Axis;
                padConfig.LeftStick.X.Negative.Negative  = true;
                padConfig.LeftStick.X.Positive.ID        = 0;
                padConfig.LeftStick.X.Positive.Type      = InputType.Axis;
                padConfig.LeftStick.X.Positive.Negative  = false;
                padConfig.LeftStick.Y.Negative.ID        = 1;
                padConfig.LeftStick.Y.Negative.Type      = InputType.Axis;
                padConfig.LeftStick.Y.Negative.Negative  = true;
                padConfig.LeftStick.Y.Positive.ID        = 1;
                padConfig.LeftStick.Y.Positive.Type      = InputType.Axis;
                padConfig.LeftStick.Y.Positive.Negative  = false;
                padConfig.RightStick.X.Negative.ID       = 2;
                padConfig.RightStick.X.Negative.Type     = InputType.Axis;
                padConfig.RightStick.X.Negative.Negative = true;
                padConfig.RightStick.X.Positive.ID       = 2;
                padConfig.RightStick.X.Positive.Type     = InputType.Axis;
                padConfig.RightStick.X.Positive.Negative = false;
                padConfig.RightStick.Y.Negative.ID       = 3;
                padConfig.RightStick.Y.Negative.Type     = InputType.Axis;
                padConfig.RightStick.Y.Negative.Negative = true;
                padConfig.RightStick.Y.Positive.ID       = 3;
                padConfig.RightStick.Y.Positive.Type     = InputType.Axis;
                padConfig.RightStick.Y.Positive.Negative = false;
                padConfig.Dpad.Up.ID        = 0;
                padConfig.Dpad.Up.Type      = InputType.PovUp;
                padConfig.Dpad.Down.ID      = 0;
                padConfig.Dpad.Down.Type    = InputType.PovDown;
                padConfig.Dpad.Left.ID      = 0;
                padConfig.Dpad.Left.Type    = InputType.PovLeft;
                padConfig.Dpad.Right.ID     = 0;
                padConfig.Dpad.Right.Type   = InputType.PovRight;
                padConfig.LeftTrigger.ID    = 6;
                padConfig.LeftTrigger.Type  = InputType.Button;
                padConfig.RightTrigger.ID   = 7;
                padConfig.RightTrigger.Type = InputType.Button;
                SdlGamePad.settings[index]  = padConfig;
            }
        }
Exemplo n.º 15
0
        static Buttons ReadButtons(IntPtr device, PadConfig c, float deadZoneSize)
        {
            short   DeadZone = (short)(deadZoneSize * short.MaxValue);
            Buttons b        = (Buttons)0;

            if (c.Button_A.ReadBool(device, DeadZone))
            {
                b |= Buttons.A;
            }
            if (c.Button_B.ReadBool(device, DeadZone))
            {
                b |= Buttons.B;
            }
            if (c.Button_X.ReadBool(device, DeadZone))
            {
                b |= Buttons.X;
            }
            if (c.Button_Y.ReadBool(device, DeadZone))
            {
                b |= Buttons.Y;
            }

            if (c.Button_LB.ReadBool(device, DeadZone))
            {
                b |= Buttons.LeftShoulder;
            }
            if (c.Button_RB.ReadBool(device, DeadZone))
            {
                b |= Buttons.RightShoulder;
            }

            if (c.Button_Back.ReadBool(device, DeadZone))
            {
                b |= Buttons.Back;
            }
            if (c.Button_Start.ReadBool(device, DeadZone))
            {
                b |= Buttons.Start;
            }

            if (c.LeftStick.Press.ReadBool(device, DeadZone))
            {
                b |= Buttons.LeftStick;
            }
            if (c.RightStick.Press.ReadBool(device, DeadZone))
            {
                b |= Buttons.RightStick;
            }

            if (c.Dpad.Up.ReadBool(device, DeadZone))
            {
                b |= Buttons.DPadUp;
            }
            if (c.Dpad.Down.ReadBool(device, DeadZone))
            {
                b |= Buttons.DPadDown;
            }
            if (c.Dpad.Left.ReadBool(device, DeadZone))
            {
                b |= Buttons.DPadLeft;
            }
            if (c.Dpad.Right.ReadBool(device, DeadZone))
            {
                b |= Buttons.DPadRight;
            }

            return(b);
        }
Exemplo n.º 16
0
        static Buttons ReadButtons(IntPtr device, PadConfig c, float deadZoneSize, Vector2 leftStick, Vector2 rightStick)
        {
            Buttons b = ReadButtons(device, c, deadZoneSize);

            b |= StickToButtons(leftStick, deadZoneSize);
            b |= StickToButtons(rightStick, deadZoneSize);

            return b;
        }
Exemplo n.º 17
0
        static void AutoConfig()
        {
            Init();
                if (!sdl)
                    return;
                Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
                    int numSticks = Sdl.SDL_NumJoysticks();
                    for (int x = 0; x < numSticks; x++) {

                        PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), 0);
                        devices[x] = Sdl.SDL_JoystickOpen (pc.ID);

                        int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
                        Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);

                        for (int b = 0; b < numbuttons; b++) {
                            //pc
                        }
                        //pc.Button_A = new Input();
                        pc.Button_A.ID = 0;
                        pc.Button_A.Type = InputType.Button;

                        pc.Button_B.ID = 1;
                        pc.Button_B.Type = InputType.Button;

                        pc.Button_X.ID = 2;
                        pc.Button_X.Type = InputType.Button;

                        pc.Button_Y.ID = 3;
                        pc.Button_Y.Type = InputType.Button;

                        pc.Button_Back.ID = 8;
                        pc.Button_Back.Type = InputType.Button;

                        pc.Button_Start.ID = 9;
                        pc.Button_Start.Type = InputType.Button;

                        pc.Button_LB.ID = 4;
                        pc.Button_LB.Type = InputType.Button;

                        pc.Button_RB.ID = 5;
                        pc.Button_RB.Type = InputType.Button;

                        pc.LeftStick.X.Negative.Type = InputType.Axis;
                        pc.LeftStick.X.Negative.Negative = true;
                        pc.LeftStick.X.Positive.Type = InputType.Axis;
                        pc.LeftStick.X.Positive.Negative = false;

                        pc.LeftStick.Y.Negative.ID = 1;
                        pc.LeftStick.Y.Negative.Type = InputType.Axis;
                        pc.LeftStick.Y.Negative.Negative = true;

                        pc.LeftStick.Y.Positive.ID = 1;
                        pc.LeftStick.Y.Positive.Type = InputType.Axis;
                        pc.LeftStick.Y.Positive.Negative = false;

                        //pc.RightStick.X.Negative.Type = InputType.Axis;
                        //pc.RightStick.X.Negative.Negative = true;
                        //pc.RightStick.X.Positive.Type = InputType.Axis;
                        //pc.RightStick.X.Positive.Negative = false;

                        //pc.RightStick.Y.Negative.ID = 1;
                        //pc.RightStick.Y.Negative.Type = InputType.Axis;
                        //pc.RightStick.Y.Negative.Negative = true;

                        //pc.RightStick.Y.Positive.ID = 1;
                        //pc.RightStick.Y.Positive.Type = InputType.Axis;
                        //pc.RightStick.Y.Positive.Negative = false;

                        pc.Dpad.Up.ID = 0;
                        pc.Dpad.Up.Type = InputType.PovUp;

                        pc.Dpad.Down.ID = 0;
                        pc.Dpad.Down.Type = InputType.PovDown;

                        pc.Dpad.Left.ID = 0;
                        pc.Dpad.Left.Type = InputType.PovLeft;

                        pc.Dpad.Right.ID = 0;
                        pc.Dpad.Right.Type = InputType.PovRight;

                        //pc.LeftTrigger.ID = 6;
                        //pc.LeftTrigger.Type = InputType.Button;

                        pc.RightTrigger.ID = 7;
                        pc.RightTrigger.Type = InputType.Button;

                        int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
                        Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);

                        for (int a = 0; a < numaxes; a++) {
                            //pc.LeftStick = new Stick();
                        }

                        int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
                        Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);

                        for (int h = 0; h < numhats; h++) {
                            //pc
                        }
                        settings[x] = pc;
            }
        }
Exemplo n.º 18
0
using System;
Exemplo n.º 19
0
        static void AutoConfig()
        {
            Init();
                if (!sdl)
                    return;
                Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
                    int numSticks = Sdl.SDL_NumJoysticks();
                    for (int x = 0; x < numSticks; x++) {

                        PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), 0);
                        devices[x] = Sdl.SDL_JoystickOpen (pc.ID);

                        int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
                        Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);

                        for (int b = 0; b < numbuttons; b++) {
                            //pc
                        }

                        if (Sdl.SDL_JoystickName(x).Contains("Microsoft") &&
                            (Sdl.SDL_JoystickName(x).Contains("X-Box") || Sdl.SDL_JoystickName(x).Contains("Xbox")))
                        {
                            pc.Button_A.ID = 0;
                            pc.Button_A.Type = InputType.Button;

                            pc.Button_B.ID = 1;
                            pc.Button_B.Type = InputType.Button;

                            pc.Button_X.ID = 2;
                            pc.Button_X.Type = InputType.Button;

                            pc.Button_Y.ID = 3;
                            pc.Button_Y.Type = InputType.Button;

                            pc.Button_Back.ID = 6;
                            pc.Button_Back.Type = InputType.Button;

                            pc.Button_Start.ID = 7;
                            pc.Button_Start.Type = InputType.Button;

                            pc.Button_LB.ID = 4;
                            pc.Button_LB.Type = InputType.Button;

                            pc.Button_RB.ID = 5;
                            pc.Button_RB.Type = InputType.Button;

                            pc.LeftStick.X.Negative.Type = InputType.Axis;
                            pc.LeftStick.X.Negative.Negative = true;
                            pc.LeftStick.X.Positive.Type = InputType.Axis;
                            pc.LeftStick.X.Positive.Negative = false;

                            pc.LeftStick.Y.Negative.ID = 1;
                            pc.LeftStick.Y.Negative.Type = InputType.Axis;
                            pc.LeftStick.Y.Negative.Negative = true;

                            pc.LeftStick.Y.Positive.ID = 1;
                            pc.LeftStick.Y.Positive.Type = InputType.Axis;
                            pc.LeftStick.Y.Positive.Negative = false;

                            pc.RightStick.X.Negative.ID = 3;
                            pc.RightStick.X.Negative.Type = InputType.Axis;
                            pc.RightStick.X.Negative.Negative = true;

                            pc.RightStick.X.Positive.ID = 3;
                            pc.RightStick.X.Positive.Type = InputType.Axis;
                            pc.RightStick.X.Positive.Negative = false;

                            pc.RightStick.Y.Negative.ID = 4;
                            pc.RightStick.Y.Negative.Type = InputType.Axis;
                            pc.RightStick.Y.Negative.Negative = true;

                            pc.RightStick.Y.Positive.ID = 4;
                            pc.RightStick.Y.Positive.Type = InputType.Axis;
                            pc.RightStick.Y.Positive.Negative = false;

                            pc.Dpad.Up.ID = 0;
                            pc.Dpad.Up.Type = InputType.PovUp;

                            pc.Dpad.Down.ID = 0;
                            pc.Dpad.Down.Type = InputType.PovDown;

                            pc.Dpad.Left.ID = 0;
                            pc.Dpad.Left.Type = InputType.PovLeft;

                            pc.Dpad.Right.ID = 0;
                            pc.Dpad.Right.Type = InputType.PovRight;

                            pc.LeftTrigger.ID = 2;
                            pc.LeftTrigger.Type = InputType.Axis;
                            // Only positive value

                            pc.RightTrigger.ID = 5;
                            pc.RightTrigger.Type = InputType.Axis;
                            // Only positive value

                            // Suggestion: Xbox Guide button <=> BigButton
                            //pc.BigButton.ID = 8;
                            //pc.BigButton.Type = InputType.Button;

                            pc.LeftStick.Press.ID = 9;
                            pc.LeftStick.Press.Type = InputType.Button;

                            pc.RightStick.Press.ID = 10;
                            pc.RightStick.Press.Type = InputType.Button;
                        }

                        else if (Sdl.SDL_JoystickName(x).Contains("Sony PLAYSTATION(R)3"))
                        {
                            pc.Button_A.ID = 14;
                            pc.Button_A.Type = InputType.Button;

                            pc.Button_B.ID = 13;
                            pc.Button_B.Type = InputType.Button;

                            pc.Button_X.ID = 15;
                            pc.Button_X.Type = InputType.Button;

                            pc.Button_Y.ID = 12;
                            pc.Button_Y.Type = InputType.Button;

                            pc.Button_Back.ID = 0;
                            pc.Button_Back.Type = InputType.Button;

                            pc.Button_Start.ID = 3;
                            pc.Button_Start.Type = InputType.Button;

                            pc.Button_LB.ID = 10;
                            pc.Button_LB.Type = InputType.Button;

                            pc.Button_RB.ID = 11;
                            pc.Button_RB.Type = InputType.Button;

                            pc.LeftStick.X.Negative.ID = 0;
                            pc.LeftStick.X.Negative.Type = InputType.Axis;
                            pc.LeftStick.X.Negative.Negative = true;

                            pc.LeftStick.X.Positive.ID = 0;
                            pc.LeftStick.X.Positive.Type = InputType.Axis;
                            pc.LeftStick.X.Positive.Negative = false;

                            pc.LeftStick.Y.Negative.ID = 1;
                            pc.LeftStick.Y.Negative.Type = InputType.Axis;
                            pc.LeftStick.Y.Negative.Negative = true;

                            pc.LeftStick.Y.Positive.ID = 1;
                            pc.LeftStick.Y.Positive.Type = InputType.Axis;
                            pc.LeftStick.Y.Positive.Negative = false;

                            pc.RightStick.X.Negative.ID = 2;
                            pc.RightStick.X.Negative.Type = InputType.Axis;
                            pc.RightStick.X.Negative.Negative = true;

                            pc.RightStick.X.Positive.ID = 2;
                            pc.RightStick.X.Positive.Type = InputType.Axis;
                            pc.RightStick.X.Positive.Negative = false;

                            pc.RightStick.Y.Negative.ID = 3;
                            pc.RightStick.Y.Negative.Type = InputType.Axis;
                            pc.RightStick.Y.Negative.Negative = true;

                            pc.RightStick.Y.Positive.ID = 3;
                            pc.RightStick.Y.Positive.Type = InputType.Axis;
                            pc.RightStick.Y.Positive.Negative = false;

                            pc.Dpad.Up.ID = 8;
                            pc.Dpad.Up.Type = InputType.PovUp;

                            pc.Dpad.Down.ID = 10;
                            pc.Dpad.Down.Type = InputType.PovDown;

                            pc.Dpad.Left.ID = 11;
                            pc.Dpad.Left.Type = InputType.PovLeft;

                            pc.Dpad.Right.ID = 9;
                            pc.Dpad.Right.Type = InputType.PovRight;

                            pc.LeftTrigger.ID = 12;
                            pc.LeftTrigger.Type = InputType.Axis;
                            // Only positive value

                            pc.RightTrigger.ID = 13;
                            pc.RightTrigger.Type = InputType.Axis;
                            // Only positive value

                            //pc.BigButton.ID = 16;
                            //pc.BigButton.Type = InputType.Button;

                            pc.LeftStick.Press.ID = 1;
                            pc.LeftStick.Press.Type = InputType.Button;

                            pc.RightStick.Press.ID = 2;
                            pc.RightStick.Press.Type = InputType.Button;
                        }

                        else
                        {
                            //pc.Button_A = new Input();
                            pc.Button_A.ID = 0;
                            pc.Button_A.Type = InputType.Button;

                            pc.Button_B.ID = 1;
                            pc.Button_B.Type = InputType.Button;

                            pc.Button_X.ID = 2;
                            pc.Button_X.Type = InputType.Button;

                            pc.Button_Y.ID = 3;
                            pc.Button_Y.Type = InputType.Button;

                            pc.Button_Back.ID = 8;
                            pc.Button_Back.Type = InputType.Button;

                            pc.Button_Start.ID = 9;
                            pc.Button_Start.Type = InputType.Button;

                            pc.Button_LB.ID = 4;
                            pc.Button_LB.Type = InputType.Button;

                            pc.Button_RB.ID = 5;
                            pc.Button_RB.Type = InputType.Button;

                            pc.LeftStick.X.Negative.Type = InputType.Axis;
                            pc.LeftStick.X.Negative.Negative = true;
                            pc.LeftStick.X.Positive.Type = InputType.Axis;
                            pc.LeftStick.X.Positive.Negative = false;

                            pc.LeftStick.Y.Negative.ID = 1;
                            pc.LeftStick.Y.Negative.Type = InputType.Axis;
                            pc.LeftStick.Y.Negative.Negative = true;

                            pc.LeftStick.Y.Positive.ID = 1;
                            pc.LeftStick.Y.Positive.Type = InputType.Axis;
                            pc.LeftStick.Y.Positive.Negative = false;

                            //pc.RightStick.X.Negative.Type = InputType.Axis;
                            //pc.RightStick.X.Negative.Negative = true;
                            //pc.RightStick.X.Positive.Type = InputType.Axis;
                            //pc.RightStick.X.Positive.Negative = false;

                            //pc.RightStick.Y.Negative.ID = 1;
                            //pc.RightStick.Y.Negative.Type = InputType.Axis;
                            //pc.RightStick.Y.Negative.Negative = true;

                            //pc.RightStick.Y.Positive.ID = 1;
                            //pc.RightStick.Y.Positive.Type = InputType.Axis;
                            //pc.RightStick.Y.Positive.Negative = false;

                            pc.Dpad.Up.ID = 0;
                            pc.Dpad.Up.Type = InputType.PovUp;

                            pc.Dpad.Down.ID = 0;
                            pc.Dpad.Down.Type = InputType.PovDown;

                            pc.Dpad.Left.ID = 0;
                            pc.Dpad.Left.Type = InputType.PovLeft;

                            pc.Dpad.Right.ID = 0;
                            pc.Dpad.Right.Type = InputType.PovRight;

                            //pc.LeftTrigger.ID = 6;
                            //pc.LeftTrigger.Type = InputType.Button;

                            pc.RightTrigger.ID = 7;
                            pc.RightTrigger.Type = InputType.Button;
                        }

                        int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
                        Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);

                        for (int a = 0; a < numaxes; a++) {
                            //pc.LeftStick = new Stick();
                        }

                        int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
                        Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);

                        for (int h = 0; h < numhats; h++) {
                            //pc
                        }
                        settings[x] = pc;
            }
        }
Exemplo n.º 20
0
        static void AutoConfig()
        {
            Init();
            if (!sdl)
            {
                return;
            }
            Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
            int numSticks = Sdl.SDL_NumJoysticks();

            for (int x = 0; x < numSticks; x++)
            {
                PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), 0);
                devices[x] = Sdl.SDL_JoystickOpen(pc.ID);

                int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
                Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);

                for (int b = 0; b < numbuttons; b++)
                {
                    //pc
                }

                if (Sdl.SDL_JoystickName(x).Contains("Microsoft") &&
                    (Sdl.SDL_JoystickName(x).Contains("X-Box") || Sdl.SDL_JoystickName(x).Contains("Xbox")))
                {
                    pc.Button_A.ID   = 0;
                    pc.Button_A.Type = InputType.Button;

                    pc.Button_B.ID   = 1;
                    pc.Button_B.Type = InputType.Button;

                    pc.Button_X.ID   = 2;
                    pc.Button_X.Type = InputType.Button;

                    pc.Button_Y.ID   = 3;
                    pc.Button_Y.Type = InputType.Button;

                    pc.Button_Back.ID   = 6;
                    pc.Button_Back.Type = InputType.Button;

                    pc.Button_Start.ID   = 7;
                    pc.Button_Start.Type = InputType.Button;

                    pc.Button_LB.ID   = 4;
                    pc.Button_LB.Type = InputType.Button;

                    pc.Button_RB.ID   = 5;
                    pc.Button_RB.Type = InputType.Button;

                    pc.LeftStick.X.Negative.Type     = InputType.Axis;
                    pc.LeftStick.X.Negative.Negative = true;
                    pc.LeftStick.X.Positive.Type     = InputType.Axis;
                    pc.LeftStick.X.Positive.Negative = false;

                    pc.LeftStick.Y.Negative.ID       = 1;
                    pc.LeftStick.Y.Negative.Type     = InputType.Axis;
                    pc.LeftStick.Y.Negative.Negative = true;

                    pc.LeftStick.Y.Positive.ID       = 1;
                    pc.LeftStick.Y.Positive.Type     = InputType.Axis;
                    pc.LeftStick.Y.Positive.Negative = false;

                    pc.RightStick.X.Negative.ID       = 3;
                    pc.RightStick.X.Negative.Type     = InputType.Axis;
                    pc.RightStick.X.Negative.Negative = true;

                    pc.RightStick.X.Positive.ID       = 3;
                    pc.RightStick.X.Positive.Type     = InputType.Axis;
                    pc.RightStick.X.Positive.Negative = false;

                    pc.RightStick.Y.Negative.ID       = 4;
                    pc.RightStick.Y.Negative.Type     = InputType.Axis;
                    pc.RightStick.Y.Negative.Negative = true;

                    pc.RightStick.Y.Positive.ID       = 4;
                    pc.RightStick.Y.Positive.Type     = InputType.Axis;
                    pc.RightStick.Y.Positive.Negative = false;

                    pc.Dpad.Up.ID   = 0;
                    pc.Dpad.Up.Type = InputType.PovUp;

                    pc.Dpad.Down.ID   = 0;
                    pc.Dpad.Down.Type = InputType.PovDown;

                    pc.Dpad.Left.ID   = 0;
                    pc.Dpad.Left.Type = InputType.PovLeft;

                    pc.Dpad.Right.ID   = 0;
                    pc.Dpad.Right.Type = InputType.PovRight;

                    pc.LeftTrigger.ID   = 2;
                    pc.LeftTrigger.Type = InputType.Axis;
                    // Only positive value

                    pc.RightTrigger.ID   = 5;
                    pc.RightTrigger.Type = InputType.Axis;
                    // Only positive value

                    // Suggestion: Xbox Guide button <=> BigButton
                    //pc.BigButton.ID = 8;
                    //pc.BigButton.Type = InputType.Button;

                    pc.LeftStick.Press.ID   = 9;
                    pc.LeftStick.Press.Type = InputType.Button;

                    pc.RightStick.Press.ID   = 10;
                    pc.RightStick.Press.Type = InputType.Button;
                }

                else if (Sdl.SDL_JoystickName(x).Contains("Sony PLAYSTATION(R)3"))
                {
                    pc.Button_A.ID   = 14;
                    pc.Button_A.Type = InputType.Button;

                    pc.Button_B.ID   = 13;
                    pc.Button_B.Type = InputType.Button;

                    pc.Button_X.ID   = 15;
                    pc.Button_X.Type = InputType.Button;

                    pc.Button_Y.ID   = 12;
                    pc.Button_Y.Type = InputType.Button;

                    pc.Button_Back.ID   = 0;
                    pc.Button_Back.Type = InputType.Button;

                    pc.Button_Start.ID   = 3;
                    pc.Button_Start.Type = InputType.Button;

                    pc.Button_LB.ID   = 10;
                    pc.Button_LB.Type = InputType.Button;

                    pc.Button_RB.ID   = 11;
                    pc.Button_RB.Type = InputType.Button;

                    pc.LeftStick.X.Negative.ID       = 0;
                    pc.LeftStick.X.Negative.Type     = InputType.Axis;
                    pc.LeftStick.X.Negative.Negative = true;

                    pc.LeftStick.X.Positive.ID       = 0;
                    pc.LeftStick.X.Positive.Type     = InputType.Axis;
                    pc.LeftStick.X.Positive.Negative = false;

                    pc.LeftStick.Y.Negative.ID       = 1;
                    pc.LeftStick.Y.Negative.Type     = InputType.Axis;
                    pc.LeftStick.Y.Negative.Negative = true;

                    pc.LeftStick.Y.Positive.ID       = 1;
                    pc.LeftStick.Y.Positive.Type     = InputType.Axis;
                    pc.LeftStick.Y.Positive.Negative = false;

                    pc.RightStick.X.Negative.ID       = 2;
                    pc.RightStick.X.Negative.Type     = InputType.Axis;
                    pc.RightStick.X.Negative.Negative = true;

                    pc.RightStick.X.Positive.ID       = 2;
                    pc.RightStick.X.Positive.Type     = InputType.Axis;
                    pc.RightStick.X.Positive.Negative = false;

                    pc.RightStick.Y.Negative.ID       = 3;
                    pc.RightStick.Y.Negative.Type     = InputType.Axis;
                    pc.RightStick.Y.Negative.Negative = true;

                    pc.RightStick.Y.Positive.ID       = 3;
                    pc.RightStick.Y.Positive.Type     = InputType.Axis;
                    pc.RightStick.Y.Positive.Negative = false;

                    pc.Dpad.Up.ID   = 8;
                    pc.Dpad.Up.Type = InputType.PovUp;

                    pc.Dpad.Down.ID   = 10;
                    pc.Dpad.Down.Type = InputType.PovDown;

                    pc.Dpad.Left.ID   = 11;
                    pc.Dpad.Left.Type = InputType.PovLeft;

                    pc.Dpad.Right.ID   = 9;
                    pc.Dpad.Right.Type = InputType.PovRight;

                    pc.LeftTrigger.ID   = 12;
                    pc.LeftTrigger.Type = InputType.Axis;
                    // Only positive value

                    pc.RightTrigger.ID   = 13;
                    pc.RightTrigger.Type = InputType.Axis;
                    // Only positive value

                    //pc.BigButton.ID = 16;
                    //pc.BigButton.Type = InputType.Button;

                    pc.LeftStick.Press.ID   = 1;
                    pc.LeftStick.Press.Type = InputType.Button;

                    pc.RightStick.Press.ID   = 2;
                    pc.RightStick.Press.Type = InputType.Button;
                }

                else
                {
                    //pc.Button_A = new Input();
                    pc.Button_A.ID   = 0;
                    pc.Button_A.Type = InputType.Button;

                    pc.Button_B.ID   = 1;
                    pc.Button_B.Type = InputType.Button;

                    pc.Button_X.ID   = 2;
                    pc.Button_X.Type = InputType.Button;

                    pc.Button_Y.ID   = 3;
                    pc.Button_Y.Type = InputType.Button;

                    pc.Button_Back.ID   = 8;
                    pc.Button_Back.Type = InputType.Button;

                    pc.Button_Start.ID   = 9;
                    pc.Button_Start.Type = InputType.Button;

                    pc.Button_LB.ID   = 4;
                    pc.Button_LB.Type = InputType.Button;

                    pc.Button_RB.ID   = 5;
                    pc.Button_RB.Type = InputType.Button;

                    pc.LeftStick.X.Negative.Type     = InputType.Axis;
                    pc.LeftStick.X.Negative.Negative = true;
                    pc.LeftStick.X.Positive.Type     = InputType.Axis;
                    pc.LeftStick.X.Positive.Negative = false;

                    pc.LeftStick.Y.Negative.ID       = 1;
                    pc.LeftStick.Y.Negative.Type     = InputType.Axis;
                    pc.LeftStick.Y.Negative.Negative = true;

                    pc.LeftStick.Y.Positive.ID       = 1;
                    pc.LeftStick.Y.Positive.Type     = InputType.Axis;
                    pc.LeftStick.Y.Positive.Negative = false;

                    //pc.RightStick.X.Negative.Type = InputType.Axis;
                    //pc.RightStick.X.Negative.Negative = true;
                    //pc.RightStick.X.Positive.Type = InputType.Axis;
                    //pc.RightStick.X.Positive.Negative = false;

                    //pc.RightStick.Y.Negative.ID = 1;
                    //pc.RightStick.Y.Negative.Type = InputType.Axis;
                    //pc.RightStick.Y.Negative.Negative = true;

                    //pc.RightStick.Y.Positive.ID = 1;
                    //pc.RightStick.Y.Positive.Type = InputType.Axis;
                    //pc.RightStick.Y.Positive.Negative = false;

                    pc.Dpad.Up.ID   = 0;
                    pc.Dpad.Up.Type = InputType.PovUp;

                    pc.Dpad.Down.ID   = 0;
                    pc.Dpad.Down.Type = InputType.PovDown;

                    pc.Dpad.Left.ID   = 0;
                    pc.Dpad.Left.Type = InputType.PovLeft;

                    pc.Dpad.Right.ID   = 0;
                    pc.Dpad.Right.Type = InputType.PovRight;

                    //pc.LeftTrigger.ID = 6;
                    //pc.LeftTrigger.Type = InputType.Button;

                    pc.RightTrigger.ID   = 7;
                    pc.RightTrigger.Type = InputType.Button;
                }

                int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
                Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);

                for (int a = 0; a < numaxes; a++)
                {
                    //pc.LeftStick = new Stick();
                }

                int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
                Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);

                for (int h = 0; h < numhats; h++)
                {
                    //pc
                }
                settings[x] = pc;
            }
        }
Exemplo n.º 21
0
        static void AutoConfig()
        {
            Init();
            if (!sdl)
            {
                return;
            }
            Console.WriteLine("Number of joysticks: " + Sdl.SDL_NumJoysticks());
            int numSticks = Sdl.SDL_NumJoysticks();

            for (int x = 0; x < numSticks; x++)
            {
                PadConfig pc = new PadConfig(Sdl.SDL_JoystickName(x), 0);
                devices[x] = Sdl.SDL_JoystickOpen(pc.ID);

                int numbuttons = Sdl.SDL_JoystickNumButtons(devices[x]);
                Console.WriteLine("Number of buttons for joystick: " + x + " - " + numbuttons);

                for (int b = 0; b < numbuttons; b++)
                {
                    //pc
                }
                //pc.Button_A = new Input();
                pc.Button_A.ID   = 0;
                pc.Button_A.Type = InputType.Button;

                pc.Button_B.ID   = 1;
                pc.Button_B.Type = InputType.Button;

                pc.Button_X.ID   = 2;
                pc.Button_X.Type = InputType.Button;

                pc.Button_Y.ID   = 3;
                pc.Button_Y.Type = InputType.Button;

                pc.Button_Back.ID   = 8;
                pc.Button_Back.Type = InputType.Button;

                pc.Button_Start.ID   = 9;
                pc.Button_Start.Type = InputType.Button;

                pc.Button_LB.ID   = 4;
                pc.Button_LB.Type = InputType.Button;

                pc.Button_RB.ID   = 5;
                pc.Button_RB.Type = InputType.Button;

                pc.LeftStick.X.Negative.Type     = InputType.Axis;
                pc.LeftStick.X.Negative.Negative = true;
                pc.LeftStick.X.Positive.Type     = InputType.Axis;
                pc.LeftStick.X.Positive.Negative = false;

                pc.LeftStick.Y.Negative.ID       = 1;
                pc.LeftStick.Y.Negative.Type     = InputType.Axis;
                pc.LeftStick.Y.Negative.Negative = true;

                pc.LeftStick.Y.Positive.ID       = 1;
                pc.LeftStick.Y.Positive.Type     = InputType.Axis;
                pc.LeftStick.Y.Positive.Negative = false;

                //pc.RightStick.X.Negative.Type = InputType.Axis;
                //pc.RightStick.X.Negative.Negative = true;
                //pc.RightStick.X.Positive.Type = InputType.Axis;
                //pc.RightStick.X.Positive.Negative = false;

                //pc.RightStick.Y.Negative.ID = 1;
                //pc.RightStick.Y.Negative.Type = InputType.Axis;
                //pc.RightStick.Y.Negative.Negative = true;

                //pc.RightStick.Y.Positive.ID = 1;
                //pc.RightStick.Y.Positive.Type = InputType.Axis;
                //pc.RightStick.Y.Positive.Negative = false;

                pc.Dpad.Up.ID   = 0;
                pc.Dpad.Up.Type = InputType.PovUp;

                pc.Dpad.Down.ID   = 0;
                pc.Dpad.Down.Type = InputType.PovDown;

                pc.Dpad.Left.ID   = 0;
                pc.Dpad.Left.Type = InputType.PovLeft;

                pc.Dpad.Right.ID   = 0;
                pc.Dpad.Right.Type = InputType.PovRight;

                //pc.LeftTrigger.ID = 6;
                //pc.LeftTrigger.Type = InputType.Button;

                pc.RightTrigger.ID   = 7;
                pc.RightTrigger.Type = InputType.Button;

                int numaxes = Sdl.SDL_JoystickNumAxes(devices[x]);
                Console.WriteLine("Number of axes for joystick: " + x + " - " + numaxes);

                for (int a = 0; a < numaxes; a++)
                {
                    //pc.LeftStick = new Stick();
                }

                int numhats = Sdl.SDL_JoystickNumHats(devices[x]);
                Console.WriteLine("Number of PovHats for joystick: " + x + " - " + numhats);

                for (int h = 0; h < numhats; h++)
                {
                    //pc
                }
                settings[x] = pc;
            }
        }