Skip to content

Commit

Permalink
DirectInput: More improvements and fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
amerkoleci committed Aug 25, 2021
1 parent ea94cd0 commit 1b8c993
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Build status](https://github.com/amerkoleci/Vortice.Windows/workflows/ci/badge.svg)](https://github.com/amerkoleci/Vortice.Windows/actions)
[![NuGet](https://img.shields.io/nuget/v/Vortice.Direct3D12.svg)](https://www.nuget.org/packages?q=Tags%3A%22Vortice.Windows%22,%22Direct3D12%22)

**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).
**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)).

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.

Expand Down
43 changes: 43 additions & 0 deletions src/Vortice.DirectInput/Capabilities.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2010-2014 SharpDX - Alexandre Mutel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

namespace Vortice.DirectInput
{
public partial struct Capabilities
{
/// <summary>
/// Gets the type of this device.
/// </summary>
public DeviceType Type => (DeviceType)(RawType & 0xFF);

/// <summary>
/// Gets the subtype of the device.
/// </summary>
public int Subtype => RawType >> 8;

/// <summary>
/// Gets a value indicating whether this instance is human interface device.
/// </summary>
/// <value>
/// <c>true</c> if this instance is human interface device; otherwise, <c>false</c>.
/// </value>
public bool IsHumanInterfaceDevice => ((RawType & 0x10000) != 0);
}
}
4 changes: 0 additions & 4 deletions src/Vortice.DirectInput/DeviceInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// Copyright (c) Amer Koleci and contributors.
// Distributed under the MIT license. See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;

namespace Vortice.DirectInput
{
Expand Down
30 changes: 30 additions & 0 deletions src/Vortice.DirectInput/IDirectInputDevice8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ public partial class IDirectInputDevice8
private DataFormat? _dataFormat;
private readonly Dictionary<string, ObjectDataFormat> _mapNameToObjectFormat = new Dictionary<string, ObjectDataFormat>();

public Capabilities Capabilities
{
get
{
unsafe
{
Capabilities capabilities = default;
capabilities.Size = sizeof(Capabilities);
GetCapabilities(&capabilities).CheckError();
return capabilities;
};
}
}

public DeviceInstance DeviceInfo
{
get
{
unsafe
{
DeviceInstance.__Native deviceInfoNative = DeviceInstance.__NewNative();
GetDeviceInfo(&deviceInfoNative).CheckError();

var deviceInfo = new DeviceInstance();
deviceInfo.__MarshalFrom(ref deviceInfoNative);
return deviceInfo;
};
}
}

/// <summary>
/// Gets the created effects.
/// </summary>
Expand Down
28 changes: 19 additions & 9 deletions src/Vortice.DirectInput/Mappings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@
<remove struct="DICOLORSET"/>

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

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

<!-- DIFILEEFFECT -->
<map struct="DIFILEEFFECT" name="EffectFile"/>
<map struct="DIFILEEFFECT" native="true" struct-to-class="true" marshal="true" new="true" />
<map struct="DIFILEEFFECT" name="EffectFile" native="true" struct-to-class="true" marshal="true" new="true" />
<map field="DIFILEEFFECT::dwSize" visibility="internal"/>
<map field="DIFILEEFFECT::GuidEffect" name="Guid"/>
<map field="DIFILEEFFECT::lpDiEffect" name="EffectParametersPointer" visibility="internal"/>
<map field="DIFILEEFFECT::szFriendlyName" name="Name"/>

<!-- DIDEVCAPS -->
<map struct="DIDEVCAPS" name="Capabilities" />
<map field="DIDEVCAPS::dwSize" visibility="internal"/>
<map field="DIDEVCAPS::dwAxes" name="AxeCount"/>
<map field="DIDEVCAPS::dwButtons" name="ButtonCount"/>
<map field="DIDEVCAPS::dwFFDriverVersion" name="DriverVersion"/>
<map field="DIDEVCAPS::dwFFMinTimeResolution" name="ForceFeedbackMinimumTimeResolution"/>
<map field="DIDEVCAPS::dwFFSamplePeriod" name="ForceFeedbackSamplePeriod"/>
<map field="DIDEVCAPS::dwPOVs" name="PovCount"/>
<map field="DIDEVCAPS::dwFlags" type="DIDC"/>
<map field="DIDEVCAPS::dwDevType" name="RawType" visibility="internal"/>

<!-- DIACTIONFORMATW -->
<map struct="DIACTIONFORMATW" name="ActionFormat" visibility="internal"/>

Expand Down Expand Up @@ -947,13 +958,15 @@
<map interface="IDirectInputDevice8W" name="IDirectInputDevice8"/>

<map method="IDirectInputDevice8W::Poll" hresult="true" check="false" />
<map method="IDirectInputDevice8W::Acquire" hresult="true" check="false" />
<map method="IDirectInputDevice8W::Unacquire" hresult="true" check="false" />

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

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

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

Expand Down Expand Up @@ -1001,9 +1014,6 @@

<map param="IDirectInputDevice8W::WriteEffectToFile" visibility="internal"/>
<map param="IDirectInputDevice8W::WriteEffectToFile::arg2" attribute="in buffer"/>

<map method="IDirectInputDevice8W::GetProperty" visibility="internal"/>
<map method="IDirectInputDevice8W::SetProperty" visibility="internal"/>

<!-- IDirectInputEffect -->
<map method="IDirectInputEffect::Initialize" visibility="internal"/>
Expand Down

0 comments on commit 1b8c993

Please sign in to comment.