From 5f5f998543353b33e65cb5cbf09f5f11d97d9278 Mon Sep 17 00:00:00 2001 From: cha0s Date: Wed, 8 Jun 2022 12:31:51 -0500 Subject: [PATCH] refactor: events --- packages/input/src/client/normalizer.js | 5 +++++ packages/input/src/traits/controllable.js | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/input/src/client/normalizer.js b/packages/input/src/client/normalizer.js index 692c097..7e415e4 100644 --- a/packages/input/src/client/normalizer.js +++ b/packages/input/src/client/normalizer.js @@ -45,6 +45,11 @@ export default class InputNormalizer extends decorate(Class) { this.stopListening(); } + emit(...args) { + super.emit(...['*', ...args]); + super.emit(...args); + } + listen(target = window.document, targetForKeyUp = window.document) { // Only listen once. if (this.target) { diff --git a/packages/input/src/traits/controllable.js b/packages/input/src/traits/controllable.js index e61b121..6c432f9 100644 --- a/packages/input/src/traits/controllable.js +++ b/packages/input/src/traits/controllable.js @@ -76,11 +76,8 @@ export default () => class Controllable extends decorate(Trait) { }, listenForInput: (inputNormalizer) => { + inputNormalizer.on('*', (...args) => this.entity.emit(...args)); this.$$actionRegistry.listen(inputNormalizer); - // @todo leak - inputNormalizer.on('pointerMove', (event) => { - this.entity.emit('pointerMove', event); - }); }, };