Beispiel #1
0
            public void OnSensorChanged(Android.Hardware.SensorEvent e)
            {
                if (e.Sensor.Type != Android.Hardware.SensorType.LinearAcceleration)
                {
                    return;
                }
                processData(e.Values.ToArray <float>());

                if ((DateTime.Now - _LatestUpdatedDataDateTime).TotalMilliseconds >= UpdateTimestep)
                {
                    _LatestUpdatedDataDateTime = DateTime.Now;
                    OnSensorDataUpdated?.Invoke(this, velocity.Array);
                }
            }
Beispiel #2
0
            public void OnSensorChanged(Android.Hardware.SensorEvent e)
            {
                if (e.Sensor.Type != DroidSensorType)
                {
                    return;
                }
                if ((DateTime.Now - _LatestUpdatedDataDateTime).TotalMilliseconds >= UpdateTimestep)
                {
                    _LatestUpdatedDataDateTime = DateTime.Now;

                    if (DroidSensorType == Android.Hardware.SensorType.GameRotationVector)
                    {
                        float[] quaternion = new float[4];
                        Android.Hardware.SensorManager.GetQuaternionFromVector(quaternion, e.Values.ToArray <float>());
                        OnSensorDataUpdated?.Invoke(this, quaternion);
                    }
                    else
                    {
                        OnSensorDataUpdated?.Invoke(this, e.Values.ToArray <float>());
                    }
                }
            }