Skip to content
Snippets Groups Projects
Commit 07732ca9 authored by netpro2k's avatar netpro2k Committed by johnshaughnessy
Browse files

Correctly handle bindings for destkop vs mobile

parent 33d17606
No related branches found
No related tags found
No related merge requests found
...@@ -98,21 +98,28 @@ AFRAME.registerSystem("userinput", { ...@@ -98,21 +98,28 @@ AFRAME.registerSystem("userinput", {
this.gamepads = []; this.gamepads = [];
if (AFRAME.utils.device.isMobile()) { const appAwareTouchscreenDevice = new AppAwareTouchscreenDevice();
window.addEventListener( const updateBindingsForVRMode = () => {
"touchdown", const inVRMode = this.el.sceneEl.is("vr-mode");
() => { if (AFRAME.utils.device.isMobile()) {
this.activeDevices.add(new AppAwareTouchscreenDevice()); if (inVRMode) {
this.activeDevices.remove(appAwareTouchscreenDevice);
this.registeredMappings.remove(touchscreenUserBindings);
} else {
this.activeDevices.add(appAwareTouchscreenDevice);
this.registeredMappings.add(touchscreenUserBindings); this.registeredMappings.add(touchscreenUserBindings);
},
{
once: true,
passive: true
} }
); } else {
} else { if (inVRMode) {
this.registeredMappings.add(keyboardMouseUserBindings); this.registeredMappings.remove(keyboardMouseUserBindings);
} } else {
this.registeredMappings.add(keyboardMouseUserBindings);
}
}
};
this.el.sceneEl.addEventListener("enter-vr", updateBindingsForVRMode);
this.el.sceneEl.addEventListener("exit-vr", updateBindingsForVRMode);
updateBindingsForVRMode();
window.addEventListener( window.addEventListener(
"gamepadconnected", "gamepadconnected",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment