Skip to content

Instantly share code, notes, and snippets.

@bwhite
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bwhite/8741534 to your computer and use it in GitHub Desktop.
Save bwhite/8741534 to your computer and use it in GitHub Desktop.
[wearscript] All gestures get logged to the console and the onGesture results are spoken aloud
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<canvas id="canvas" width="640" height="360" style="display:block"></canvas>
<script>
function show(msg) {
WS.log(msg)
WS.cardModify(0, WS.cardFactory(msg, ''));
}
function onGesture(gesture) {
show('onGesture: ' + gesture);
WS.say(gesture.replace('_', ' '));
}
function onFingerCountChanged(i, i2) {
show('onFingerCountChanged: ' + i + ' ' + i2);
}
function onScroll(v, v2, v3) {
show('onScroll: ' + v + ' ' + v2 + ' ' + v3);
}
function onTwoFingerScroll(v, v2, v3) {
show('onTwoFingerScroll: ' + v + ' ' + v2 + ' ' + v3);
}
function onVerticalScroll(v, v2, v3) {
show('onVerticalScroll: ' + v + ' ' + v2 + ' ' + v3);
}
function server() {
WS.displayCardScroll();
WS.cardInsert(0, WS.cardFactory('Touch Glass', ''));
var events = 'onGesture onFingerCountChanged onScroll onTwoFingerScroll onVerticalScroll'.split(' ');
for (var i = 0; i < events.length; i++)
WS.gestureCallback(events[i], events[i]);
}
function main() {
if (WS.scriptVersion(1)) return;
WS.serverConnect('{{WSUrl}}', 'server');
}
window.onload = main;
</script>
</body>
</html>
{
"name": "GDK Gestures Example"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment