nefarius / ViGEm.NET

.NET bindings for the ViGEmClient library.
https://docs.nefarius.at/projects/ViGEm/
MIT License
107 stars 39 forks source link

ViGEm Client .NET SDK

.NET bindings for the ViGEmClient native library.

Build status Nuget Discord GitHub followers Mastodon Follow


🧟 THIS PROJECT HAS BEEN RETIRED 🧟

Users of this software are encouraged to read the end-of-life statement. So long, cheers 🖖


About

.NET API to interact with features offered by ViGEm Bus Driver.

Installation

This library can be consumed via pre-built NuGet:

Install-Package Nefarius.ViGEm.Client

Examples

Get full output report of an emulated DS4

Requires ViGEmBus v1.19.418 or newer.

using Nefarius.ViGEm.Client;

// initializes the SDK instance
var client = new ViGEmClient();

// prepares a new DS4
var ds4 = client.CreateDualShock4Controller();

// brings the DS4 online
ds4.Connect();

// recommended: run this in its own thread
while (true)
    try
    {
        // blocks for 250ms to not burn CPU cycles if no report is available
        // an overload is available that blocks indefinitely until the device is disposed, your choice!
        var buffer = ds4.AwaitRawOutputReport(250, out var timedOut);

        if (timedOut)
        {
            Console.WriteLine("Timed out");
            continue;
        }

        // you got a new report, parse it and do whatever you need to do :)
        // here we simply hex-dump the contents
        Console.WriteLine($"[OUT] {string.Join(" ", buffer.Select(b => b.ToString("X2")))}");
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
        Thread.Sleep(1000);
    }

Contribute

Bugs & Features

Found a bug and want it fixed? Open a detailed issue on the GitHub issue tracker!

Have an idea for a new feature? Let's have a chat about your request on our support channels.

Questions & Support

Please respect that the GitHub issue tracker isn't a helpdesk. We offer support resources, where you're welcome to check out and engage in discussions!

3rd party credits

This project uses Fody Costura to embed the native SDK DLLs into the resulting assembly ❤️