Jump to content

Reading controller's touchpad value


1glayfan
 Share

Recommended Posts

Hello,

I am using the WinMR controllers, and basically trying to read input of the touchpad (big round button)

I am intending for the user to hit either top, bottom, left or right part of the button, basically for navigation purpose.

Here are the test codes that I wrote:

controller.onTouchpadButtonStateChangedObservable.add((gamepadButton: BABYLON.ExtendedGamepadButton, eventState: BABYLON.EventState) => {
    console.log('pressed=%s, value=%d', gamepadButton.pressed, gamepadButton.value);
});

controller.onTouchpadValuesChangedObservable.add((stickValue: BABYLON.StickValues, eventState: BABYLON.EventState) => {
    console.log('x=%d, y=%d', stickValue.x, stickValue.y);
});

I tried both observables just to see which one is the useful one. Although I am getting the callback, unfortunately the value gamepadButton.value and stickValue x and y are always 0, regardless which part of the button is pressed.

I suppose we should be to distinguish which part (the top/bottom/left/right) of the button is being pressed, right ?

Please help! thank you.

Link to comment
Share on other sites

Which controller are you using?  Also, very noob question - how are you getting the console output?  I have never tried to debug through Mixed Reality Portal - was curious how that was done or how you accomplished that.  I'd like to try it out!

Also, just looking through the source.  Won't solve your touchpad issue, but are you getting trackpad Stick values through with onTrackpadValuesChangedObservable.add(...)?
https://github.com/BabylonJS/Babylon.js/blob/master/src/Gamepad/Controllers/babylon.windowsMotionController.ts#L114
 

Link to comment
Share on other sites

@brianzinn well I am using the winmr controller (made by Dell). I believe all controllers in winmr behave the same way.

I do still need to hit F12 to see the console output while wearing the vr headset, yeah I had to kind of peek at the console. :) If you have better debug console for VR mode, please let me know.

I just tried the onTrackpadValuesChangedObservable per your suggestion, the behavior is the same: always getting x=0 and y=0 regardless of how I pressed the button.

The babylonjs doc does mention that that api is only an alias to the onTouchpadValuesChangedObservable, so I guess this is why.

From http://doc.babylonjs.com/how_to/webvr_camera:

       .... Touchpad axis - axis values. Mapped to onTouchpadValuesChangedObservable and onTrackpadValuesChangedObservable (aliases).

 

Link to comment
Share on other sites

Thanks.  I'll try in a few hours.

edit: I am at least getting trackpad value {x, y}.  here is my playground (I'm using console.dir as it appears I cannot inspect objects after the fact):
https://playground.babylonjs.com/#IUUXNE#1

Here is a screenshot:
trackpad.thumb.png.24efec2d8f8c5f3b52c81655c4d8cae9.png

To get touchpad values I would hope for a better debug experience.  that is really awkward!  I would expect all WMR devices are the same as well.  Cheers.

Link to comment
Share on other sites

@Deltakosh @trevordev

Sorry this is a false alarm, The onTouchpadValuesChangedObservable is actually working, it's returning value between -1.0 to 1.0 for the x and y and I was formatting the value incorrectly (truncated to zero).

Here is the updated playground: http://playground.babylonjs.com/#M5XR49#14

However, the onTouchpadButtonStateChangedObservable is still returning zero for the value btw. Is this actually expected ?

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...