From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz4Ii-000815-Sa for qemu-devel@nongnu.org; Thu, 11 Dec 2014 09:01:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xz4Ic-0004mB-Fd for qemu-devel@nongnu.org; Thu, 11 Dec 2014 09:01:04 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60443) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xz4Ic-0004m6-7o for qemu-devel@nongnu.org; Thu, 11 Dec 2014 09:00:58 -0500 Message-ID: <5489A396.5090504@redhat.com> Date: Thu, 11 Dec 2014 15:00:54 +0100 From: Max Reitz MIME-Version: 1.0 References: <1418294973-21790-1-git-send-email-kraxel@redhat.com> <1418294973-21790-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1418294973-21790-4-git-send-email-kraxel@redhat.com> Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 03/10] sdl2: move keyboard input code to new sdl2-input.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gerd Hoffmann , qemu-devel@nongnu.org Cc: Anthony Liguori On 2014-12-11 at 11:49, Gerd Hoffmann wrote: > Signed-off-by: Gerd Hoffmann > --- > include/ui/sdl2.h | 4 +++ > ui/Makefile.objs | 2 +- > ui/sdl2-input.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ui/sdl2.c | 75 ++------------------------------------ > 4 files changed, 114 insertions(+), 73 deletions(-) > create mode 100644 ui/sdl2-input.c > > diff --git a/include/ui/sdl2.h b/include/ui/sdl2.h > index 7f91a75..e1c304a 100644 > --- a/include/ui/sdl2.h > +++ b/include/ui/sdl2.h > @@ -9,3 +9,7 @@ struct sdl2_console { > int x, y; > int hidden; > }; > + > +void sdl2_reset_keys(struct sdl2_console *scon); > +void sdl2_process_key(struct sdl2_console *scon, > + SDL_KeyboardEvent *ev); > diff --git a/ui/Makefile.objs b/ui/Makefile.objs > index b25e85f..011c5bb 100644 > --- a/ui/Makefile.objs > +++ b/ui/Makefile.objs > @@ -20,7 +20,7 @@ ifeq ($(CONFIG_SDLABI),1.2) > sdl.mo-objs := sdl.o sdl_zoom.o > endif > ifeq ($(CONFIG_SDLABI),2.0) > -sdl.mo-objs := sdl2.o > +sdl.mo-objs := sdl2.o sdl2-input.o > endif > sdl.mo-cflags := $(SDL_CFLAGS) > > diff --git a/ui/sdl2-input.c b/ui/sdl2-input.c > new file mode 100644 > index 0000000..6702e8e > --- /dev/null > +++ b/ui/sdl2-input.c > @@ -0,0 +1,106 @@ > +/* > + * QEMU SDL display driver > + * > + * Copyright (c) 2003 Fabrice Bellard > + * > + * Permission is hereby granted, free of charge, to any person obtaining a copy > + * of this software and associated documentation files (the "Software"), to deal > + * in the Software without restriction, including without limitation the rights > + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell > + * copies of the Software, and to permit persons to whom the Software is > + * furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER > + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, > + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN > + * THE SOFTWARE. > + */ > +/* Ported SDL 1.2 code to 2.0 by Dave Airlie. */ > + > +/* Avoid compiler warning because macro is redefined in SDL_syswm.h. */ > +#undef WIN32_LEAN_AND_MEAN > + > +#include > +#include > + > +#include "qemu-common.h" > +#include "ui/console.h" > +#include "ui/input.h" > +#include "ui/sdl2.h" > +#include "sysemu/sysemu.h" > + > +#include "sdl2-keymap.h" > + > +static uint8_t modifiers_state[SDL_NUM_SCANCODES]; > + > +void sdl2_reset_keys(struct sdl2_console *scon) > +{ > + QemuConsole *con = scon ? scon->dcl.con : NULL; > + int i; > + > + for (i = 0; i < 256; i++) { Should this be SDL_NUM_SCANCODES? > + if (modifiers_state[i]) { > + int qcode = sdl2_scancode_to_qcode[i]; > + qemu_input_event_send_key_qcode(con, qcode, false); > + modifiers_state[i] = 0; > + } > + } > +} Max