diff options
author | Mathias Agopian <mathias@google.com> | 2010-07-21 18:10:22 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2010-07-21 18:10:22 -0700 |
commit | 50558b956157dad980441bf4fb44931ce834e36b (patch) | |
tree | 2d208a78ab3a1c77d91751b8bbe5cafd9415f0d8 /native | |
parent | c1b11b1b37d0692bd3c63575c9f2c0d9fa566602 (diff) | |
parent | bc54e63c84a517f0dca88ba900ff2b56719f685b (diff) | |
download | frameworks_base-50558b956157dad980441bf4fb44931ce834e36b.zip frameworks_base-50558b956157dad980441bf4fb44931ce834e36b.tar.gz frameworks_base-50558b956157dad980441bf4fb44931ce834e36b.tar.bz2 |
resolved conflicts for merge of bc54e63c to master
Change-Id: I4245b15b4cda6963d735442c0c6a04a0477ff5e1
Diffstat (limited to 'native')
-rw-r--r-- | native/android/sensor.cpp | 37 | ||||
-rw-r--r-- | native/include/android/sensor.h | 34 |
2 files changed, 42 insertions, 29 deletions
diff --git a/native/android/sensor.cpp b/native/android/sensor.cpp index 7a3907e..e1fc4e7 100644 --- a/native/android/sensor.cpp +++ b/native/android/sensor.cpp @@ -43,17 +43,18 @@ ASensorManager* ASensorManager_getInstance() return &SensorManager::getInstance(); } -int ASensorManager_getSensorList(ASensorManager* manager, ASensor** list) +int ASensorManager_getSensorList(ASensorManager* manager, + ASensorList* list) { - Sensor* l; + Sensor const* const* l; int c = static_cast<SensorManager*>(manager)->getSensorList(&l); if (list) { - *list = l; + *list = reinterpret_cast<ASensorList>(l); } return c; } -ASensor* ASensorManager_getDefaultSensor(ASensorManager* manager, int type) +ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type) { return static_cast<SensorManager*>(manager)->getDefaultSensor(type); } @@ -82,23 +83,23 @@ int ASensorManager_destroyEventQueue(ASensorManager* manager, /*****************************************************************************/ -int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor* sensor) +int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor) { return static_cast<SensorEventQueue*>(queue)->enableSensor( - static_cast<Sensor*>(sensor)); + static_cast<Sensor const*>(sensor)); } -int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor* sensor) +int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor) { return static_cast<SensorEventQueue*>(queue)->disableSensor( - static_cast<Sensor*>(sensor)); + static_cast<Sensor const*>(sensor)); } -int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor* sensor, +int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec) { return static_cast<SensorEventQueue*>(queue)->setEventRate( - static_cast<Sensor*>(sensor), us2ns(usec)); + static_cast<Sensor const*>(sensor), us2ns(usec)); } int ASensorEventQueue_hasEvents(ASensorEventQueue* queue) @@ -128,23 +129,23 @@ ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, /*****************************************************************************/ -const char* ASensor_getName(ASensor* sensor) +const char* ASensor_getName(ASensor const* sensor) { - return static_cast<Sensor*>(sensor)->getName().string(); + return static_cast<Sensor const*>(sensor)->getName().string(); } -const char* ASensor_getVendor(ASensor* sensor) +const char* ASensor_getVendor(ASensor const* sensor) { - return static_cast<Sensor*>(sensor)->getVendor().string(); + return static_cast<Sensor const*>(sensor)->getVendor().string(); } -int ASensor_getType(ASensor* sensor) +int ASensor_getType(ASensor const* sensor) { - return static_cast<Sensor*>(sensor)->getType(); + return static_cast<Sensor const*>(sensor)->getType(); } -float ASensor_getResolution(ASensor* sensor) +float ASensor_getResolution(ASensor const* sensor) { - return static_cast<Sensor*>(sensor)->getResolution(); + return static_cast<Sensor const*>(sensor)->getResolution(); } diff --git a/native/include/android/sensor.h b/native/include/android/sensor.h index 4291d3e..00d95d8 100644 --- a/native/include/android/sensor.h +++ b/native/include/android/sensor.h @@ -87,6 +87,7 @@ enum { * A sensor event. */ +/* NOTE: Must match hardware/sensors.h */ typedef struct ASensorVector { union { float v[3]; @@ -95,23 +96,32 @@ typedef struct ASensorVector { float y; float z; }; + struct { + float azimuth; + float pitch; + float roll; + }; }; int8_t status; uint8_t reserved[3]; } ASensorVector; +/* NOTE: Must match hardware/sensors.h */ typedef struct ASensorEvent { - int sensor; + int32_t version; /* sizeof(struct ASensorEvent) */ + int32_t sensor; + int32_t type; int32_t reserved0; + int64_t timestamp; union { float data[16]; + ASensorVector vector; ASensorVector acceleration; ASensorVector magnetic; float temperature; float distance; float light; }; - int64_t timestamp; int32_t reserved1[4]; } ASensorEvent; @@ -124,6 +134,8 @@ typedef struct ASensorEventQueue ASensorEventQueue; struct ASensor; typedef struct ASensor ASensor; +typedef ASensor const* ASensorRef; +typedef ASensorRef const* ASensorList; /*****************************************************************************/ @@ -141,13 +153,13 @@ ASensorManager* ASensorManager_getInstance(); /* * Returns the list of available sensors. */ -int ASensorManager_getSensorList(ASensorManager* manager, ASensor** list); +int ASensorManager_getSensorList(ASensorManager* manager, ASensorList* list); /* * Returns the default sensor for the given type, or NULL if no sensor * of that type exist. */ -ASensor* ASensorManager_getDefaultSensor(ASensorManager* manager, int type); +ASensor const* ASensorManager_getDefaultSensor(ASensorManager* manager, int type); /* * Creates a new sensor event queue and associate it with a looper. @@ -166,12 +178,12 @@ int ASensorManager_destroyEventQueue(ASensorManager* manager, ASensorEventQueue* /* * Enable the selected sensor. Returns a negative error code on failure. */ -int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor* sensor); +int ASensorEventQueue_enableSensor(ASensorEventQueue* queue, ASensor const* sensor); /* * Disable the selected sensor. Returns a negative error code on failure. */ -int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor* sensor); +int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor const* sensor); /* * Sets the delivery rate of events in microseconds for the given sensor. @@ -179,7 +191,7 @@ int ASensorEventQueue_disableSensor(ASensorEventQueue* queue, ASensor* sensor); * rate. * Returns a negative error code on failure. */ -int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor* sensor, int32_t usec); +int ASensorEventQueue_setEventRate(ASensorEventQueue* queue, ASensor const* sensor, int32_t usec); /* * Returns true if there are one or more events available in the @@ -210,22 +222,22 @@ ssize_t ASensorEventQueue_getEvents(ASensorEventQueue* queue, /* * Returns this sensor's name (non localized) */ -const char* ASensor_getName(ASensor* sensor); +const char* ASensor_getName(ASensor const* sensor); /* * Returns this sensor's vendor's name (non localized) */ -const char* ASensor_getVendor(ASensor* sensor); +const char* ASensor_getVendor(ASensor const* sensor); /* * Return this sensor's type */ -int ASensor_getType(ASensor* sensor); +int ASensor_getType(ASensor const* sensor); /* * Returns this sensors's resolution */ -float ASensor_getResolution(ASensor* sensor); +float ASensor_getResolution(ASensor const* sensor); #ifdef __cplusplus |