xiphiaz

How can I register a custom gamepad

Recommended Posts

Hello,

 

I'm attempting to implement support in my scene for navigating with a 3dconnexion spacenavigator, which has 6 axes. I can see it successfully registers as a gamepad, and can see four of the six axes bound to the "leftStick" and "rightStick" attributes, however I of course need the extra two axes.

I thought about creating a new `3dConnexionGamepad extends BABYLON.Gamepad` class, however I can't think of a way to get the `GamepadManager` to create an instance of my custom class. Is this possible? If not is there a workaround like mabye binding to the `.update()` method of the gamepad instance?

Share this post


Link to post
Share on other sites

Interesting (and important) question!

You are totally right, the gamepad manager doesn't allow it. I am creating an issue for this, let me see how we can solve this in the best way. My best suggestion currently is to allow setting the number of axes on the Generic gamepad. Will keep you updated here :)

 

Share this post


Link to post
Share on other sites

Issue was created - https://github.com/BabylonJS/Babylon.js/issues/3514 

Just wanted to note, that you can always access gamepad.browserGamepad.axes[0..5] (gamepad being Babylon's generated gamepad object) to get the current data from the 6 axes you have. This is a low-level solution, with no (babylon-)events fired. You could run a beforeRender loop to read the values, and do whatever you want with them.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.