From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1Atxw2-0007Pd-0j for qemu-devel@nongnu.org; Thu, 19 Feb 2004 18:50:26 -0500 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1AtxvQ-00072L-6e for qemu-devel@nongnu.org; Thu, 19 Feb 2004 18:50:20 -0500 Received: from [193.252.22.28] (helo=mwinf0301.wanadoo.fr) by monty-python.gnu.org with esmtp (Exim 4.30) id 1AtxvP-000714-IZ for qemu-devel@nongnu.org; Thu, 19 Feb 2004 18:49:47 -0500 Received: from free.fr (ATuileries-112-1-4-144.w81-53.abo.wanadoo.fr [81.53.133.144]) by mwinf0301.wanadoo.fr (SMTP Server) with ESMTP id 1E5464007E8 for ; Fri, 20 Feb 2004 00:49:44 +0100 (CET) Message-ID: <40354BEE.4080009@free.fr> Date: Fri, 20 Feb 2004 00:51:10 +0100 From: Fabrice Bellard MIME-Version: 1.0 Subject: Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS? References: <200402061916.43243.joshdeb@metzlers.org> <200402071007.50988.joshdeb@metzlers.org> <20040207151338.GB1692@stud.uni-erlangen.de> In-Reply-To: <20040207151338.GB1692@stud.uni-erlangen.de> Content-Type: multipart/mixed; boundary="------------050308000201050204040706" Reply-To: qemu-devel@nongnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------050308000201050204040706 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I tried something like this (see attached patch), but it does not work reliably. It seems that the X11 server does not always interpret the XChangeKeyboardMapping() function. Does anyone have a solution ? WARNING: if you try this patch, save your keyboard mapping with 'xmodmap -pke' before ! Fabrice. --------------050308000201050204040706 Content-Type: text/plain; name="sdl.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sdl.patch" Index: sdl.c =================================================================== RCS file: /cvsroot/qemu/qemu/sdl.c,v retrieving revision 1.4 diff -u -w -r1.4 sdl.c --- sdl.c 6 Feb 2004 19:56:42 -0000 1.4 +++ sdl.c 19 Feb 2004 23:44:07 -0000 @@ -42,6 +42,15 @@ #include +#if defined(__linux__) +#define HAVE_X11 +#endif + +#ifdef HAVE_X11 +#include +#include +#endif + #include "cpu.h" #include "exec-all.h" @@ -165,8 +174,123 @@ } } +#ifdef HAVE_X11 + +#define NB_REDEFINED_KEYCODES 12 +#define KEYCODE_MIN 67 +#define KEYCODE_MAX 96 + +static int redefined_keycodes[NB_REDEFINED_KEYCODES] = { + 67, /* F1 */ + 68, + 69, + 70, + 71, + 72, + 73, + 74, + 75, + 76, /* F10 */ + 95, /* F11 */ + 96, /* F12 */ +#if 0 + 22, /* backspace (not enabled for easier abort) */ +#endif +}; + +static KeySym qemu_keysyms[NB_REDEFINED_KEYCODES] = { + XK_F1, + XK_F2, + XK_F3, + XK_F4, + XK_F5, + XK_F6, + XK_F7, + XK_F8, + XK_F9, + XK_F10, + XK_F11, + XK_F12, +#if 0 + XK_BackSpace, +#endif +}; + +static KeySym *saved_keysyms, *new_keysyms; +static int saved_nb_keysyms; +static int mappings_modified; +static Display *x11_dpy; + +static void change_x11_mappings(void) +{ + int i, j, k; + + if (!x11_dpy) + x11_dpy = XOpenDisplay(NULL); + + if (!saved_keysyms) { + /* save F1-F12 mappings and X11 specific mappings. We do only + one XGetKeyboardMapping and XSetKeyboardMapping because the + X11 server is not able to hangdle many mapping change at + once. */ + saved_keysyms = XGetKeyboardMapping(x11_dpy, + KEYCODE_MIN, + KEYCODE_MAX - KEYCODE_MIN + 1, + &saved_nb_keysyms); +#if 1 + for(i = 0; i < NB_REDEFINED_KEYCODES; i++) { + printf("keycode %d = ", redefined_keycodes[i]); + k = (redefined_keycodes[i] - KEYCODE_MIN) * saved_nb_keysyms; + for(j=0;j