Updating support for XNACC

Note: It is only for Windows currently

--HG--
branch : xnacc-integration
This commit is contained in:
Nathan Adams 2012-05-26 18:36:11 -05:00
parent 1c897e7530
commit e9e97dae39
5 changed files with 69 additions and 4 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView> <ProjectView>ProjectFiles</ProjectView>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -91,6 +91,7 @@
* - Fixing bug where loadrecentangleitem wouldn't be called by Gleed2D library * - Fixing bug where loadrecentangleitem wouldn't be called by Gleed2D library
* - Changing AxiosTitleFile.GetStream() to return Stream instead of FileStream * - Changing AxiosTitleFile.GetStream() to return Stream instead of FileStream
* - Changing IAxiosFile.GetStream() to return Stream instead of FileStream * - Changing IAxiosFile.GetStream() to return Stream instead of FileStream
* - Adding support for XNACC
* *
*/ */
#endregion #endregion

View File

@ -15,6 +15,11 @@ using Microsoft.Xna.Framework.Input.Touch;
using FarseerPhysics.SamplesFramework; using FarseerPhysics.SamplesFramework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
#if WINDOWS
using XNACC.BaseTypes;
#endif
using System.Linq;
namespace GameStateManagement namespace GameStateManagement
{ {
@ -37,8 +42,46 @@ namespace GameStateManagement
/// query methods for high level input actions such as "move up through the menu" /// query methods for high level input actions such as "move up through the menu"
/// or "pause the game". /// or "pause the game".
/// </summary> /// </summary>
#if WINDOWS
public class InputState : IConsoleKeyboard
#else
public class InputState public class InputState
#endif
{ {
#if WINDOWS
#region XNACC
/*
* These are needed for XNACC
* -- Nathan Adams [adamsna@datanethost.net] - 5/26/2012
*/
private KeyboardState KeyState;
private List<Keys> newlyPressedKeys = new List<Keys>();
private List<Keys> heldKeys = new List<Keys>();
private Keys[] oldPressedKeys;
private Keys[] newPressedKeys;
public KeyboardState CurrentKeyboardState
{
get { return KeyState; }
}
public IList<Keys> NewlyPressedKeys
{
get { return newlyPressedKeys; }
}
public IList<Keys> HeldKeys
{
get { return heldKeys; }
}
/*
* End XNACC variables
*/
#endregion
#endif
public const int MaxInputs = 4; public const int MaxInputs = 4;
public readonly KeyboardState[] CurrentKeyboardStates; public readonly KeyboardState[] CurrentKeyboardStates;
@ -270,6 +313,27 @@ namespace GameStateManagement
/// </summary> /// </summary>
public void Update(GameTime gameTime) public void Update(GameTime gameTime)
{ {
#if WINDOWS
#region XNACC
KeyState = Keyboard.GetState();
oldPressedKeys = newPressedKeys;
newPressedKeys = KeyState.GetPressedKeys();
newlyPressedKeys.Clear();
heldKeys.Clear();
foreach (Keys key in newPressedKeys)
{
if (oldPressedKeys.Contains(key))
heldKeys.Add(key);
else
newlyPressedKeys.Add(key);
}
#endregion
#endif
//PlayerIndex p; //PlayerIndex p;
_lastMouseState = _currentMouseState; _lastMouseState = _currentMouseState;
if (_handleVirtualStick) if (_handleVirtualStick)

View File

@ -11,7 +11,7 @@ using System.Threading;
using System.IO; using System.IO;
using System.ComponentModel; using System.ComponentModel;
using System.Reflection; using System.Reflection;
using JRTS.XNA.Console.BaseTypes; using XNACC.BaseTypes;
using System.Diagnostics; using System.Diagnostics;
#endif #endif
#endregion #endregion
@ -71,7 +71,7 @@ using System.Diagnostics;
//NA: Seriously Microsoft? //NA: Seriously Microsoft?
#if WINDOWS #if WINDOWS
/// <summary>Namespace that contains code related to the XNACC (CommandConsole) component</summary> /// <summary>Namespace that contains code related to the XNACC (CommandConsole) component</summary>
namespace JRTS.XNA.Console namespace XNACC.Console
{ {
/// <summary>Base functionality of the XNACC (CommandConsole) component</summary> /// <summary>Base functionality of the XNACC (CommandConsole) component</summary>
public class CommandConsoleBase : DrawableGameComponent public class CommandConsoleBase : DrawableGameComponent

View File

@ -6,7 +6,7 @@ using Microsoft.Xna.Framework.Input;
#if WINDOWS #if WINDOWS
/// <summary>Namespace that contains shared types related to the XNACC (CommandConsole) component</summary> /// <summary>Namespace that contains shared types related to the XNACC (CommandConsole) component</summary>
namespace JRTS.XNA.Console.BaseTypes namespace XNACC.BaseTypes
{ {
#region IConsoleKeyboard #region IConsoleKeyboard
/// <summary>Basic keyboard/input functionality required by the CommandConsole(Base) class</summary> /// <summary>Basic keyboard/input functionality required by the CommandConsole(Base) class</summary>