Hi everyone. This is my first post here, and here's my issue. I'm trying to read the mouse from the virtual console thru /dev/sysmouse. I can successfully open the mouse, but when I try to query the mouse through ioctl(), I get Inappropriate ioctl for device. I recently upgraded to 13.2. The code outputs the following.
Code:
Mouse opened successfully. File descriptor: 3.
ioctl() failed. Error: 25 - Inappropriate ioctl for device
C:
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mouse.h>
#include <sys/consio.h>
int main(void) {
int mouse_fd; /* mouse file descriptor */
static mouse_info_t mouse_info; /* BSD mouse info */
mouse_fd = open("/dev/sysmouse", O_RDONLY);
if (mouse_fd < 0) {
fprintf(stdout, "Mouse could not be opened. Error: %d - %s\n", errno, strerror(errno));
} else {
fprintf(stdout, "Mouse opened successfully. File descriptor: %d.\n", mouse_fd);
mouse_info.operation = MOUSE_GETINFO;
if (ioctl(mouse_fd, CONS_MOUSECTL, &mouse_info) < 0) {
fprintf(stdout, "ioctl() failed. Error: %d - %s\n", errno, strerror(errno));
} else {
fprintf(stdout, "Mouse read successfully.\n");
}
close(mouse_fd);
}
return(0);
}