Permalink
Browse files

Gamepad support implemented for Win/Lin/OSX

  • Loading branch information...
1 parent cef31c6 commit 8d09d7dbcb8347e064ca39f2d2c889525014ee64 @Ragath Ragath committed Nov 14, 2011
@@ -1,6 +1,6 @@

-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Framework.Linux", "MonoGame.Framework\MonoGame.Framework.Linux.csproj", "{35253CE1-C864-4CD3-8249-4D1319748E8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lidgren.Network.Linux", "ThirdParty\Lidgren.Network\Lidgren.Network.Linux.csproj", "{AE483C29-042E-4226-BA52-D247CE7676DA}"
@@ -44,91 +44,96 @@ namespace Microsoft.Xna.Framework.Input
{
public struct GamePadButtons
{
- private Buttons _buttons;
-
- public GamePadButtons(Buttons buttons)
- {
- _buttons = buttons;
- }
+ internal Buttons buttons;
public ButtonState A
{
get
{
- return ((_buttons & Buttons.A) == Buttons.A) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.A) == Buttons.A) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState B
{
get
{
- return ((_buttons & Buttons.B) == Buttons.B) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.B) == Buttons.B) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState Back
{
get
{
- return ((_buttons & Buttons.Back) == Buttons.Back) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.Back) == Buttons.Back) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState X
{
get
{
- return ((_buttons & Buttons.X) == Buttons.X) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.X) == Buttons.X) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState Y
{
get
{
- return ((_buttons & Buttons.Y) == Buttons.Y) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.Y) == Buttons.Y) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState Start
{
get
{
- return ((_buttons & Buttons.Start) == Buttons.Start) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.Start) == Buttons.Start) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState LeftShoulder
{
get
{
- return ((_buttons & Buttons.LeftShoulder) == Buttons.LeftShoulder) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.LeftShoulder) == Buttons.LeftShoulder) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState LeftStick
{
get
{
- return ((_buttons & Buttons.LeftStick) == Buttons.LeftStick) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.LeftStick) == Buttons.LeftStick) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState RightShoulder
{
get
{
- return ((_buttons & Buttons.RightShoulder) == Buttons.RightShoulder) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.RightShoulder) == Buttons.RightShoulder) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState RightStick
{
get
{
- return ((_buttons & Buttons.RightStick) == Buttons.RightStick) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.RightStick) == Buttons.RightStick) ? ButtonState.Pressed : ButtonState.Released;
}
}
public ButtonState BigButton
{
get
{
- return ((_buttons & Buttons.BigButton) == Buttons.BigButton) ? ButtonState.Pressed : ButtonState.Released;
+ return ((buttons & Buttons.BigButton) == Buttons.BigButton) ? ButtonState.Pressed : ButtonState.Released;
}
}
+
+ public GamePadButtons(Buttons buttons)
+ {
+ this.buttons = buttons;
+ }
+ internal GamePadButtons(params Buttons[] buttons)
+ : this()
+ {
+ foreach (Buttons b in buttons)
+ this.buttons |= b;
+ }
}
-
}
@@ -1,4 +1,4 @@
-// #region License
+#region License
// /*
// Microsoft Public License (Ms-PL)
// MonoGame - Copyright © 2009 The MonoGame Team
@@ -36,53 +36,54 @@
// permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
// purpose and non-infringement.
// */
-// #endregion License
-//
-
-using System;
-
-namespace Microsoft.Xna.Framework.Input
+#endregion License
+
+using System;
+
+namespace Microsoft.Xna.Framework.Input
{
- public struct GamePadDPad
+ public struct GamePadDPad
{
- public GamePadDPad (
- ButtonState upValue,
- ButtonState downValue,
- ButtonState leftValue,
- ButtonState rightValue )
- {
- }
-
- public ButtonState Down
- {
- get
- {
- return ButtonState.Released;
- }
- }
-
- public ButtonState Left
- {
- get
- {
- return ButtonState.Released;
- }
- }
-
- public ButtonState Right
- {
- get
- {
- return ButtonState.Released;
- }
- }
-
- public ButtonState Up
- {
- get
- {
- return ButtonState.Released;
- }
- }
- }
-}
+ public ButtonState Down
+ {
+ get;
+ internal set;
+ }
+ public ButtonState Left
+ {
+ get;
+ internal set;
+ }
+ public ButtonState Right
+ {
+ get;
+ internal set;
+ }
+ public ButtonState Up
+ {
+ get;
+ internal set;
+ }
+
+ public GamePadDPad(ButtonState upValue, ButtonState downValue, ButtonState leftValue, ButtonState rightValue)
+ : this()
+ {
+ Up = upValue;
+ Down = downValue;
+ Left = leftValue;
+ Right = rightValue;
+ }
+ internal GamePadDPad(Buttons b)
+ : this()
+ {
+ if ((b & Buttons.DPadDown) == Buttons.DPadDown)
+ Down = ButtonState.Pressed;
+ if ((b & Buttons.DPadLeft) == Buttons.DPadLeft)
+ Left = ButtonState.Pressed;
+ if ((b & Buttons.DPadRight) == Buttons.DPadRight)
+ Right = ButtonState.Pressed;
+ if ((b & Buttons.DPadUp) == Buttons.DPadUp)
+ Up = ButtonState.Pressed;
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 8d09d7d

Please sign in to comment.