Merge pull request #15 from Philmod/pilot-keyboard

Define keyboard layout through the config file
Esse commit está contido em:
Laurent Eschenauer
2013-05-30 22:02:57 -07:00
6 arquivos alterados com 77 adições e 52 exclusões
+2
Ver Arquivo
@@ -5,3 +5,5 @@ config.js
node_modules
components
_site
pictures
temp.js
+2 -3
Ver Arquivo
@@ -54,9 +54,8 @@ bower install
3. Run `node app.js`
4. Point your browser to http://localhost:3000/
If you have enabled the **pilot** plugin, you can fly the drone with the following keys. Yes,
these are azerty bindings :-) If you need qwerty ones, just hack the plugin. I'll need to find
a way to provide custome configuration etc.
If you have enabled the **pilot** plugin, you can fly the drone with the following keys. You can define your keyboard in the
config file. In the plugin, `azerty` and `qwerty` keyboards are defined. Feel free to define others.
Use `Z, S, Q, D` to move front, back and sideways. Use your `cursors` to go up/down or turn
clockwise/counter clockwise. Use `t` to takeoff and `l` for landing.
+3
Ver Arquivo
@@ -47,6 +47,9 @@ app.get('/', function (req, res) {
title: 'Express'
,scripts: scripts
,styles: styles
,options: {
keyboard: config.keyboard
}
});
});
+1
Ver Arquivo
@@ -1,4 +1,5 @@
var config = {
keyboard: 'azerty',
plugins: [
"video-png" // Display the video feed as static pngs (work in every browser)
//, "video-stream" // Display the video as a native h264 stream decoded in JS
+66 -49
Ver Arquivo
@@ -3,57 +3,74 @@ PILOT_ACCELERATION = 0.04;
(function(window, document) {
'use strict';
var keyCodeMap = {"0":"96","1":"97","2":"98","3":"99","4":"100","5":"101","6":"102","7":"103","8":"104","9":"105","backspace":"8","tab":"9","return":"13","shift":"16","ctrl":"17","alt":"18","pausebreak":"19","capslock":"20","escape":"27"," ":"32","pageup":"33","pagedown":"34","end":"35","home":"36","left":"37","up":"38","right":"39","down":"40","+":"107","printscreen":"44","insert":"45","delete":"46",";":"186","=":"187","a":"65","b":"66","c":"67","d":"68","e":"69","f":"70","g":"71","h":"72","i":"73","j":"74","k":"75","l":"76","m":"77","n":"78","o":"79","p":"80","q":"81","r":"82","s":"83","t":"84","u":"85","v":"86","w":"87","x":"88","y":"89","z":"90","*":"106","-":"189",".":"190","/":"191","f1":"112","f2":"113","f3":"114","f4":"115","f5":"116","f6":"117","f7":"118","f8":"119","f9":"120","f10":"121","f11":"122","f12":"123","numlock":"144","scrolllock":"145",",":"188","`":"192","[":"219","\\":"220","]":"221","'":"222"};
;
var forward = 'w'
, backward = 's'
, left = 'a'
, right = 'd'
;
if (options && options.keyboard === 'qwerty') { }
else if (options && options.keyboard === 'azerty') {
forward = 'z';
backward = 's';
left = 'q';
right = 'd';
}
// Static keymap used within this module
var Keymap = {
90 : {
ev : 'move',
action : 'front'
},
83 : {
ev : 'move',
action : 'back'
},
81 : {
ev : 'move',
action : 'left'
},
68 : {
ev : 'move',
action : 'right'
},
38 : {
ev : 'move',
action : 'up'
},
40 : {
ev : 'move',
action : 'down'
},
37 : {
ev : 'move',
action : 'counterClockwise'
},
39 : {
ev : 'move',
action : 'clockwise'
},
32 : {
ev : 'drone',
action : 'stop'
},
84 : {
ev : 'drone',
action : 'takeoff'
},
76 : {
ev : 'drone',
action : 'land'
},
69 : {
ev : 'drone',
action : 'disableEmergency'
}
};
38 : {
ev : 'move',
action : 'up'
},
40 : {
ev : 'move',
action : 'down'
},
37 : {
ev : 'move',
action : 'counterClockwise'
},
39 : {
ev : 'move',
action : 'clockwise'
},
32 : {
ev : 'drone',
action : 'stop'
},
84 : {
ev : 'drone',
action : 'takeoff'
},
76 : {
ev : 'drone',
action : 'land'
},
69 : {
ev : 'drone',
action : 'disableEmergency'
}
};
Keymap[keyCodeMap[forward]] = {
ev : 'move',
action : 'front'
};
Keymap[keyCodeMap[backward]] = {
ev : 'move',
action : 'back'
};
Keymap[keyCodeMap[left]] = {
ev : 'move',
action : 'left'
};
Keymap[keyCodeMap[right]] = {
ev : 'move',
action : 'right'
};
/*
* Constructuor
+3
Ver Arquivo
@@ -9,6 +9,9 @@
<% for(var i=0; i<styles.length; i++) {%>
<link rel="stylesheet" href="<%= styles[i] %>"><% } %>
</head>
<script>
var options = <%- JSON.stringify(options) %>;
</script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
<script type="text/javascript" src="/components/jquery/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.fullscreen-min.js"></script>