Skip to content
Snippets Groups Projects
Commit a6e5100c authored by johnshaughnessy's avatar johnshaughnessy
Browse files

Check whether active sets actually changed

parent b6f29838
No related branches found
No related tags found
No related merge requests found
...@@ -948,5 +948,13 @@ export const viveUserBindings = addSetsToBindings({ ...@@ -948,5 +948,13 @@ export const viveUserBindings = addSetsToBindings({
xform: xforms.falling, xform: xforms.falling,
priority: 3 priority: 3
} }
],
[sets.inputFocused]: [
{
src: { value: "/device/keyboard" },
dest: { value: paths.noop },
xform: xforms.noop,
priority: 1000
}
] ]
}); });
...@@ -25,6 +25,16 @@ import { resolveActionSets } from "./resolve-action-sets"; ...@@ -25,6 +25,16 @@ import { resolveActionSets } from "./resolve-action-sets";
import { GamepadDevice } from "./devices/gamepad"; import { GamepadDevice } from "./devices/gamepad";
import { gamepadBindings } from "./bindings/generic-gamepad"; import { gamepadBindings } from "./bindings/generic-gamepad";
function intersection(setA, setB) {
var _intersection = new Set();
for (var elem of setB) {
if (setA.has(elem)) {
_intersection.add(elem);
}
}
return _intersection;
}
const satisfiesPath = (binding, path) => { const satisfiesPath = (binding, path) => {
return Object.values(binding.dest) && Object.values(binding.dest).indexOf(path) !== -1; return Object.values(binding.dest) && Object.values(binding.dest).indexOf(path) !== -1;
}; };
...@@ -142,6 +152,7 @@ AFRAME.registerSystem("userinput", { ...@@ -142,6 +152,7 @@ AFRAME.registerSystem("userinput", {
init() { init() {
this.frame = {}; this.frame = {};
this.prevActiveSets = new Set();
this.activeSets = new Set([sets.global]); this.activeSets = new Set([sets.global]);
this.pendingSetChanges = []; this.pendingSetChanges = [];
this.xformStates = new Map(); this.xformStates = new Map();
...@@ -256,11 +267,17 @@ AFRAME.registerSystem("userinput", { ...@@ -256,11 +267,17 @@ AFRAME.registerSystem("userinput", {
this.masks = computeMasks(this.sortedBindings); this.masks = computeMasks(this.sortedBindings);
} }
this.prevActiveSets.clear();
for (const item of this.activeSets) {
this.prevActiveSets.add(item);
}
resolveActionSets(); resolveActionSets();
for (const { set, value } of this.pendingSetChanges) { for (const { set, value } of this.pendingSetChanges) {
this.activeSets[value ? "add" : "delete"](set); this.activeSets[value ? "add" : "delete"](set);
} }
const activeSetsChanged = this.pendingSetChanges.length; // TODO: correct this const activeSetsChanged =
this.prevActiveSets.size !== this.activeSets.size ||
intersection(this.prevActiveSets, this.activeSets).size !== this.activeSets.size;
this.pendingSetChanges.length = 0; this.pendingSetChanges.length = 0;
if (registeredMappingsChanged || activeSetsChanged || (!this.actives && !this.masked)) { if (registeredMappingsChanged || activeSetsChanged || (!this.actives && !this.masked)) {
this.prevActives = this.actives; this.prevActives = this.actives;
......
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