Open danrossi opened 6 years ago
I made a heap of changes to be able to module the gamepad update process. Sadly that wouldnt work. This seems to work
if( this.controllers[ i ] === undefined ) {
THREE.VRController.onGamepadConnect( gamepad );
}
else if (this.controllers[ i ].gamepad.timestamp !== gamepad.timestamp) {
console.log("gamepad change");
//this.controllers[ i ].gamepad = gamepad;
//this.controllers[ i ].updateGamepad(gamepad);
THREE.VRController.onGamepadDisconnect( this.controllers[ i ].gamepad );
THREE.VRController.onGamepadConnect( gamepad );
}
I put the fix here now and added a method to disconnect all controllers.
I am working on an Es6 version as this code is hard to maintain and needs some efficiency improvements I think.
https://github.com/danrossi/THREE.VRController/blob/master/VRController.js#L831
example of all fixes in that branch and current three.js is here
I am not sure what the story is with Occulus. But the Gamepad instance changes when exiting then re-entering presentation mode. The timestamp is different which can be detected.
A new gamepad instance is required to be updated. I have tried to modify myself but it's not detecting button changes when updating to it yet. I haven't uploaded my tests with a working example yet.
Something like this could detect the change and either update the gamepad or disconnect the controller.
In GearVR / Daydream taking off the headset does not dispatch a deactivate event to possible manage gamepad disconnection that way. Only exit presentation events would work.
I guess it has to be disconnected and reconnected ?