From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Iqq6B-0002nW-AB for mharc-grub-devel@gnu.org; Sat, 10 Nov 2007 08:10:07 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Iqq69-0002jy-HM for grub-devel@gnu.org; Sat, 10 Nov 2007 08:10:05 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Iqq66-0002dJ-VI for grub-devel@gnu.org; Sat, 10 Nov 2007 08:10:05 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Iqq66-0002d7-Qu for grub-devel@gnu.org; Sat, 10 Nov 2007 08:10:02 -0500 Received: from mailout11.sul.t-online.de ([194.25.134.85] helo=mailout11.sul.t-online.com) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Iqq66-0002Q3-I0 for grub-devel@gnu.org; Sat, 10 Nov 2007 08:10:02 -0500 Received: from fwd28.aul.t-online.de by mailout11.aul.t-online.de with smtp id 1Iqq65-0007mY-00; Sat, 10 Nov 2007 14:10:01 +0100 Received: from [10.3.2.2] (G-H2pvZEgh4IIxfDbPPikyiyPf7g6JxrmybnXFBmMUXV3MMfpcWale03eUvaAWWwKB@[217.235.250.31]) by fwd28.aul.t-online.de with esmtp id 1Iqq5s-0vTUn20; Sat, 10 Nov 2007 14:09:48 +0100 Message-ID: <4735AD9B.5090401@t-online.de> Date: Sat, 10 Nov 2007 14:09:47 +0100 From: Christian Franke User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 MIME-Version: 1.0 To: The development of GRUB 2 References: <472B9CBF.9030702@t-online.de> <87ir4bla7w.fsf@xs4all.nl> In-Reply-To: <87ir4bla7w.fsf@xs4all.nl> Content-Type: multipart/mixed; boundary="------------020509080401020004000102" X-ID: G-H2pvZEgh4IIxfDbPPikyiyPf7g6JxrmybnXFBmMUXV3MMfpcWale03eUvaAWWwKB X-TOI-MSGID: 33e62305-dc6c-4816-8a4c-d224553376ac X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Subject: Re: [PATCH] Fix grub-emu curses KEY_* mapping 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: Sat, 10 Nov 2007 13:10:05 -0000 This is a multi-part message in MIME format. --------------020509080401020004000102 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Marco Gerards wrote: > Christian Franke writes: > >> Curses function keys do not work in grub-emu, this patch fixes this in >> grub_ncurses_getkey(). >> > > Ha! I once noticed this and forgot to document this bug :( > > >> Another approach would be to remove the scancode translation in >> grub_console_getkey(), and check for GRUB_CONSOLE_KEY_* in >> grub_cmdline_get() instead. The GRUB_CONSOLE_KEY_* definitions are >> already platform specific. >> > > Yes, this is really weird! All archs define these macros and expect > for i386-pc none of them are used. I actually wonder if any of those > work :-) > > Even on i386-pc, GRUB_CONSOLE_KEY_* are only used once in the translation table of grub_console_getkey(). The defines are not part of the console interface definition. I would suggest to remove the defines from all include/grub/PLATFORM/console.h. The GRUB_CONSOLE_KEY_* in i386/pc/startup.S can be replaced with the constants itself. >> ... >> >> + /* XXX: return GRUB_CONSOLE_KEY_* does not work here, >> + grub_cmdline_get() does not check for these constants. >> + At least on i386-pc, GRUB_CONSOLE_KEY_* are in fact keyboard >> + scancodes which are converted into control chars by >> + grub_console_getkey(). */ >> + >> > > I do not think this comment is needed. You explained it in the > email. I do not like comments that explain why we aren't doing some > things, it is usually better to explain why we do something if it is a > hack or not obvious. In this case I prefer no comment. > > >> switch (c) >> { >> case KEY_LEFT: >> - c = GRUB_CONSOLE_KEY_LEFT; >> + c = 2; /*GRUB_CONSOLE_KEY_LEFT*/ >> break; >> > > Please just remove the comment. As this appears to be wrong anyways > :-) > > Done. Christian 2007-11-10 Christian Franke * util/console.c (grub_ncurses_getkey): Change curses KEY_* mapping, now return control chars instead of GRUB_CONSOLE_KEY_* constants. This fixes the problem that function keys did not work in grub-emu. --------------020509080401020004000102 Content-Type: text/x-patch; name="grub2-console-key-2.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="grub2-console-key-2.patch" --- grub2.orig/util/console.c 2007-07-22 01:32:31.000000000 +0200 +++ grub2/util/console.c 2007-11-10 13:20:02.171875000 +0100 @@ -164,50 +164,50 @@ grub_ncurses_getkey (void) switch (c) { case KEY_LEFT: - c = GRUB_CONSOLE_KEY_LEFT; + c = 2; break; case KEY_RIGHT: - c = GRUB_CONSOLE_KEY_RIGHT; + c = 6; break; case KEY_UP: - c = GRUB_CONSOLE_KEY_UP; + c = 16; break; case KEY_DOWN: - c = GRUB_CONSOLE_KEY_DOWN; + c = 14; break; case KEY_IC: - c = GRUB_CONSOLE_KEY_IC; + c = 24; break; case KEY_DC: - c = GRUB_CONSOLE_KEY_DC; + c = 4; break; case KEY_BACKSPACE: /* XXX: For some reason ncurses on xterm does not return KEY_BACKSPACE. */ case 127: - c = GRUB_CONSOLE_KEY_BACKSPACE; + c = 8; break; case KEY_HOME: - c = GRUB_CONSOLE_KEY_HOME; + c = 1; break; case KEY_END: - c = GRUB_CONSOLE_KEY_END; + c = 5; break; case KEY_NPAGE: - c = GRUB_CONSOLE_KEY_NPAGE; + c = 3; break; case KEY_PPAGE: - c = GRUB_CONSOLE_KEY_PPAGE; + c = 7; break; } --------------020509080401020004000102--