Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Voice control interface #32
Merged
Commits
Jump to file or symbol
Failed to load files and symbols.
Diff settings
Viewing a subset of changes. View all
add voice interface file
- Loading branch information...
Jeff Zhang
authored and Jeff Zhang
committed
Jul 4, 2016
commit 0ca17cd800647438f6bcb5703e2872c54aebcb9b
| @@ -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.