Add tool to toggle relative/absolute mouse modes
This commit is contained in:
parent
19d0c05557
commit
0c5187f8ab
|
@ -0,0 +1,37 @@
|
|||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
int main(int argc, char * argv[]) {
|
||||
if (argc < 2) {
|
||||
fprintf(stderr, "%s: argument (relative or absolute) expected\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fd = open("/dev/absmouse",O_WRONLY);
|
||||
if (fd < 0) {
|
||||
/* try vmmouse */
|
||||
fd = open("/dev/vmmouse",O_WRONLY);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "%s: no valid mouse interface found.\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
int flag = 0;
|
||||
if (!strcmp(argv[1],"relative")) {
|
||||
flag = 1;
|
||||
}
|
||||
if (!strcmp(argv[1],"absolute")) {
|
||||
flag = 2;
|
||||
}
|
||||
|
||||
if (!flag) {
|
||||
fprintf(stderr, "%s: invalid argument\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ioctl(fd, flag, NULL);
|
||||
}
|
Loading…
Reference in New Issue