njz3 / vJoy

Virtual Joystick
http://vjoystick.sourceforge.net
MIT License
301 stars 39 forks source link

vJoy not working with Web Gamepad API #12

Open Miniontoby opened 1 year ago

Miniontoby commented 1 year ago

Hi, This issue is fixed and you will find a summary of the problem and solution below:


Original Question

The Web Gamepad API doesn't seem to be able to show/receive the Axes values: image

The buttons work fine, but the axes don't. Here is an example test URL: https://luser.github.io/gamepadtest/


Working solution

njz3 made an update that fixes this problem, but the problem is that he cannot sign the driver, so you will need to follow this guide to install this update:

  1. Install the certificate in the "Trusted Root Certification" store. (So open it, click install, [select local user if you have admin rights], click next, select 'install in the following archive', select "Trusted Root Certification", hit next, click confirm)

  2. Enable SIGNTEST mode in your windows: Open CMD (or PowerShell) AS ROOT, run Bcdedit.exe -set TESTSIGNING ON and then if it says "operation successful", you will need to reboot your computer. [If it didn't say that but it says something about Secure Boot, you will need to disable Secure Boot FIRST]. Now when you computer is booted up, you should see in the bottom right of your desktop the text "Testing Mode"

  3. Now download this testing build installer and then open it to install.

  4. To make sure it will work, open the "Configure vJoy" app and uncheck one of the axis, hit apply and then check the axis again and hit apply.

P.s. If you want the SDK, you can find that at this link


If you still cannot get it to work after trying these methods, you may add a comment to this issue.

darkain commented 1 year ago

I'm running into the exact same issue. It looks like it only effects Chromium based browsers. Firefox is working as intended.

Miniontoby commented 1 year ago

I'm running into the exact same issue. It looks like it only effects Chromium based browsers. Firefox is working as intended.

Chromium based browsers require constant pinging for the buttons to function normally, so I guess this might also have to do something with this problem. But when using an actual controller, it works fine, but I just want to make my own!

And like every browser is based on chromium, except Firefox...

njz3 commented 1 year ago

Probably not related to vJoy (as it works in Firefox) ?

Miniontoby commented 1 year ago

Probably not related to vJoy (as it works in Firefox) ?

No it is related! A 'normal' gamepad DOES work on chromium browsers! But vJoy doesn't work!

njz3 commented 1 year ago

Just tried with older version of vJoy and got same issue. I guess it is because the gamepad API does not perform polling of the gamepad status, it is event based. vJoy does not send any "USB" status packet like a standard joystick, which means there is no event when the internal values change.

Miniontoby commented 1 year ago

So can that be implemented? Or do you mean that I am using an old version?

njz3 commented 1 year ago

It is difficult to tell you whether this is easy to add or not (I do not have enough knowledge to add that function). I tested v2.1.9.1 and v2.2.1.1 and both gave me the same issue.

Miniontoby commented 1 year ago

So what do you suggest now?

njz3 commented 1 year ago

Maybe you can modify the gamepad API to perform polling of the status ?

Miniontoby commented 1 year ago

Polling is what all these websites already are using (and what I also already am using)! But yeah still no axis data.

Update: I see https://github.com/njz3/vJoy/blob/master/driver/sys/usb.c which does seem to include some USB packet stuff, but it is mostly commented out

njz3 commented 1 year ago

Hi, I found the "bug", and it is in vjoy : vjoy uses 32bits axis values which in very unusual for HID gamepad or joystick. By changing the driver to expose a 16bits value for axis in the HID, the gamepad test you provided works perfectly in chrome.

Miniontoby commented 1 year ago

By changing the driver to expose a 16bits value for axis in the HID

Can you make a new (github) release using that? Since my laptop is too full to install the netstandard developer thingy, so I cannot build it myself.

Or is it an 'setting' that I should change?

njz3 commented 1 year ago

I can only compile a test signed build, requiring TESTSIGNING mode to be enabled on your computer.

Miniontoby commented 1 year ago

requiring TESTSIGNING mode to be enabled on your computer.

I believe that is still enabled, and if not, I know how to enable it.

njz3 commented 1 year ago

Found another issue with Continuous Hat Switches. They are 32 bits in the HID using 1/100th of a degree unit with range from 0..35900, but this makes a bug when going after 32767 (327,67degrees) : the value roll back to a negative value, meaning it does not display in joy.cpl or other joystick diagnostics tool. I will change it to 1/10th of a degree, limiting to 0..3599.

njz3 commented 1 year ago

Here is a build for testing: https://drive.google.com/file/d/1SEYtmJMelM_2xMC0SeO8neArsTy6_fh2/view?usp=sharing The certificate (to be installed in "Trusted Root Certification" store): https://drive.google.com/file/d/1QAWUyx7mptCcIt99xyQ3mjhte9KgxxDY/view?usp=sharing And the SDK: https://drive.google.com/file/d/1r1MUxAatZxZW-fnKETdP7weKKwXJMGkL/view?usp=sharing

Miniontoby commented 1 year ago

It didn't install!

Update: I got 1 step further, I updated the logs above

njz3 commented 1 year ago

Have you installed the certificate first ? And do you run in TESTSIGN mode ? (there should be a text watermark in the bottom right corner of your windows desktop)

Miniontoby commented 1 year ago

I didn't install the cert in the correct place first. Now it asks me to install or not, and then it still fails. I updated the logs in the previous message.

(and yeah I dont yet have TESTSIGN enabled, will have to do that, but need to finish some documents first)

njz3 commented 1 year ago

The build CANNOT be installed without enabling TESTSIGNING mode on your windows test computer.

Miniontoby commented 1 year ago

Oke sure, I have to disable Secure Boot first...

njz3 commented 1 year ago

Please show me screenshot of your certificate store and your watermark image

Miniontoby commented 1 year ago

I disbled secure boot and enabled testsign and it installed! But now it seems that Gamepad API doesn't even see the controller AT ALL.

EDIT: the feeder doesn't work. As in buttons don't actually get pressed and the axis are doing strange (Need to set Y axis to 0 to let X work, and Z controls Y)

Btw, does this mode need to stay enabled for me to use this?

njz3 commented 1 year ago

The test sign mode must be enabled to use the build I do, because I do not own a valid EV code certificate to sign the driver (Microsoft constraints...). For your feeder issue, I need to see your vJoy configuration and how your perform your test with the feeder. Also, I uploaded a new version a few minutes ago (same download link). Can you download and try again?

Miniontoby commented 1 year ago

The test sign mode must be enabled to use the build I do, because I do not own a valid EV code certificate to sign the driver (Microsoft constraints...). For your feeder issue, I need to see your vJoy configuration and how your perform your test with the feeder. Also, I uploaded a new version a few minutes ago (same download link). Can you download and try again?

Fore my feeder test, I used the feeder and the monitor programs included. I just put the monitor on AOT (AlwaysOnTop) and then I clicked the buttons and changed the sliders and then looked at the output, which didn't match input.

I will try out the new version now and let you know if the issue is changed

Miniontoby commented 1 year ago

I downloaded the new setup thingy and it didn't change it.

Here is a screenshot of the feeder test thingy:

image

njz3 commented 1 year ago

Also a note : I know you cannot detect the joystick on the navigator like Chrome or Edge if you are using a remote desktop to your test computer. You must be physically connected with an open session to detect the joystick. I don't know why.

Miniontoby commented 1 year ago

It cannot find the joystick since you need to press a button for chrome to let it find the gamepad. And since the buttons are NOT working, chrome won't detect/allow detect of the gamepad

njz3 commented 1 year ago

Please send me your contact information to see what happen on your personnel setup.

Miniontoby commented 1 year ago

Idk what contact info you mean, but I use Windows 10 Home - 10.0.19045 Build 19045

Miniontoby commented 1 year ago

After changing the enabled axis (and the amount of buttons) and apply that and then changing it back and applying again, It Now Works!!!

Thanks!

I will be doing more tests first before I close this issue and I will edit the original message to tell everyone how it is fixed