Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GearVR / Daydream Gamepad not updated when exiting and entering presentation mode #15

Open
danrossi opened this issue Feb 28, 2018 · 3 comments

Comments

@danrossi
Copy link

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.

if (this.controllers[ i ].gamepad.timestamp !== gamepad.timestamp) {

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 ?

@danrossi
Copy link
Author

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 );
				}

@danrossi
Copy link
Author

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

@danrossi
Copy link
Author

danrossi commented Mar 1, 2018

example of all fixes in that branch and current three.js is here

http://dev.electroteque.org/vrcontroller/raycast.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant