public Gamepad(int player_num) { if (player_num < 0 || player_num > 4) { throw new ArgumentException(); } // Get the user index SlimDX.XInput.UserIndex userIndex = SlimDX.XInput.UserIndex.Any; switch (player_num) { case 1: userIndex = SlimDX.XInput.UserIndex.One; break; case 2: userIndex = SlimDX.XInput.UserIndex.Two; break; case 3: userIndex = SlimDX.XInput.UserIndex.Three; break; case 4: userIndex = SlimDX.XInput.UserIndex.Four; break; } controller = new Controller(userIndex); }
////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// private bool IsGamepadPresent(SlimDX.XInput.UserIndex userIndex, ref string name) { Xbox360Controller.Gamepad360 g; g = new Xbox360Controller.Gamepad360(userIndex); name = g.ToString(); return(g.Connected); }