log mousemovement

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);

}
 
V

Victor Bazarov

Wijnand said:
I found something to log youre mousemovements in unix, can anyone
give me a hand how to port this to windows. [..]

Yes, somebody in the Windows programming newsgroup can. Here mouse
movementes are offtopic, since C++ has no means to control hardware
and everything you need is platform-specific. Please see FAQ for
the list of places where to post.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top