jehervy / node-virtual-gamepads

Node virtual gamepads
MIT License
235 stars 53 forks source link

Feature Request: Windows support #80

Closed egemenertugrul closed 3 years ago

egemenertugrul commented 4 years ago

I've forked the master branch and added Windows support for x360 input: https://github.com/egemenertugrul/node-virtual-gamepads

It makes use of node-ViGEmClient and ViGEmBus. See README.md for further details. There's no keyboard or touchpad support at the moment.

It was a rather hasty development so did not use CoffeeScript as I'm not very familiar with it. But still, something could be arranged. There are major changes that would break the master branch. Shall we create a completely separate branch called windows? What would you suggest?

Major changes:

  • Downgraded 'forever-monitor' to 1.0.0 from 2.0.0, see this.
  • Dependencies:
    • Added: "vigemclient: 1.1.2"
    • Removed: "ioctl", "ref", "ref-struct" and "ref-array"
  • Added 'virtual_gamepad_hub_vigem.js' and 'virtual_gamepad_vigem.js'.
  • Edited 'server.js'.

TODO: Implement keyboard and touchpad input, improve gamepad code, refactor, etc.

robsdedude commented 4 years ago

I love to see basic Windows support :+1:. But this will be a nightmare to support. Most fixes/changes would have to be done on two branches and have to be tested on two operating systems. I don't have Windows easily available so I couldn't test changes in the windows branch. Not sure how to tackle those problems. Dependency subsets and OS switches in the code could be part of the solution.

hifihedgehog commented 3 years ago

Thanks, @egemenertugrul for creating your Windows version. I am noticing that your fork won't build currently in my environment. I followed the instruction using Node.js 9 and I am getting the following error: 'ThreadSafeFunction is not a member of 'Napi.' It seems to have to do with the vigemclient, because if I try installing that node package globally outside of the package, the same error is emitted.

EDIT: I instead used Node.js 14 and it seemed to install okay.

egemenertugrul commented 3 years ago

Glad to hear it worked! @hifihedgehog

hifihedgehog commented 3 years ago

Glad to hear it worked! @hifihedgehog

No problem, @egemenertugrul! Here is something from me to try and pay it forward. To anyone who is reading this thread who wants to run this as a windowless startup program in the background (this would be analogous to "nohup" in Linux), throw this text into a .VBS script file and it will do the trick! Then just copy that file to your Start Menu startup folder (for all users, that would be C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup) and you are good to go:

Dim objShell
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.CurrentDirectory = "C:\node-virtual-gamepads-windows\"
objShell.Run("""node"" main.js"), 0
Set objShell = Nothing

References: https://keestalkstech.com/2016/07/start-nodejs-app-windowless-windows/ https://devblogs.microsoft.com/scripting/how-can-i-change-the-working-folder-of-a-script/ https://www.addictivetips.com/windows-tips/run-app-as-admin-at-startup-on-windows-10/