W
Wijnand Smant
Hi,
I found something to log youre mousemovements in unix, can anyone give me a
hand how to port this to windows.
Which handles do I need, and what do I need to include?
Grtz,
Wijnand
---------------------
unix version
----------------------------------------------------------------------------
--------
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
int fd;
int wholex = 0;
int wholey = 0;
int overflowx = 0;
int overflowy = 0;
float wegx = 0;
float wegy = 0;
int x;
int y;
int lbutton;
int rbutton;
char z[4];
int sign = 0;
fd = open("/dev/input/mouse0", O_RDWR);
if (fd < 0) {
perror("open mouse (/dev/input/mouse0)");
exit(1);
}
/* read the 3 bytes */
while (read(fd, &z, 3) > 0) {
/* read 3 bytes */
if ( (z[0] & 8) == 0) {
fprintf(stderr, "No mouse data\n");
exit(1);
}
x = z[1];
y = z[2];
/* sign bit */
if (z[0] & 0x10) {
x = - (256 - z[1]);
}
if (z[0] & 0x20) {
y = - (256 - z[2]);
}
if (z[0] & 0x80) {
overflowy = 1;
} else {
overflowy = 0;
}
if (z[0] & 0x40) {
overflowx = 1;
} else {
overflowx = 0;
}
wholex += x;
wholey += y;
/* Nehme mal die normalen Messwerte */
wegx = wholex; /* / 174.7; */
wegy = wholey; /* / 174.7; */
if ((overflowy == 0) && (overflowx == 0)) {
printf("x: %8.2f pixel, y: %8.2f pixel\n", wegx, wegy);
} else {
printf("TOO FAST!\n");
}
fflush(stdout);
}
exit(0);
}
I found something to log youre mousemovements in unix, can anyone give me a
hand how to port this to windows.
Which handles do I need, and what do I need to include?
Grtz,
Wijnand
---------------------
unix version
----------------------------------------------------------------------------
--------
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char *argv[]) {
int fd;
int wholex = 0;
int wholey = 0;
int overflowx = 0;
int overflowy = 0;
float wegx = 0;
float wegy = 0;
int x;
int y;
int lbutton;
int rbutton;
char z[4];
int sign = 0;
fd = open("/dev/input/mouse0", O_RDWR);
if (fd < 0) {
perror("open mouse (/dev/input/mouse0)");
exit(1);
}
/* read the 3 bytes */
while (read(fd, &z, 3) > 0) {
/* read 3 bytes */
if ( (z[0] & 8) == 0) {
fprintf(stderr, "No mouse data\n");
exit(1);
}
x = z[1];
y = z[2];
/* sign bit */
if (z[0] & 0x10) {
x = - (256 - z[1]);
}
if (z[0] & 0x20) {
y = - (256 - z[2]);
}
if (z[0] & 0x80) {
overflowy = 1;
} else {
overflowy = 0;
}
if (z[0] & 0x40) {
overflowx = 1;
} else {
overflowx = 0;
}
wholex += x;
wholey += y;
/* Nehme mal die normalen Messwerte */
wegx = wholex; /* / 174.7; */
wegy = wholey; /* / 174.7; */
if ((overflowy == 0) && (overflowx == 0)) {
printf("x: %8.2f pixel, y: %8.2f pixel\n", wegx, wegy);
} else {
printf("TOO FAST!\n");
}
fflush(stdout);
}
exit(0);
}