private void ThrowIfInvalidGamepadState(XboxGamepadState report) { if (report == null) { throw new ArgumentNullException("report"); } }
public void TestXboxGamepadStateEqualsWithSimilar() { var gamepad1 = new XboxGamepadState() { Buttons = XboxGamepadButtons.A, LeftTrigger = 1.0f, RightTrigger = 1.0f, LeftThumbstickX = -1.0f, LeftThumbstickY = 0.3f, RightThumbstickX = 0.1f, RightThumbstickY = -0.2f }; var gamepad2 = new XboxGamepadState() { Buttons = XboxGamepadButtons.A, LeftTrigger = 1.0f, RightTrigger = 1.0f, LeftThumbstickX = -1.0f, LeftThumbstickY = 0.3f, RightThumbstickX = 0.1f, RightThumbstickY = -0.21f }; Assert.AreEqual(gamepad1, gamepad2, "Gamepads are not equal"); }
public void TestXboxGamepadSetXboxGamepadStateThrowsWhenNotConnected() { var gamepad = new GamesTest.Xbox.Input.XboxGamepad(this.XboxConsole); XboxGamepadState state = new XboxGamepadState(); this.VerifyGamepadThrowsFunc <XboxInputException>( () => gamepad.SetXboxGamepadState(state), "SetGamepadState did not throw an exception when not connected."); }
/// <summary> /// Sets the state of the XboxGamepad. /// </summary> /// <param name="systemIpAddress">The system IP address of the console.</param> /// <param name="gamepadId">The id of the XboxGamepad to set the state of.</param> /// <param name="report">The state to set.</param> public void SendGamepadReport(string systemIpAddress, ulong gamepadId, XboxGamepadState report) { this.ThrowIfDisposed(); this.ThrowIfInvalidSystemIpAddress(systemIpAddress); this.ThrowIfInvalidGamepadState(report); this.PerformXdkAction( systemIpAddress, () => this.SendXboxGamepadReportImpl(systemIpAddress, gamepadId, report), "Failed to send a gamepad report."); }
public void TestXboxGamepadStateEqualsWithDifferent() { var gamepad1 = new XboxGamepadState() { Buttons = XboxGamepadButtons.A }; var gamepad2 = new XboxGamepadState() { Buttons = XboxGamepadButtons.B }; Assert.AreNotEqual(gamepad1, gamepad2, "Gamepads are equal"); }
/// <summary> /// Sets the gamepad state. /// </summary> /// <param name="state">The new state for the gamepad.</param> public void SetGamepadState(XboxGamepadState state) { if (state == null) { throw new ArgumentNullException("state"); } GAMEPAD_REPORT report; report.Buttons = (ushort)state.Buttons; report.LeftThumbstickX = this.ConvertGamepadStateThumbstickValue(state.LeftThumbstickX); report.LeftThumbstickY = this.ConvertGamepadStateThumbstickValue(state.LeftThumbstickY); report.RightThumbstickX = this.ConvertGamepadStateThumbstickValue(state.RightThumbstickX); report.RightThumbstickY = this.ConvertGamepadStateThumbstickValue(state.RightThumbstickY); report.LeftTrigger = this.ConvertGamepadStateTriggerValue(state.LeftTrigger); report.RightTrigger = this.ConvertGamepadStateTriggerValue(state.RightTrigger); this.xtfGamepad.SetGamepadState(report); }
public void TestXboxGamepadSendGamepadStateCallsAdapterSendGamepadReportCorrectly() { var gamepad = new GamesTest.Xbox.Input.XboxGamepad(this.XboxConsole); var gamepadState = new XboxGamepadState(); bool adapterCalled = false; this.shimAdapter = new ShimXboxConsoleAdapterBase(new StubXboxConsoleAdapterBase(null)) { SendGamepadReportStringUInt64XboxGamepadState = (systemIpAddress, gamepadId, adapterGamepadState) => { adapterCalled = true; Assert.AreEqual(this.XboxConsole.SystemIpAddressString, systemIpAddress, "SystemIpAddress did not match the one from the XboxConsole"); Assert.AreEqual(gamepad.Id, gamepadId, "Gamepad Id is not equal to one being set"); Assert.AreEqual(gamepadState, adapterGamepadState, "GamepadState not equal to one being set"); } }; gamepad.Connect(); gamepad.SetXboxGamepadState(gamepadState); Assert.IsTrue(adapterCalled, "Adapter SetGamepadState never called"); }
/// <summary> /// Sets the state of the XboxGamepad. /// </summary> /// <param name="ipAddress">The tools IP address of the console.</param> /// <param name="xboxGamepadId">The Id of the XboxGamepad to set the state of.</param> /// <param name="report">The state to set the XboxGamepad to.</param> public virtual void SendGamepadReport(string ipAddress, int xboxGamepadId, XboxGamepadState report) { throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage); }
/// <summary> /// Sets the state of the XboxGamepad. /// </summary> /// <param name="systemIpAddress">The system IP address of the console.</param> /// <param name="gamepadId">The Id of the XboxGamepad to set the state of.</param> /// <param name="report">The state to set.</param> protected virtual void SendXboxGamepadReportImpl(string systemIpAddress, ulong gamepadId, XboxGamepadState report) { throw new XboxConsoleFeatureNotSupportedException(NotSupportedMessage); }