From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MgNPC-00058B-UC for mharc-grub-devel@gnu.org; Wed, 26 Aug 2009 14:39:35 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MgNPB-00057V-9n for grub-devel@gnu.org; Wed, 26 Aug 2009 14:39:33 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MgNP4-00054r-Ex for grub-devel@gnu.org; Wed, 26 Aug 2009 14:39:32 -0400 Received: from [199.232.76.173] (port=33614 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MgNP4-00054l-5g for grub-devel@gnu.org; Wed, 26 Aug 2009 14:39:26 -0400 Received: from xvm-190-8.ghst.net ([217.70.190.8]:40743 helo=aybabtu.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MgNP2-0007fc-Lf for grub-devel@gnu.org; Wed, 26 Aug 2009 14:39:25 -0400 Received: from [192.168.10.10] (helo=localhost) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1MgNOe-0004Hf-TR for grub-devel@gnu.org; Wed, 26 Aug 2009 20:39:01 +0200 Received: from rmh by localhost with local (Exim 4.69) (envelope-from ) id 1MgNOe-0005VU-9I for grub-devel@gnu.org; Wed, 26 Aug 2009 20:39:00 +0200 Date: Wed, 26 Aug 2009 20:39:00 +0200 From: Robert Millan To: The development of GRUB 2 Message-ID: <20090826183900.GA21030@thorin> References: <20090812153520.GA11691@riva.ucam.org> <20090812221431.GD11691@riva.ucam.org> <20090824092406.GE11691@riva.ucam.org> <20090824122352.GB18956@thorin> <20090824220419.GA31998@riva.ucam.org> <20090824224120.GC25093@thorin> <20090824230217.GM11691@riva.ucam.org> <20090826153356.GA6830@riva.ucam.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090826153356.GA6830@riva.ucam.org> Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: Re: [PATCH] Detect key modifier status in 'sleep --interruptible' X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Aug 2009 18:39:33 -0000 On Wed, Aug 26, 2009 at 04:33:56PM +0100, Colin Watson wrote: > Index: commands/sleep.c > =================================================================== > --- commands/sleep.c (revision 2535) > +++ commands/sleep.c (working copy) > [...] > > +static int > +grub_check_keyboard (void) > +{ > + int mods = grub_getkeystatus (); > + if (mods >= 0 && (mods & GRUB_TERM_STATUS_SHIFT) != 0) > + return 1; > + > + if (grub_checkkey () >= 0 && > + GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC) > + return 1; > + > + return 0; > +} > + > /* Based on grub_millisleep() from kern/generic/millisleep.c. */ > static int > grub_interruptible_millisleep (grub_uint32_t ms) > @@ -52,8 +66,7 @@ > start = grub_get_time_ms (); > > while (grub_get_time_ms () - start < ms) > - if (grub_checkkey () >= 0 && > - GRUB_TERM_ASCII_CHAR (grub_getkey ()) == GRUB_TERM_ESC) > + if (grub_check_keyboard ()) > return 1; I'm still not convinced that we want the sleep bits. They seem too ad-hoc, and I'd like to hear what others think first. But if I understood correctly, you plan on using keystatus command only? > +static int > +grub_console_getkeystatus (void) > +{ > + grub_uint8_t status = bios_data_area->keyboard_flag_lower; > + int mods = 0; > + > + if (status & 0x03) > + mods |= GRUB_TERM_STATUS_SHIFT; > + if (status & 0x04) > + mods |= GRUB_TERM_STATUS_CTRL; > + if (status & 0x08) > + mods |= GRUB_TERM_STATUS_ALT; > + > + return mods; > +} This should be macroified (but for the time being, I have no problem with our internal representation matching the one in BIOS Data Area, hence no translation would be needed on i386-pc). > + /* Set idle time to the minimum offered by the spec (4 milliseconds) so > + that we can find out the current state. */ > + grub_usb_control_msg (usbdev, 0x21, 0x0A, 1<<8, 0, 0, 0); > + > + grub_usb_control_msg (usbdev, (1 << 7) | (1 << 5) | 1, 0x02, 0, 0, 1, (char *) data); > + > [...] > + /* Go back to reporting every time an event occurs and not more often than > + that. */ > + grub_usb_control_msg (usbdev, 0x21, 0x0A, 0<<8, 0, 0, 0); If they represent fixed numbers like registers/ports, these hex values should be macros too. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all."