From 972f7121e84c2a76f358ce6896363da42f0f7c91 Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Fri, 11 Nov 2011 15:21:41 +0000 Subject: [PATCH] renamed CurrentCreator to DefaultCreator project wide extended InputSystem selector in WindowsGame sample fixed some interface issues in XInput InputSystem added FormatConvert to InputSystem XInput to translate GamePadButtons from XInput to ANX --- ANX.Framework/Game.cs | 14 ++-- ANX.Framework/Graphics/BlendState.cs | 4 +- ANX.Framework/Graphics/DepthStencilState.cs | 4 +- ANX.Framework/Graphics/Effect.cs | 2 +- ANX.Framework/Graphics/GraphicsAdapter.cs | 2 +- ANX.Framework/Graphics/GraphicsDevice.cs | 2 +- ANX.Framework/Graphics/IndexBuffer.cs | 4 +- ANX.Framework/Graphics/RasterizerState.cs | 4 +- ANX.Framework/Graphics/SamplerState.cs | 4 +- ANX.Framework/Graphics/SpriteBatch.cs | 2 +- ANX.Framework/Graphics/Texture2D.cs | 2 +- ANX.Framework/Graphics/VertexBuffer.cs | 2 +- ANX.Framework/Input/GamePad.cs | 2 +- .../MotionSensing/MotionSensingDevice.cs | 2 +- ANX.Framework/Input/Mouse.cs | 2 +- ANX.Framework/NonXNA/AddInSystemFactory.cs | 16 ++-- .../ANX.InputSystem.Windows.XInput.csproj | 1 + .../FormatConverter.cs | 81 +++++++++++++++++++ ANX.InputSystem.Windows.XInput/GamePad.cs | 2 +- Samples/WindowsGame/AddInSelector.Designer.cs | 39 +++++---- Samples/WindowsGame/AddInSelector.cs | 4 +- Samples/WindowsGame/Program.cs | 2 +- Samples/WindowsGame/WindowsGame.csproj | 4 + 23 files changed, 143 insertions(+), 58 deletions(-) create mode 100644 ANX.InputSystem.Windows.XInput/FormatConverter.cs diff --git a/ANX.Framework/Game.cs b/ANX.Framework/Game.cs index f5d0393d..06231a3b 100644 --- a/ANX.Framework/Game.cs +++ b/ANX.Framework/Game.cs @@ -103,29 +103,29 @@ namespace ANX.Framework AddInSystemFactory.Instance.Initialize(); - AddInSystemFactory.Instance.SetCurrentCreator(inputSystemName); - IInputSystemCreator inputSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator(); + AddInSystemFactory.Instance.SetDefaultCreator(inputSystemName); + IInputSystemCreator inputSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator(); if (inputSystemCreator != null) { this.gameServices.AddService(typeof(IInputSystemCreator), inputSystemCreator); } - AddInSystemFactory.Instance.SetCurrentCreator(soundSystemName); - ISoundSystemCreator soundSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator(); + AddInSystemFactory.Instance.SetDefaultCreator(soundSystemName); + ISoundSystemCreator soundSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator(); if (soundSystemCreator != null) { this.gameServices.AddService(typeof(ISoundSystemCreator), soundSystemCreator); } - AddInSystemFactory.Instance.SetCurrentCreator(renderSystemName); - IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator(); + AddInSystemFactory.Instance.SetDefaultCreator(renderSystemName); + IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator(); if (renderSystemCreator != null) { this.gameServices.AddService(typeof(IRenderSystemCreator), renderSystemCreator); } //TODO: error handling if creator is null - this.host = AddInSystemFactory.Instance.GetCurrentCreator().CreateGameHost(this); + this.host = AddInSystemFactory.Instance.GetDefaultCreator().CreateGameHost(this); this.host.Activated += new EventHandler(this.HostActivated); this.host.Deactivated += new EventHandler(this.HostDeactivated); diff --git a/ANX.Framework/Graphics/BlendState.cs b/ANX.Framework/Graphics/BlendState.cs index f3b73fc2..b0c21cf7 100644 --- a/ANX.Framework/Graphics/BlendState.cs +++ b/ANX.Framework/Graphics/BlendState.cs @@ -78,7 +78,7 @@ namespace ANX.Framework.Graphics public BlendState() { - this.nativeBlendState = AddInSystemFactory.Instance.GetCurrentCreator().CreateBlendState(); + this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator().CreateBlendState(); this.AlphaBlendFunction = BlendFunction.Add; this.AlphaDestinationBlend = Blend.One; @@ -101,7 +101,7 @@ namespace ANX.Framework.Graphics private BlendState(Blend sourceBlend, Blend destinationBlend, string name) { - this.nativeBlendState = AddInSystemFactory.Instance.GetCurrentCreator().CreateBlendState(); + this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator().CreateBlendState(); this.AlphaBlendFunction = BlendFunction.Add; this.AlphaDestinationBlend = destinationBlend; diff --git a/ANX.Framework/Graphics/DepthStencilState.cs b/ANX.Framework/Graphics/DepthStencilState.cs index f91ba178..0afcfa11 100644 --- a/ANX.Framework/Graphics/DepthStencilState.cs +++ b/ANX.Framework/Graphics/DepthStencilState.cs @@ -83,7 +83,7 @@ namespace ANX.Framework.Graphics public DepthStencilState() { - nativeDepthStencilState = AddInSystemFactory.Instance.GetCurrentCreator().CreateDepthStencilState(); + nativeDepthStencilState = AddInSystemFactory.Instance.GetDefaultCreator().CreateDepthStencilState(); CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep; CounterClockwiseStencilFail = StencilOperation.Keep; @@ -104,7 +104,7 @@ namespace ANX.Framework.Graphics private DepthStencilState(bool depthBufferEnabled, bool depthBufferWriteEnabled, string name) { - nativeDepthStencilState = AddInSystemFactory.Instance.GetCurrentCreator().CreateDepthStencilState(); + nativeDepthStencilState = AddInSystemFactory.Instance.GetDefaultCreator().CreateDepthStencilState(); CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep; CounterClockwiseStencilFail = StencilOperation.Keep; diff --git a/ANX.Framework/Graphics/Effect.cs b/ANX.Framework/Graphics/Effect.cs index ff85e35c..5bff9b8e 100644 --- a/ANX.Framework/Graphics/Effect.cs +++ b/ANX.Framework/Graphics/Effect.cs @@ -76,7 +76,7 @@ namespace ANX.Framework.Graphics public Effect(GraphicsDevice graphicsDevice, byte[] byteCode) : base(graphicsDevice) { - this.nativeEffect = AddInSystemFactory.Instance.GetCurrentCreator().CreateEffect(graphicsDevice, new MemoryStream(byteCode, false)); + this.nativeEffect = AddInSystemFactory.Instance.GetDefaultCreator().CreateEffect(graphicsDevice, new MemoryStream(byteCode, false)); this.techniqueCollection = new EffectTechniqueCollection(this, this.nativeEffect); this.currentTechnique = this.techniqueCollection[0]; diff --git a/ANX.Framework/Graphics/GraphicsAdapter.cs b/ANX.Framework/Graphics/GraphicsAdapter.cs index 66c6823d..e0733e16 100644 --- a/ANX.Framework/Graphics/GraphicsAdapter.cs +++ b/ANX.Framework/Graphics/GraphicsAdapter.cs @@ -66,7 +66,7 @@ namespace ANX.Framework.Graphics { adapters = new List(); - IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator(); + IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator(); adapters.AddRange(renderSystemCreator.GetAdapterList()); } diff --git a/ANX.Framework/Graphics/GraphicsDevice.cs b/ANX.Framework/Graphics/GraphicsDevice.cs index 6894186b..5fdabd38 100644 --- a/ANX.Framework/Graphics/GraphicsDevice.cs +++ b/ANX.Framework/Graphics/GraphicsDevice.cs @@ -98,7 +98,7 @@ namespace ANX.Framework.Graphics this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); - nativeDevice = AddInSystemFactory.Instance.GetCurrentCreator().CreateGraphicsDevice(presentationParameters); + nativeDevice = AddInSystemFactory.Instance.GetDefaultCreator().CreateGraphicsDevice(presentationParameters); this.samplerStateCollection = new SamplerStateCollection(this, 8); //TODO: get maximum number of sampler states from capabilities this.textureCollection = new TextureCollection(); diff --git a/ANX.Framework/Graphics/IndexBuffer.cs b/ANX.Framework/Graphics/IndexBuffer.cs index 99d12264..60eeac37 100644 --- a/ANX.Framework/Graphics/IndexBuffer.cs +++ b/ANX.Framework/Graphics/IndexBuffer.cs @@ -70,7 +70,7 @@ namespace ANX.Framework.Graphics this.indexCount = indexCount; this.bufferUsage = usage; - this.nativeIndexBuffer = AddInSystemFactory.Instance.GetCurrentCreator().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage); + this.nativeIndexBuffer = AddInSystemFactory.Instance.GetDefaultCreator().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage); } public IndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage) @@ -92,7 +92,7 @@ namespace ANX.Framework.Graphics this.indexCount = indexCount; this.bufferUsage = usage; - this.nativeIndexBuffer = AddInSystemFactory.Instance.GetCurrentCreator().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage); + this.nativeIndexBuffer = AddInSystemFactory.Instance.GetDefaultCreator().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage); } public void GetData(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct diff --git a/ANX.Framework/Graphics/RasterizerState.cs b/ANX.Framework/Graphics/RasterizerState.cs index 0f83509f..aa9e52fc 100644 --- a/ANX.Framework/Graphics/RasterizerState.cs +++ b/ANX.Framework/Graphics/RasterizerState.cs @@ -73,7 +73,7 @@ namespace ANX.Framework.Graphics public RasterizerState() { - this.nativeRasterizerState = AddInSystemFactory.Instance.GetCurrentCreator().CreateRasterizerState(); + this.nativeRasterizerState = AddInSystemFactory.Instance.GetDefaultCreator().CreateRasterizerState(); this.CullMode = CullMode.CullCounterClockwiseFace; this.DepthBias = 0f; @@ -85,7 +85,7 @@ namespace ANX.Framework.Graphics private RasterizerState(CullMode cullMode, string name) { - this.nativeRasterizerState = AddInSystemFactory.Instance.GetCurrentCreator().CreateRasterizerState(); + this.nativeRasterizerState = AddInSystemFactory.Instance.GetDefaultCreator().CreateRasterizerState(); this.CullMode = cullMode; this.DepthBias = 0f; diff --git a/ANX.Framework/Graphics/SamplerState.cs b/ANX.Framework/Graphics/SamplerState.cs index c06bf865..f10a37b7 100644 --- a/ANX.Framework/Graphics/SamplerState.cs +++ b/ANX.Framework/Graphics/SamplerState.cs @@ -77,7 +77,7 @@ namespace ANX.Framework.Graphics public SamplerState() { - this.nativeSamplerState = AddInSystemFactory.Instance.GetCurrentCreator().CreateSamplerState(); + this.nativeSamplerState = AddInSystemFactory.Instance.GetDefaultCreator().CreateSamplerState(); this.AddressU = TextureAddressMode.Wrap; this.AddressV = TextureAddressMode.Wrap; @@ -90,7 +90,7 @@ namespace ANX.Framework.Graphics private SamplerState(TextureFilter filter, TextureAddressMode addressMode, string name) { - this.nativeSamplerState = AddInSystemFactory.Instance.GetCurrentCreator().CreateSamplerState(); + this.nativeSamplerState = AddInSystemFactory.Instance.GetDefaultCreator().CreateSamplerState(); this.AddressU = addressMode; this.AddressV = addressMode; diff --git a/ANX.Framework/Graphics/SpriteBatch.cs b/ANX.Framework/Graphics/SpriteBatch.cs index a4c254b7..3baa9cad 100644 --- a/ANX.Framework/Graphics/SpriteBatch.cs +++ b/ANX.Framework/Graphics/SpriteBatch.cs @@ -99,7 +99,7 @@ namespace ANX.Framework.Graphics base.GraphicsDevice = graphicsDevice; - this.spriteBatchEffect = new Effect(graphicsDevice, AddInSystemFactory.Instance.GetCurrentCreator().GetShaderByteCode(NonXNA.PreDefinedShader.SpriteBatch)); + this.spriteBatchEffect = new Effect(graphicsDevice, AddInSystemFactory.Instance.GetDefaultCreator().GetShaderByteCode(NonXNA.PreDefinedShader.SpriteBatch)); this.spriteInfos = new SpriteInfo[InitialBatchSize]; diff --git a/ANX.Framework/Graphics/Texture2D.cs b/ANX.Framework/Graphics/Texture2D.cs index abdc0d74..2f74cc3b 100644 --- a/ANX.Framework/Graphics/Texture2D.cs +++ b/ANX.Framework/Graphics/Texture2D.cs @@ -173,7 +173,7 @@ namespace ANX.Framework.Graphics private void CreateNativeTextureSurface() { - base.nativeTexture = AddInSystemFactory.Instance.GetCurrentCreator().CreateTexture(GraphicsDevice, format, Width, Height, levelCount); + base.nativeTexture = AddInSystemFactory.Instance.GetDefaultCreator().CreateTexture(GraphicsDevice, format, Width, Height, levelCount); } } } diff --git a/ANX.Framework/Graphics/VertexBuffer.cs b/ANX.Framework/Graphics/VertexBuffer.cs index 6d8cef59..e6b1ecb4 100644 --- a/ANX.Framework/Graphics/VertexBuffer.cs +++ b/ANX.Framework/Graphics/VertexBuffer.cs @@ -75,7 +75,7 @@ namespace ANX.Framework.Graphics this.vertexDeclaration = vertexDeclaration; this.bufferUsage = usage; - this.nativeVertexBuffer = AddInSystemFactory.Instance.GetCurrentCreator().CreateVertexBuffer(graphicsDevice, vertexDeclaration, vertexCount, usage); + this.nativeVertexBuffer = AddInSystemFactory.Instance.GetDefaultCreator().CreateVertexBuffer(graphicsDevice, vertexDeclaration, vertexCount, usage); } public BufferUsage BufferUsage diff --git a/ANX.Framework/Input/GamePad.cs b/ANX.Framework/Input/GamePad.cs index 82c39f26..f755881f 100644 --- a/ANX.Framework/Input/GamePad.cs +++ b/ANX.Framework/Input/GamePad.cs @@ -60,7 +60,7 @@ namespace ANX.Framework.Input static GamePad() { - gamePad = AddInSystemFactory.Instance.GetCurrentCreator().GamePad; + gamePad = AddInSystemFactory.Instance.GetDefaultCreator().GamePad; } public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex) diff --git a/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs b/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs index ef539ae8..95875d72 100644 --- a/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs +++ b/ANX.Framework/Input/MotionSensing/MotionSensingDevice.cs @@ -62,7 +62,7 @@ namespace ANX.Framework.Input.MotionSensing static MotionSensingDevice() { - motionSensingDevice = AddInSystemFactory.Instance.GetCurrentCreator().MotionSensingDevice; + motionSensingDevice = AddInSystemFactory.Instance.GetDefaultCreator().MotionSensingDevice; } public static GraphicsDevice GraphicsDevice diff --git a/ANX.Framework/Input/Mouse.cs b/ANX.Framework/Input/Mouse.cs index 3538a42f..d7b09808 100644 --- a/ANX.Framework/Input/Mouse.cs +++ b/ANX.Framework/Input/Mouse.cs @@ -59,7 +59,7 @@ namespace ANX.Framework.Input static Mouse() { - mouse = AddInSystemFactory.Instance.GetCurrentCreator().Mouse; + mouse = AddInSystemFactory.Instance.GetDefaultCreator().Mouse; } public static IntPtr WindowHandle diff --git a/ANX.Framework/NonXNA/AddInSystemFactory.cs b/ANX.Framework/NonXNA/AddInSystemFactory.cs index 85cfd7c5..caa59138 100644 --- a/ANX.Framework/NonXNA/AddInSystemFactory.cs +++ b/ANX.Framework/NonXNA/AddInSystemFactory.cs @@ -62,7 +62,7 @@ namespace ANX.Framework.NonXNA private Dictionary creators; private static AddInSystemFactory instance; private bool initialized; - private Dictionary currentCreators = new Dictionary(); + private Dictionary defaultCreators = new Dictionary(); public static AddInSystemFactory Instance { @@ -158,28 +158,28 @@ namespace ANX.Framework.NonXNA } } - public T GetCurrentCreator() where T : class, ICreator + public T GetDefaultCreator() where T : class, ICreator { Type type = typeof(T); - if (currentCreators.ContainsKey(type)) + if (defaultCreators.ContainsKey(type)) { - return currentCreators[type] as T; + return defaultCreators[type] as T; } return default(T); } - public void SetCurrentCreator(T creator) where T : class, ICreator + public void SetDefaultCreator(T creator) where T : class, ICreator { - currentCreators[typeof(T)] = creator; + defaultCreators[typeof(T)] = creator; } - public void SetCurrentCreator(string creatorName) + public void SetDefaultCreator(string creatorName) { ICreator creator = null; creators.TryGetValue(creatorName.ToLowerInvariant(), out creator); - currentCreators[creator.GetType().GetInterfaces()[0]] = creator; + defaultCreators[creator.GetType().GetInterfaces()[0]] = creator; } } diff --git a/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj b/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj index 3f394b1d..a996d95d 100644 --- a/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj +++ b/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj @@ -50,6 +50,7 @@ + diff --git a/ANX.InputSystem.Windows.XInput/FormatConverter.cs b/ANX.InputSystem.Windows.XInput/FormatConverter.cs new file mode 100644 index 00000000..4c4c8006 --- /dev/null +++ b/ANX.InputSystem.Windows.XInput/FormatConverter.cs @@ -0,0 +1,81 @@ +#region Using Statements +using System; +using ANX.Framework.Input; +using SharpDX.XInput; + +#endregion // Using Statements + +#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.Windows.XInput +{ + internal class FormatConverter + { + public static Buttons Translate(SharpDX.XInput.GamepadButtonFlags buttons) + { + Buttons tb = 0; + + tb |= (buttons & GamepadButtonFlags.A) == GamepadButtonFlags.A ? Buttons.A : 0; + tb |= (buttons & GamepadButtonFlags.B) == GamepadButtonFlags.B ? Buttons.B : 0; + tb |= (buttons & GamepadButtonFlags.Back) == GamepadButtonFlags.Back ? Buttons.Back : 0; + tb |= (buttons & GamepadButtonFlags.DPadDown) == GamepadButtonFlags.DPadDown ? Buttons.DPadDown : 0; + tb |= (buttons & GamepadButtonFlags.DPadLeft) == GamepadButtonFlags.DPadLeft ? Buttons.DPadLeft : 0; + tb |= (buttons & GamepadButtonFlags.DPadRight) == GamepadButtonFlags.DPadRight ? Buttons.DPadRight : 0; + tb |= (buttons & GamepadButtonFlags.DPadUp) == GamepadButtonFlags.DPadUp ? Buttons.DPadUp : 0; + tb |= (buttons & GamepadButtonFlags.LeftShoulder) == GamepadButtonFlags.LeftShoulder ? Buttons.LeftShoulder : 0; + tb |= (buttons & GamepadButtonFlags.LeftThumb) == GamepadButtonFlags.LeftThumb ? Buttons.LeftTrigger : 0; + tb |= (buttons & GamepadButtonFlags.RightShoulder) == GamepadButtonFlags.RightShoulder ? Buttons.RightShoulder : 0; + tb |= (buttons & GamepadButtonFlags.RightThumb) == GamepadButtonFlags.RightThumb ? Buttons.RightTrigger : 0; + tb |= (buttons & GamepadButtonFlags.Start) == GamepadButtonFlags.Start ? Buttons.Start : 0; + tb |= (buttons & GamepadButtonFlags.X) == GamepadButtonFlags.X ? Buttons.X : 0; + tb |= (buttons & GamepadButtonFlags.Y) == GamepadButtonFlags.Y ? Buttons.Y : 0; + + return tb; + } + } +} diff --git a/ANX.InputSystem.Windows.XInput/GamePad.cs b/ANX.InputSystem.Windows.XInput/GamePad.cs index 7884347f..80faf91b 100644 --- a/ANX.InputSystem.Windows.XInput/GamePad.cs +++ b/ANX.InputSystem.Windows.XInput/GamePad.cs @@ -99,7 +99,7 @@ namespace ANX.InputSystem.Windows.XInput { result = controller[(int)playerIndex].GetState(); //returnres = new GamePadCapabilities(result.Type,result.Gamepad.Buttons.) - returnres = new GamePadState((int)result.Gamepad.Buttons, true, result.PacketNumber, new Vector2(result.Gamepad.LeftThumbX, result.Gamepad.LeftThumbY), new Vector2(result.Gamepad.RightThumbX, result.Gamepad.RightThumbY), (float)result.Gamepad.LeftTrigger, (float)result.Gamepad.RightTrigger); + returnres = new GamePadState(new Vector2(result.Gamepad.LeftThumbX, result.Gamepad.LeftThumbY), new Vector2(result.Gamepad.RightThumbX, result.Gamepad.RightThumbY), (float)result.Gamepad.LeftTrigger, (float)result.Gamepad.RightTrigger, FormatConverter.Translate(result.Gamepad.Buttons)); } else { diff --git a/Samples/WindowsGame/AddInSelector.Designer.cs b/Samples/WindowsGame/AddInSelector.Designer.cs index 8e57d39b..7bea4345 100644 --- a/Samples/WindowsGame/AddInSelector.Designer.cs +++ b/Samples/WindowsGame/AddInSelector.Designer.cs @@ -32,17 +32,17 @@ this.button2 = new System.Windows.Forms.Button(); this.label1 = new System.Windows.Forms.Label(); this.cbRenderSystem = new System.Windows.Forms.ComboBox(); - this.cbInputSystem = new System.Windows.Forms.ComboBox(); this.label2 = new System.Windows.Forms.Label(); this.cbAudioSystem = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.cbInputSystems = new System.Windows.Forms.CheckedListBox(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); this.SuspendLayout(); // // button1 // - this.button1.Location = new System.Drawing.Point(12, 283); + this.button1.Location = new System.Drawing.Point(12, 342); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(182, 23); this.button1.TabIndex = 0; @@ -53,7 +53,7 @@ // button2 // this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.button2.Location = new System.Drawing.Point(313, 283); + this.button2.Location = new System.Drawing.Point(313, 342); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(182, 23); this.button2.TabIndex = 1; @@ -78,29 +78,20 @@ this.cbRenderSystem.Size = new System.Drawing.Size(277, 21); this.cbRenderSystem.TabIndex = 3; // - // cbInputSystem - // - this.cbInputSystem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.cbInputSystem.FormattingEnabled = true; - this.cbInputSystem.Location = new System.Drawing.Point(184, 211); - this.cbInputSystem.Name = "cbInputSystem"; - this.cbInputSystem.Size = new System.Drawing.Size(277, 21); - this.cbInputSystem.TabIndex = 5; - // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(52, 214); + this.label2.Location = new System.Drawing.Point(52, 236); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(68, 13); + this.label2.Size = new System.Drawing.Size(73, 13); this.label2.TabIndex = 4; - this.label2.Text = "Input-System"; + this.label2.Text = "Input-Systems"; // // cbAudioSystem // this.cbAudioSystem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.cbAudioSystem.FormattingEnabled = true; - this.cbAudioSystem.Location = new System.Drawing.Point(184, 238); + this.cbAudioSystem.Location = new System.Drawing.Point(184, 209); this.cbAudioSystem.Name = "cbAudioSystem"; this.cbAudioSystem.Size = new System.Drawing.Size(277, 21); this.cbAudioSystem.TabIndex = 7; @@ -108,7 +99,7 @@ // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(52, 241); + this.label3.Location = new System.Drawing.Point(52, 212); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(71, 13); this.label3.TabIndex = 6; @@ -124,17 +115,25 @@ this.pictureBox1.TabIndex = 8; this.pictureBox1.TabStop = false; // + // cbInputSystems + // + this.cbInputSystems.FormattingEnabled = true; + this.cbInputSystems.Location = new System.Drawing.Point(184, 236); + this.cbInputSystems.Name = "cbInputSystems"; + this.cbInputSystems.Size = new System.Drawing.Size(277, 94); + this.cbInputSystems.TabIndex = 9; + // // AddInSelector // this.AcceptButton = this.button1; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.button2; - this.ClientSize = new System.Drawing.Size(507, 318); + this.ClientSize = new System.Drawing.Size(507, 371); + this.Controls.Add(this.cbInputSystems); this.Controls.Add(this.pictureBox1); this.Controls.Add(this.cbAudioSystem); this.Controls.Add(this.label3); - this.Controls.Add(this.cbInputSystem); this.Controls.Add(this.label2); this.Controls.Add(this.cbRenderSystem); this.Controls.Add(this.label1); @@ -158,10 +157,10 @@ private System.Windows.Forms.Button button2; private System.Windows.Forms.Label label1; public System.Windows.Forms.ComboBox cbRenderSystem; - public System.Windows.Forms.ComboBox cbInputSystem; private System.Windows.Forms.Label label2; public System.Windows.Forms.ComboBox cbAudioSystem; private System.Windows.Forms.Label label3; private System.Windows.Forms.PictureBox pictureBox1; + internal System.Windows.Forms.CheckedListBox cbInputSystems; } } \ No newline at end of file diff --git a/Samples/WindowsGame/AddInSelector.cs b/Samples/WindowsGame/AddInSelector.cs index f97ef926..e96d4735 100644 --- a/Samples/WindowsGame/AddInSelector.cs +++ b/Samples/WindowsGame/AddInSelector.cs @@ -30,9 +30,9 @@ namespace WindowsGame1 foreach (IInputSystemCreator inputSystemCreator in AddInSystemFactory.Instance.GetCreators()) { - cbInputSystem.Items.Add(inputSystemCreator.Name); + cbInputSystems.Items.Add(inputSystemCreator.Name); } - cbInputSystem.SelectedIndex = 0; + cbInputSystems.SetItemChecked(0, true); foreach (ISoundSystemCreator soundSystemCreator in AddInSystemFactory.Instance.GetCreators()) { diff --git a/Samples/WindowsGame/Program.cs b/Samples/WindowsGame/Program.cs index d511a7d9..7ccad686 100644 --- a/Samples/WindowsGame/Program.cs +++ b/Samples/WindowsGame/Program.cs @@ -19,7 +19,7 @@ namespace WindowsGame1 AddInSelector selector = new AddInSelector(); if (selector.ShowDialog() == System.Windows.Forms.DialogResult.OK) { - using (Game1 game = new Game1(selector.cbRenderSystem.Text, selector.cbInputSystem.Text, selector.cbAudioSystem.Text)) + using (Game1 game = new Game1(selector.cbRenderSystem.Text, selector.cbInputSystems.CheckedItems[0].ToString(), selector.cbAudioSystem.Text)) { game.Run(); } diff --git a/Samples/WindowsGame/WindowsGame.csproj b/Samples/WindowsGame/WindowsGame.csproj index 87fb249f..a085f353 100644 --- a/Samples/WindowsGame/WindowsGame.csproj +++ b/Samples/WindowsGame/WindowsGame.csproj @@ -107,6 +107,10 @@ {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35} ANX.Framework + + {E5D69E75-D77C-493F-BBDA-6F9E73B82549} + ANX.InputSystem.Windows.Kinect + {60D08399-244F-46A3-91F1-4CFD26D961A3} ANX.InputSystem.Windows.XInput