Carolyn Van Slyck avatar Carolyn Van Slyck committed e7ccf14

* Moved game controller state and action into game controller directory

Comments (0)

Files changed (4)

OMG/GameController/GameControllerAction.cs

+using System;
+
+namespace OMG.GameController
+{
+    [Flags]
+    public enum GameControllerAction
+    {
+        None = 0,
+        Quit = 1,
+        Up = 2,
+        Down = 4,
+        Left = 8,
+        Right = 16,
+        Select = 32
+    }
+}

OMG/GameController/GameControllerState.cs

+using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Input;
+using OMG.GameController;
+
+namespace OMG.GameController
+{
+    public class GameControllerState
+    {
+        public GameControllerAction Actions { get; private set; }
+        public Vector2 GameCursorLocation;
+
+        public static bool KeyboardActivated;
+        public static bool MouseActivated;
+        public static bool GamePadActivated;
+
+        public static GameControllerState GetState(GameTime gameTime)
+        {
+            var state = new GameControllerState { Actions = GameControllerAction.None };
+
+            GamePadState? gamePad = GetActiveGamePad();
+            KeyboardActivated = MouseActivated = (gamePad == null);
+            GamePadActivated = gamePad.HasValue;
+
+            if (GamePadActivated)
+            {
+                XboxControllerAction xboxActions = XboxController.ProcessGamePad(gamePad.Value, state);
+                state.Actions |= xboxActions.Actions;
+                GameCursor.UpdateLocation(xboxActions.RightThumbStickDirection, gameTime);
+            }
+            if (KeyboardActivated)
+            {
+                state.Actions |= KeyboardController.ProcessKeyboard(state);
+            }
+            if (MouseActivated)
+            {
+                MouseAction mouseActions = MouseController.ProcessMouse(state);
+                state.Actions |= mouseActions.Actions;
+                GameCursor.Location = mouseActions.Location;
+            }
+            state.GameCursorLocation = GameCursor.Location;
+
+            return state;
+        }
+
+        public bool HasAction(GameControllerAction action)
+        {
+            return (Actions & action) == action;
+        }
+
+        private static GamePadState? GetActiveGamePad()
+        {
+            var gamePadState = GamePad.GetState(PlayerIndex.One);
+            if (gamePadState.IsConnected)
+                return gamePadState;
+
+            gamePadState = GamePad.GetState(PlayerIndex.Two);
+            if (gamePadState.IsConnected)
+                return gamePadState;
+
+            gamePadState = GamePad.GetState(PlayerIndex.Three);
+            if (gamePadState.IsConnected)
+                return gamePadState;
+
+            gamePadState = GamePad.GetState(PlayerIndex.Four);
+            if (gamePadState.IsConnected)
+                return gamePadState;
+
+            return null;
+        }
+    }
+}

OMG/GameControllerAction.cs

-using System;
-
-namespace OMG.GameController
-{
-    [Flags]
-    public enum GameControllerAction
-    {
-        None = 0,
-        Quit = 1,
-        Up = 2,
-        Down = 4,
-        Left = 8,
-        Right = 16,
-        Select = 32
-    }
-}

OMG/GameControllerState.cs

-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Input;
-using OMG.GameController;
-
-namespace OMG.GameController
-{
-    public class GameControllerState
-    {
-        public GameControllerAction Actions { get; private set; }
-        public Vector2 GameCursorLocation;
-
-        public static bool KeyboardActivated;
-        public static bool MouseActivated;
-        public static bool GamePadActivated;
-
-        public static GameControllerState GetState(GameTime gameTime)
-        {
-            var state = new GameControllerState { Actions = GameControllerAction.None };
-
-            GamePadState? gamePad = GetActiveGamePad();
-            KeyboardActivated = MouseActivated = (gamePad == null);
-            GamePadActivated = gamePad.HasValue;
-
-            if (GamePadActivated)
-            {
-                XboxControllerAction xboxActions = XboxController.ProcessGamePad(gamePad.Value, state);
-                state.Actions |= xboxActions.Actions;
-                GameCursor.UpdateLocation(xboxActions.RightThumbStickDirection, gameTime);
-            }
-            if (KeyboardActivated)
-            {
-                state.Actions |= KeyboardController.ProcessKeyboard(state);
-            }
-            if (MouseActivated)
-            {
-                MouseAction mouseActions = MouseController.ProcessMouse(state);
-                state.Actions |= mouseActions.Actions;
-                GameCursor.Location = mouseActions.Location;
-            }
-            state.GameCursorLocation = GameCursor.Location;
-
-            return state;
-        }
-
-        public bool HasAction(GameControllerAction action)
-        {
-            return (Actions & action) == action;
-        }
-
-        private static GamePadState? GetActiveGamePad()
-        {
-            var gamePadState = GamePad.GetState(PlayerIndex.One);
-            if (gamePadState.IsConnected)
-                return gamePadState;
-
-            gamePadState = GamePad.GetState(PlayerIndex.Two);
-            if (gamePadState.IsConnected)
-                return gamePadState;
-
-            gamePadState = GamePad.GetState(PlayerIndex.Three);
-            if (gamePadState.IsConnected)
-                return gamePadState;
-
-            gamePadState = GamePad.GetState(PlayerIndex.Four);
-            if (gamePadState.IsConnected)
-                return gamePadState;
-
-            return null;
-        }
-    }
-}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.