int vibrator_exists() { int fd; #ifdef QEMU_HARDWARE if (qemu_check()) { return 1; } #endif fd = open(THE_DEVICE, O_RDWR); if(fd < 0) return 0; close(fd); return 1; }
static int sendit(int timeout_ms) { int nwr, ret, fd; char value[20]; #ifdef QEMU_HARDWARE if (qemu_check()) { return qemu_control_command( "vibrator:%d",timeout_ms); } #endif fd = open(THE_DEVICE, O_RDWR); if(fd < 0) return errno; timeout_ms = timeout_ms * 3; nwr = sprintf(value, "%d\n", timeout_ms); ret = write(fd, value, nwr); close(fd); return (ret == nwr) ? 0 : -1; }
int sendit(int timeout_ms) { int nwr, ret, fd; char value[20]; #ifdef QEMU_HARDWARE if (qemu_check()) { return qemu_control_command( "vibrator:%d", timeout_ms ); } #endif timeout_ms = 0x140000 | timeout_ms; // add 0x14000 to set vibration level to 31. fd = open(THE_DEVICE, O_RDWR); if(fd < 0) return errno; nwr = sprintf(value, "%d", timeout_ms); ret = write(fd, value, nwr); close(fd); return (ret == nwr) ? 0 : -1; }