Skip to content
Snippets Groups Projects
Commit 0094d614 authored by joni's avatar joni
Browse files

Fix behaviour event handling.

parent b8566f7e
No related branches found
No related tags found
No related merge requests found
......@@ -8,10 +8,16 @@ function joystick_dpad4(el, outputPrefix) {
this.previous = "none";
this.hapticIntensity = "low";
this.emitDPad4 = this.emitDPad4.bind(this);
el.addEventListener("axismove", this.emitDPad4);
this.el = el;
}
joystick_dpad4.prototype = {
addEventListeners: function() {
this.el.addEventListener("axismove", this.emitDPad4);
},
removeEventListeners: function() {
this.el.removeEventListener("axismove", this.emitDPad4);
},
emitDPad4: function(event) {
const x = event.detail.axis[0];
const y = event.detail.axis[1];
......
......@@ -10,12 +10,20 @@ function trackpad_dpad4(el, outputPrefix) {
this.unpress = this.unpress.bind(this);
this.hapticIntensity = "low";
this.centerRadius = 0.6;
el.addEventListener("axismove", this.emitDPad4);
el.addEventListener("trackpaddown", this.press);
el.addEventListener("trackpadup", this.unpress);
this.el = el;
}
trackpad_dpad4.prototype = {
addEventListeners: function() {
this.el.addEventListener("axismove", this.emitDPad4);
this.el.addEventListener("trackpaddown", this.press);
this.el.addEventListener("trackpadup", this.unpress);
},
removeEventListeners: function() {
this.el.removeEventListener("axismove", this.emitDPad4);
this.el.removeEventListener("trackpaddown", this.press);
this.el.removeEventListener("trackpadup", this.unpress);
},
press: function() {
this.pressed = true;
},
......
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