I want to use VR controller joysticks/thumbpads to set view direction and for other things. The webvr documentation describes how to find controller configurations and read joystick positions, but is not clear on how joystick changes could trigger actions. Is there example code for this?
Help on VR controller joystick events
-
-
Hi,
i used this code, bit old and not recently tested.. but i guess it still works (?)
In the webvr.xml find around line 69 this:Codeif(!global.webvr.iswebxr, vr_ctrl_l.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 3 AND vrbuttonstate == "up", vrsetup_open(); );' ); vr_ctrl_r.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 3 AND vrbuttonstate == "up", vrsetup_open(); );' ); );
change that to:
Codeif(!global.webvr.iswebxr, vr_ctrl_l.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 3 AND vrbuttonstate == "up", vrsetup_open(); );' ); vr_ctrl_r.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 3 AND vrbuttonstate == "up", vrsetup_open(); );' ); ); vr_ctrl_l.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 4 AND vrbuttonstate == "down", set(walkaround.down,1); );' ); vr_ctrl_l.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 4 AND vrbuttonstate == "up", set(walkaround.down,0); );' ); vr_ctrl_l.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 5 AND vrbuttonstate == "down", set(walkaround.up,1); );' ); vr_ctrl_l.addevent('onvrcontrollerbutton', 'if(vrbuttonindex == 5 AND vrbuttonstate == "up", set(walkaround.up,0); );' );
maybe this helps you investigating further t/for what you exactly need.
Tuur -
Thanks, Tuur.
But what is walkaround?
-- Tom
-
Hi,
Check the code. Not on compu now... but i think it is just a variable name for moving.
So this makes you go up and down on your left controller buttons in3d .. when i'm right. But you can assign what you like.
Tuur
-
HI Tuur
I was asking about joysticks/thumbpads. I don't think those are defined as 'buttons', but the docs are not clear on this.
Pano2VR's webxr tours do use the joystick x axis events to switch between panos.
-
.. so when i push the joystick to the right .. next pano.. left .. prev pano?
Should be reasonably easy.. i'll might have a go to be sure after i've tested the next pca add-on.. coming days..
Tuur
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!