1 #pragma once
2 
3 #include <jsi/jsi.h>
4 #include <memory>
5 #include <unordered_set>
6 
7 #include "PlatformDepMethodsHolder.h"
8 #include "RuntimeManager.h"
9 #include "Shareables.h"
10 
11 namespace reanimated {
12 
13 using namespace facebook;
14 
15 enum SensorType {
16   ACCELEROMETER = 1,
17   GYROSCOPE = 2,
18   GRAVITY = 3,
19   MAGNETIC_FIELD = 4,
20   ROTATION_VECTOR = 5,
21 };
22 
23 class AnimatedSensorModule {
24   std::unordered_set<int> sensorsIds_;
25   RegisterSensorFunction platformRegisterSensorFunction_;
26   UnregisterSensorFunction platformUnregisterSensorFunction_;
27 
28  public:
29   AnimatedSensorModule(
30       const PlatformDepMethodsHolder &platformDepMethodsHolder);
31   ~AnimatedSensorModule();
32 
33   jsi::Value registerSensor(
34       jsi::Runtime &rt,
35       const std::shared_ptr<JSRuntimeHelper> &runtimeHelper,
36       const jsi::Value &sensorType,
37       const jsi::Value &interval,
38       const jsi::Value &iosReferenceFrame,
39       const jsi::Value &sensorDataContainer);
40   void unregisterSensor(const jsi::Value &sensorId);
41   void unregisterAllSensors();
42 };
43 
44 } // namespace reanimated
45