re-added some missing files
This commit is contained in:
parent
a07485dbc7
commit
4e6a14a984
@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{60D08399-244F-46A3-91F1-4CFD26D961A3}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ANX.InputDevices.Windows.XInput</RootNamespace>
|
||||
<AssemblyName>ANX.InputDevices.Windows.XInput</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE;DEBUG;XNAEXT</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>..\..\bin\Debug\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\NLog\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\SharpDX.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.Diagnostics">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\SharpDX.Diagnostics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.DirectInput">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\SharpDX.DirectInput.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SharpDX.XInput">
|
||||
<HintPath>..\..\lib\SharpDX\Bin\SharpDX.XInput.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FormatConverter.cs" />
|
||||
<Compile Include="GamePadCreator.cs" />
|
||||
<Compile Include="Keyboard.cs" />
|
||||
<Compile Include="KeyboardCreator.cs" />
|
||||
<Compile Include="MouseCreator.cs" />
|
||||
<Compile Include="Metadata.Designer.cs">
|
||||
<DependentUpon>Metadata.resx</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<Compile Include="Mouse.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="GamePad.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework.csproj">
|
||||
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
|
||||
<Name>ANX.Framework</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Metadata.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Metadata.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
404
InputSystems/ANX.InputDevices.Windows.XInput/FormatConverter.cs
Normal file
404
InputSystems/ANX.InputDevices.Windows.XInput/FormatConverter.cs
Normal file
@ -0,0 +1,404 @@
|
||||
#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.InputDevices.Windows.XInput
|
||||
{
|
||||
internal class FormatConverter
|
||||
{
|
||||
public static ANX.Framework.Input.Keys Translate(SharpDX.DirectInput.Key key)
|
||||
{
|
||||
//TODO: implement all keys
|
||||
//TODO: test if a array with the mapping which is constructed once is faster
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case SharpDX.DirectInput.Key.A:
|
||||
return Keys.A;
|
||||
case SharpDX.DirectInput.Key.AT:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.AX:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.AbntC1:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.AbntC2:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Add:
|
||||
return Keys.Add;
|
||||
case SharpDX.DirectInput.Key.Apostrophe:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Applications:
|
||||
//check
|
||||
return Keys.Apps;
|
||||
case SharpDX.DirectInput.Key.B:
|
||||
return Keys.B;
|
||||
case SharpDX.DirectInput.Key.Back:
|
||||
return Keys.Back;
|
||||
case SharpDX.DirectInput.Key.Backslash:
|
||||
return Keys.OemBackslash;
|
||||
case SharpDX.DirectInput.Key.C:
|
||||
return Keys.C;
|
||||
case SharpDX.DirectInput.Key.Calculator:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Capital:
|
||||
//check
|
||||
return Keys.CapsLock;
|
||||
case SharpDX.DirectInput.Key.Colon:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Comma:
|
||||
return Keys.OemComma;
|
||||
case SharpDX.DirectInput.Key.Convert:
|
||||
return Keys.ImeConvert;
|
||||
case SharpDX.DirectInput.Key.D:
|
||||
return Keys.D;
|
||||
case SharpDX.DirectInput.Key.D0:
|
||||
return Keys.D0;
|
||||
case SharpDX.DirectInput.Key.D1:
|
||||
return Keys.D1;
|
||||
case SharpDX.DirectInput.Key.D2:
|
||||
return Keys.D2;
|
||||
case SharpDX.DirectInput.Key.D3:
|
||||
return Keys.D3;
|
||||
case SharpDX.DirectInput.Key.D4:
|
||||
return Keys.D4;
|
||||
case SharpDX.DirectInput.Key.D5:
|
||||
return Keys.D5;
|
||||
case SharpDX.DirectInput.Key.D6:
|
||||
return Keys.D6;
|
||||
case SharpDX.DirectInput.Key.D7:
|
||||
return Keys.D7;
|
||||
case SharpDX.DirectInput.Key.D8:
|
||||
return Keys.D8;
|
||||
case SharpDX.DirectInput.Key.D9:
|
||||
return Keys.D9;
|
||||
case SharpDX.DirectInput.Key.Decimal:
|
||||
return Keys.Decimal;
|
||||
case SharpDX.DirectInput.Key.Delete:
|
||||
return Keys.Delete;
|
||||
case SharpDX.DirectInput.Key.Divide:
|
||||
return Keys.Divide;
|
||||
case SharpDX.DirectInput.Key.Down:
|
||||
return Keys.Down;
|
||||
case SharpDX.DirectInput.Key.E:
|
||||
return Keys.E;
|
||||
case SharpDX.DirectInput.Key.End:
|
||||
return Keys.End;
|
||||
case SharpDX.DirectInput.Key.Equals:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Escape:
|
||||
return Keys.Escape;
|
||||
case SharpDX.DirectInput.Key.F:
|
||||
return Keys.F;
|
||||
case SharpDX.DirectInput.Key.F1:
|
||||
return Keys.F1;
|
||||
case SharpDX.DirectInput.Key.F10:
|
||||
return Keys.F10;
|
||||
case SharpDX.DirectInput.Key.F11:
|
||||
return Keys.F11;
|
||||
case SharpDX.DirectInput.Key.F12:
|
||||
return Keys.F12;
|
||||
case SharpDX.DirectInput.Key.F13:
|
||||
return Keys.F13;
|
||||
case SharpDX.DirectInput.Key.F14:
|
||||
return Keys.F14;
|
||||
case SharpDX.DirectInput.Key.F15:
|
||||
return Keys.F15;
|
||||
case SharpDX.DirectInput.Key.F2:
|
||||
return Keys.F2;
|
||||
case SharpDX.DirectInput.Key.F3:
|
||||
return Keys.F3;
|
||||
case SharpDX.DirectInput.Key.F4:
|
||||
return Keys.F4;
|
||||
case SharpDX.DirectInput.Key.F5:
|
||||
return Keys.F5;
|
||||
case SharpDX.DirectInput.Key.F6:
|
||||
return Keys.F6;
|
||||
case SharpDX.DirectInput.Key.F7:
|
||||
return Keys.F7;
|
||||
case SharpDX.DirectInput.Key.F8:
|
||||
return Keys.F8;
|
||||
case SharpDX.DirectInput.Key.F9:
|
||||
return Keys.F9;
|
||||
case SharpDX.DirectInput.Key.G:
|
||||
return Keys.G;
|
||||
case SharpDX.DirectInput.Key.Grave:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.H:
|
||||
return Keys.H;
|
||||
case SharpDX.DirectInput.Key.Home:
|
||||
return Keys.Home;
|
||||
case SharpDX.DirectInput.Key.I:
|
||||
return Keys.I;
|
||||
case SharpDX.DirectInput.Key.Insert:
|
||||
return Keys.Insert;
|
||||
case SharpDX.DirectInput.Key.J:
|
||||
return Keys.J;
|
||||
case SharpDX.DirectInput.Key.K:
|
||||
return Keys.K;
|
||||
case SharpDX.DirectInput.Key.Kana:
|
||||
return Keys.Kana;
|
||||
case SharpDX.DirectInput.Key.Kanji:
|
||||
return Keys.Kanji;
|
||||
case SharpDX.DirectInput.Key.L:
|
||||
return Keys.L;
|
||||
case SharpDX.DirectInput.Key.Left:
|
||||
return Keys.Left;
|
||||
case SharpDX.DirectInput.Key.LeftAlt:
|
||||
return Keys.LeftAlt;
|
||||
case SharpDX.DirectInput.Key.LeftBracket:
|
||||
return Keys.OemOpenBrackets;
|
||||
case SharpDX.DirectInput.Key.LeftControl:
|
||||
return Keys.LeftControl;
|
||||
case SharpDX.DirectInput.Key.LeftShift:
|
||||
return Keys.LeftShift;
|
||||
case SharpDX.DirectInput.Key.LeftWindowsKey:
|
||||
return Keys.LeftWindows;
|
||||
case SharpDX.DirectInput.Key.M:
|
||||
return Keys.M;
|
||||
case SharpDX.DirectInput.Key.Mail:
|
||||
return Keys.LaunchMail;
|
||||
case SharpDX.DirectInput.Key.MediaSelect:
|
||||
return Keys.SelectMedia;
|
||||
case SharpDX.DirectInput.Key.MediaStop:
|
||||
return Keys.MediaStop;
|
||||
case SharpDX.DirectInput.Key.Minus:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Multiply:
|
||||
return Keys.Multiply;
|
||||
case SharpDX.DirectInput.Key.Mute:
|
||||
return Keys.VolumeMute;
|
||||
case SharpDX.DirectInput.Key.MyComputer:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.N:
|
||||
return Keys.N;
|
||||
case SharpDX.DirectInput.Key.NextTrack:
|
||||
return Keys.MediaNextTrack;
|
||||
case SharpDX.DirectInput.Key.NoConvert:
|
||||
return Keys.ImeNoConvert;
|
||||
case SharpDX.DirectInput.Key.NumberLock:
|
||||
return Keys.NumLock;
|
||||
case SharpDX.DirectInput.Key.NumberPad0:
|
||||
return Keys.NumPad0;
|
||||
case SharpDX.DirectInput.Key.NumberPad1:
|
||||
return Keys.NumPad1;
|
||||
case SharpDX.DirectInput.Key.NumberPad2:
|
||||
return Keys.NumPad2;
|
||||
case SharpDX.DirectInput.Key.NumberPad3:
|
||||
return Keys.NumPad3;
|
||||
case SharpDX.DirectInput.Key.NumberPad4:
|
||||
return Keys.NumPad4;
|
||||
case SharpDX.DirectInput.Key.NumberPad5:
|
||||
return Keys.NumPad5;
|
||||
case SharpDX.DirectInput.Key.NumberPad6:
|
||||
return Keys.NumPad6;;
|
||||
case SharpDX.DirectInput.Key.NumberPad7:
|
||||
return Keys.NumPad7;
|
||||
case SharpDX.DirectInput.Key.NumberPad8:
|
||||
return Keys.NumPad8;
|
||||
case SharpDX.DirectInput.Key.NumberPad9:
|
||||
return Keys.NumPad9;
|
||||
case SharpDX.DirectInput.Key.NumberPadComma:
|
||||
return Keys.OemComma;
|
||||
case SharpDX.DirectInput.Key.NumberPadEnter:
|
||||
return Keys.Enter;
|
||||
case SharpDX.DirectInput.Key.NumberPadEquals:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.O:
|
||||
return Keys.O;
|
||||
case SharpDX.DirectInput.Key.Oem102:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.P:
|
||||
return Keys.P;
|
||||
case SharpDX.DirectInput.Key.PageDown:
|
||||
return Keys.PageDown;
|
||||
case SharpDX.DirectInput.Key.PageUp:
|
||||
return Keys.PageUp;
|
||||
case SharpDX.DirectInput.Key.Pause:
|
||||
return Keys.Pause;
|
||||
case SharpDX.DirectInput.Key.Period:
|
||||
return Keys.OemPeriod;
|
||||
case SharpDX.DirectInput.Key.PlayPause:
|
||||
return Keys.MediaPlayPause;
|
||||
case SharpDX.DirectInput.Key.Power:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.PreviousTrack:
|
||||
return Keys.MediaPreviousTrack;
|
||||
case SharpDX.DirectInput.Key.PrintScreen:
|
||||
return Keys.PrintScreen;
|
||||
case SharpDX.DirectInput.Key.Q:
|
||||
return Keys.Q;
|
||||
case SharpDX.DirectInput.Key.R:
|
||||
return Keys.R;
|
||||
case SharpDX.DirectInput.Key.Return:
|
||||
//check
|
||||
return Keys.Enter;
|
||||
case SharpDX.DirectInput.Key.Right:
|
||||
return Keys.Right;
|
||||
case SharpDX.DirectInput.Key.RightAlt:
|
||||
return Keys.RightAlt;
|
||||
case SharpDX.DirectInput.Key.RightBracket:
|
||||
return Keys.OemCloseBrackets;
|
||||
case SharpDX.DirectInput.Key.RightControl:
|
||||
return Keys.RightControl;
|
||||
case SharpDX.DirectInput.Key.RightShift:
|
||||
return Keys.RightShift;
|
||||
case SharpDX.DirectInput.Key.RightWindowsKey:
|
||||
return Keys.RightWindows;
|
||||
case SharpDX.DirectInput.Key.S:
|
||||
return Keys.S;
|
||||
case SharpDX.DirectInput.Key.ScrollLock:
|
||||
//check
|
||||
return Keys.Scroll;
|
||||
case SharpDX.DirectInput.Key.Semicolon:
|
||||
return Keys.OemSemicolon;
|
||||
case SharpDX.DirectInput.Key.Slash:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Sleep:
|
||||
return Keys.Sleep;
|
||||
case SharpDX.DirectInput.Key.Space:
|
||||
return Keys.Space;
|
||||
case SharpDX.DirectInput.Key.Stop:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Subtract:
|
||||
return Keys.Subtract;
|
||||
case SharpDX.DirectInput.Key.T:
|
||||
return Keys.T;
|
||||
case SharpDX.DirectInput.Key.Tab:
|
||||
return Keys.Tab;
|
||||
case SharpDX.DirectInput.Key.U:
|
||||
return Keys.U;
|
||||
case SharpDX.DirectInput.Key.Underline:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Unknown:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Unlabeled:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.UpArrow:
|
||||
return Keys.Up;
|
||||
case SharpDX.DirectInput.Key.V:
|
||||
return Keys.V;
|
||||
case SharpDX.DirectInput.Key.VolumeDown:
|
||||
return Keys.VolumeDown;
|
||||
case SharpDX.DirectInput.Key.VolumeUp:
|
||||
return Keys.VolumeUp;
|
||||
case SharpDX.DirectInput.Key.W:
|
||||
return Keys.W;
|
||||
case SharpDX.DirectInput.Key.Wake:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.WebBack:
|
||||
return Keys.BrowserBack;
|
||||
case SharpDX.DirectInput.Key.WebFavorites:
|
||||
return Keys.BrowserFavorites;
|
||||
case SharpDX.DirectInput.Key.WebForward:
|
||||
return Keys.BrowserForward;
|
||||
case SharpDX.DirectInput.Key.WebHome:
|
||||
return Keys.BrowserHome;
|
||||
case SharpDX.DirectInput.Key.WebRefresh:
|
||||
return Keys.BrowserRefresh;
|
||||
case SharpDX.DirectInput.Key.WebSearch:
|
||||
return Keys.BrowserSearch;
|
||||
case SharpDX.DirectInput.Key.WebStop:
|
||||
return Keys.BrowserStop;
|
||||
case SharpDX.DirectInput.Key.X:
|
||||
return Keys.X;
|
||||
case SharpDX.DirectInput.Key.Y:
|
||||
return Keys.Y;
|
||||
case SharpDX.DirectInput.Key.Yen:
|
||||
break;
|
||||
case SharpDX.DirectInput.Key.Z:
|
||||
return Keys.Z;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public static KeyboardState Translate(SharpDX.DirectInput.KeyboardState keyboardState)
|
||||
{
|
||||
int keyCount = keyboardState.PressedKeys.Count;
|
||||
Keys[] keys = new Keys[keyCount];
|
||||
|
||||
for (int i = 0; i < keyCount; i++)
|
||||
{
|
||||
keys[i] = Translate(keyboardState.PressedKeys[i]);
|
||||
}
|
||||
|
||||
KeyboardState ks = new KeyboardState(keys);
|
||||
|
||||
return ks;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
159
InputSystems/ANX.InputDevices.Windows.XInput/GamePad.cs
Normal file
159
InputSystems/ANX.InputDevices.Windows.XInput/GamePad.cs
Normal file
@ -0,0 +1,159 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.Input;
|
||||
using ANX.Framework;
|
||||
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.InputDevices.Windows.XInput
|
||||
{
|
||||
public class GamePad : IGamePad
|
||||
{
|
||||
#region Private Members
|
||||
private Controller[] controller;
|
||||
private const float thumbstickRangeFactor = 1.0f / short.MaxValue;
|
||||
|
||||
#endregion // Private Members
|
||||
|
||||
public GamePad()
|
||||
{
|
||||
controller = new Controller[4];
|
||||
controller[0] = new Controller(UserIndex.One);
|
||||
controller[1] = new Controller(UserIndex.Two);
|
||||
controller[2] = new Controller(UserIndex.Three);
|
||||
controller[3] = new Controller(UserIndex.Four);
|
||||
}
|
||||
public GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
|
||||
{
|
||||
Capabilities result;
|
||||
GamePadCapabilities returnres;
|
||||
//SharpDX.XInput.Capabilities = new SharpDX.XInput.Capabilities();
|
||||
try
|
||||
{
|
||||
result = controller[(int)playerIndex].GetCapabilities(DeviceQueryType.Gamepad);
|
||||
returnres = new GamePadCapabilities();
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
returnres = new GamePadCapabilities();
|
||||
} return returnres;
|
||||
}
|
||||
|
||||
public GamePadState GetState(PlayerIndex playerIndex, out bool isConnected, out int packetNumber)
|
||||
{
|
||||
State result;
|
||||
GamePadState returnres;
|
||||
if(controller[(int)playerIndex].IsConnected)
|
||||
{
|
||||
result = controller[(int)playerIndex].GetState();
|
||||
//returnres = new GamePadCapabilities(result.Type,result.Gamepad.Buttons.)
|
||||
returnres = new GamePadState(new Vector2(result.Gamepad.LeftThumbX * thumbstickRangeFactor, result.Gamepad.LeftThumbY * thumbstickRangeFactor), new Vector2(result.Gamepad.RightThumbX * thumbstickRangeFactor, result.Gamepad.RightThumbY * thumbstickRangeFactor), (float)result.Gamepad.LeftTrigger, (float)result.Gamepad.RightTrigger, FormatConverter.Translate(result.Gamepad.Buttons));
|
||||
packetNumber = result.PacketNumber;
|
||||
isConnected = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
isConnected = false;
|
||||
packetNumber = 0;
|
||||
returnres = new GamePadState();
|
||||
}
|
||||
|
||||
|
||||
return returnres;
|
||||
}
|
||||
|
||||
public GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode, out bool isConnected, out int packetNumber)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor)
|
||||
{
|
||||
short left;
|
||||
short right;
|
||||
if (Math.Abs(leftMotor)>1)
|
||||
{
|
||||
left = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
left = Convert.ToInt16(Math.Abs(leftMotor) * short.MaxValue);
|
||||
}
|
||||
if (Math.Abs(rightMotor) > 1)
|
||||
{
|
||||
right = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
right = Convert.ToInt16(Math.Abs(rightMotor) * short.MaxValue);
|
||||
}
|
||||
|
||||
if (controller[(int)playerIndex].IsConnected)
|
||||
{
|
||||
Vibration vib = new Vibration();
|
||||
vib.LeftMotorSpeed = left;
|
||||
vib.RightMotorSpeed = right;
|
||||
controller[(int)playerIndex].SetVibration(vib);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA;
|
||||
using NLog;
|
||||
using ANX.Framework.NonXNA.InputSystem;
|
||||
|
||||
#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.InputDevices.Windows.XInput
|
||||
{
|
||||
public class GamePadCreator : IGamePadCreator
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "XInput.GamePad";
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCreator(InputDeviceFactory factory)
|
||||
{
|
||||
factory.AddCreator(this);
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get { return 10; }
|
||||
}
|
||||
|
||||
public IGamePad CreateGamePadInstance()
|
||||
{
|
||||
return new GamePad();
|
||||
}
|
||||
}
|
||||
}
|
128
InputSystems/ANX.InputDevices.Windows.XInput/Keyboard.cs
Normal file
128
InputSystems/ANX.InputDevices.Windows.XInput/Keyboard.cs
Normal file
@ -0,0 +1,128 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ANX.InputDevices;
|
||||
using ANX.Framework.NonXNA;
|
||||
using SharpDX.DirectInput;
|
||||
using DXKeyboard=SharpDX.DirectInput.Keyboard;
|
||||
#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.InputDevices.Windows.XInput
|
||||
{
|
||||
public class Keyboard : IKeyboard
|
||||
{
|
||||
#region Private Members
|
||||
private DirectInput directInput;
|
||||
private DXKeyboard nativeKeyboard;
|
||||
private KeyboardState nativeState;
|
||||
|
||||
#endregion // Private Members
|
||||
|
||||
public IntPtr WindowHandle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Keyboard()
|
||||
{
|
||||
this.nativeState = new KeyboardState();
|
||||
}
|
||||
|
||||
public Framework.Input.KeyboardState GetState(Framework.PlayerIndex playerIndex)
|
||||
{
|
||||
//TODO: prevent new
|
||||
|
||||
// only available on XBox, behaviour regarding MSDN: empty keystate
|
||||
|
||||
return new Framework.Input.KeyboardState();
|
||||
}
|
||||
|
||||
public Framework.Input.KeyboardState GetState()
|
||||
{
|
||||
if (this.nativeKeyboard == null && this.WindowHandle != null && this.WindowHandle != IntPtr.Zero)
|
||||
{
|
||||
this.directInput = new DirectInput();
|
||||
this.nativeKeyboard = new DXKeyboard(this.directInput);
|
||||
this.nativeKeyboard.SetCooperativeLevel(this.WindowHandle, CooperativeLevel.NonExclusive | CooperativeLevel.Background);
|
||||
this.nativeKeyboard.Acquire();
|
||||
}
|
||||
|
||||
if (this.nativeKeyboard != null)
|
||||
{
|
||||
nativeKeyboard.GetCurrentState(ref this.nativeState);
|
||||
if (this.nativeState.PressedKeys.Count > 0)
|
||||
{
|
||||
return FormatConverter.Translate(this.nativeState);
|
||||
}
|
||||
}
|
||||
|
||||
return new Framework.Input.KeyboardState();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (this.nativeKeyboard != null)
|
||||
{
|
||||
this.nativeKeyboard.Unacquire();
|
||||
this.nativeKeyboard.Dispose();
|
||||
this.nativeKeyboard = null;
|
||||
}
|
||||
|
||||
if (this.directInput != null)
|
||||
{
|
||||
this.directInput.Dispose();
|
||||
this.directInput = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA;
|
||||
using NLog;
|
||||
using ANX.Framework.NonXNA.InputSystem;
|
||||
|
||||
#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.InputDevices.Windows.XInput
|
||||
{
|
||||
public class KeyboardCreator : IKeyboardCreator
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "DirectInput.DXKeyboard";
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCreator(InputDeviceFactory factory)
|
||||
{
|
||||
factory.AddCreator(this);
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get { return 10; }
|
||||
}
|
||||
|
||||
public IKeyboard CreateKeyboardInstance()
|
||||
{
|
||||
return new Keyboard();
|
||||
}
|
||||
}
|
||||
}
|
72
InputSystems/ANX.InputDevices.Windows.XInput/Metadata.Designer.cs
generated
Normal file
72
InputSystems/ANX.InputDevices.Windows.XInput/Metadata.Designer.cs
generated
Normal file
@ -0,0 +1,72 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Dieser Code wurde von einem Tool generiert.
|
||||
// Laufzeitversion: 4.0.30319.239
|
||||
//
|
||||
// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn
|
||||
// der Code erneut generiert wird.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ANX.InputDevices.Windows.XInput {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
|
||||
/// </summary>
|
||||
// Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert
|
||||
// -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert.
|
||||
// Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
|
||||
// mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Metadata {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Metadata() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ANX.InputDevices.Windows.XInput.Metadata", typeof(Metadata).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
|
||||
/// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
public static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sucht eine lokalisierte Zeichenfolge, die Win32NT ähnelt.
|
||||
/// </summary>
|
||||
public static string SupportedPlatforms {
|
||||
get {
|
||||
return ResourceManager.GetString("SupportedPlatforms", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
124
InputSystems/ANX.InputDevices.Windows.XInput/Metadata.resx
Normal file
124
InputSystems/ANX.InputDevices.Windows.XInput/Metadata.resx
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="SupportedPlatforms" xml:space="preserve">
|
||||
<value>Win32NT</value>
|
||||
<comment> </comment>
|
||||
</data>
|
||||
</root>
|
137
InputSystems/ANX.InputDevices.Windows.XInput/Mouse.cs
Normal file
137
InputSystems/ANX.InputDevices.Windows.XInput/Mouse.cs
Normal file
@ -0,0 +1,137 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ANX.Framework.NonXNA;
|
||||
using ANX.Framework.Input;
|
||||
using SharpDX.DirectInput;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework;
|
||||
|
||||
#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
|
||||
|
||||
using MouseX = SharpDX.DirectInput.Mouse;
|
||||
|
||||
namespace ANX.InputDevices.Windows.XInput
|
||||
{
|
||||
class Mouse : IMouse
|
||||
{
|
||||
#region Interop
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool GetCursorPos(ref Point lpPoint);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern void SetCursorPos(int x, int y);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
static extern bool ScreenToClient(IntPtr hWnd, ref Point lpPoint);
|
||||
|
||||
#endregion // Interop
|
||||
|
||||
#region Private Members
|
||||
private DirectInput directInput;
|
||||
private MouseX mouse;
|
||||
|
||||
#endregion // Private Members
|
||||
|
||||
public IntPtr WindowHandle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Mouse()
|
||||
{
|
||||
this.directInput = new DirectInput();
|
||||
this.mouse = new MouseX(this.directInput);
|
||||
this.mouse.Properties.AxisMode = DeviceAxisMode.Absolute;
|
||||
this.mouse.Acquire();
|
||||
}
|
||||
|
||||
public ANX.Framework.Input.MouseState GetState()
|
||||
{
|
||||
var state = this.mouse.GetCurrentState();
|
||||
|
||||
Point cursorPos = new Point();
|
||||
GetCursorPos(ref cursorPos);
|
||||
if (WindowHandle != IntPtr.Zero)
|
||||
{
|
||||
ScreenToClient(WindowHandle, ref cursorPos);
|
||||
}
|
||||
|
||||
state.X = cursorPos.X;
|
||||
state.Y = cursorPos.Y;
|
||||
|
||||
ButtonState left = new ButtonState();
|
||||
ButtonState middle = new ButtonState();
|
||||
ButtonState right = new ButtonState();
|
||||
ButtonState x1 = new ButtonState();
|
||||
ButtonState x2 = new ButtonState();
|
||||
if(state.Buttons[0]){left=ButtonState.Pressed;}
|
||||
if(state.Buttons[1]){middle=ButtonState.Pressed;}
|
||||
if(state.Buttons[2]){right=ButtonState.Pressed;}
|
||||
if(state.Buttons[3]){x1=ButtonState.Pressed;}
|
||||
if(state.Buttons[4]){x2=ButtonState.Pressed;}
|
||||
return new ANX.Framework.Input.MouseState(state.X,state.Y,state.Z,left,middle,right,x1,x2);
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
Point currentPosition = new Point(x, y);
|
||||
GetCursorPos(ref currentPosition);
|
||||
if (WindowHandle != IntPtr.Zero)
|
||||
{
|
||||
ScreenToClient(WindowHandle, ref currentPosition);
|
||||
}
|
||||
SetCursorPos(currentPosition.X, currentPosition.Y);
|
||||
}
|
||||
}
|
||||
}
|
88
InputSystems/ANX.InputDevices.Windows.XInput/MouseCreator.cs
Normal file
88
InputSystems/ANX.InputDevices.Windows.XInput/MouseCreator.cs
Normal file
@ -0,0 +1,88 @@
|
||||
#region Using Statements
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using ANX.Framework.NonXNA;
|
||||
using NLog;
|
||||
using ANX.Framework.NonXNA.InputSystem;
|
||||
|
||||
#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.InputDevices.Windows.XInput
|
||||
{
|
||||
public class MouseCreator : IMouseCreator
|
||||
{
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return "DirectInput.Mouse";
|
||||
}
|
||||
}
|
||||
|
||||
public void RegisterCreator(InputDeviceFactory factory)
|
||||
{
|
||||
factory.AddCreator(this);
|
||||
}
|
||||
|
||||
public int Priority
|
||||
{
|
||||
get { return 10; }
|
||||
}
|
||||
|
||||
public IMouse CreateMouseInstance()
|
||||
{
|
||||
return new Mouse();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user