initial version

This commit is contained in:
Matthieu Herrb 2024-11-07 15:21:46 +01:00
commit 6cdb039c6c
9 changed files with 556 additions and 0 deletions

71
twsmouse.c Normal file
View file

@ -0,0 +1,71 @@
/* wsmouse events dump */
#include <sys/time.h>
#include <dev/wscons/wsconsio.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
int fd, n;
char *dev;
struct wscons_event event;
if (argc == 2) {
dev = argv[1];
} else {
dev = "/dev/wsmouse";
}
fd = open(dev, O_RDONLY);
if (fd < 0) {
perror("open");
exit(1);
}
while (1) {
n = read(fd, &event, sizeof(struct wscons_event));
if (n <= 0) {
perror("read");
}
// printf("device: %#x: ", event.device);
switch (event.type) {
case WSCONS_EVENT_MOUSE_UP:
printf("MOUSE_UP: 0x%x\n", event.value);
break;
case WSCONS_EVENT_MOUSE_DOWN:
printf("MOUSE_DOWN: 0x%x\n", event.value);
break;
case WSCONS_EVENT_MOUSE_DELTA_X:
printf("MOUSE_DELTA_X: %d\n", event.value);
break;
case WSCONS_EVENT_MOUSE_DELTA_Y:
printf("MOUSE_DELTA_Y: %d\n", event.value);
break;
#ifdef WSCONS_EVENT_MOUSE_DELTA_Z
case WSCONS_EVENT_MOUSE_DELTA_Z:
printf("MOUSE_DELTA_Z: %d\n", event.value);
break;
#endif
#ifdef WSCONS_EVENT_MOUSE_ABSOLUTE_Z
case WSCONS_EVENT_MOUSE_ABSOLUTE_Z:
printf("MOUSE_ABSOLUTE_Z: %d\n", event.value);
break;
#endif
case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
printf("MOUSE_ABSOLUTE_X: %d\n", event.value);
break;
case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
printf("MOUSE_ABSOLUTE_Y: %d\n", event.value);
break;
case WSCONS_EVENT_SYNC:
printf("SYNC\n");
break;
default:
printf("unknown event type 0x%x, value 0x%x\n",
event.type, event.value);
}
}
}