add Voice control interface #32

Merged
merged 5 commits into from Jul 8, 2016
Jump to file or symbol
Failed to load files and symbols.
+730 −2
Diff settings

Always

Just for now

Viewing a subset of changes. View all

add voice interface file

  • Loading branch information...
Jeff Zhang Jeff Zhang
Jeff Zhang authored and Jeff Zhang committed Jul 4, 2016
commit 0ca17cd800647438f6bcb5703e2872c54aebcb9b
View
@@ -64,6 +64,8 @@
<script src="user_scripts/XAudioJS/resampler.js"></script>
<script src="user_scripts/XAudioJS/XAudioServer.js"></script>
<script src="user_scripts/Interface.js"></script>
+ <script src="user_scripts/annyang.min.js"></script>
+ <script src="user_scripts/VoiceController.js"></script>
<link rel="stylesheet" href="user_css/main.css">
</head>
<body>
@@ -1,9 +1,9 @@
-var mapButtontoIndex = {"A":0, "B":1, "Select":2, "Start":3, "Right":4, "Left": 5, "Up":6 ,"Down":7, "R":8, "L":9}
+var mapButtontoIndex = {"a":0, "b":1, "select":2, "start":3, "right":4, "left": 5, "up":6 ,"down":7, "r":8, "l":9}
function pressButton(button, time) {
if(button in mapButtontoIndex ){
-
+
index = mapButtontoIndex[button]
IodineGUI.Iodine.keyDown(index);
@@ -0,0 +1,32 @@
+if(annyang){
+
+ pressKeyFunctionConstructor = function(key){
+ key = key.toLowerCase()
+ var func = function(){
+ pressButton(key,20);
+ };
+ return func;
+ }
+
+ handleButton = function(key){
+ //lower case the key to ignore capitals
+ key = key.toLowerCase();
+ pressButton(key, 20);
+ }
+
+ var mapButtontoIndex = {"a":0, "b":1, "select":2, "start":3, "right":4, "left": 5, "up":6 ,"down":7, "r":8, "l":9};
+
+ var commands = {};
+
+ for (var key in mapButtontoIndex){
+ commands[key] = pressKeyFunctionConstructor(key);
+ }
+ commands["press (the) button *key"] = handleButton;
+ commands["press (the) key *key"] = handleButton;
+
+
+
+ // Add our commands to annyang
+ annyang.addCommands(commands);
+ annyang.start();
+}
Oops, something went wrong.