#ifndef CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
#define CHROMEOS_ACCELEROMETER_ACCELEROMETER_READER_H_
-#include <vector>
-
#include "base/memory/ref_counted.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "chromeos/chromeos_export.h"
-#include "ui/gfx/geometry/vector3d_f.h"
+#include "ui/accelerometer/accelerometer_types.h"
namespace base {
class TaskRunner;
ConfigurationData();
~ConfigurationData();
- // Scale of accelerometers (i.e. raw value * 1.0f / scale = G's).
- unsigned int base_scale;
- unsigned int lid_scale;
+ // Number of accelerometers on device.
+ size_t count;
+
+ // Length of accelerometer updates.
+ size_t length;
+
+ // Which accelerometers are present on device.
+ bool has[ui::ACCELEROMETER_SOURCE_COUNT];
+
+ // Scale of accelerometers (i.e. raw value * scale = m/s^2).
+ float scale[ui::ACCELEROMETER_SOURCE_COUNT][3];
// Index of each accelerometer axis in data stream.
- std::vector<unsigned int> index;
+ int index[ui::ACCELEROMETER_SOURCE_COUNT][3];
};
typedef base::RefCountedData<ConfigurationData> Configuration;
typedef base::RefCountedData<char[12]> Reading;
// An interface to receive data from the AccelerometerReader.
class Delegate {
public:
- virtual void HandleAccelerometerReading(const gfx::Vector3dF& base,
- const gfx::Vector3dF& lid) = 0;
+ virtual ~Delegate() {}
+
+ virtual void HandleAccelerometerUpdate(
+ const ui::AccelerometerUpdate& update) = 0;
};
- AccelerometerReader(base::TaskRunner* blocking_task_runner,
+ AccelerometerReader(scoped_refptr<base::TaskRunner> blocking_task_runner,
Delegate* delegate);
~AccelerometerReader();
// OnDataRead with the result.
void TriggerRead();
- // If |success|, converts the raw reading to a pair of Vector3dF
- // values and notifies the |delegate_| with the new readings.
+ // If |success|, converts the raw reading to an AccelerometerUpdate
+ // message and notifies the |delegate_| with the new readings.
// Triggers another read from the accelerometer at the current sampling rate.
void OnDataRead(scoped_refptr<Reading> reading, bool success);
// A weak pointer to the delegate to send accelerometer readings to.
Delegate* delegate_;
+ // The last seen accelerometer data.
+ ui::AccelerometerUpdate update_;
+
// The accelerometer configuration.
scoped_refptr<Configuration> configuration_;