Zum Hauptinhalt springen
  1. Blogs/

Linux - Mausbewegungen auslesen

1 min· loading ·
Daniel
Autor
Daniel
Engineer, Coder and Open-Source enthusiast.
Autor
Daniel

Kann man ja eventuell mal gebrauchen.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/input.h>

#define MOUSEFILE "/dev/input/event5"

int main() {
    int fd;
    struct input_event ie;
    if((fd = open(MOUSEFILE, O_RDONLY)) == -1) {
        perror("opening device");
        exit(EXIT_FAILURE);
    }
    while(read(fd, &ie, sizeof(struct input_event))) {
        printf("time %ld . %06ldttype %dtcode %dtvalue %dn",
                ie.time.tv_sec, ie.time.tv_usec, ie.type, ie.code, ie.value);
    }
    return 0;
}

Verwandte Artikel