diff options
-rw-r--r-- | libsensors/yas_orientation.c | 15 |
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; } |