How to take input from quest 2 controllers

I have a working three.js game and I want to use the quest 2 controllers instead of a keyboard, but I would need to get button inputs and joystick inputs from the controllers, how would I do that?

You need to retrieve gamepad events

Here is a basic exemple with the controller 1, more or less the same as three.js base exemple
excepted the last line. I added some handedness too, always useful to know which hand controller is assigned to.

controller1.addEventListener( 'connected', ( event ) => {
if (event.data.handedness == "left" ){
	//do something here
	}
if (event.data.handedness == "right" ){
	//do something here
	}
//get buttons inputs from controller 1
	controller1.gamepad = event.data.gamepad;	

Next, to detect button press: This exemple target the thumbStick, it’s the most complex one.

			//thumbstick full press forward = -1.0 press backward = 1.0   release = 0.0
			if ( controller1.gamepad.axes[3] < 0 ){
			 //do something here
			} 

Official reference guide for webXR gamepad object

oh, thanks! what’s button 7?