From e0df170a198f6b875fbbe37a7fa8a3c5fdf3aa5c Mon Sep 17 00:00:00 2001 From: Ian C Date: Sun, 29 Apr 2012 23:05:51 +0000 Subject: Adding driver and test project. --- Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo | Bin 50176 -> 50176 bytes Native/EmuKeyboardDesigner/MainForm.cs | 21 ++-- WindowsPhone/KeyboardTest.sln | 66 +++++++++++ WindowsPhone/KeyboardTest.suo | Bin 0 -> 46592 bytes .../KeyboardTest/KeyboardTest/Background.png | Bin 0 -> 12776 bytes WindowsPhone/KeyboardTest/KeyboardTest/Game.ico | Bin 0 -> 4286 bytes WindowsPhone/KeyboardTest/KeyboardTest/Game1.cs | 124 +++++++++++++++++++++ .../KeyboardTest/KeyboardTest/KeyboardTest.csproj | 114 +++++++++++++++++++ .../KeyboardTest/KeyboardTest/PhoneGameThumb.png | Bin 0 -> 3176 bytes WindowsPhone/KeyboardTest/KeyboardTest/Program.cs | 21 ++++ .../KeyboardTest/Properties/AppManifest.xml | 6 + .../KeyboardTest/Properties/AssemblyInfo.cs | 36 ++++++ .../KeyboardTest/Properties/WMAppManifest.xml | 37 ++++++ .../KeyboardTest/KeyboardTest/Spectrum.keyboard | Bin 0 -> 235 bytes .../KeyboardTestContent.contentproj | 47 ++++++++ .../KeyboardTest/KeyboardTestContent/keyboard.png | Bin 0 -> 114056 bytes .../Noddybox.Emulation.Keyboard.Schema.csproj | 70 ++++++++++++ .../Properties/AssemblyInfo.cs | 37 ++++++ .../Noddybox.Emulation.Xna.Keyboard.csproj | 83 ++++++++++++++ .../Properties/AssemblyInfo.cs | 36 ++++++ .../KeyboardDefinition.cs | 62 +++++------ .../KeyboardKey.cs | 61 +++++----- 22 files changed, 743 insertions(+), 78 deletions(-) create mode 100644 WindowsPhone/KeyboardTest.sln create mode 100644 WindowsPhone/KeyboardTest.suo create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Background.png create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Game.ico create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Game1.cs create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/KeyboardTest.csproj create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/PhoneGameThumb.png create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Program.cs create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Properties/AppManifest.xml create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Properties/AssemblyInfo.cs create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Properties/WMAppManifest.xml create mode 100644 WindowsPhone/KeyboardTest/KeyboardTest/Spectrum.keyboard create mode 100644 WindowsPhone/KeyboardTest/KeyboardTestContent/KeyboardTestContent.contentproj create mode 100644 WindowsPhone/KeyboardTest/KeyboardTestContent/keyboard.png create mode 100644 WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Noddybox.Emulation.Keyboard.Schema.csproj create mode 100644 WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Properties/AssemblyInfo.cs create mode 100644 WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Noddybox.Emulation.Xna.Keyboard.csproj create mode 100644 WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Properties/AssemblyInfo.cs diff --git a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo index aa47a7d..db01de5 100644 Binary files a/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo and b/Native/EmuKeyboardDesigner/EmuKeyboardDesigner.suo differ diff --git a/Native/EmuKeyboardDesigner/MainForm.cs b/Native/EmuKeyboardDesigner/MainForm.cs index 36144b9..33ebd22 100644 --- a/Native/EmuKeyboardDesigner/MainForm.cs +++ b/Native/EmuKeyboardDesigner/MainForm.cs @@ -86,17 +86,15 @@ namespace EmuKeyboardDesigner { OpenFileDialog fsel = new OpenFileDialog(); - fsel.Filter = "XML Files(*.XML)|*.XML"; + fsel.Filter = "Keyboard Files (*.keyboard)|*.keyboard"; if (fsel.ShowDialog() == DialogResult.OK) { try { - XmlDocument xml = new XmlDocument(); + BinaryReader stream = new BinaryReader(File.OpenRead(fsel.FileName), Encoding.UTF8); - xml.Load(fsel.FileName); - - KeyboardDefinition def = KeyboardDefinition.CreateFromXML(xml); + KeyboardDefinition def = KeyboardDefinition.Load(stream); keyList.Items.Clear(); @@ -109,6 +107,9 @@ namespace EmuKeyboardDesigner { keyList.SelectedIndex = 0; } + + stream.Close(); + stream.Dispose(); } catch (Exception ex) { @@ -121,7 +122,8 @@ namespace EmuKeyboardDesigner { SaveFileDialog fsel = new SaveFileDialog(); - fsel.Filter = "XML Files(*.XML)|*.XML"; + fsel.Filter = "Keyboard Files (*.keyboard)|*.keyboard"; + fsel.AddExtension = true; if (fsel.ShowDialog() == DialogResult.OK) { @@ -134,9 +136,12 @@ namespace EmuKeyboardDesigner def.Definitions.Add(k); } - XmlDocument doc = def.CreateXML(); + BinaryWriter stream = new BinaryWriter(File.Create(fsel.FileName), Encoding.UTF8); + + def.Save(stream); - doc.Save(fsel.FileName); + stream.Close(); + stream.Dispose(); } catch (Exception ex) { diff --git a/WindowsPhone/KeyboardTest.sln b/WindowsPhone/KeyboardTest.sln new file mode 100644 index 0000000..199f13f --- /dev/null +++ b/WindowsPhone/KeyboardTest.sln @@ -0,0 +1,66 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 Express for Windows Phone +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KeyboardTest", "KeyboardTest\KeyboardTest\KeyboardTest.csproj", "{A645334A-FABE-49EF-85EB-5A13871C266D}" +EndProject +Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "KeyboardTestContent", "KeyboardTest\KeyboardTestContent\KeyboardTestContent.contentproj", "{6BA269E1-4B99-43F2-A140-3454D78F4D17}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Noddybox.Emulation.Keyboard.Schema", "Noddybox.Emulation.Keyboard.Schema\Noddybox.Emulation.Keyboard.Schema.csproj", "{0F5AA96A-9253-4E06-A3F9-5517A2A9C558}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Noddybox.Emulation.Xna.Keyboard", "Noddybox.Emulation.Xna.Keyboard\Noddybox.Emulation.Xna.Keyboard.csproj", "{3B034AAA-A9FD-4307-95F2-D87BE0A51990}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|Windows Phone = Debug|Windows Phone + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|Windows Phone = Release|Windows Phone + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A645334A-FABE-49EF-85EB-5A13871C266D}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Debug|Mixed Platforms.Build.0 = Debug|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Debug|Mixed Platforms.Deploy.0 = Debug|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Debug|Windows Phone.Build.0 = Debug|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Debug|Windows Phone.Deploy.0 = Debug|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Release|Any CPU.ActiveCfg = Release|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Release|Mixed Platforms.ActiveCfg = Release|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Release|Mixed Platforms.Build.0 = Release|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Release|Mixed Platforms.Deploy.0 = Release|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Release|Windows Phone.ActiveCfg = Release|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Release|Windows Phone.Build.0 = Release|Windows Phone + {A645334A-FABE-49EF-85EB-5A13871C266D}.Release|Windows Phone.Deploy.0 = Release|Windows Phone + {6BA269E1-4B99-43F2-A140-3454D78F4D17}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone + {6BA269E1-4B99-43F2-A140-3454D78F4D17}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone + {6BA269E1-4B99-43F2-A140-3454D78F4D17}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone + {6BA269E1-4B99-43F2-A140-3454D78F4D17}.Release|Any CPU.ActiveCfg = Release|Windows Phone + {6BA269E1-4B99-43F2-A140-3454D78F4D17}.Release|Mixed Platforms.ActiveCfg = Release|Windows Phone + {6BA269E1-4B99-43F2-A140-3454D78F4D17}.Release|Windows Phone.ActiveCfg = Release|Windows Phone + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Debug|Windows Phone.ActiveCfg = Debug|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Any CPU.Build.0 = Release|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558}.Release|Windows Phone.ActiveCfg = Release|Any CPU + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Debug|Any CPU.ActiveCfg = Debug|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Debug|Mixed Platforms.ActiveCfg = Debug|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Debug|Mixed Platforms.Build.0 = Debug|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Debug|Windows Phone.Build.0 = Debug|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Release|Any CPU.ActiveCfg = Release|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Release|Mixed Platforms.ActiveCfg = Release|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Release|Mixed Platforms.Build.0 = Release|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Release|Windows Phone.ActiveCfg = Release|Windows Phone + {3B034AAA-A9FD-4307-95F2-D87BE0A51990}.Release|Windows Phone.Build.0 = Release|Windows Phone + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/WindowsPhone/KeyboardTest.suo b/WindowsPhone/KeyboardTest.suo new file mode 100644 index 0000000..9205510 Binary files /dev/null and b/WindowsPhone/KeyboardTest.suo differ diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Background.png b/WindowsPhone/KeyboardTest/KeyboardTest/Background.png new file mode 100644 index 0000000..4af7a5f Binary files /dev/null and b/WindowsPhone/KeyboardTest/KeyboardTest/Background.png differ diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Game.ico b/WindowsPhone/KeyboardTest/KeyboardTest/Game.ico new file mode 100644 index 0000000..8cff41e Binary files /dev/null and b/WindowsPhone/KeyboardTest/KeyboardTest/Game.ico differ diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Game1.cs b/WindowsPhone/KeyboardTest/KeyboardTest/Game1.cs new file mode 100644 index 0000000..e5af385 --- /dev/null +++ b/WindowsPhone/KeyboardTest/KeyboardTest/Game1.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Audio; +using Microsoft.Xna.Framework.Content; +using Microsoft.Xna.Framework.GamerServices; +using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Input; +using Microsoft.Xna.Framework.Input.Touch; +using Microsoft.Xna.Framework.Media; +using Noddybox.Emulation.Xna.Keyboard; +using Noddybox.Emulation.Keyboard.Schema; +using System.IO; + +namespace KeyboardTest +{ + /// + /// This is the main type for your game + /// + public class Game1 : Microsoft.Xna.Framework.Game + { + GraphicsDeviceManager graphics; + SpriteBatch spriteBatch; + Texture2D keyboardImage; + + public enum KeySymbol + { + Key1, + Key2, + Key3, + Key4, + Key5, + Key6, + Key7, + Key8, + Key9, + Key0 + } + + KeyboardDriver keyboard; + + public Game1() + { + graphics = new GraphicsDeviceManager(this); + graphics.SupportedOrientations = DisplayOrientation.Portrait; + + Content.RootDirectory = "Content"; + + // Frame rate is 30 fps by default for Windows Phone. + TargetElapsedTime = TimeSpan.FromTicks(333333); + + // Extend battery life under lock. + InactiveSleepTime = TimeSpan.FromSeconds(1); + } + + /// + /// Allows the game to perform any initialization it needs to before starting to run. + /// This is where it can query for any required services and load any non-graphic + /// related content. Calling base.Initialize will enumerate through any components + /// and initialize them as well. + /// + protected override void Initialize() + { + // TODO: Add your initialization logic here + + base.Initialize(); + } + + /// + /// LoadContent will be called once per game and is the place to load + /// all of your content. + /// + protected override void LoadContent() + { + // Create a new SpriteBatch, which can be used to draw textures. + spriteBatch = new SpriteBatch(GraphicsDevice); + + keyboardImage = Content.Load("keyboard"); + + KeyboardDefinition def; + + using (BinaryReader stream = new BinaryReader(TitleContainer.OpenStream(@"Spectrum.keyboard"))) + { + def = KeyboardDefinition.Load(stream); + } + + keyboard = new KeyboardDriver(keyboardImage, Vector2.Zero, def); + } + + /// + /// UnloadContent will be called once per game and is the place to unload + /// all content. + /// + protected override void UnloadContent() + { + // TODO: Unload any non ContentManager content here + } + + /// + /// Allows the game to run logic such as updating the world, + /// checking for collisions, gathering input, and playing audio. + /// + /// Provides a snapshot of timing values. + protected override void Update(GameTime gameTime) + { + // TODO: Add your update logic here + + base.Update(gameTime); + } + + /// + /// This is called when the game should draw itself. + /// + /// Provides a snapshot of timing values. + protected override void Draw(GameTime gameTime) + { + graphics.GraphicsDevice.Clear(Color.PaleVioletRed); + spriteBatch.Begin(); + keyboard.Draw(spriteBatch); + spriteBatch.End(); + } + } +} diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/KeyboardTest.csproj b/WindowsPhone/KeyboardTest/KeyboardTest/KeyboardTest.csproj new file mode 100644 index 0000000..fedeed5 --- /dev/null +++ b/WindowsPhone/KeyboardTest/KeyboardTest/KeyboardTest.csproj @@ -0,0 +1,114 @@ + + + + {A645334A-FABE-49EF-85EB-5A13871C266D} + {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + Windows Phone + Library + Properties + KeyboardTest + KeyboardTest + v4.0 + Client + v4.0 + Windows Phone + Reach + dce4fe6e-26f4-43cf-971c-31f6e78066c4 + Game + 1 + false + $(AssemblyName).xap + Properties\AppManifest.xml + Properties\WMAppManifest.xml + Background.png + KeyboardTest + + + Game.ico + PhoneGameThumb.png + + + true + full + false + bin\Windows Phone\Debug + DEBUG;TRACE;WINDOWS_PHONE + prompt + 4 + true + false + false + + + pdbonly + true + bin\Windows Phone\Release + TRACE;WINDOWS_PHONE + prompt + 4 + true + false + false + + + + + + + + + + + + + + + + + + true + + + true + + + + + PreserveNewest + + + + + + true + + + true + + + + + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558} + Noddybox.Emulation.Keyboard.Schema + + + {3B034AAA-A9FD-4307-95F2-D87BE0A51990} + Noddybox.Emulation.Xna.Keyboard + + + KeyboardTestContent + Content + + + + + + \ No newline at end of file diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/PhoneGameThumb.png b/WindowsPhone/KeyboardTest/KeyboardTest/PhoneGameThumb.png new file mode 100644 index 0000000..a45f4db Binary files /dev/null and b/WindowsPhone/KeyboardTest/KeyboardTest/PhoneGameThumb.png differ diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Program.cs b/WindowsPhone/KeyboardTest/KeyboardTest/Program.cs new file mode 100644 index 0000000..66a93da --- /dev/null +++ b/WindowsPhone/KeyboardTest/KeyboardTest/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace KeyboardTest +{ +#if WINDOWS || XBOX + static class Program + { + /// + /// The main entry point for the application. + /// + static void Main(string[] args) + { + using (Game1 game = new Game1()) + { + game.Run(); + } + } + } +#endif +} + diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Properties/AppManifest.xml b/WindowsPhone/KeyboardTest/KeyboardTest/Properties/AppManifest.xml new file mode 100644 index 0000000..a955232 --- /dev/null +++ b/WindowsPhone/KeyboardTest/KeyboardTest/Properties/AppManifest.xml @@ -0,0 +1,6 @@ + + + + diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Properties/AssemblyInfo.cs b/WindowsPhone/KeyboardTest/KeyboardTest/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..505e65f --- /dev/null +++ b/WindowsPhone/KeyboardTest/KeyboardTest/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("KeyboardTest")] +[assembly: AssemblyProduct("KeyboardTest")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. Only Windows +// assemblies support COM. +[assembly: ComVisible(false)] + +// On Windows, the following GUID is for the ID of the typelib if this +// project is exposed to COM. On other platforms, it unique identifies the +// title storage container when deploying this assembly to the device. +[assembly: Guid("a8941355-2750-4e06-9666-7861504db51c")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("en-US")] \ No newline at end of file diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Properties/WMAppManifest.xml b/WindowsPhone/KeyboardTest/KeyboardTest/Properties/WMAppManifest.xml new file mode 100644 index 0000000..0b6b828 --- /dev/null +++ b/WindowsPhone/KeyboardTest/KeyboardTest/Properties/WMAppManifest.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + + + + + + + diff --git a/WindowsPhone/KeyboardTest/KeyboardTest/Spectrum.keyboard b/WindowsPhone/KeyboardTest/KeyboardTest/Spectrum.keyboard new file mode 100644 index 0000000..2607d6c Binary files /dev/null and b/WindowsPhone/KeyboardTest/KeyboardTest/Spectrum.keyboard differ diff --git a/WindowsPhone/KeyboardTest/KeyboardTestContent/KeyboardTestContent.contentproj b/WindowsPhone/KeyboardTest/KeyboardTestContent/KeyboardTestContent.contentproj new file mode 100644 index 0000000..3ed205e --- /dev/null +++ b/WindowsPhone/KeyboardTest/KeyboardTestContent/KeyboardTestContent.contentproj @@ -0,0 +1,47 @@ + + + + {6BA269E1-4B99-43F2-A140-3454D78F4D17} + {96E2B04D-8817-42c6-938A-82C39BA4D311};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + x86 + Library + Properties + v4.0 + v4.0 + bin\$(Platform)\$(Configuration) + Content + + + x86 + + + x86 + + + KeyboardTestContent + + + + + + + + + + + + keyboard + TextureImporter + TextureProcessor + + + + + \ No newline at end of file diff --git a/WindowsPhone/KeyboardTest/KeyboardTestContent/keyboard.png b/WindowsPhone/KeyboardTest/KeyboardTestContent/keyboard.png new file mode 100644 index 0000000..a607364 Binary files /dev/null and b/WindowsPhone/KeyboardTest/KeyboardTestContent/keyboard.png differ diff --git a/WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Noddybox.Emulation.Keyboard.Schema.csproj b/WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Noddybox.Emulation.Keyboard.Schema.csproj new file mode 100644 index 0000000..3ba4e63 --- /dev/null +++ b/WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Noddybox.Emulation.Keyboard.Schema.csproj @@ -0,0 +1,70 @@ + + + + Debug + AnyCPU + 10.0.20506 + 2.0 + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558} + {C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc} + Library + Properties + Noddybox.Emulation.Keyboard.Schema + Noddybox.Emulation.Keyboard.Schema + v4.0 + $(TargetFrameworkVersion) + WindowsPhone71 + Silverlight + false + true + true + + + true + full + false + Bin\Debug + DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + pdbonly + true + Bin\Release + TRACE;SILVERLIGHT;WINDOWS_PHONE + true + true + prompt + 4 + + + + + + + + + + + + KeyboardDefinition.cs + + + KeyboardKey.cs + + + + + + + + \ No newline at end of file diff --git a/WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Properties/AssemblyInfo.cs b/WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..defbfae --- /dev/null +++ b/WindowsPhone/Noddybox.Emulation.Keyboard.Schema/Properties/AssemblyInfo.cs @@ -0,0 +1,37 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Noddybox.Emulation.Keyboard.Schema")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Noddybox.Emulation.Keyboard.Schema")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("5a9db641-2d92-4b2e-b125-79ab0bbb44c9")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("en-US")] diff --git a/WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Noddybox.Emulation.Xna.Keyboard.csproj b/WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Noddybox.Emulation.Xna.Keyboard.csproj new file mode 100644 index 0000000..92eefd7 --- /dev/null +++ b/WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Noddybox.Emulation.Xna.Keyboard.csproj @@ -0,0 +1,83 @@ + + + + {3B034AAA-A9FD-4307-95F2-D87BE0A51990} + {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + Windows Phone + Library + Properties + Noddybox.Emulation.Xna.Keyboard + Noddybox.Emulation.Xna.Keyboard + v4.0 + Client + v4.0 + Windows Phone + Reach + 2f332963-aa65-41d2-a897-d8dba47bb8f4 + Library + 1 + + + true + full + false + bin\Windows Phone\Debug + DEBUG;TRACE;WINDOWS_PHONE + prompt + 4 + true + false + false + + + pdbonly + true + bin\Windows Phone\Release + TRACE;WINDOWS_PHONE + prompt + 4 + true + false + false + + + + + + + + + + + + 4.0 + + + 4.0 + + + + + + KeyboardDriver.cs + + + + + + {0F5AA96A-9253-4E06-A3F9-5517A2A9C558} + Noddybox.Emulation.Keyboard.Schema + + + + + + \ No newline at end of file diff --git a/WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Properties/AssemblyInfo.cs b/WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6579f5a --- /dev/null +++ b/WindowsPhone/Noddybox.Emulation.Xna.Keyboard/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Resources; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Noddybox.Emulation.Xna.Keyboard")] +[assembly: AssemblyProduct("Noddybox.Emulation.Xna.Keyboard")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyCopyright("Copyright © 2012")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. Only Windows +// assemblies support COM. +[assembly: ComVisible(false)] + +// On Windows, the following GUID is for the ID of the typelib if this +// project is exposed to COM. On other platforms, it unique identifies the +// title storage container when deploying this assembly to the device. +[assembly: Guid("c95f04eb-9a91-4c45-8b47-9a60b904e7f3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: NeutralResourcesLanguageAttribute("en-US")] \ No newline at end of file diff --git a/src/Noddybox.Emulation.Keyboard.Schema/KeyboardDefinition.cs b/src/Noddybox.Emulation.Keyboard.Schema/KeyboardDefinition.cs index 5ca3f47..10a1c51 100644 --- a/src/Noddybox.Emulation.Keyboard.Schema/KeyboardDefinition.cs +++ b/src/Noddybox.Emulation.Keyboard.Schema/KeyboardDefinition.cs @@ -16,7 +16,7 @@ // Copyright (c) 2012 Ian Cowburn // using System; -using System.Xml; +using System.IO; using System.Collections.Generic; namespace Noddybox.Emulation.Keyboard.Schema @@ -26,6 +26,12 @@ namespace Noddybox.Emulation.Keyboard.Schema /// public class KeyboardDefinition { + #region Version + + private const string magic = "KEYBDEF1.0"; + + #endregion + #region Properties /// @@ -35,57 +41,45 @@ namespace Noddybox.Emulation.Keyboard.Schema #endregion - #region Xml functions + #region Load/Save /// - /// Create the XML for this keyboard definition. + /// Save this keybaord definition to the stream. /// - /// The created XML document. - public XmlDocument CreateXML() + /// The stream to write to. + public void Save(BinaryWriter stream) { - XmlDocument doc = new XmlDocument(); - - doc.AppendChild(doc.CreateXmlDeclaration("1.0", null, null)); - doc.AppendChild(doc.CreateElement("Keyboard")); - + stream.Write(magic); + stream.Write(Definitions.Count); + foreach (KeyboardKey k in Definitions) { - XmlElement e = doc.CreateElement("Key"); - k.SetElement(e); - doc.DocumentElement.AppendChild(e); + k.Save(stream); } - - return doc; } /// - /// Create an object from XML. + /// Load a keyboard definition from the passed stream. /// - /// The XML document to load from. - /// The created object. - public static KeyboardDefinition CreateFromXML(XmlDocument doc) + /// The stream to read from. + /// The KeyboardDefinition object. + public static KeyboardDefinition Load(BinaryReader stream) { - KeyboardDefinition definition = new KeyboardDefinition(); - - if (doc.DocumentElement.Name != "Keyboard") + if (stream.ReadString() != magic) { - throw new ArgumentException("Root element not a keyboard"); + throw new ArgumentException("Stream has wrong magic"); } - foreach (XmlNode n in doc.DocumentElement.ChildNodes) + KeyboardDefinition keyboard = new KeyboardDefinition(); + + int count = stream.ReadInt32(); + + for(int f = 0; f < count ; f++) { - if (n is XmlElement) - { - XmlElement e = (XmlElement)n; - - if (e.Name == "Key") - { - definition.Definitions.Add(KeyboardKey.CreateFromElement(e)); - } - } + keyboard.Definitions.Add(KeyboardKey.Load(stream)); } - return definition; + return keyboard; } #endregion diff --git a/src/Noddybox.Emulation.Keyboard.Schema/KeyboardKey.cs b/src/Noddybox.Emulation.Keyboard.Schema/KeyboardKey.cs index 6dac9b1..501fd2f 100644 --- a/src/Noddybox.Emulation.Keyboard.Schema/KeyboardKey.cs +++ b/src/Noddybox.Emulation.Keyboard.Schema/KeyboardKey.cs @@ -16,7 +16,7 @@ // Copyright (c) 2012 Ian Cowburn // using System; -using System.Xml; +using System.IO; namespace Noddybox.Emulation.Keyboard.Schema { @@ -61,50 +61,39 @@ namespace Noddybox.Emulation.Keyboard.Schema #endregion - #region Xml members + #region Load/Save /// - /// Set up an XmlElement with the contents of this object. + /// Save this object to a stream. /// - /// The document the element is to be attached to. - public void SetElement(XmlElement element) + /// The stream to write to. + public void Save(BinaryWriter stream) { - element.SetAttribute("KeySymbol", KeySymbol); - element.SetAttribute("X", X.ToString()); - element.SetAttribute("Y", Y.ToString()); - element.SetAttribute("Width", Width.ToString()); - element.SetAttribute("Height", Height.ToString()); - element.SetAttribute("Sticky", Sticky.ToString()); + stream.Write(KeySymbol); + stream.Write(X); + stream.Write(Y); + stream.Write(Width); + stream.Write(Height); + stream.Write(Sticky); } /// - /// Create an instance of this object from an XmlElement. + /// Create an instance of this object from a stream. /// - /// The document the element is to be attached to. - /// The XML element. - public static KeyboardKey CreateFromElement(XmlElement element) + /// The stream to read from. + /// The KeyboardKey object. + public static KeyboardKey Load(BinaryReader stream) { - XmlAttribute symbol = element.Attributes["KeySymbol"]; - XmlAttribute x = element.Attributes["X"]; - XmlAttribute y = element.Attributes["Y"]; - XmlAttribute width = element.Attributes["Width"]; - XmlAttribute height = element.Attributes["Height"]; - XmlAttribute sticky = element.Attributes["Sticky"]; - - if (symbol == null || x == null || y == null || width == null || height == null || sticky == null) - { - throw new ArgumentException("Element does not contain expected attributes"); - } - - return new KeyboardKey() - { - KeySymbol = symbol.Value, - X = Convert.ToInt32(x.Value), - Y = Convert.ToInt32(y.Value), - Width = Convert.ToInt32(width.Value), - Height = Convert.ToInt32(height.Value), - Sticky = Convert.ToBoolean(sticky.Value) - }; + KeyboardKey key = new KeyboardKey(); + + key.KeySymbol = stream.ReadString(); + key.X = stream.ReadInt32(); + key.Y = stream.ReadInt32(); + key.Width = stream.ReadInt32(); + key.Height = stream.ReadInt32(); + key.Sticky = stream.ReadBoolean(); + + return key; } #endregion -- cgit v1.2.3