Date: Mon, 21 Nov 2016 16:02:27 +0700 From: Olivier <Olivier.Nicole@cs.ait.ac.th> To: freebsd-hackers@freebsd.org Subject: New behavious in /dev/consolectl Message-ID: <wu7y40dgq8s.fsf@banyan.cs.ait.ac.th>
next in thread | raw e-mail | index | archive | help
Hi, I am not sure this is the right list to ask the question, but I have the following problem that is bugging me. I have a simple program that read the middle button of the mouse at start-up and reply with (close/pressed or open/released) (see below). In previous versions of FreeBSD (up to 9 I think), if the middle button was pressed down when I launched the program, it was detected, and I could launch and relaunch the program, it was always replying with "close". Now (FreeBSD 10), the close is only detected on the first run. The second run will reply "open", even if I keep the button pressed all the time between the 2 runs; like if by reading the button, I was erasing the memory. Please consider the following examples: The first run is just to show what is happening to answer the mouse button action. Run 2 is started with the button pressed and the output is correct. After run 2 is aborted and run 3 is launched, the ouput is incorrect. If I cycle the mouse button between run 3 and 4, the output is then correct. Run # mouse button output release 1 start program open open press closed & hold closed hold closed release open open open CTRL-C press & hold 2 start program hold hold closed hold closed hold closed CTRL-C hold hold 3 start program hold open hold open hold open hold open CTRL-C hold release press & hold 4 start program hold closed hold closed hold closed hold closed CTRL-C hold I am pretty positive it was not an issue on previous versions of FreeBSD, as I have been relying on this for a long time because all my system is built around this feature (mouse button is wired to a switch that detects if a door if open or closed). What has been changed in the recent versions of FreeBSD? Thanks in advance, Olivier #include <sys/mouse.h> #include <sys/consio.h> #include <stdio.h> #include <fcntl.h> #include <unistd.h> int main (int argc, char ** argv, char** env) { int fd_mouse; struct mouse_info mouse_info; fd_mouse=open("/dev/consolectl", O_RDWR); while (1) { mouse_info.operation=MOUSE_GETINFO; ioctl(fd_mouse, CONS_MOUSECTL, &mouse_info); if (((mouse_info.u.data.buttons&(int)2)==2)) { printf("closed\n"); } else { printf("open\n"); } sleep(1); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?wu7y40dgq8s.fsf>