diff options
Diffstat (limited to 'libsensors/orientationd/orientationd.h')
-rw-r--r-- | libsensors/orientationd/orientationd.h | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/libsensors/orientationd/orientationd.h b/libsensors/orientationd/orientationd.h index 41aad5e..7e169e4 100644 --- a/libsensors/orientationd/orientationd.h +++ b/libsensors/orientationd/orientationd.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2013 Paul Kocialkowski + * Copyright (C) 2013 Paul Kocialkowski <contact@paulk.fr> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,36 +15,72 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <stdint.h> +#include <poll.h> #include <linux/input.h> -#ifndef _ORIENTATION_H_ -#define _ORIENTATION_H_ +#include <hardware/sensors.h> +#include <hardware/hardware.h> -/* - * Vector - */ +#ifndef _ORIENTATIOND_H_ +#define _ORIENTATIOND_H_ -struct vector { - float x; - float y; - float z; +struct orientationd_data; +struct orientationd_handlers { + char *input_name; + int handle; + int poll_fd; + + int (*get_data)(struct orientationd_handlers *handlers, + struct orientationd_data *data); }; -typedef struct vector vector; +struct orientationd_data { + struct orientationd_handlers **handlers; + int handlers_count; + + struct pollfd *poll_fds; + int poll_fds_count; -void vector_add(vector *v, vector *a); -void vector_multiply(vector *v, float k); -void vector_cross(vector *v, vector *c, vector *out); -float vector_scalar(vector *v, vector *d); -float vector_length(vector *v); + sensors_vec_t orientation; + sensors_vec_t acceleration; + sensors_vec_t magnetic; + + unsigned int delay; + int input_fd; + + int activated; + + pthread_t thread; + pthread_mutex_t mutex; + int thread_continue; +}; + +extern struct orientationd_handlers *orientationd_handlers[]; +extern int orientationd_handlers_count; /* * Input */ -int64_t input_timestamp(struct input_event *event); -int input_open(char *name, int write); +void input_event_set(struct input_event *event, int type, int code, int value); +long int timestamp(struct timeval *time); +long int input_timestamp(struct input_event *event); +int uinput_rel_create(const char *name); +void uinput_destroy(int uinput_fd); +int input_open(char *name); int sysfs_path_prefix(char *name, char *path_prefix); +int sysfs_value_read(char *path); +int sysfs_value_write(char *path, int value); +int sysfs_string_read(char *path, char *buffer, size_t length); +int sysfs_string_write(char *path, char *buffer, size_t length); + +/* + * Sensors + */ + +extern struct orientationd_handlers bma250; +extern struct orientationd_handlers yas530; #endif |