aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZiyan <jaraidaniel@gmail.com>2015-08-13 00:57:12 +0200
committerAndreas Blaesius <skate4life@gmx.de>2015-08-15 14:23:40 -0700
commitf8b2c0625e957726c55d4d21c101c0b4e4d052ba (patch)
treeb8b4804928237bee9ba4b3e2cff8cc1b1e865b8c
parentc0befab5818c9aebd211e1806c88a339cfeb776c (diff)
downloaddevice_samsung_espressowifi-f8b2c0625e957726c55d4d21c101c0b4e4d052ba.zip
device_samsung_espressowifi-f8b2c0625e957726c55d4d21c101c0b4e4d052ba.tar.gz
device_samsung_espressowifi-f8b2c0625e957726c55d4d21c101c0b4e4d052ba.tar.bz2
espresso-common: libsensors: store previous orientation values
Since we only get updates from the sensor, it is needed to save (and return) all axis values. Change-Id: Ibe4448262f17d6a15154d16ecb0acc476b3399f0
-rw-r--r--libsensors/yas_orientation.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libsensors/yas_orientation.c b/libsensors/yas_orientation.c
index c14ed72..3d74e31 100644
--- a/libsensors/yas_orientation.c
+++ b/libsensors/yas_orientation.c
@@ -39,6 +39,8 @@ struct yas_orientation_data {
char path_enable[PATH_MAX];
char path_delay[PATH_MAX];
+
+ sensors_vec_t orientation;
};
int yas_orientation_init(struct piranha_sensors_handlers *handlers,
@@ -234,15 +236,18 @@ float yas_orientation_convert(int value)
int yas_orientation_get_data(struct piranha_sensors_handlers *handlers,
struct sensors_event_t *event)
{
+ struct yas_orientation_data *data;
struct input_event input_event;
int input_fd;
int rc;
// ALOGD("%s(%p, %p)", __func__, handlers, event);
- if (handlers == NULL || event == NULL)
+ if (handlers == NULL || handlers->data == NULL || event == NULL)
return -EINVAL;
+ data = (struct yas_orientation_data *) handlers->data;
+
input_fd = handlers->poll_fd;
if (input_fd < 0)
return -EINVAL;
@@ -252,6 +257,10 @@ int yas_orientation_get_data(struct piranha_sensors_handlers *handlers,
event->sensor = handlers->handle;
event->type = handlers->handle;
+ event->orientation.azimuth = data->orientation.azimuth;
+ event->orientation.pitch = data->orientation.pitch;
+ event->orientation.roll = data->orientation.roll;
+
do {
rc = read(input_fd, &input_event, sizeof(input_event));
if (rc < (int) sizeof(input_event))
@@ -277,6 +286,10 @@ int yas_orientation_get_data(struct piranha_sensors_handlers *handlers,
}
} while (input_event.type != EV_SYN);
+ data->orientation.azimuth = event->orientation.azimuth;
+ data->orientation.pitch = event->orientation.pitch;
+ data->orientation.roll = event->orientation.roll;
+
return 0;
}