You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

67 lines
1.3 KiB

#include <linux/types.h>
#include <linux/input.h>
#include <linux/hidraw.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
int main(int argc, char **argv)
{
int fd;
int i, res = 0;
char buf[256];
/* Open the Device with non-blocking reads. In real life,
don't use a hard coded path; use libudev instead. */
fd = open("/dev/hidraw0", O_RDWR|O_NONBLOCK);
if (fd < 0) {
perror("Unable to open device");
return 1;
}
memset(buf, 0x0, sizeof(buf));
switch (argv[1][0]) {
case '0':
break;
case '1':
buf[2] = 0xff;
break;
case '2':
buf[3] = 0xff;
break;
case '3':
buf[4] = 0xff;
break;
case '4':
buf[5] = 0xff;
break;
default:
printf("Please specify 0 ... 4 as single argument.\n");
}
/* Send a Report to the Device */
buf[0] = 0x00; /* Report Number */
buf[1] = 0x00; /* Report ID */
//buf[2] = 0x01; /* Buzzer 1 */
//buf[3] = 0x00; /* Buzzer 2 */
//buf[4] = 0x00; /* Buzzer 3 */
//buf[5] = 0x01; /* Buzzer 4 */
res = write(fd, buf, 6);
if (res < 0) {
printf("Error: %d\n", errno);
perror("write");
} else {
//printf("write() wrote %d bytes\n", res);
}
close(fd);
return 0;
}