Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <errno.h>
- #include <sys/types.h>
- #include <unistd.h>
- #include <string.h>
- #define BUF_SIZE 8192
- int main(int argc, char *argv[])
- {
- char *filename = "/proc/bus/input/devices";
- int fd; /* Input and output file descriptors */
- ssize_t fd_size; /* Number of bytes returned by read() and write() */
- char buffer[BUF_SIZE]; /* Character buffer */
- fd = open(filename, O_RDONLY);
- if (fd == -1) {
- perror("open");
- return 2;
- }
- fd_size = read(fd, &buffer,BUF_SIZE);
- char *ptr;
- ptr=strstr(buffer,"Logitech G400s");
- ptr=strstr(ptr,"Handlers");
- ptr=strstr(ptr,"event");
- char *text = "/dev/input/";
- write(1,text,strlen(text));
- do {
- write(1,ptr,1);
- } while(*++ptr != ' ');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement