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