From a6a7d2161239443d524be84cf39ba66a8d8bfaf9 Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Thu, 1 Dec 2011 09:16:01 +0000 Subject: [PATCH] - renamed ANX.InputSystemS.Windows.Recording to ANX.Input.System.Recording --- .../ANX.InputSystem.Recording.csproj | 76 +++++++ .../ANX.InputSystem.Recording/Creator.cs | 108 ++++++++++ .../Metadata.Designer.cs | 72 +++++++ .../ANX.InputSystem.Recording/Metadata.resx | 123 +++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++ .../RecordableDevice.cs | 197 ++++++++++++++++++ .../RecordingGamePad.cs | 86 ++++++++ .../RecordingHelper.cs | 87 ++++++++ .../RecordingKeyboard.cs | 82 ++++++++ .../RecordingMotionSensingDevice.cs | 97 +++++++++ .../RecordingMouse.cs | 130 ++++++++++++ 11 files changed, 1094 insertions(+) create mode 100644 InputSystems/ANX.InputSystem.Recording/ANX.InputSystem.Recording.csproj create mode 100644 InputSystems/ANX.InputSystem.Recording/Creator.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/Metadata.Designer.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/Metadata.resx create mode 100644 InputSystems/ANX.InputSystem.Recording/Properties/AssemblyInfo.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/RecordableDevice.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/RecordingGamePad.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/RecordingHelper.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/RecordingKeyboard.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/RecordingMotionSensingDevice.cs create mode 100644 InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs diff --git a/InputSystems/ANX.InputSystem.Recording/ANX.InputSystem.Recording.csproj b/InputSystems/ANX.InputSystem.Recording/ANX.InputSystem.Recording.csproj new file mode 100644 index 00000000..32d063c9 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/ANX.InputSystem.Recording.csproj @@ -0,0 +1,76 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {DB88DDEB-7281-405D-8FCA-5681B6B2BD7A} + Library + Properties + ANX.InputSystem.Recording + ANX.InputSystem.Recording + v4.0 + 512 + + + true + full + false + ..\..\bin\Debug\ + TRACE;DEBUG;XNAEXT + prompt + 4 + + + pdbonly + true + ..\..\bin\Release\ + TRACE;XNAEXT + prompt + 4 + + + + + + + + + + + + + Metadata.resx + True + True + + + + + + + + + + + + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35} + ANX.Framework + + + + + PublicResXFileCodeGenerator + Metadata.Designer.cs + + + + + \ No newline at end of file diff --git a/InputSystems/ANX.InputSystem.Recording/Creator.cs b/InputSystems/ANX.InputSystem.Recording/Creator.cs new file mode 100644 index 00000000..eeb68018 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/Creator.cs @@ -0,0 +1,108 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.InputSystem.Recording +{ + public class Creator : IInputSystemCreator + { + public IGamePad GamePad + { + get { return new RecordingGamePad(); } + } + + public IMouse Mouse + { + get { return new RecordingMouse(); } + } + + public IKeyboard Keyboard + { + get { return new RecordingKeyboard(); } + } + +#if XNAEXT + public IMotionSensingDevice MotionSensingDevice + { + get { return new RecordingMotionSensingDevice(); } + } +#endif + + public void RegisterCreator(AddInSystemFactory factory) + { + factory.AddCreator(this); + } + + public string Name + { + get { return "Recording"; } + } + + public int Priority + { + get { return int.MaxValue; } + } + + public bool IsSupported + { + get + { + //TODO: this is just a very basic version of test for support + return AddInSystemFactory.Instance.OperatingSystem.Platform == PlatformID.Win32NT; + } + } + + } +} diff --git a/InputSystems/ANX.InputSystem.Recording/Metadata.Designer.cs b/InputSystems/ANX.InputSystem.Recording/Metadata.Designer.cs new file mode 100644 index 00000000..101f0079 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/Metadata.Designer.cs @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.239 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace ANX.InputSystem.Recording { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Metadata { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Metadata() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ANX.InputSystem.Recording.Metadata", typeof(Metadata).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Win32NT ähnelt. + /// + public static string SupportedPlatforms { + get { + return ResourceManager.GetString("SupportedPlatforms", resourceCulture); + } + } + } +} diff --git a/InputSystems/ANX.InputSystem.Recording/Metadata.resx b/InputSystems/ANX.InputSystem.Recording/Metadata.resx new file mode 100644 index 00000000..c90f8c84 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/Metadata.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Win32NT + + \ No newline at end of file diff --git a/InputSystems/ANX.InputSystem.Recording/Properties/AssemblyInfo.cs b/InputSystems/ANX.InputSystem.Recording/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a6c23285 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("ANX.InputSystems.Windows.Recording")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("ANX.Framework Team")] +[assembly: AssemblyProduct("ANX.InputSystems.Windows.Recording")] +[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("cbb5cead-130a-4ede-9257-8fc816f95935")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("0.0.1.0")] +[assembly: AssemblyFileVersion("0.0.1.0")] diff --git a/InputSystems/ANX.InputSystem.Recording/RecordableDevice.cs b/InputSystems/ANX.InputSystem.Recording/RecordableDevice.cs new file mode 100644 index 00000000..daa8b76e --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/RecordableDevice.cs @@ -0,0 +1,197 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.InputSystem.Recording +{ + /// + /// Abstract Class. Classes derived from this class allow recording and Playback of Inputs. + /// + public abstract class RecordableDevice + { + protected Stream recordStream; //The stream where the input is written to + protected int nullStateCounter; //Used to sum up frames with no input. + + public RecordingState RecordingState { get; protected set; } + + public event EventHandler EndOfPlaybackReached; + + /// + /// How many bytes this Instance requires per Frame. Must never change! + /// + public int FramePacketLenght { get; protected set; } + + public RecordableDevice() + { + RecordingState = RecordingState.None; + } + + /// + /// Initializes the Device using a new + /// MemoryStream for input-buffering. + /// + public virtual void Initialize() + { + Initialize(new MemoryStream()); + } + + /// + /// Initializes the Device using the specified stream + /// for input-buffering. + /// + public virtual void Initialize(Stream bufferStream) + { + recordStream = bufferStream; + } + + public virtual void StartRecording() + { + if (RecordingState == RecordingState.Recording) + return; + + RecordingState = RecordingState.Recording; + } + + public virtual void StopRecording() + { + if (RecordingState != RecordingState.Recording) + throw new InvalidOperationException("Recording wasn't started for this device!"); + + RecordingState = RecordingState.None; + } + + public virtual void StartPlayback() + { + if (RecordingState == RecordingState.Recording) + throw new InvalidOperationException("Recording is currently running for this device."); + + RecordingState = RecordingState.Playback; + } + + public virtual void StopPlayback() + { + RecordingState = RecordingState.None; + } + + /// + /// Writes the current input state to the buffering stream. Pass null + /// for state, if no input is done (no keys down etc.). + /// Must be called once per Frame! + /// + protected virtual void WriteState(byte[] state) + { + if (state == null) + { + nullStateCounter++; + return; + } + + if (state.Length != FramePacketLenght) + throw new InvalidOperationException("The passed state's lenght does not match the speficed FramePaketLenght."); + + if (nullStateCounter > 0) //Note how many packets we had nothing + { + recordStream.WriteByte((byte)PacketType.NullFrameCounter); + recordStream.Write(BitConverter.GetBytes(nullStateCounter), 0, 4); + } + + recordStream.WriteByte((byte)PacketType.InputData); + recordStream.Write(state, 0, state.Length); + } + + /// + /// Reads the next input-state from the buffering stream. Might + /// return null, if no input was made in this frame. + /// Must be called once per Frame! + /// + protected virtual byte[] ReadState() + { + if (nullStateCounter > 0) //we have null-states pending + { + nullStateCounter--; + return null; + } + + if (recordStream.Position == recordStream.Length) + { + OnEndOfPlaybackReached(); + return null; //TODO: Better switch to RecordingState.None here? + } + + PacketType type = (PacketType)recordStream.ReadByte(); + switch (type) + { + case PacketType.NullFrameCounter: + byte[] buffer = new byte[4]; + recordStream.Read(buffer, 0, 4); + nullStateCounter = BitConverter.ToInt32(buffer, 0) - 1; + return null; + case PacketType.InputData: + byte[] buffer2 = new byte[FramePacketLenght]; + recordStream.Read(buffer2, 0, FramePacketLenght); + return buffer2; + default: + throw new NotImplementedException("The PaketType " + Enum.GetName(typeof(PacketType), type) + "is not supported."); + } + + } + + protected virtual void OnEndOfPlaybackReached() + { + if (EndOfPlaybackReached != null) + EndOfPlaybackReached(this, EventArgs.Empty); + } + } +} diff --git a/InputSystems/ANX.InputSystem.Recording/RecordingGamePad.cs b/InputSystems/ANX.InputSystem.Recording/RecordingGamePad.cs new file mode 100644 index 00000000..a81c864e --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/RecordingGamePad.cs @@ -0,0 +1,86 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using ANX.Framework.Input; +using ANX.Framework; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.InputSystem.Recording +{ + /// + /// Wrapper arround another IGamePad, will record all inputs and allows playback. + /// + public class RecordingGamePad : RecordableDevice, IGamePad + { + public GamePadCapabilities GetCapabilities(PlayerIndex playerIndex) + { + throw new NotImplementedException(); + } + + public GamePadState GetState(PlayerIndex playerIndex, out bool isConnected, out int packetNumber) + { + throw new NotImplementedException(); + } + + public GamePadState GetState(PlayerIndex playerIndex, Framework.Input.GamePadDeadZone deadZoneMode, out bool isConnected, out int packetNumber) + { + throw new NotImplementedException(); + } + + public bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor) + { + throw new NotImplementedException(); + } + } +} diff --git a/InputSystems/ANX.InputSystem.Recording/RecordingHelper.cs b/InputSystems/ANX.InputSystem.Recording/RecordingHelper.cs new file mode 100644 index 00000000..9b2c60f8 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/RecordingHelper.cs @@ -0,0 +1,87 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.InputSystem.Recording +{ + public enum RecordingState + { + /// + /// This device is recording input. + /// + Recording, + /// + /// This device plays back recorded input. + /// + Playback, + /// + /// Playback and Recording paused, the current values will be passed through. + /// + None + } + + enum PacketType : byte + { + NullFrameCounter = 0, + InputData = 1 + } + + /// + /// Static Helper-class containing some recording related stuff. + /// + static class RecordingHelper + { + + } +} diff --git a/InputSystems/ANX.InputSystem.Recording/RecordingKeyboard.cs b/InputSystems/ANX.InputSystem.Recording/RecordingKeyboard.cs new file mode 100644 index 00000000..b752601c --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/RecordingKeyboard.cs @@ -0,0 +1,82 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using ANX.Framework; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.InputSystem.Recording +{ + /// + /// Wrapper arround another IKeyboard, will record all inputs and allows playback. + /// + public class RecordingKeyboard : RecordableDevice, IKeyboard + { + public IntPtr WindowHandle { get; set; } + + public Framework.Input.KeyboardState GetState() + { + throw new NotImplementedException(); + } + + public Framework.Input.KeyboardState GetState(PlayerIndex playerIndex) + { + throw new NotImplementedException(); + } + + public void Dispose() + { + throw new NotImplementedException(); + } + } +} diff --git a/InputSystems/ANX.InputSystem.Recording/RecordingMotionSensingDevice.cs b/InputSystems/ANX.InputSystem.Recording/RecordingMotionSensingDevice.cs new file mode 100644 index 00000000..ba65c734 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/RecordingMotionSensingDevice.cs @@ -0,0 +1,97 @@ +#if XNAEXT + +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using ANX.Framework.Graphics; +using ANX.Framework.Input.MotionSensing; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.InputSystem.Recording +{ + /// + /// Wrapper aroung another IMotionSensingDevice, will record all inputs and allows playback. + /// + public class RecordingMotionSensingDevice : RecordableDevice, IMotionSensingDevice + { + public GraphicsDevice GraphicsDevice + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public MotionSensingDeviceType DeviceType + { + get { throw new NotImplementedException(); } + } + + public MotionSensingDeviceState GetState() + { + throw new NotImplementedException(); + } + + public void Dispose() + { + throw new NotImplementedException(); + } + } +} + +#endif \ No newline at end of file diff --git a/InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs b/InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs new file mode 100644 index 00000000..f660a194 --- /dev/null +++ b/InputSystems/ANX.InputSystem.Recording/RecordingMouse.cs @@ -0,0 +1,130 @@ +#region Using Statements +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using ANX.Framework.NonXNA; +using ANX.Framework.Input; +using System.IO; + +#endregion + +#region License + +// +// This file is part of the ANX.Framework created by the "ANX.Framework developer group". +// +// This file is released under the Ms-PL license. +// +// +// +// Microsoft Public License (Ms-PL) +// +// This license governs use of the accompanying software. If you use the software, you accept this license. +// If you do not accept the license, do not use the software. +// +// 1.Definitions +// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning +// here as under U.S. copyright law. +// A "contribution" is the original software, or any additions or changes to the software. +// A "contributor" is any person that distributes its contribution under this license. +// "Licensed patents" are a contributor's patent claims that read directly on its contribution. +// +// 2.Grant of Rights +// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations +// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to +// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution +// or any derivative works that you create. +// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in +// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed +// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution +// in the software or derivative works of the contribution in the software. +// +// 3.Conditions and Limitations +// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. +// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your +// patent license from such contributor to the software ends automatically. +// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution +// notices that are present in the software. +// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including +// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or +// object code form, you may only do so under a license that complies with this license. +// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees, +// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the +// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a +// particular purpose and non-infringement. + +#endregion // License + +namespace ANX.InputSystem.Recording +{ + [Flags] + public enum MouseRecordInfo : byte + { + LeftButton = 1, + RightButton = 2, + MiddleButton = 4, + X1Button = 8, + X2Button = 16, + ScrollWheel = 32, + XPosition = 64, + YPosition = 128, + LRMButtons = LeftButton | RightButton | MiddleButton, + XButtons = X1Button | X2Button, + AllButtons = LRMButtons | XButtons, + Position = XPosition | YPosition, + All = AllButtons | Position | ScrollWheel + } + + /// + /// Wrapper arround another IGamePad, will record all inputs and allows playback. + /// + public class RecordingMouse : RecordableDevice, IMouse + { + public IntPtr WindowHandle { get; set; } + + public MouseState GetState() + { + throw new NotImplementedException(); + } + + public void SetPosition(int x, int y) + { + throw new NotImplementedException(); + } + + public void Initialize(MouseRecordInfo info) + { + base.Initialize(); + } + + public void Initialize(MouseRecordInfo info, Stream bufferStream) + { + base.Initialize(bufferStream); + } + + private int GetPaketSize(MouseRecordInfo info) + { + int ret = 0; //TODO: Pack the bools in one byte to save space sizeof(bool) == sizeof(byte)! + if (info.HasFlag(MouseRecordInfo.LeftButton)) + ret += sizeof(bool); + if (info.HasFlag(MouseRecordInfo.RightButton)) + ret += sizeof(bool); + if (info.HasFlag(MouseRecordInfo.MiddleButton)) + ret += sizeof(bool); + if (info.HasFlag(MouseRecordInfo.X1Button)) + ret += sizeof(bool); + if (info.HasFlag(MouseRecordInfo.X2Button)) + ret += sizeof(bool); + + if (info.HasFlag(MouseRecordInfo.XPosition)) + ret += sizeof(int); + if (info.HasFlag(MouseRecordInfo.YPosition)) + ret += sizeof(int); + if (info.HasFlag(MouseRecordInfo.ScrollWheel)) + ret += sizeof(int); + + return ret; + } + } +}