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
This commit is contained in:
parent
9695acd2e3
commit
972f7121e8
@ -103,29 +103,29 @@ namespace ANX.Framework
|
|||||||
|
|
||||||
AddInSystemFactory.Instance.Initialize();
|
AddInSystemFactory.Instance.Initialize();
|
||||||
|
|
||||||
AddInSystemFactory.Instance.SetCurrentCreator(inputSystemName);
|
AddInSystemFactory.Instance.SetDefaultCreator(inputSystemName);
|
||||||
IInputSystemCreator inputSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator<IInputSystemCreator>();
|
IInputSystemCreator inputSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IInputSystemCreator>();
|
||||||
if (inputSystemCreator != null)
|
if (inputSystemCreator != null)
|
||||||
{
|
{
|
||||||
this.gameServices.AddService(typeof(IInputSystemCreator), inputSystemCreator);
|
this.gameServices.AddService(typeof(IInputSystemCreator), inputSystemCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInSystemFactory.Instance.SetCurrentCreator(soundSystemName);
|
AddInSystemFactory.Instance.SetDefaultCreator(soundSystemName);
|
||||||
ISoundSystemCreator soundSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator<ISoundSystemCreator>();
|
ISoundSystemCreator soundSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
|
||||||
if (soundSystemCreator != null)
|
if (soundSystemCreator != null)
|
||||||
{
|
{
|
||||||
this.gameServices.AddService(typeof(ISoundSystemCreator), soundSystemCreator);
|
this.gameServices.AddService(typeof(ISoundSystemCreator), soundSystemCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInSystemFactory.Instance.SetCurrentCreator(renderSystemName);
|
AddInSystemFactory.Instance.SetDefaultCreator(renderSystemName);
|
||||||
IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>();
|
IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
||||||
if (renderSystemCreator != null)
|
if (renderSystemCreator != null)
|
||||||
{
|
{
|
||||||
this.gameServices.AddService(typeof(IRenderSystemCreator), renderSystemCreator);
|
this.gameServices.AddService(typeof(IRenderSystemCreator), renderSystemCreator);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: error handling if creator is null
|
//TODO: error handling if creator is null
|
||||||
this.host = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateGameHost(this);
|
this.host = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateGameHost(this);
|
||||||
|
|
||||||
this.host.Activated += new EventHandler<EventArgs>(this.HostActivated);
|
this.host.Activated += new EventHandler<EventArgs>(this.HostActivated);
|
||||||
this.host.Deactivated += new EventHandler<EventArgs>(this.HostDeactivated);
|
this.host.Deactivated += new EventHandler<EventArgs>(this.HostDeactivated);
|
||||||
|
@ -78,7 +78,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
public BlendState()
|
public BlendState()
|
||||||
{
|
{
|
||||||
this.nativeBlendState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateBlendState();
|
this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateBlendState();
|
||||||
|
|
||||||
this.AlphaBlendFunction = BlendFunction.Add;
|
this.AlphaBlendFunction = BlendFunction.Add;
|
||||||
this.AlphaDestinationBlend = Blend.One;
|
this.AlphaDestinationBlend = Blend.One;
|
||||||
@ -101,7 +101,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
private BlendState(Blend sourceBlend, Blend destinationBlend, string name)
|
private BlendState(Blend sourceBlend, Blend destinationBlend, string name)
|
||||||
{
|
{
|
||||||
this.nativeBlendState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateBlendState();
|
this.nativeBlendState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateBlendState();
|
||||||
|
|
||||||
this.AlphaBlendFunction = BlendFunction.Add;
|
this.AlphaBlendFunction = BlendFunction.Add;
|
||||||
this.AlphaDestinationBlend = destinationBlend;
|
this.AlphaDestinationBlend = destinationBlend;
|
||||||
|
@ -83,7 +83,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
public DepthStencilState()
|
public DepthStencilState()
|
||||||
{
|
{
|
||||||
nativeDepthStencilState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateDepthStencilState();
|
nativeDepthStencilState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateDepthStencilState();
|
||||||
|
|
||||||
CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep;
|
CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep;
|
||||||
CounterClockwiseStencilFail = StencilOperation.Keep;
|
CounterClockwiseStencilFail = StencilOperation.Keep;
|
||||||
@ -104,7 +104,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
private DepthStencilState(bool depthBufferEnabled, bool depthBufferWriteEnabled, string name)
|
private DepthStencilState(bool depthBufferEnabled, bool depthBufferWriteEnabled, string name)
|
||||||
{
|
{
|
||||||
nativeDepthStencilState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateDepthStencilState();
|
nativeDepthStencilState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateDepthStencilState();
|
||||||
|
|
||||||
CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep;
|
CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep;
|
||||||
CounterClockwiseStencilFail = StencilOperation.Keep;
|
CounterClockwiseStencilFail = StencilOperation.Keep;
|
||||||
|
@ -76,7 +76,7 @@ namespace ANX.Framework.Graphics
|
|||||||
public Effect(GraphicsDevice graphicsDevice, byte[] byteCode)
|
public Effect(GraphicsDevice graphicsDevice, byte[] byteCode)
|
||||||
: base(graphicsDevice)
|
: base(graphicsDevice)
|
||||||
{
|
{
|
||||||
this.nativeEffect = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateEffect(graphicsDevice, new MemoryStream(byteCode, false));
|
this.nativeEffect = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateEffect(graphicsDevice, new MemoryStream(byteCode, false));
|
||||||
|
|
||||||
this.techniqueCollection = new EffectTechniqueCollection(this, this.nativeEffect);
|
this.techniqueCollection = new EffectTechniqueCollection(this, this.nativeEffect);
|
||||||
this.currentTechnique = this.techniqueCollection[0];
|
this.currentTechnique = this.techniqueCollection[0];
|
||||||
|
@ -66,7 +66,7 @@ namespace ANX.Framework.Graphics
|
|||||||
{
|
{
|
||||||
adapters = new List<GraphicsAdapter>();
|
adapters = new List<GraphicsAdapter>();
|
||||||
|
|
||||||
IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>();
|
IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
|
||||||
adapters.AddRange(renderSystemCreator.GetAdapterList());
|
adapters.AddRange(renderSystemCreator.GetAdapterList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
|
this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
|
||||||
|
|
||||||
nativeDevice = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateGraphicsDevice(presentationParameters);
|
nativeDevice = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateGraphicsDevice(presentationParameters);
|
||||||
|
|
||||||
this.samplerStateCollection = new SamplerStateCollection(this, 8); //TODO: get maximum number of sampler states from capabilities
|
this.samplerStateCollection = new SamplerStateCollection(this, 8); //TODO: get maximum number of sampler states from capabilities
|
||||||
this.textureCollection = new TextureCollection();
|
this.textureCollection = new TextureCollection();
|
||||||
|
@ -70,7 +70,7 @@ namespace ANX.Framework.Graphics
|
|||||||
this.indexCount = indexCount;
|
this.indexCount = indexCount;
|
||||||
this.bufferUsage = usage;
|
this.bufferUsage = usage;
|
||||||
|
|
||||||
this.nativeIndexBuffer = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage);
|
this.nativeIndexBuffer = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage)
|
public IndexBuffer(GraphicsDevice graphicsDevice, Type indexType, int indexCount, BufferUsage usage)
|
||||||
@ -92,7 +92,7 @@ namespace ANX.Framework.Graphics
|
|||||||
this.indexCount = indexCount;
|
this.indexCount = indexCount;
|
||||||
this.bufferUsage = usage;
|
this.bufferUsage = usage;
|
||||||
|
|
||||||
this.nativeIndexBuffer = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage);
|
this.nativeIndexBuffer = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateIndexBuffer(graphicsDevice, indexElementSize, indexCount, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
|
public void GetData<T>(int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
|
||||||
|
@ -73,7 +73,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
public RasterizerState()
|
public RasterizerState()
|
||||||
{
|
{
|
||||||
this.nativeRasterizerState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateRasterizerState();
|
this.nativeRasterizerState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateRasterizerState();
|
||||||
|
|
||||||
this.CullMode = CullMode.CullCounterClockwiseFace;
|
this.CullMode = CullMode.CullCounterClockwiseFace;
|
||||||
this.DepthBias = 0f;
|
this.DepthBias = 0f;
|
||||||
@ -85,7 +85,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
private RasterizerState(CullMode cullMode, string name)
|
private RasterizerState(CullMode cullMode, string name)
|
||||||
{
|
{
|
||||||
this.nativeRasterizerState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateRasterizerState();
|
this.nativeRasterizerState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateRasterizerState();
|
||||||
|
|
||||||
this.CullMode = cullMode;
|
this.CullMode = cullMode;
|
||||||
this.DepthBias = 0f;
|
this.DepthBias = 0f;
|
||||||
|
@ -77,7 +77,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
public SamplerState()
|
public SamplerState()
|
||||||
{
|
{
|
||||||
this.nativeSamplerState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateSamplerState();
|
this.nativeSamplerState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateSamplerState();
|
||||||
|
|
||||||
this.AddressU = TextureAddressMode.Wrap;
|
this.AddressU = TextureAddressMode.Wrap;
|
||||||
this.AddressV = TextureAddressMode.Wrap;
|
this.AddressV = TextureAddressMode.Wrap;
|
||||||
@ -90,7 +90,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
private SamplerState(TextureFilter filter, TextureAddressMode addressMode, string name)
|
private SamplerState(TextureFilter filter, TextureAddressMode addressMode, string name)
|
||||||
{
|
{
|
||||||
this.nativeSamplerState = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateSamplerState();
|
this.nativeSamplerState = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateSamplerState();
|
||||||
|
|
||||||
this.AddressU = addressMode;
|
this.AddressU = addressMode;
|
||||||
this.AddressV = addressMode;
|
this.AddressV = addressMode;
|
||||||
|
@ -99,7 +99,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
base.GraphicsDevice = graphicsDevice;
|
base.GraphicsDevice = graphicsDevice;
|
||||||
|
|
||||||
this.spriteBatchEffect = new Effect(graphicsDevice, AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().GetShaderByteCode(NonXNA.PreDefinedShader.SpriteBatch));
|
this.spriteBatchEffect = new Effect(graphicsDevice, AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().GetShaderByteCode(NonXNA.PreDefinedShader.SpriteBatch));
|
||||||
|
|
||||||
this.spriteInfos = new SpriteInfo[InitialBatchSize];
|
this.spriteInfos = new SpriteInfo[InitialBatchSize];
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ namespace ANX.Framework.Graphics
|
|||||||
|
|
||||||
private void CreateNativeTextureSurface()
|
private void CreateNativeTextureSurface()
|
||||||
{
|
{
|
||||||
base.nativeTexture = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateTexture(GraphicsDevice, format, Width, Height, levelCount);
|
base.nativeTexture = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateTexture(GraphicsDevice, format, Width, Height, levelCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ namespace ANX.Framework.Graphics
|
|||||||
this.vertexDeclaration = vertexDeclaration;
|
this.vertexDeclaration = vertexDeclaration;
|
||||||
this.bufferUsage = usage;
|
this.bufferUsage = usage;
|
||||||
|
|
||||||
this.nativeVertexBuffer = AddInSystemFactory.Instance.GetCurrentCreator<IRenderSystemCreator>().CreateVertexBuffer(graphicsDevice, vertexDeclaration, vertexCount, usage);
|
this.nativeVertexBuffer = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>().CreateVertexBuffer(graphicsDevice, vertexDeclaration, vertexCount, usage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BufferUsage BufferUsage
|
public BufferUsage BufferUsage
|
||||||
|
@ -60,7 +60,7 @@ namespace ANX.Framework.Input
|
|||||||
|
|
||||||
static GamePad()
|
static GamePad()
|
||||||
{
|
{
|
||||||
gamePad = AddInSystemFactory.Instance.GetCurrentCreator<IInputSystemCreator>().GamePad;
|
gamePad = AddInSystemFactory.Instance.GetDefaultCreator<IInputSystemCreator>().GamePad;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
|
public static GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
|
||||||
|
@ -62,7 +62,7 @@ namespace ANX.Framework.Input.MotionSensing
|
|||||||
|
|
||||||
static MotionSensingDevice()
|
static MotionSensingDevice()
|
||||||
{
|
{
|
||||||
motionSensingDevice = AddInSystemFactory.Instance.GetCurrentCreator<IInputSystemCreator>().MotionSensingDevice;
|
motionSensingDevice = AddInSystemFactory.Instance.GetDefaultCreator<IInputSystemCreator>().MotionSensingDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GraphicsDevice GraphicsDevice
|
public static GraphicsDevice GraphicsDevice
|
||||||
|
@ -59,7 +59,7 @@ namespace ANX.Framework.Input
|
|||||||
|
|
||||||
static Mouse()
|
static Mouse()
|
||||||
{
|
{
|
||||||
mouse = AddInSystemFactory.Instance.GetCurrentCreator<IInputSystemCreator>().Mouse;
|
mouse = AddInSystemFactory.Instance.GetDefaultCreator<IInputSystemCreator>().Mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IntPtr WindowHandle
|
public static IntPtr WindowHandle
|
||||||
|
@ -62,7 +62,7 @@ namespace ANX.Framework.NonXNA
|
|||||||
private Dictionary<String, ICreator> creators;
|
private Dictionary<String, ICreator> creators;
|
||||||
private static AddInSystemFactory instance;
|
private static AddInSystemFactory instance;
|
||||||
private bool initialized;
|
private bool initialized;
|
||||||
private Dictionary<Type, ICreator> currentCreators = new Dictionary<Type, ICreator>();
|
private Dictionary<Type, ICreator> defaultCreators = new Dictionary<Type, ICreator>();
|
||||||
|
|
||||||
public static AddInSystemFactory Instance
|
public static AddInSystemFactory Instance
|
||||||
{
|
{
|
||||||
@ -158,28 +158,28 @@ namespace ANX.Framework.NonXNA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T GetCurrentCreator<T>() where T : class, ICreator
|
public T GetDefaultCreator<T>() where T : class, ICreator
|
||||||
{
|
{
|
||||||
Type type = typeof(T);
|
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);
|
return default(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetCurrentCreator<T>(T creator) where T : class, ICreator
|
public void SetDefaultCreator<T>(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;
|
ICreator creator = null;
|
||||||
creators.TryGetValue(creatorName.ToLowerInvariant(), out creator);
|
creators.TryGetValue(creatorName.ToLowerInvariant(), out creator);
|
||||||
currentCreators[creator.GetType().GetInterfaces()[0]] = creator;
|
defaultCreators[creator.GetType().GetInterfaces()[0]] = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Creator.cs" />
|
<Compile Include="Creator.cs" />
|
||||||
|
<Compile Include="FormatConverter.cs" />
|
||||||
<Compile Include="Mouse.cs" />
|
<Compile Include="Mouse.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="GamePad.cs" />
|
<Compile Include="GamePad.cs" />
|
||||||
|
81
ANX.InputSystem.Windows.XInput/FormatConverter.cs
Normal file
81
ANX.InputSystem.Windows.XInput/FormatConverter.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -99,7 +99,7 @@ namespace ANX.InputSystem.Windows.XInput
|
|||||||
{
|
{
|
||||||
result = controller[(int)playerIndex].GetState();
|
result = controller[(int)playerIndex].GetState();
|
||||||
//returnres = new GamePadCapabilities(result.Type,result.Gamepad.Buttons.)
|
//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
|
else
|
||||||
{
|
{
|
||||||
|
39
Samples/WindowsGame/AddInSelector.Designer.cs
generated
39
Samples/WindowsGame/AddInSelector.Designer.cs
generated
@ -32,17 +32,17 @@
|
|||||||
this.button2 = new System.Windows.Forms.Button();
|
this.button2 = new System.Windows.Forms.Button();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.cbRenderSystem = new System.Windows.Forms.ComboBox();
|
this.cbRenderSystem = new System.Windows.Forms.ComboBox();
|
||||||
this.cbInputSystem = new System.Windows.Forms.ComboBox();
|
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.cbAudioSystem = new System.Windows.Forms.ComboBox();
|
this.cbAudioSystem = new System.Windows.Forms.ComboBox();
|
||||||
this.label3 = new System.Windows.Forms.Label();
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||||
|
this.cbInputSystems = new System.Windows.Forms.CheckedListBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// button1
|
// 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.Name = "button1";
|
||||||
this.button1.Size = new System.Drawing.Size(182, 23);
|
this.button1.Size = new System.Drawing.Size(182, 23);
|
||||||
this.button1.TabIndex = 0;
|
this.button1.TabIndex = 0;
|
||||||
@ -53,7 +53,7 @@
|
|||||||
// button2
|
// button2
|
||||||
//
|
//
|
||||||
this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
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.Name = "button2";
|
||||||
this.button2.Size = new System.Drawing.Size(182, 23);
|
this.button2.Size = new System.Drawing.Size(182, 23);
|
||||||
this.button2.TabIndex = 1;
|
this.button2.TabIndex = 1;
|
||||||
@ -78,29 +78,20 @@
|
|||||||
this.cbRenderSystem.Size = new System.Drawing.Size(277, 21);
|
this.cbRenderSystem.Size = new System.Drawing.Size(277, 21);
|
||||||
this.cbRenderSystem.TabIndex = 3;
|
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
|
// label2
|
||||||
//
|
//
|
||||||
this.label2.AutoSize = true;
|
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.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.TabIndex = 4;
|
||||||
this.label2.Text = "Input-System";
|
this.label2.Text = "Input-Systems";
|
||||||
//
|
//
|
||||||
// cbAudioSystem
|
// cbAudioSystem
|
||||||
//
|
//
|
||||||
this.cbAudioSystem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.cbAudioSystem.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.cbAudioSystem.FormattingEnabled = true;
|
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.Name = "cbAudioSystem";
|
||||||
this.cbAudioSystem.Size = new System.Drawing.Size(277, 21);
|
this.cbAudioSystem.Size = new System.Drawing.Size(277, 21);
|
||||||
this.cbAudioSystem.TabIndex = 7;
|
this.cbAudioSystem.TabIndex = 7;
|
||||||
@ -108,7 +99,7 @@
|
|||||||
// label3
|
// label3
|
||||||
//
|
//
|
||||||
this.label3.AutoSize = true;
|
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.Name = "label3";
|
||||||
this.label3.Size = new System.Drawing.Size(71, 13);
|
this.label3.Size = new System.Drawing.Size(71, 13);
|
||||||
this.label3.TabIndex = 6;
|
this.label3.TabIndex = 6;
|
||||||
@ -124,17 +115,25 @@
|
|||||||
this.pictureBox1.TabIndex = 8;
|
this.pictureBox1.TabIndex = 8;
|
||||||
this.pictureBox1.TabStop = false;
|
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
|
// AddInSelector
|
||||||
//
|
//
|
||||||
this.AcceptButton = this.button1;
|
this.AcceptButton = this.button1;
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.CancelButton = this.button2;
|
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.pictureBox1);
|
||||||
this.Controls.Add(this.cbAudioSystem);
|
this.Controls.Add(this.cbAudioSystem);
|
||||||
this.Controls.Add(this.label3);
|
this.Controls.Add(this.label3);
|
||||||
this.Controls.Add(this.cbInputSystem);
|
|
||||||
this.Controls.Add(this.label2);
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.cbRenderSystem);
|
this.Controls.Add(this.cbRenderSystem);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
@ -158,10 +157,10 @@
|
|||||||
private System.Windows.Forms.Button button2;
|
private System.Windows.Forms.Button button2;
|
||||||
private System.Windows.Forms.Label label1;
|
private System.Windows.Forms.Label label1;
|
||||||
public System.Windows.Forms.ComboBox cbRenderSystem;
|
public System.Windows.Forms.ComboBox cbRenderSystem;
|
||||||
public System.Windows.Forms.ComboBox cbInputSystem;
|
|
||||||
private System.Windows.Forms.Label label2;
|
private System.Windows.Forms.Label label2;
|
||||||
public System.Windows.Forms.ComboBox cbAudioSystem;
|
public System.Windows.Forms.ComboBox cbAudioSystem;
|
||||||
private System.Windows.Forms.Label label3;
|
private System.Windows.Forms.Label label3;
|
||||||
private System.Windows.Forms.PictureBox pictureBox1;
|
private System.Windows.Forms.PictureBox pictureBox1;
|
||||||
|
internal System.Windows.Forms.CheckedListBox cbInputSystems;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,9 +30,9 @@ namespace WindowsGame1
|
|||||||
|
|
||||||
foreach (IInputSystemCreator inputSystemCreator in AddInSystemFactory.Instance.GetCreators<IInputSystemCreator>())
|
foreach (IInputSystemCreator inputSystemCreator in AddInSystemFactory.Instance.GetCreators<IInputSystemCreator>())
|
||||||
{
|
{
|
||||||
cbInputSystem.Items.Add(inputSystemCreator.Name);
|
cbInputSystems.Items.Add(inputSystemCreator.Name);
|
||||||
}
|
}
|
||||||
cbInputSystem.SelectedIndex = 0;
|
cbInputSystems.SetItemChecked(0, true);
|
||||||
|
|
||||||
foreach (ISoundSystemCreator soundSystemCreator in AddInSystemFactory.Instance.GetCreators<ISoundSystemCreator>())
|
foreach (ISoundSystemCreator soundSystemCreator in AddInSystemFactory.Instance.GetCreators<ISoundSystemCreator>())
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace WindowsGame1
|
|||||||
AddInSelector selector = new AddInSelector();
|
AddInSelector selector = new AddInSelector();
|
||||||
if (selector.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
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();
|
game.Run();
|
||||||
}
|
}
|
||||||
|
@ -107,6 +107,10 @@
|
|||||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||||
<Name>ANX.Framework</Name>
|
<Name>ANX.Framework</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\..\ANX.InputSystem.Windows.Kinect\ANX.InputSystem.Windows.Kinect.csproj">
|
||||||
|
<Project>{E5D69E75-D77C-493F-BBDA-6F9E73B82549}</Project>
|
||||||
|
<Name>ANX.InputSystem.Windows.Kinect</Name>
|
||||||
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\ANX.InputSystem.Windows.XInput\ANX.InputSystem.Windows.XInput.csproj">
|
<ProjectReference Include="..\..\ANX.InputSystem.Windows.XInput\ANX.InputSystem.Windows.XInput.csproj">
|
||||||
<Project>{60D08399-244F-46A3-91F1-4CFD26D961A3}</Project>
|
<Project>{60D08399-244F-46A3-91F1-4CFD26D961A3}</Project>
|
||||||
<Name>ANX.InputSystem.Windows.XInput</Name>
|
<Name>ANX.InputSystem.Windows.XInput</Name>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user