Skip to content

Commit 1b8c993

Browse files
committed
DirectInput: More improvements and fixes.
1 parent ea94cd0 commit 1b8c993

File tree

5 files changed

+93
-14
lines changed

5 files changed

+93
-14
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Build status](https://github.com/amerkoleci/Vortice.Windows/workflows/ci/badge.svg)](https://github.com/amerkoleci/Vortice.Windows/actions)
55
[![NuGet](https://img.shields.io/nuget/v/Vortice.Direct3D12.svg)](https://www.nuget.org/packages?q=Tags%3A%22Vortice.Windows%22,%22Direct3D12%22)
66

7-
**Vortice.Windows** is a collection of Win32 and UWP libraries with bindings support for [DXGI](https://docs.microsoft.com/en-us/windows/desktop/direct3ddxgi/d3d10-graphics-programming-guide-dxgi), [WIC](https://docs.microsoft.com/en-us/windows/desktop/wic/-wic-lh), [DirectWrite](https://docs.microsoft.com/en-us/windows/desktop/directwrite/direct-write-portal), [Direct2D](https://docs.microsoft.com/en-us/windows/desktop/direct2d/direct2d-portal), [Direct3D9](https://docs.microsoft.com/en-us/windows/win32/direct3d9/dx9-graphics), [Direct3D11](https://docs.microsoft.com/en-us/windows/desktop/direct3d11/atoc-dx-graphics-direct3d-11), [Direct3D12](https://docs.microsoft.com/en-us/windows/desktop/direct3d12/directx-12-programming-guide), [XInput](https://docs.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput), [XAudio2](https://docs.microsoft.com/en-us/windows/win32/xaudio2/xaudio2-introduction) and [X3DAudio](https://docs.microsoft.com/it-it/windows/win32/xaudio2/x3daudio).
7+
**Vortice.Windows** is a collection of Win32 and UWP libraries with bindings support for [DXGI](https://docs.microsoft.com/en-us/windows/desktop/direct3ddxgi/d3d10-graphics-programming-guide-dxgi), [WIC](https://docs.microsoft.com/en-us/windows/desktop/wic/-wic-lh), [DirectWrite](https://docs.microsoft.com/en-us/windows/desktop/directwrite/direct-write-portal), [Direct2D](https://docs.microsoft.com/en-us/windows/desktop/direct2d/direct2d-portal), [Direct3D9](https://docs.microsoft.com/en-us/windows/win32/direct3d9/dx9-graphics), [Direct3D11](https://docs.microsoft.com/en-us/windows/desktop/direct3d11/atoc-dx-graphics-direct3d-11), [Direct3D12](https://docs.microsoft.com/en-us/windows/desktop/direct3d12/directx-12-programming-guide), [XInput](https://docs.microsoft.com/en-us/windows/win32/xinput/getting-started-with-xinput), [XAudio2](https://docs.microsoft.com/en-us/windows/win32/xaudio2/xaudio2-introduction), [X3DAudio](https://docs.microsoft.com/it-it/windows/win32/xaudio2/x3daudio) and [DirectInput](https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee416842(v=vs.85)).
88

99
This library targets .NET Standard 2.0 and uses modern .NET API, see [CHANGELOG](https://github.com/amerkoleci/Vortice.Windows/blob/master/CHANGELOG.md) for list of changes between commits.
1010

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
namespace Vortice.DirectInput
22+
{
23+
public partial struct Capabilities
24+
{
25+
/// <summary>
26+
/// Gets the type of this device.
27+
/// </summary>
28+
public DeviceType Type => (DeviceType)(RawType & 0xFF);
29+
30+
/// <summary>
31+
/// Gets the subtype of the device.
32+
/// </summary>
33+
public int Subtype => RawType >> 8;
34+
35+
/// <summary>
36+
/// Gets a value indicating whether this instance is human interface device.
37+
/// </summary>
38+
/// <value>
39+
/// <c>true</c> if this instance is human interface device; otherwise, <c>false</c>.
40+
/// </value>
41+
public bool IsHumanInterfaceDevice => ((RawType & 0x10000) != 0);
42+
}
43+
}

src/Vortice.DirectInput/DeviceInstance.cs

-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@
1717
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1818
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1919
// THE SOFTWARE.
20-
// Copyright (c) Amer Koleci and contributors.
21-
// Distributed under the MIT license. See the LICENSE file in the project root for more information.
22-
23-
using System.Runtime.InteropServices;
2420

2521
namespace Vortice.DirectInput
2622
{

src/Vortice.DirectInput/IDirectInputDevice8.cs

+30
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,36 @@ public partial class IDirectInputDevice8
3636
private DataFormat? _dataFormat;
3737
private readonly Dictionary<string, ObjectDataFormat> _mapNameToObjectFormat = new Dictionary<string, ObjectDataFormat>();
3838

39+
public Capabilities Capabilities
40+
{
41+
get
42+
{
43+
unsafe
44+
{
45+
Capabilities capabilities = default;
46+
capabilities.Size = sizeof(Capabilities);
47+
GetCapabilities(&capabilities).CheckError();
48+
return capabilities;
49+
};
50+
}
51+
}
52+
53+
public DeviceInstance DeviceInfo
54+
{
55+
get
56+
{
57+
unsafe
58+
{
59+
DeviceInstance.__Native deviceInfoNative = DeviceInstance.__NewNative();
60+
GetDeviceInfo(&deviceInfoNative).CheckError();
61+
62+
var deviceInfo = new DeviceInstance();
63+
deviceInfo.__MarshalFrom(ref deviceInfoNative);
64+
return deviceInfo;
65+
};
66+
}
67+
}
68+
3969
/// <summary>
4070
/// Gets the created effects.
4171
/// </summary>

src/Vortice.DirectInput/Mappings.xml

+19-9
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@
774774
<remove struct="DICOLORSET"/>
775775

776776
<!-- Make all dwSize fields in structure hidden by default -->
777-
<map field=".*::dwSize" relation="struct-size()" visibility="internal"/>
777+
<map field=".*::dwSize" visibility="internal"/>
778778

779779
<!--
780780
DIACTIONW has an inner union that we need to remove.
@@ -828,13 +828,24 @@
828828
<map field="DIEFFECT::lpvTypeSpecificParams" name="TypeSpecificParamPointer" visibility="internal"/>
829829

830830
<!-- DIFILEEFFECT -->
831-
<map struct="DIFILEEFFECT" name="EffectFile"/>
832-
<map struct="DIFILEEFFECT" native="true" struct-to-class="true" marshal="true" new="true" />
831+
<map struct="DIFILEEFFECT" name="EffectFile" native="true" struct-to-class="true" marshal="true" new="true" />
833832
<map field="DIFILEEFFECT::dwSize" visibility="internal"/>
834833
<map field="DIFILEEFFECT::GuidEffect" name="Guid"/>
835834
<map field="DIFILEEFFECT::lpDiEffect" name="EffectParametersPointer" visibility="internal"/>
836835
<map field="DIFILEEFFECT::szFriendlyName" name="Name"/>
837836

837+
<!-- DIDEVCAPS -->
838+
<map struct="DIDEVCAPS" name="Capabilities" />
839+
<map field="DIDEVCAPS::dwSize" visibility="internal"/>
840+
<map field="DIDEVCAPS::dwAxes" name="AxeCount"/>
841+
<map field="DIDEVCAPS::dwButtons" name="ButtonCount"/>
842+
<map field="DIDEVCAPS::dwFFDriverVersion" name="DriverVersion"/>
843+
<map field="DIDEVCAPS::dwFFMinTimeResolution" name="ForceFeedbackMinimumTimeResolution"/>
844+
<map field="DIDEVCAPS::dwFFSamplePeriod" name="ForceFeedbackSamplePeriod"/>
845+
<map field="DIDEVCAPS::dwPOVs" name="PovCount"/>
846+
<map field="DIDEVCAPS::dwFlags" type="DIDC"/>
847+
<map field="DIDEVCAPS::dwDevType" name="RawType" visibility="internal"/>
848+
838849
<!-- DIACTIONFORMATW -->
839850
<map struct="DIACTIONFORMATW" name="ActionFormat" visibility="internal"/>
840851

@@ -947,13 +958,15 @@
947958
<map interface="IDirectInputDevice8W" name="IDirectInputDevice8"/>
948959

949960
<map method="IDirectInputDevice8W::Poll" hresult="true" check="false" />
961+
<map method="IDirectInputDevice8W::Acquire" hresult="true" check="false" />
950962
<map method="IDirectInputDevice8W::Unacquire" hresult="true" check="false" />
951963

952964
<map method="IDirectInputDevice8W::Escape" visibility="internal" />
953-
<map param="IDirectInputDevice8W::GetCapabilities::arg0" attribute="out"/>
965+
<map method="IDirectInputDevice8W::GetCapabilities" hresult="true" check="false" visibility="internal" property="false"/>
966+
<map param="IDirectInputDevice8W::GetCapabilities::arg0" type="void" keep-pointers="true" return="false" />
954967

955-
<map method="IDirectInputDevice8W::GetDeviceInfo" name="GetInformation"/>
956-
<map param="IDirectInputDevice8W::GetDeviceInfo::arg0" attribute="out"/>
968+
<map method="IDirectInputDevice8W::GetDeviceInfo" hresult="true" check="false" visibility="internal" property="false"/>
969+
<map param="IDirectInputDevice8W::GetDeviceInfo::arg0" type="void" keep-pointers="true" return="false" />
957970

958971
<map method="IDirectInputDevice8W::GetImageInfo" visibility="internal"/>
959972

@@ -1001,9 +1014,6 @@
10011014

10021015
<map param="IDirectInputDevice8W::WriteEffectToFile" visibility="internal"/>
10031016
<map param="IDirectInputDevice8W::WriteEffectToFile::arg2" attribute="in buffer"/>
1004-
1005-
<map method="IDirectInputDevice8W::GetProperty" visibility="internal"/>
1006-
<map method="IDirectInputDevice8W::SetProperty" visibility="internal"/>
10071017

10081018
<!-- IDirectInputEffect -->
10091019
<map method="IDirectInputEffect::Initialize" visibility="internal"/>

0 commit comments

Comments
 (0)