public ISensor this[SensorType sensorType] { get { for (int i = 0; i < _Sensors.Count; i++) { if (_Sensors[i].SensorType == sensorType) { return(_Sensors[i]); } } if (sensorType == SensorType.Velocity) { VelocitySensor veloctiySensor = new VelocitySensor(this); _Sensors.Add(veloctiySensor); return(veloctiySensor); } else { Android.Hardware.SensorType?droidTypeNullable = sensorTypeToDroidSensorType(sensorType); if (droidTypeNullable == null) { return(null); } Android.Hardware.SensorType droidSensorType = (Android.Hardware.SensorType)droidTypeNullable; Android.Hardware.Sensor droidSensor = _DroidSensorManager.GetDefaultSensor(droidSensorType); //检查一下这个Sensor是不是已经被创建过了 SingleSensor sensor = new SingleSensor(this, droidSensor); _Sensors.Add(sensor); return(sensor); } } }
public SingleSensor(SensorManager sensorManager, Android.Hardware.Sensor droidSensor) { this.DroidSensor = droidSensor; this._SensorManager = sensorManager; _Registered = false; _LatestUpdatedDataDateTime = DateTime.Now; UpdateTimestep = 15; }
public VelocitySensor(SensorManager sensorManager) { this.sensorManager = sensorManager; Activated = false; _LatestUpdatedDataDateTime = DateTime.Now; linearAcceleration = sensorManager._DroidSensorManager.GetDefaultSensor(Android.Hardware.SensorType.LinearAcceleration); UpdateTimestep = 15; previousProcessDataTime = DateTime.Now; }
public void OnAccuracyChanged(Android.Hardware.Sensor sensor, Android.Hardware.SensorStatus accuracy) { }
public void OnAccuracyChanged(Android.Hardware.Sensor sensor, [GeneratedEnum] Android.Hardware.SensorStatus accuracy) { }
public Accelerometer( IWindow window ) { OpenTK.Platform.Android.AndroidGameView gameView = ( window.Handle as OpenTK.Platform.Android.AndroidGameView ); sensorManager = gameView.Context.GetSystemService ( Android.Content.Context.SensorService ) as Android.Hardware.SensorManager; sensor = sensorManager.GetDefaultSensor ( Android.Hardware.SensorType.Accelerometer ); }