Merge "minui: Add haptic feedback to virtual keys" into froyo

This commit is contained in:
Koushik Dutta 2010-11-28 03:54:03 +00:00 committed by Gerrit Code Review
commit 517a16b98f

View File

@ -29,6 +29,9 @@
#define MAX_DEVICES 16
#define VIBRATOR_TIMEOUT_FILE "/sys/class/timed_output/vibrator/enable"
#define VIBRATOR_TIME_MS 50
enum {
DOWN_NOT,
DOWN_SENT,
@ -65,6 +68,26 @@ static inline int ABS(int x) {
return x<0?-x:x;
}
int vibrate(int timeout_ms)
{
char str[20];
int fd;
int ret;
fd = open(VIBRATOR_TIMEOUT_FILE, O_WRONLY);
if (fd < 0)
return -1;
ret = snprintf(str, sizeof(str), "%d", timeout_ms);
ret = write(fd, str, ret);
close(fd);
if (ret < 0)
return -1;
return 0;
}
/* Returns empty tokens */
static char *vk_strtok_r(char *str, const char *delim, char **save_str)
{
@ -300,6 +323,8 @@ static int vk_modify(struct ev *e, struct input_event *ev)
ev->type = EV_KEY;
ev->code = e->vks[i].scancode;
ev->value = 1;
vibrate(VIBRATOR_TIME_MS);
return 0;
}
}