From owner-freebsd-hackers@freebsd.org Mon Nov 21 09:02:40 2016 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 90C6FC4DDA3 for ; Mon, 21 Nov 2016 09:02:40 +0000 (UTC) (envelope-from Olivier.Nicole@cs.ait.ac.th) Received: from mail.cs.ait.ac.th (mail.cs.ait.ac.th [192.41.170.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2591A1804 for ; Mon, 21 Nov 2016 09:02:39 +0000 (UTC) (envelope-from Olivier.Nicole@cs.ait.ac.th) Received: from mail.cs.ait.ac.th (localhost [127.0.0.1]) by mail.cs.ait.ac.th (Postfix) with ESMTP id 5ED27D7885 for ; Mon, 21 Nov 2016 16:02:29 +0700 (ICT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=cs.ait.ac.th; h= content-type:content-type:mime-version:message-id:date:date :subject:subject:from:from:received:received:received; s= selector1; t=1479718948; x=1481533349; bh=PFRlL181NPWGbIgr3EUHSr sIR5Px9jNEegiZlq0xGYg=; b=bYjfjaGEXnUY1o485YPPQf/RFJjL65QkHTVG/g fItYsU3pQrITwXOZrbIlHYJiv0GQgfiHoX0oszrBIA9D/Bhm5jDlNdIfonG6yFfa y63g2qvoOBpMpeQXRbkWFFunCDQ0aae4E637snOlM6ONeoFqDCQQBBXcRhZREmJo Zo8TE= X-Virus-Scanned: amavisd-new at cs.ait.ac.th Received: from mail.cs.ait.ac.th ([127.0.0.1]) by mail.cs.ait.ac.th (mail.cs.ait.ac.th [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id DvTL2gwGvJrj for ; Mon, 21 Nov 2016 16:02:28 +0700 (ICT) Received: from banyan.cs.ait.ac.th (banyan.cs.ait.ac.th [192.41.170.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.cs.ait.ac.th (Postfix) with ESMTPS id 45AA8D7884 for ; Mon, 21 Nov 2016 16:02:28 +0700 (ICT) Received: (from on@localhost) by banyan.cs.ait.ac.th (8.15.2/8.15.2/Submit) id uAL92RsZ038367; Mon, 21 Nov 2016 16:02:27 +0700 (ICT) (envelope-from on@banyan.cs.ait.ac.th) From: Olivier To: freebsd-hackers@freebsd.org Subject: New behavious in /dev/consolectl Date: Mon, 21 Nov 2016 16:02:27 +0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Nov 2016 09:02:40 -0000 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 #include #include #include #include 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); } }