XInput Mouse.GetState();
This commit is contained in:
parent
07b520f17b
commit
eae177fe8d
@ -34,6 +34,9 @@
|
|||||||
<Reference Include="SharpDX">
|
<Reference Include="SharpDX">
|
||||||
<HintPath>..\lib\SharpDX\Bin\SharpDX.dll</HintPath>
|
<HintPath>..\lib\SharpDX\Bin\SharpDX.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="SharpDX.DirectInput">
|
||||||
|
<HintPath>..\lib\SharpDX\Bin\SharpDX.DirectInput.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="SharpDX.XInput">
|
<Reference Include="SharpDX.XInput">
|
||||||
<HintPath>..\lib\SharpDX\Bin\SharpDX.XInput.dll</HintPath>
|
<HintPath>..\lib\SharpDX\Bin\SharpDX.XInput.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -4,11 +4,16 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using ANX.Framework.NonXNA;
|
using ANX.Framework.NonXNA;
|
||||||
using ANX.Framework.Input;
|
using ANX.Framework.Input;
|
||||||
|
using SharpDX.DirectInput;
|
||||||
|
using MouseX = SharpDX.DirectInput.Mouse;
|
||||||
|
|
||||||
|
|
||||||
namespace ANX.InputSystem.Windows.XInput
|
namespace ANX.InputSystem.Windows.XInput
|
||||||
{
|
{
|
||||||
class Mouse:IMouse
|
class Mouse:IMouse
|
||||||
{
|
{
|
||||||
|
private DirectInput directInput;
|
||||||
|
private MouseX mouse;
|
||||||
public IntPtr WindowHandle
|
public IntPtr WindowHandle
|
||||||
{
|
{
|
||||||
get
|
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)
|
public void SetPosition(int x, int y)
|
||||||
|
@ -146,7 +146,16 @@ namespace WindowsGame1
|
|||||||
{ GraphicsDevice.Clear(Color.Green); }
|
{ GraphicsDevice.Clear(Color.Green); }
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GraphicsDevice.Clear(Color.CornflowerBlue);
|
if (Mouse.GetState().XButton1 == ButtonState.Pressed)
|
||||||
|
{
|
||||||
|
GraphicsDevice.Clear(Color.Chocolate);
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GraphicsDevice.Clear(Color.CornflowerBlue);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spriteBatch.Begin();
|
spriteBatch.Begin();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user