Commits

Eric Rochester committed 60188cb

Added stubs for device motion/orientation handlers.

Comments (0)

Files changed (1)

     ball.center();
     ball.render(view);
 
-    // windows.addEventListener('deviceorientation', onWindowDeviceOrientation, false);
+    windows.addEventListener('deviceorientation', onDeviceOrientation, true);
+    windows.addEventListener('devicemotion', onDeviceMotion, true);
     view.addEventListener('resize', onResize, false);
     view.ontouchend = onTouchEnd;
 
 
 function onDeviceOrientation(ev)
 {
-    if (ev.alpha) {
-        ball = init(view);
-    }
+    alert(ev.alpha + ', ' + ev.beta + ', ' + ev.gamma + ', ' + ev.absolute + ', ' + ev.compassCalibrated);
+}
+
+function onDeviceMotion(ev)
+{
+    alert(
+            'acceleration: ' + ev.acceleration.x + ', ' + ev.acceleration.y + ', ' + ev.accelteration.x +
+            '\nw/gravity   : ' + ev.accelerationIncludingGravity.x + ', ' + ev.accelerationIncludingGravity.y + ', ' + ev.accelteration.x +
+            '\nrotation    : ' + ev.rotationRate.alpha + ev.rotationRate.beta + ev.rotationRate.gamma
+         );
 }
 
 function resizeCanvas()