Search code examples
c#unity-game-engineemulationdevice-emulation

How do I simulate the joystick of a PS4 controller on a PC using C#?


I've been creating a program to play games on a computer, but the controls are on my phone. But, I didn't know how to simulate the joystick, so I searched online.

In this website, someone said that I need to make my own device driver to simulate it, but in this website (Solution 2), it says that you could do it using Joystick Notification Messages. I looked it up, but it seems like it only supports C++, not C#.

This previous website (Solution 1) also stated that you could do it by faking an rs232 serial port, however I do not know what that means, nor do I have the tools to do it.

I used Unity for the program, so I figured, if I made a post on Unity Forum, I would get an answer. Turns out, I didn't get an answer. (link to my thread on the forum)

Is there any way to simulate the joystick of a PS4 controller using C#, preferably without external programs and device drivers, or am I stuck using vJoy or ViGEm?

Thanks in advance!


Solution

  • I ended up using ViGEm, which is compatible with C#. ViGEm is a gamepad emulation program for C# that supports XBOX 360 and PS4 controllers.
    The reason I use ViGEm instead of vJoy is because ViGEm has simpler instructions and a forum.

    Update: Since December 2023, ViGEm has entered end of life: https://docs.nefarius.at/projects/ViGEm/End-of-Life/