Skip to content

Commit e930164

Browse files
committed
Remove . from the activators
1 parent 7f0b1f0 commit e930164

File tree

5 files changed

+23
-20
lines changed

5 files changed

+23
-20
lines changed

‎examples/basic/index.html‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@
8787
'vive-controls': {
8888
gripdown: 'changeTask',
8989
//trackpaddown: 'logdefault',
90-
'trackpad.doubletouch': 'doubletouch',
91-
'trackpad.doublepress': 'doublepress',
92-
//'trackpad.longpress': 'longpress',
90+
'trackpaddoubletouch': 'doubletouch',
91+
'trackpaddoublepress': 'doublepress',
92+
//'trackpadlongpress': 'longpress',
9393
'trackpaddpadleftdown': 'dpadleft',
94-
'trackpaddpadright.longpress': 'dpadrightlong'
94+
'trackpaddpadrightlongpress': 'dpadrightlong'
9595
},
9696
'oculus-touch-controls': {
9797
abuttondown: 'changeTask'

‎src/activators/doublepress.js‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ DoublePress.prototype = {
2020
}
2121
},
2222

23-
removeListeners () {
24-
console.log('destroying');
23+
destroy () {
2524
this.el.removeEventListener(this.eventName, this.onButtonDown);
2625
}
2726
}

‎src/activators/doubletouch.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ DoubleTouch.prototype = {
2121
},
2222

2323
removeListeners () {
24-
console.log('destroying');
2524
this.el.removeEventListener(this.eventName, this.onButtonDown);
2625
}
2726
}

‎src/activators/longpress.js‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ LongPress.prototype = {
2727
},
2828

2929
removeListeners () {
30-
console.log('destroying');
3130
this.el.removeEventListener(this.eventNameDown, this.onButtonDown);
3231
this.el.removeEventListener(this.eventNameUp, this.onButtonUp);
3332
}

‎src/index.js‎

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,28 @@ AFRAME.registerSystem('input-mapping', {
175175
}
176176
};
177177

178+
function checkActivator (eventName) {
179+
for (var activatorSuffix in AFRAME.inputActivators) {
180+
if (eventName.endsWith(activatorSuffix)) {
181+
return activatorSuffix;
182+
}
183+
}
184+
return null;
185+
}
186+
178187
for (var eventName in mappingsPerController.mappings) {
179-
var modifier = null;
180-
if (eventName.indexOf('.') !== -1) {
181-
var aux = eventName.split('.');
182-
button = aux[0]; // eg: trackpad
183-
modifierName = aux[1]; // eg: doublepress
184-
var Activator = AFRAME.inputActivators[modifierName];
185-
if (!Activator) {
186-
console.error('input-mapping: No activator found');
188+
// Check for activators
189+
for (var activatorSuffix in AFRAME.inputActivators) {
190+
if (eventName.endsWith(activatorSuffix)) {
191+
AFRAME.inputActivators[activatorSuffix];
192+
var button = eventName.substr(0, eventName.indexOf(activatorSuffix));
193+
var Activator = AFRAME.inputActivators[activatorSuffix];
194+
var onActivate = OnActivate(eventName);
195+
controllerObj.activators[eventName] = new Activator(controllerObj.element, button, onActivate);
187196
break;
188197
}
189-
190-
var onActivate = OnActivate(eventName);
191-
controllerObj.activators[eventName] = new Activator(controllerObj.element, button, onActivate);
192198
}
193-
199+
194200
var onActivate = OnActivate(eventName);
195201
controllerObj.element.addEventListener(eventName, onActivate);
196202
controllerObj.handlers[eventName] = onActivate;

0 commit comments

Comments
 (0)