From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtNUE-00058T-U8 for qemu-devel@nongnu.org; Wed, 18 Dec 2013 15:13:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VtNU6-0001h8-8f for qemu-devel@nongnu.org; Wed, 18 Dec 2013 15:12:54 -0500 Received: from v220110690675601.yourvserver.net ([37.221.199.173]:43238) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VtNU6-0001gj-2B for qemu-devel@nongnu.org; Wed, 18 Dec 2013 15:12:46 -0500 Message-ID: <52B201B0.8030006@weilnetz.de> Date: Wed, 18 Dec 2013 21:12:32 +0100 From: Stefan Weil MIME-Version: 1.0 References: <1386429917-7629-1-git-send-email-sw@weilnetz.de> <52B1E94F.2070200@suse.de> In-Reply-To: <52B1E94F.2070200@suse.de> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] gtk: Support keyboard translation for hosts running Windows List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?ISO-8859-15?Q?Andreas_F=E4rber?= , qemu-devel Cc: Anthony Liguori Am 18.12.2013 19:28, schrieb Andreas F=E4rber: > Am 07.12.2013 16:25, schrieb Stefan Weil: >> GTK uses different hardware keycodes on Windows hosts, so some special >> handling is needed to get the QEMU keycode. >> >> Signed-off-by: Stefan Weil >> --- >> ui/gtk.c | 18 +++++++++++++++--- >> 1 file changed, 15 insertions(+), 3 deletions(-) >> >> diff --git a/ui/gtk.c b/ui/gtk.c >> index 6316f5b..a633d89 100644 >> --- a/ui/gtk.c >> +++ b/ui/gtk.c >> @@ -34,6 +34,10 @@ >> #define GETTEXT_PACKAGE "qemu" >> #define LOCALEDIR "po" >> =20 >> +#ifdef _WIN32 >> +# define _WIN32_WINNT 0x0601 /* needed to get definition of MAPVK_VK_= TO_VSC */ > IIRC that symbol forces compilation for that particular Windows version > and later versions but won't work on lower versions then, right? > In that case shouldn't that live somewhere more central than gtk.c, lik= e > QEMU_CFLAGS in configure? The MinGW include files only define MAPVK_VK_TO_VSC if _WIN32_WINNT >=3D 0x0601 (=3D=3D _WIN32_WINNT_WIN7). By default, _WIN32_WINNT =3D=3D 0x0502= (=3D=3D _WIN32_WINNT_WS03). A more central place is fine for the future, but for now I'd prefer to minimize potential cross effects. We already have a name conflict between Windows macros and local QEMU macros in a file which is not Windows related at all. Ideally, only few source files would include Windows include file - then _WIN32_WINNT could be defined in=20 include/sysemu/os-win32.h. >> +#endif >> + >> #include "qemu-common.h" >> =20 >> #ifdef CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE >> @@ -704,11 +708,18 @@ static gboolean gd_button_event(GtkWidget *widge= t, GdkEventButton *button, >> static gboolean gd_key_event(GtkWidget *widget, GdkEventKey *key, voi= d *opaque) >> { >> GtkDisplayState *s =3D opaque; >> - int gdk_keycode; >> - int qemu_keycode; >> + int gdk_keycode =3D key->hardware_keycode; >> int i; >> =20 >> - gdk_keycode =3D key->hardware_keycode; >> +#ifdef _WIN32 >> + UINT qemu_keycode =3D MapVirtualKey(gdk_keycode, MAPVK_VK_TO_VSC)= ; > Possibly handle the #ifndef MAPVK_VK_TO_VSC case? > What Windows version are we talking about anyway? XP? Vista? 7? I have no solution for the #ifndef MAPVK_VK_TO_VSC case. The code works for me with Windows 7 and 8.1, but might work with older versions, too. If someone has Windows XP, a test can be run with http://qemu.weilnetz.de/w32/qemu-w32-setup-20131128.exe. According to MSDN, MapVirtualKey is available since Windows 2000 Professional. > Regards, > Andreas Regards, Stefan