Skip to content

Instantly share code, notes, and snippets.

@scottgwald
Forked from bwhite/glass.html
Created February 7, 2014 21:21
Show Gist options
  • Save scottgwald/8872108 to your computer and use it in GitHub Desktop.
Save scottgwald/8872108 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