コード例 #1
0
 public EmulationSlot(uint slotNumber, XboxGamepad gamepad, Keyboard keyboard, Mouse mouse, Preset preset)
     : base(slotNumber, gamepad, keyboard, mouse, preset)
 {
     this.InitializeComponent();
     if (gamepad.Exsists)
     {
         this.InvalidateReason = SlotInvalidationReason.Controller_Already_Plugged_In;
     }
 }
コード例 #2
0
        /// <summary>
        /// Creates an XboxGamepad for this console.
        /// </summary>
        /// <returns>A new XboxGamepad.</returns>
        /// <remarks>
        /// Does not attempt to connect the XboxGamepad, and does not
        /// provide control over a physical controller.
        /// </remarks>
        public XboxGamepad CreateXboxGamepad()
        {
            this.ThrowIfDisposed();

            var gamepad = new XboxGamepad(this);

            this.XboxGamepads.Add(gamepad);

            return(gamepad);
        }
コード例 #3
0
        public void TestPairWithVirtualControllerExclusiveThrowsArgumentExceptions()
        {
            XboxGamepad gamepad = new XboxGamepad(this.xboxConsole);
            XboxUser    user    = this.CreateTestUser();

            ShimXboxConsoleAdapterBase.AllInstances.PairGamepadToUserExclusiveStringUInt64UInt32 = (adapter, systemIpAddress, gamepadId, userId) =>
            {
                Assert.Fail("Test should never have gotten to the adapters method.");
            };

            user.PairWithVirtualControllerExclusive(gamepad);
        }
コード例 #4
0
ファイル: XboxUser.cs プロジェクト: veli-gotolabs/XboxConsole
        /// <summary>
        /// Pairs a user with a virtual controller exclusivly.
        /// </summary>
        /// <param name="gamepad">The virtual gamepad with which the user will be paired.</param>
        public void PairWithVirtualControllerExclusive(XboxGamepad gamepad)
        {
            if (gamepad == null)
            {
                throw new ArgumentNullException("gamepad", "gamepad cannot be null.");
            }

            if (!gamepad.Id.HasValue)
            {
                throw new ArgumentException("gamepad must have a non-null id value.", "gamepad");
            }

            this.Console.Adapter.PairGamepadToUserExclusive(this.Console.SystemIpAddressAndSessionKeyCombined, gamepad.Id.Value, this.UserId);
        }
コード例 #5
0
        public void TestPairWithMethodsPassOnIds()
        {
            const uint  ExpectedUserId    = TestUserId;
            const ulong ExpectedGamepadId = 9876543210;
            var         gamepad           = new XboxGamepad(this.xboxConsole);

            XboxUser user = this.CreateTestUser();

            ShimXboxConsoleAdapterBase.AllInstances.ConnectXboxGamepadString = (_, __) => ExpectedGamepadId;

            gamepad.Connect();

            ShimXboxConsoleAdapterBase.AllInstances.PairGamepadToUserStringUInt64UInt32 = (adapter, systemIpAddress, gamepadId, userId) =>
            {
                Assert.AreEqual(ExpectedGamepadId, gamepadId, "The XboxUser did not pass in the expected id parameter");
                Assert.AreEqual(ExpectedUserId, userId, "The XboxUser did not pass in the expected id parameter");
            };

            user.PairWithPhysicalController(ExpectedGamepadId);

            user.PairWithVirtualController(gamepad);
        }
コード例 #6
0
        public void TestPairWithMethodsCallAdapterPairGamepadToUser()
        {
            var gamepad = new XboxGamepad(this.xboxConsole);

            gamepad.Connect();

            XboxUser user = this.CreateTestUser();

            bool isCorrectMethodCalled = false;

            ShimXboxConsoleAdapterBase.AllInstances.PairGamepadToUserStringUInt64UInt32 = (adapter, systemIpAddress, gamepadId, userId) =>
            {
                isCorrectMethodCalled = true;
            };

            user.PairWithPhysicalController(0);
            Assert.IsTrue(isCorrectMethodCalled, "The PairWithPhysicalController method didn't call the adapter's PairGamepadToUser(systemIpAddress, gamepadId, userId).");

            isCorrectMethodCalled = false;

            user.PairWithVirtualController(gamepad);
            Assert.IsTrue(isCorrectMethodCalled, "The PairWithVirtualController method didn't call the adapter's PairGamepadToUser(systemIpAddress, gamepadId, userId).");
        }