XInput Mouse.GetState();

This commit is contained in:
SND\rene87_cp 2011-11-05 00:34:45 +00:00
parent 07b520f17b
commit eae177fe8d
3 changed files with 38 additions and 3 deletions

View File

@ -34,6 +34,9 @@
<Reference Include="SharpDX">
<HintPath>..\lib\SharpDX\Bin\SharpDX.dll</HintPath>
</Reference>
<Reference Include="SharpDX.DirectInput">
<HintPath>..\lib\SharpDX\Bin\SharpDX.DirectInput.dll</HintPath>
</Reference>
<Reference Include="SharpDX.XInput">
<HintPath>..\lib\SharpDX\Bin\SharpDX.XInput.dll</HintPath>
</Reference>

View File

@ -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)

View File

@ -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();