diff --git a/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj b/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj
index f0ea1700..3f394b1d 100644
--- a/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj
+++ b/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj
@@ -34,6 +34,9 @@
..\lib\SharpDX\Bin\SharpDX.dll
+
+ ..\lib\SharpDX\Bin\SharpDX.DirectInput.dll
+
..\lib\SharpDX\Bin\SharpDX.XInput.dll
diff --git a/ANX.InputSystem.Windows.XInput/Mouse.cs b/ANX.InputSystem.Windows.XInput/Mouse.cs
index a1eadb7c..5a96c453 100644
--- a/ANX.InputSystem.Windows.XInput/Mouse.cs
+++ b/ANX.InputSystem.Windows.XInput/Mouse.cs
@@ -4,11 +4,16 @@ using System.Linq;
using System.Text;
using ANX.Framework.NonXNA;
using ANX.Framework.Input;
+using SharpDX.DirectInput;
+using MouseX = SharpDX.DirectInput.Mouse;
+
namespace ANX.InputSystem.Windows.XInput
{
class Mouse:IMouse
{
+ private DirectInput directInput;
+ private MouseX mouse;
public IntPtr WindowHandle
{
get
@@ -21,9 +26,27 @@ namespace ANX.InputSystem.Windows.XInput
}
}
- public MouseState GetState()
+ public Mouse()
{
- throw new NotImplementedException();
+ this.directInput = new DirectInput();
+ this.mouse = new MouseX(this.directInput);
+ this.mouse.Acquire();
+ }
+
+ public ANX.Framework.Input.MouseState GetState()
+ {
+ var state = this.mouse.GetCurrentState();
+ ButtonState left = new ButtonState();
+ ButtonState middle = new ButtonState();
+ ButtonState right = new ButtonState();
+ ButtonState x1 = new ButtonState();
+ ButtonState x2 = new ButtonState();
+ if(state.Buttons[0]){left=ButtonState.Pressed;}
+ if(state.Buttons[1]){middle=ButtonState.Pressed;}
+ if(state.Buttons[2]){right=ButtonState.Pressed;}
+ if(state.Buttons[3]){x1=ButtonState.Pressed;}
+ if(state.Buttons[4]){x2=ButtonState.Pressed;}
+ return new ANX.Framework.Input.MouseState(state.X,state.Y,state.Z,left,middle,right,x1,x2);
}
public void SetPosition(int x, int y)
diff --git a/Samples/SimpleSprite/Game1.cs b/Samples/SimpleSprite/Game1.cs
index 4c159743..812380b9 100644
--- a/Samples/SimpleSprite/Game1.cs
+++ b/Samples/SimpleSprite/Game1.cs
@@ -146,7 +146,16 @@ namespace WindowsGame1
{ GraphicsDevice.Clear(Color.Green); }
else
{
- GraphicsDevice.Clear(Color.CornflowerBlue);
+ if (Mouse.GetState().XButton1 == ButtonState.Pressed)
+ {
+ GraphicsDevice.Clear(Color.Chocolate);
+
+ }
+ else
+ {
+ GraphicsDevice.Clear(Color.CornflowerBlue);
+
+ }
}
spriteBatch.Begin();