OLD | NEW |
1 <script> | 1 <script> |
2 import '/sky/framework/shell.dart' as shell; | 2 import '/sky/framework/shell.dart' as shell; |
3 import 'dart:sky'; | 3 import 'dart:sky'; |
4 import 'package:sky/services/sensors/sensors.mojom.dart'; | 4 import 'package:sky/services/sensors/sensors.mojom.dart'; |
5 | 5 |
6 // TODO(abarth): We should factor this out into a kinemetics library. | 6 // TODO(abarth): We should factor this out into a kinematics library. |
7 class _ShakeDetector extends SensorListener { | 7 class _ShakeDetector extends SensorListener { |
8 _ShakeDetector() { | 8 _ShakeDetector() { |
9 SensorServiceProxy sensorService = new SensorServiceProxy.unbound(); | 9 SensorServiceProxy sensorService = new SensorServiceProxy.unbound(); |
10 shell.requestService(sensorService); | 10 shell.requestService(sensorService); |
11 | 11 |
12 _stub = new SensorListenerStub.unbound() | 12 _stub = new SensorListenerStub.unbound() |
13 ..delegate = this; | 13 ..delegate = this; |
14 sensorService.ptr.addListener(SensorType_ACCELEROMETER, _stub); | 14 sensorService.ptr.addListener(SensorType_ACCELEROMETER, _stub); |
15 _stub.listen(); | 15 _stub.listen(); |
16 } | 16 } |
(...skipping 17 matching lines...) Expand all Loading... |
34 bool isShaking = false; | 34 bool isShaking = false; |
35 SensorListenerStub _stub; | 35 SensorListenerStub _stub; |
36 } | 36 } |
37 | 37 |
38 _ShakeDetector _detector; | 38 _ShakeDetector _detector; |
39 | 39 |
40 void _init(_) { | 40 void _init(_) { |
41 _detector = new _ShakeDetector(); | 41 _detector = new _ShakeDetector(); |
42 } | 42 } |
43 </script> | 43 </script> |
OLD | NEW |