Commit be168e59 authored by Matthias Möller's avatar Matthias Möller

added controller functionality

parent 1613f56c
......@@ -36,9 +36,12 @@ export default Ember.Component.extend({
this._super(...arguments);
this.status=Ember.computed("emotivWebsocket.status", function(){return this.get("emotivWebsocket").status;}.bind(this));
this.click=this.click.bind(this);
$(document)[0].addEventListener("keyup", function(evt){
if(evt.ctrlKey && evt.key=="b"){
this.get("emotivWebsocket").toogleActivation();
let controllerID = evt.controller;
let controllerFlag = evt.controllerFlag;
this.get("emotivWebsocket").toogleActivation(controllerID, controllerFlag);
}
}.bind(this));
}
......
......@@ -6,6 +6,7 @@ export default Ember.Service.extend({
socketReference:null,
status:"",
isActivated: false,
activatedControllers: {},
start: function(){
this.set("status", "connecting");
......@@ -30,14 +31,14 @@ export default Ember.Service.extend({
data = JSON.parse(data);
let mentalCommand = data["mentalCommand"];
console.log(mentalCommand, typeof(mentalCommand));
//MentalCommand is a push
if(mentalCommand === 2){
this.triggerZoom(-0.1);
this.triggerZoom(0.1);
//MentalCommand is a pull
}else if(mentalCommand === 4){
this.triggerZoom(0.1);
this.triggerZoom(-0.1);
}
},
......@@ -45,21 +46,33 @@ export default Ember.Service.extend({
Ember.run.later(this, function(){this.set("status", "disconnected")}, 1000);
},
triggerZoom(wheelDelta){
let canvas = $("#threeCanvas")[0];
let event = new Event("mousewheel",
{
"bubbles":true,
"cancelable":false
});
event.clientX = canvas.clientX;
event.clientY = canvas.clientY;
event.wheelDelta = wheelDelta;
for(var key in this.get('activatedControllers')){
if(this.get('activatedControllers')[key]){
event.controllerID = key;
}
}
canvas.dispatchEvent(event);
},
toogleActivation: function(){
toogleActivation: function(controllerID, controllerFlag){
this.set("isActivated", !this.get("isActivated"));
if(controllerID){
this.get('activatedControllers')[controllerID] = controllerFlag;
}
}
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment