From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=41390 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PlL8H-0001Ty-Hd for qemu-devel@nongnu.org; Fri, 04 Feb 2011 07:51:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PlL8F-0008QR-Dq for qemu-devel@nongnu.org; Fri, 04 Feb 2011 07:51:25 -0500 Received: from mail-vx0-f173.google.com ([209.85.220.173]:62528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PlL8F-0008QI-BX for qemu-devel@nongnu.org; Fri, 04 Feb 2011 07:51:23 -0500 Received: by vxb40 with SMTP id 40so670859vxb.4 for ; Fri, 04 Feb 2011 04:51:22 -0800 (PST) Message-ID: <4D4BF645.90009@codemonkey.ws> Date: Fri, 04 Feb 2011 06:51:17 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 0.14] ui/sdl: Fix handling of caps lock and num lock keys References: <1290901711.2438.34.camel@deep-thought> <1296768907-12798-1-git-send-email-weil@mail.berlios.de> In-Reply-To: <1296768907-12798-1-git-send-email-weil@mail.berlios.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Weil Cc: Kevin Wolf , Anthony Liguori , Benjamin Drung , QEMU Developers On 02/03/2011 03:35 PM, Stefan Weil wrote: > Starting with SDL version 1.2.14, caps lock and num lock keys > will send a SDL_KEYUP when SDL_DISABLE_LOCK_KEYS=1 is set in > the environment. > > The new code sets the environment unconditionally > (it won't harm old versions which do not know it). > > The workaround for SDL_KEYUP is only compiled with old SDL versions. > > A similar patch without handling of old SDL versions was already > published by Benjamin Drung for Ubuntu. > > Cc: Anthony Liguori > Cc: Kevin Wolf > Cc: Benjamin Drung > Signed-off-by: Stefan Weil > Applied to master, Thanks. Regards, Anthony Liguori > --- > ui/sdl.c | 8 ++++++++ > 1 files changed, 8 insertions(+), 0 deletions(-) > > diff --git a/ui/sdl.c b/ui/sdl.c > index a1458ce..47ac49c 100644 > --- a/ui/sdl.c > +++ b/ui/sdl.c > @@ -388,12 +388,16 @@ static void sdl_process_key(SDL_KeyboardEvent *ev) > else > modifiers_state[keycode] = 1; > break; > +#define QEMU_SDL_VERSION ((SDL_MAJOR_VERSION<< 8) + SDL_MINOR_VERSION) > +#if QEMU_SDL_VERSION< 0x102 || QEMU_SDL_VERSION == 0x102&& SDL_PATCHLEVEL< 14 > + /* SDL versions before 1.2.14 don't support key up for caps/num lock. */ > case 0x45: /* num lock */ > case 0x3a: /* caps lock */ > /* SDL does not send the key up event, so we generate it */ > kbd_put_keycode(keycode); > kbd_put_keycode(keycode | SCANCODE_UP); > return; > +#endif > } > > /* now send the key code */ > @@ -831,6 +835,10 @@ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame) > setenv("SDL_VIDEO_ALLOW_SCREENSAVER", "1", 0); > } > > + /* Enable normal up/down events for Caps-Lock and Num-Lock keys. > + * This requires SDL>= 1.2.14. */ > + setenv("SDL_DISABLE_LOCK_KEYS", "1", 1); > + > flags = SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE; > if (SDL_Init (flags)) { > fprintf(stderr, "Could not initialize SDL(%s) - exiting\n", >