accelerometer.c revision 9091e686f43184065381aa71929e3df36a4ea2e1
feb2c590898bd03d4dfd8a77c429a471776527c5Julian Kigwana * accelerometer - exports device orientation through property
208f1c0d2a321a44c504ed47bbe0378ea2a9d1f2Phil Ostler * When an "change" event is received on an accelerometer,
feb2c590898bd03d4dfd8a77c429a471776527c5Julian Kigwana * open its device node, and from the value, as well as the previous
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <limits.h>
#include "libudev.h"
#include "libudev-private.h"
static int debug = 0;
if (debug) {
static const char *orientations[] = {
return orientations[o];
static OrientationUp
return ORIENTATION_UNDEFINED;
return ORIENTATION_UNDEFINED;
static OrientationUp
int rotation;
return ret;
static OrientationUp
const char *value;
return ORIENTATION_UNDEFINED;
#define SET_AXIS(axis, code_) if (ev[i].code == code_) { if (got_##axis == 0) { axis = ev[i].value; got_##axis = true; } }
const char *devpath)
bool got_syn = false;
if (fd < 0)
if (r < (int) sizeof(struct input_event))
for (i = 0; i < r / (int) sizeof(struct input_event); i++) {
if (got_syn) {
got_syn = true;
goto read_dev;
static void help(void)
char *devnode;
log_open();
int option;
switch (option) {
help();
exit(0);
help();
const char *node;
log_close();