Navigation

    ViGEm Forums

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Twitter
    • GitHub
    • Discord

    ViGEm.NET Feeder Example (Step-by-Step)

    Guides and Documentation
    guide tutorial vigem vigem.net
    1
    1
    487
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Daltz333
      Daltz333 last edited by Daltz333

      ViGEm.NET Feeder Example

      This guide assumes you have a basic knowledge of C# and Visual Studio. It currently uses the new .NET refine API

      Prerequisites

      • Visual Studio 2017
      • .NET Framework 4.5.2 or higher

      Creating a new Console Application

      👉 Go ahead and launch Visual Studio

      2019-03-16-20-19-16.png

      👉 Navigate to File -> New -> Project

      2019-03-16-20-20-15.png

      👉 Select Console App (.NET Framework)

      2019-03-16-20-20-51.png

      Installing the NuGet

      I do indeed love some nougat bars... oh... wrong kind of nuget

      Before you can do anything, you MUST target .NET Framework 4.5.2 or greater!

      👉 Right click your project and select "Properties"

      2019-03-16-20-30-44.png

      👉 Select .NET Framework 4.5.2 from the dropdown

      2019-03-16-20-33-32.png

      👉 Navigate to Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...

      2019-03-16-20-22-55.png

      👉 Navigate to Browser, and then search for ViGEm

      2019-03-16-20-25-27.png

      👉 Select your application and press "Install"

      2019-03-16-20-26-40.png

      😄 Congratulations! Go buy yourself a... breadstick 😉

      Writing the code

      🔥 Boom! The Code! 🔥

      using System.Threading;
      using Nefarius.ViGEm.Client;
      using Nefarius.ViGEm.Client.Targets;
      using Nefarius.ViGEm.Client.Targets.Xbox360;
      
      namespace ConsoleApp1
      {
          class Program
          {
              static void Main(string[] args)
              {
                  ViGEmClient client = new ViGEmClient();
      
                  IXbox360Controller controller = client.CreateXbox360Controller();
      
                  controller.Connect();
      
                  //minimum of -32768, maximum of 32767
                  controller.SetAxisValue(Xbox360Axis.LeftThumbX, -32768);
      
                  //true or false
                  controller.SetButtonState(Xbox360Button.X, true);
      
                  //minimum of 0, maximum of 255
                  controller.SetSliderValue(Xbox360Slider.LeftTrigger, 255);
      
                  Thread.Sleep(5000);
      
              }
          }
      }
      

      An explanation of what this does you may ask❓
      Well... I have an answer!

      ViGEmClient client = new ViGEmClient();
      

      ✍ This spawns our ViGEmClient object

      IXbox360Controller controller = client.CreateXbox360Controller();
      

      ✍ This gives us our XBox360 controller which is derived from the VirtualGamepad interface

      //minimum of -32768, maximum of 32767
      controller.SetAxisValue(Xbox360Axis.LeftThumbX, -32768);
      

      ✍ This sets the Left Thumb X axis to 100% to the left. -32768 is the maximum "left" value and 32767 is the maximum "right" value

       //true or false
      controller.SetButtonState(Xbox360Button.X, true);
      

      ✍ This sets the virtual Xbox360 X button to active. It can only be enabled (true) or disabled (false)

      //minimum of 0, maximum of 255
      controller.SetSliderValue(Xbox360Slider.LeftTrigger, 255);
      

      ✍ This sets the virtual Xbox360 LeftTrigger to be fully pressed

      Checking our code

      The built in windows utility joy.cpl is quite bad as it only polls devices when the window is focused. In our case, we'll be using the program called "XInput Controller Tester"

      2019-03-16-20-49-10.png

      As you can see, our code runs and we can see the inputs we set!

      1 Reply Last reply Reply Quote 0
      • First post
        Last post