Guest_imported
New member
- Jan 1, 1970
- 0
Below is the code I use to get ANYTHING from the mouse, it does work and read in the data from the mouse, but it has no format, and is just garbage.
Example:
Left = "ÿûÿ¿ È"
Right = "ûÿ¿ È"
Left click is 3 line feeds.
I know its something simple but I am too new to find it, I have looked everywhere, but most open("/dev/mouse", O_RDWR); searches turn up load of useless .diff files.
Please help me if you can, I have been trying to figure it out for about 2 weeks.
#include "stdio.h"
#include "sys/types.h"
#include "unistd.h"
#include "fcntl.h"
void
main() {
int fd; /* file descriptor for the device */
char buff[16]; /* string of 16 bytes */
if ((fd = open("/dev/mouse", O_RDWR)) < 0) {
fprintf(stderr, "Can't open: "
; perror("/dev/mouse"
; exit(1);
} else {
printf("/dev/mlouse opened with fd = %d\n", fd);
}
printf("size of buff is %d\n", sizeof(buff));
printf("read returns %d\n", read(fd, buff, sizeof(buff)));
buff[15] = 0; /* null terminate the string */
/* display the data read into the buffer */
printf("buff is:\n%s\n", buff);
close(fd);
}
All I really care about is direction and speed of the mouse going left to right, and the state change of the left button. I can't use libgpm, ncurses, or allegro, I just need those 3 things. I am using allegro now, but I need to not have x-windows running do to space requirements.
Example:
Left = "ÿûÿ¿ È"
Right = "ûÿ¿ È"
Left click is 3 line feeds.
I know its something simple but I am too new to find it, I have looked everywhere, but most open("/dev/mouse", O_RDWR); searches turn up load of useless .diff files.
Please help me if you can, I have been trying to figure it out for about 2 weeks.
#include "stdio.h"
#include "sys/types.h"
#include "unistd.h"
#include "fcntl.h"
void
main() {
int fd; /* file descriptor for the device */
char buff[16]; /* string of 16 bytes */
if ((fd = open("/dev/mouse", O_RDWR)) < 0) {
fprintf(stderr, "Can't open: "
} else {
printf("/dev/mlouse opened with fd = %d\n", fd);
}
printf("size of buff is %d\n", sizeof(buff));
printf("read returns %d\n", read(fd, buff, sizeof(buff)));
buff[15] = 0; /* null terminate the string */
/* display the data read into the buffer */
printf("buff is:\n%s\n", buff);
close(fd);
}
All I really care about is direction and speed of the mouse going left to right, and the state change of the left button. I can't use libgpm, ncurses, or allegro, I just need those 3 things. I am using allegro now, but I need to not have x-windows running do to space requirements.