From 7e32bffb6952901756751c5e1b6cb83b18580fef Mon Sep 17 00:00:00 2001 From: Laurent Eschenauer Date: Tue, 3 Sep 2013 14:00:45 +0200 Subject: [PATCH] Press 'c' to switch camera channel (front/bottom) --- plugins/pilot/index.js | 7 +++++++ plugins/pilot/public/js/pilot.js | 7 +++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/pilot/index.js b/plugins/pilot/index.js index b5c223f..9b0e288 100644 --- a/plugins/pilot/index.js +++ b/plugins/pilot/index.js @@ -1,3 +1,5 @@ +var channel = 0; + function pilot(name, deps) { deps.io.sockets.on('connection', function (socket) { socket.on('/pilot/move', function (cmd) { @@ -22,6 +24,11 @@ function pilot(name, deps) { console.log("animate", cmd); return deps.client.animate(cmd.action, 500); }); + socket.on('/pilot/channel', function (cmd) { + channel = (channel == 0) ? 1 : 0; + console.log("switching to channel %d", channel); + return deps.client.config('video:video_channel', channel); + }); }); }; diff --git a/plugins/pilot/public/js/pilot.js b/plugins/pilot/public/js/pilot.js index 90402f2..681bebb 100644 --- a/plugins/pilot/public/js/pilot.js +++ b/plugins/pilot/public/js/pilot.js @@ -10,7 +10,8 @@ PILOT_ACCELERATION = 0.04; , backward = 's' , left = 'a' , right = 'd' - , flip = 'f' + , flip = 'f' + , channel = 'c' ; if (options && options.keyboard === 'qwerty') { } else if (options && options.keyboard === 'azerty') { @@ -75,7 +76,9 @@ PILOT_ACCELERATION = 0.04; ev : 'move', action : 'right' }; - + Keymap[keyCodeMap[channel]] = { + ev : 'channel' + }; /* * Constructuor