From 1c31d39db82879985f56a422393cd639bff51006 Mon Sep 17 00:00:00 2001 From: Mu-Woong Lee Date: Mon, 2 May 2016 13:55:34 +0900 Subject: [PATCH] Remap the axis enums for ABI compatibility Change-Id: I282db494c388f8c09f58021026b78110acedd231 Signed-off-by: Mu-Woong Lee --- include/sensor.h | 24 ++++++++++++------------ src/sensor.cpp | 4 +++- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/include/sensor.h b/include/sensor.h index f79b76a..f40013e 100644 --- a/include/sensor.h +++ b/include/sensor.h @@ -859,18 +859,18 @@ int sensor_get_max_batch_count(sensor_h sensor, int *max_batch_count); */ typedef enum { - SENSOR_UTIL_AXIS_X = 0x01, /**< +X */ - SENSOR_UTIL_AXIS_Y = 0x02, /**< +Y */ - SENSOR_UTIL_AXIS_Z = 0x03, /**< +Z */ - SENSOR_UTIL_AXIS_MINUS_X = 0x81, /**< -X */ - SENSOR_UTIL_AXIS_MINUS_Y = 0x82, /**< -Y */ - SENSOR_UTIL_AXIS_MINUS_Z = 0x83, /**< -Z */ - sensor_util_axis_x = 0x01, - sensor_util_axis_y = 0x02, - sensor_util_axis_z = 0x03, - sensor_util_axis_minus_x = 0x81, - sensor_util_axis_minus_y = 0x82, - sensor_util_axis_minus_z = 0x83, + SENSOR_UTIL_AXIS_MINUS_X = 0, /**< -X */ + SENSOR_UTIL_AXIS_MINUS_Y, /**< -Y */ + SENSOR_UTIL_AXIS_MINUS_Z, /**< -Z */ + SENSOR_UTIL_AXIS_X, /**< +X */ + SENSOR_UTIL_AXIS_Y, /**< +Y */ + SENSOR_UTIL_AXIS_Z, /**< +Z */ + sensor_util_axis_minus_x = SENSOR_UTIL_AXIS_MINUS_X, + sensor_util_axis_minus_y, + sensor_util_axis_minus_z, + sensor_util_axis_x, + sensor_util_axis_y, + sensor_util_axis_z, } sensor_util_axis_e; /** diff --git a/src/sensor.cpp b/src/sensor.cpp index ce6b02a..2dc1aef 100644 --- a/src/sensor.cpp +++ b/src/sensor.cpp @@ -47,6 +47,8 @@ #define SENSOR_LISTENER_MAGIC 0xCAFECAFE +#define CONVERT_AXIS_ENUM(X) ((X) < 3 ? (X) + 0x81 : (X) - 2) + static int sensor_connect(sensor_h sensor, sensor_listener_h listener) { int id = SENSOR_UNDEFINED_ID; @@ -811,7 +813,7 @@ int sensor_util_get_inclination(float I[], float* inclination) int sensor_util_remap_coordinate_system(float inR[], sensor_util_axis_e x, sensor_util_axis_e y, float outR[]) { - if (remapCoordinateSystem(inR, x, y, outR) < 0) + if (remapCoordinateSystem(inR, CONVERT_AXIS_ENUM(x), CONVERT_AXIS_ENUM(y), outR) < 0) return SENSOR_ERROR_INVALID_PARAMETER; return SENSOR_ERROR_NONE; -- 2.7.4