diff --git a/ANX.Framework.TestCenter/ANX.Framework.TestCenter.csproj b/ANX.Framework.TestCenter/ANX.Framework.TestCenter.csproj
index 95ab4fbc..789945f6 100644
--- a/ANX.Framework.TestCenter/ANX.Framework.TestCenter.csproj
+++ b/ANX.Framework.TestCenter/ANX.Framework.TestCenter.csproj
@@ -62,6 +62,7 @@
+
diff --git a/ANX.Framework.TestCenter/AssertHelper.cs b/ANX.Framework.TestCenter/AssertHelper.cs
index 2d012164..6696b5b0 100644
--- a/ANX.Framework.TestCenter/AssertHelper.cs
+++ b/ANX.Framework.TestCenter/AssertHelper.cs
@@ -160,6 +160,9 @@ using ANXCurveKeyCollection = ANX.Framework.CurveKeyCollection;
using XNACurveTangent = Microsoft.Xna.Framework.CurveTangent;
using ANXCurveTangent = ANX.Framework.CurveTangent;
+using XNAGamePadState = Microsoft.Xna.Framework.Input.GamePadState;
+using ANXGamePadState = ANX.Framework.Input.GamePadState;
+
#endregion // Datatype usings
namespace ANX.Framework.TestCenter
@@ -796,7 +799,20 @@ namespace ANX.Framework.TestCenter
Assert.Fail(String.Format("{0} failed: xna({1}) anx({2})", test, xna.ToString(), anx.ToString()));
}
}
-
+
+ public static void ConvertEquals(XNAGamePadState xna, ANXGamePadState anx, String test)
+ {
+ if ((xna.Buttons.ToString()==anx.Buttons.ToString())&&(xna.DPad.ToString()==anx.DPad.ToString())&&(xna.IsConnected==anx.IsConnected)&&(xna.ThumbSticks.ToString()==anx.ThumbSticks.ToString())&&(xna.Triggers.ToString()==anx.Triggers.ToString()))
+ {
+ Assert.Pass(test + " passed");
+ }
+ else
+ {
+ Assert.Fail(String.Format("{0} failed: xna({1}) anx({2})", test, xna.ToString(), anx.ToString()));
+ }
+ }
+
+
private static bool Compare(XNACurve xna, ANXCurve anx)
{
return (xna.IsConstant == anx.IsConstant) && (Compare(xna.Keys, anx.Keys)) && (Compare(xna.PreLoop, anx.PreLoop)) && (Compare(xna.PostLoop, anx.PostLoop));
@@ -836,6 +852,6 @@ namespace ANX.Framework.TestCenter
return ((int)xna == (int)anx);
}
-
+
}
}
diff --git a/ANX.Framework.TestCenter/Strukturen/CurveTest.cs b/ANX.Framework.TestCenter/Strukturen/CurveTest.cs
index ba4f3e23..ca68c54b 100644
--- a/ANX.Framework.TestCenter/Strukturen/CurveTest.cs
+++ b/ANX.Framework.TestCenter/Strukturen/CurveTest.cs
@@ -68,7 +68,7 @@ using ANXCurveTangent = ANX.Framework.CurveTangent;
// particular purpose and non-infringement.
#endregion // License
-namespace ANX.Framework.TestCenter.Struckturen.classTest
+namespace ANX.Framework.TestCenter.Strukturen
{
[TestFixture]
class CurveTest
diff --git a/ANX.Framework.TestCenter/Strukturen/Input/GamePadTest.cs b/ANX.Framework.TestCenter/Strukturen/Input/GamePadTest.cs
new file mode 100644
index 00000000..4f3d7b6b
--- /dev/null
+++ b/ANX.Framework.TestCenter/Strukturen/Input/GamePadTest.cs
@@ -0,0 +1,106 @@
+#region Using Statements
+using System;
+using System.IO;
+using ANX.Framework.NonXNA;
+using NUnit.Framework;
+#endregion // Using Statements
+
+using XNAGamePad = Microsoft.Xna.Framework.Input.GamePad;
+using ANXGamePad = ANX.Framework.Input.GamePad;
+
+using XNAGamePadState = Microsoft.Xna.Framework.Input.GamePadState;
+using ANXGamePadState = ANX.Framework.Input.GamePadState;
+
+using XNAGamePadDPad = Microsoft.Xna.Framework.Input.GamePadDPad;
+using ANXGamePadDPad = ANX.Framework.Input.GamePadDPad;
+
+using ANXButtons = ANX.Framework.Input.Buttons;
+using XNAButtons = Microsoft.Xna.Framework.Input.Buttons;
+
+using XNAButtonState = Microsoft.Xna.Framework.Input.ButtonState;
+using ANXButtonState = ANX.Framework.Input.ButtonState;
+
+using XNAPlayerIndex = Microsoft.Xna.Framework.PlayerIndex;
+using ANXPlayerIndex = ANX.Framework.PlayerIndex;
+
+
+#region License
+
+//
+// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
+//
+// This file is released under the Ms-PL license.
+//
+//
+//
+// Microsoft Public License (Ms-PL)
+//
+// This license governs use of the accompanying software. If you use the software, you accept this license.
+// If you do not accept the license, do not use the software.
+//
+// 1.Definitions
+// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
+// here as under U.S. copyright law.
+// A "contribution" is the original software, or any additions or changes to the software.
+// A "contributor" is any person that distributes its contribution under this license.
+// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
+//
+// 2.Grant of Rights
+// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
+// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
+// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
+// or any derivative works that you create.
+// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
+// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
+// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
+// in the software or derivative works of the contribution in the software.
+//
+// 3.Conditions and Limitations
+// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
+// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
+// patent license from such contributor to the software ends automatically.
+// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
+// notices that are present in the software.
+// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
+// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
+// object code form, you may only do so under a license that complies with this license.
+// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
+// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
+// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
+// particular purpose and non-infringement.
+
+#endregion // License
+
+namespace ANX.Framework.TestCenter.Strukturen.Input
+{
+ [TestFixture]
+ class GamePadTest
+ {
+
+ static object[] twoplayer =
+ {
+ new object[]{XNAPlayerIndex.One, ANXPlayerIndex.One},
+ new object[]{XNAPlayerIndex.Two, ANXPlayerIndex.Two},
+ new object[]{XNAPlayerIndex.Three, ANXPlayerIndex.Three},
+ new object[]{XNAPlayerIndex.Four, ANXPlayerIndex.Four},
+ };
+
+ [SetUp]
+ public void BeforeEach()
+ {
+ AddInSystemFactory.Instance.Initialize();
+
+ AddInSystemFactory.Instance.SetDefaultCreator("XInput");
+ }
+
+ [TestCaseSource("twoplayer")]
+ public void GetState(XNAPlayerIndex xnaplayer, ANXPlayerIndex anxplayer)
+ {
+ XNAGamePadState xnastate = XNAGamePad.GetState(xnaplayer);
+ ANXGamePadState anxstate = ANXGamePad.GetState(anxplayer);
+
+ AssertHelper.ConvertEquals(xnastate, anxstate, "GetState");
+
+ }
+ }
+}
diff --git a/ANX.Framework/Input/GamePad.cs b/ANX.Framework/Input/GamePad.cs
index f755881f..25f1f736 100644
--- a/ANX.Framework/Input/GamePad.cs
+++ b/ANX.Framework/Input/GamePad.cs
@@ -70,12 +70,22 @@ namespace ANX.Framework.Input
public static GamePadState GetState(PlayerIndex playerIndex)
{
- return gamePad.GetState(playerIndex);
+ bool isConnected;
+ int packetNumber;
+ GamePadState ret = gamePad.GetState(playerIndex,out isConnected, out packetNumber);
+ ret.IsConnected = isConnected;
+ ret.PacketNumber = packetNumber;
+ return ret;
}
public static GamePadState GetState (PlayerIndex playerIndex,GamePadDeadZone deadZoneMode)
{
- return gamePad.GetState(playerIndex, deadZoneMode);
+ bool isConnected;
+ int packetNumber;
+ GamePadState ret = gamePad.GetState(playerIndex,deadZoneMode, out isConnected, out packetNumber);
+ ret.IsConnected = isConnected;
+ ret.PacketNumber = packetNumber;
+ return ret;
}
public static bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor)
diff --git a/ANX.Framework/Input/GamePadState.cs b/ANX.Framework/Input/GamePadState.cs
index 3a0353e4..3dc23cc8 100644
--- a/ANX.Framework/Input/GamePadState.cs
+++ b/ANX.Framework/Input/GamePadState.cs
@@ -64,8 +64,8 @@ namespace ANX.Framework.Input
private Buttons buttonsValue;
- //private bool isConnected ;
- //private int packetNumber ;
+ private bool isConnected;
+ private int packetNumber;
#endregion // Private Members
@@ -75,7 +75,8 @@ namespace ANX.Framework.Input
this.triggers = triggers;
this.buttons = buttons;
this.dPad = dPad;
-
+ this.isConnected = false;
+ this.packetNumber = 0;
this.buttonsValue = this.buttons.Buttons | this.dPad.Buttons;
}
@@ -90,6 +91,8 @@ namespace ANX.Framework.Input
buttonField |= buttons[i];
}
this.buttonsValue = buttonField;
+ this.isConnected = false;
+ this.packetNumber = 0;
this.buttons = new GamePadButtons(this.buttonsValue);
this.dPad = new GamePadDPad(this.buttonsValue);
@@ -145,7 +148,11 @@ namespace ANX.Framework.Input
{
get
{
- throw new NotImplementedException();
+ return this.isConnected;
+ }
+ internal set
+ {
+ this.isConnected = value;
}
}
@@ -153,7 +160,11 @@ namespace ANX.Framework.Input
{
get
{
- throw new NotImplementedException();
+ return this.packetNumber;
+ }
+ internal set
+ {
+ this.packetNumber = value;
}
}
diff --git a/ANX.Framework/NonXNA/InputSystem/IGamePad.cs b/ANX.Framework/NonXNA/InputSystem/IGamePad.cs
index 0b519222..d43b78bc 100644
--- a/ANX.Framework/NonXNA/InputSystem/IGamePad.cs
+++ b/ANX.Framework/NonXNA/InputSystem/IGamePad.cs
@@ -9,8 +9,8 @@ namespace ANX.Framework.NonXNA
public interface IGamePad
{
GamePadCapabilities GetCapabilities(PlayerIndex playerIndex);
- GamePadState GetState(PlayerIndex playerIndex);
- GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode);
+ GamePadState GetState(PlayerIndex playerIndex, out bool isConnected, out int packetNumber);
+ GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode, out bool isConnected, out int packetNumber);
bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor);
}
}
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/GamePad.cs b/InputSystems/ANX.InputSystem.Windows.XInput/GamePad.cs
index 80faf91b..138a85fc 100644
--- a/InputSystems/ANX.InputSystem.Windows.XInput/GamePad.cs
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/GamePad.cs
@@ -91,7 +91,7 @@ namespace ANX.InputSystem.Windows.XInput
} return returnres;
}
- public GamePadState GetState(PlayerIndex playerIndex)
+ public GamePadState GetState(PlayerIndex playerIndex, out bool isConnected, out int packetNumber)
{
State result;
GamePadState returnres;
@@ -100,10 +100,13 @@ namespace ANX.InputSystem.Windows.XInput
result = controller[(int)playerIndex].GetState();
//returnres = new GamePadCapabilities(result.Type,result.Gamepad.Buttons.)
returnres = new GamePadState(new Vector2(result.Gamepad.LeftThumbX, result.Gamepad.LeftThumbY), new Vector2(result.Gamepad.RightThumbX, result.Gamepad.RightThumbY), (float)result.Gamepad.LeftTrigger, (float)result.Gamepad.RightTrigger, FormatConverter.Translate(result.Gamepad.Buttons));
+ packetNumber = result.PacketNumber;
+ isConnected = true;
}
else
{
-
+ isConnected = false;
+ packetNumber = 0;
returnres = new GamePadState();
}
@@ -111,7 +114,7 @@ namespace ANX.InputSystem.Windows.XInput
return returnres;
}
- public GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode)
+ public GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode, out bool isConnected, out int packetNumber)
{
throw new NotImplementedException();
}