Skip to content

Commit

Permalink
Merge branch 'controllers' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkirie authored Nov 20, 2022
2 parents a974020 + 524ce80 commit e05fc18
Show file tree
Hide file tree
Showing 250 changed files with 414,797 additions and 112,544 deletions.
39 changes: 27 additions & 12 deletions ControllerCommon/ControllerCommon.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
<PackageReference Include="HidSharp" Version="2.1.0" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Core" Version="1.1.4" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="6.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Toolkit.Uwp.Notifications" Version="7.1.3" />
<PackageReference Include="Nefarius.Utilities.DeviceManagement" Version="3.3.196" />
<PackageReference Include="Nefarius.ViGEm.Client" Version="1.21.230" />
<PackageReference Include="Nefarius.ViGEm.Client" Version="1.21.232" />
<PackageReference Include="NetCoreNamedPipeWrapper" Version="1.0.4" />
<PackageReference Include="PInvoke.Kernel32" Version="0.7.124" />
<PackageReference Include="PInvoke.User32" Version="0.7.124" />
Expand All @@ -37,16 +37,19 @@
<PackageReference Include="SharpDX.XInput" Version="4.2.0" />
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
<PackageReference Include="System.IO.Pipes.AccessControl" Version="5.0.0" />
<PackageReference Include="System.IO.Ports" Version="6.0.0" />
<PackageReference Include="System.Management" Version="6.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="6.0.0" />
<PackageReference Include="System.IO.Ports" Version="7.0.0" />
<PackageReference Include="System.Management" Version="7.0.0" />
<PackageReference Include="System.ServiceProcess.ServiceController" Version="7.0.0" />
<PackageReference Include="WindowsInput" Version="6.4.0" />
</ItemGroup>

<ItemGroup>
<Reference Include="Nefarius.Utilities.DeviceManagement">
<HintPath>..\Resources\Nefarius.Utilities.DeviceManagement.dll</HintPath>
</Reference>
<Reference Include="neptune-hidapi.net">
<HintPath>..\Resources\neptune-hidapi.net.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
Expand All @@ -64,4 +67,16 @@
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<None Update="hidapi.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="hidapi.net.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="JoyShockLibrary.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
163 changes: 0 additions & 163 deletions ControllerCommon/ControllerEx.cs

This file was deleted.

65 changes: 65 additions & 0 deletions ControllerCommon/Controllers/DInputController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using ControllerCommon.Managers;
using SharpDX.DirectInput;
using SharpDX.XInput;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;

namespace ControllerCommon.Controllers
{
public class DInputController : IController
{
protected Joystick Controller;
protected JoystickState State = new();
protected JoystickState prevState = new();

public DInputController(Joystick joystick, PnPDetails details)
{
Controller = joystick;
UserIndex = joystick.Properties.JoystickId;

Details = details;
Details.isHooked = true;

// Set BufferSize in order to use buffered data.
joystick.Properties.BufferSize = 128;
}

public override string ToString()
{
return Controller.Information.ProductName;
}

public override void UpdateReport()
{
// update states
prevState = State;

base.UpdateReport();
}

public override bool IsConnected()
{
return (bool)(!Controller?.IsDisposed);
}

public override void Plug()
{
// Acquire the joystick
Controller.Acquire();

base.Plug();
}

public override void Unplug()
{
// Acquire the joystick
Controller.Unacquire();

base.Unplug();
}
}
}
Loading

0 comments on commit e05fc18

Please sign in to comment.