blob: fcea21c6b5a1ccbaecceea11b815a8c4a5d7180a [file] [log] [blame]
The Android Open Source Projectd6054a32008-10-21 07:00:00 -07001#include <hardware/vibrator.h>
2
3#include <stdio.h>
4#include <unistd.h>
5#include <fcntl.h>
6#include <errno.h>
7
8#define THE_DEVICE "/sys/class/timed_output/vibrator/enable"
9
10static int sendit(int timeout_ms)
11{
12 int nwr, ret, fd;
13 char value[20];
14
15 fd = open(THE_DEVICE, O_RDWR);
16 if(fd < 0)
17 return errno;
18
19 nwr = sprintf(value, "%d\n", timeout_ms);
20 ret = write(fd, value, nwr);
21
22 close(fd);
23
24 return (ret == nwr) ? 0 : -1;
25}
26
27int vibrator_on()
28{
29 /* constant on, up to maximum allowed time */
30 return sendit(-1);
31}
32
33int vibrator_off()
34{
35 return sendit(0);
36}