* [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
@ 2004-02-07 0:16 Josh Metzler
2004-02-07 7:33 ` Lionel Ulmer
2004-02-07 15:07 ` Josh Metzler
0 siblings, 2 replies; 8+ messages in thread
From: Josh Metzler @ 2004-02-07 0:16 UTC (permalink / raw)
To: qemu-devel
Now that I have xfree86 working in qemu, I would like to be able to send
Ctrl+Alt+F1 to it to switch back to a vt. When I try this, though, my host
machine switches to vt1, even if I have the mouse captured by qemu. Is there
any way to do this?
Thanks,
Josh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
2004-02-07 0:16 [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS? Josh Metzler
@ 2004-02-07 7:33 ` Lionel Ulmer
2004-02-07 7:58 ` Thomas Glanzmann
2004-02-07 15:07 ` Josh Metzler
1 sibling, 1 reply; 8+ messages in thread
From: Lionel Ulmer @ 2004-02-07 7:33 UTC (permalink / raw)
To: qemu-devel
On Fri, Feb 06, 2004 at 07:16:43PM -0500, Josh Metzler wrote:
> Now that I have xfree86 working in qemu, I would like to be able to send
> Ctrl+Alt+F1 to it to switch back to a vt. When I try this, though, my host
> machine switches to vt1, even if I have the mouse captured by qemu. Is there
> any way to do this?
Well, XFree86 is catching these special event codes and does not even send
them to the applications (ie all the the Ctrl+Alt+ +/- or Fx ones).
The only way to support is would be to do as VNC does : have a key pop-up a
menu with 'Send Ctrl+Alt+F1 to system'.
Lionel
--
Lionel Ulmer - http://www.bbrox.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
2004-02-07 7:33 ` Lionel Ulmer
@ 2004-02-07 7:58 ` Thomas Glanzmann
2004-02-07 8:32 ` Ian C. Blenke
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Glanzmann @ 2004-02-07 7:58 UTC (permalink / raw)
To: qemu-devel
Hi,
> > Now that I have xfree86 working in qemu, I would like to be able to send
> > Ctrl+Alt+F1 to it to switch back to a vt. When I try this, though, my host
> > machine switches to vt1, even if I have the mouse captured by qemu. Is there
> > any way to do this?
yes it is possible. vmware does (per remote X also).
> Well, XFree86 is catching these special event codes and does not even send
> them to the applications (ie all the the Ctrl+Alt+ +/- or Fx ones).
I had a quick look at the sources of XFree86 and there was the
possibility to grab the keyboard exclusive. I don't rember what it was
called exactly, but it shouldn't be that hard to find it.
The only key which isn't catched is MAGIC SYSRQ, I think.
> The only way to support is would be to do as VNC does : have a key
> pop-up a menu with 'Send Ctrl+Alt+F1 to system'.
Many people do so, but I think the vmware way is the easier to use.
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
2004-02-07 7:58 ` Thomas Glanzmann
@ 2004-02-07 8:32 ` Ian C. Blenke
2004-02-07 9:35 ` Thomas Glanzmann
0 siblings, 1 reply; 8+ messages in thread
From: Ian C. Blenke @ 2004-02-07 8:32 UTC (permalink / raw)
To: qemu-devel
If you have the vlock package installed on your host, try running "vlock -a"
from the command line.
You can make this change permanent as well. XFree86 4.3.0 and later have
the "DontVTSwitch" option in the "ServerFlags" section to disable VT console
switching (CNTL-ALT-Fn)
Older versions have a similar "DontZap" option for the CNTL-ALT-BKSP sequence,
as well as a "DontZoom" option for the CNTL-ALT-+/- sequence.
# /etc/X11/XF86Config-4
Section "ServerFlags"
...
Option "DontVTSwitch" "true"
Option "DontZap" "true"
Option "DontZoom" "true"
...
EndSection
Hope this helps.
- Ian C. Blenke <ian@blenke.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
2004-02-07 8:32 ` Ian C. Blenke
@ 2004-02-07 9:35 ` Thomas Glanzmann
0 siblings, 0 replies; 8+ messages in thread
From: Thomas Glanzmann @ 2004-02-07 9:35 UTC (permalink / raw)
To: qemu-devel
Hi,
> If you have the vlock package installed on your host, try running
> "vlock -a" from the command line.
nice tool. I didn't know about it. But it isn't working under X for me.
> You can make this change permanent as well. XFree86 4.3.0 and later
> have the "DontVTSwitch" option in the "ServerFlags" section to disable
> VT console switching (CNTL-ALT-Fn)
That's true. But there is also the possibility for the application to
control this. If you start vmware (even from remote) ctrl-alt-f1 won't
switch your terminal but the one of the virtual machine.
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
2004-02-07 0:16 [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS? Josh Metzler
2004-02-07 7:33 ` Lionel Ulmer
@ 2004-02-07 15:07 ` Josh Metzler
2004-02-07 15:13 ` Thomas Glanzmann
1 sibling, 1 reply; 8+ messages in thread
From: Josh Metzler @ 2004-02-07 15:07 UTC (permalink / raw)
To: qemu-devel
On Friday 06 February 2004 07:16 pm, Josh Metzler wrote:
> Now that I have xfree86 working in qemu, I would like to be able to send
> Ctrl+Alt+F1 to it to switch back to a vt. When I try this, though, my host
> machine switches to vt1, even if I have the mouse captured by qemu. Is
> there any way to do this?
>
> Thanks,
> Josh
Thanks for the replies. I do agree that the vmware method would be easiest
(as I also like to be able to switch to a vt on my host as well). A few
other possibilities I can think of, the first two of which are used by Bochs:
1) Bochs has a "send special key combo" button, for which you can set the key
combination.
2) In Bochs if you press a modifier key (Ctrl, Alt, or Shift) while the mouse
is over the emulator window (not captured), then move the mouse off the
window, and then release the key, it stays pressed for the guest OS. So, you
press Ctrl+Alt over the emulator, move the mouse off and release, then move
back over and hit F1. This takes some getting used to (especially when you
do it accidentally and can't figure out why all your keystrokes have a Ctrl
character with them), but once used to it, it is easy to use.
3) Use some special Ctrl+a codes in the xterm that launched Qemu
Another possible method, which Bochs uses, is you press Ctrl+Alt while the
mouse is over the emulator (for example Ctrl+a Ctrl+F1 could send a
Ctrl+Alt+F1, Ctrl+a F7 could send an Alt+F7 ...) This would maybe be easiest
to implement (since Ctrl+a Ctrl+a already sends a Ctrl+a), but maybe the
hardest to learn to use.
Josh
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
2004-02-07 15:07 ` Josh Metzler
@ 2004-02-07 15:13 ` Thomas Glanzmann
2004-02-19 23:51 ` Fabrice Bellard
0 siblings, 1 reply; 8+ messages in thread
From: Thomas Glanzmann @ 2004-02-07 15:13 UTC (permalink / raw)
To: qemu-devel
Hi Josh,
> 2) In Bochs if you press a modifier key (Ctrl, Alt, or Shift) while the mouse
> is over the emulator window (not captured), then move the mouse off the
> window, and then release the key, it stays pressed for the guest OS. So, you
> press Ctrl+Alt over the emulator, move the mouse off and release, then move
> back over and hit F1. This takes some getting used to (especially when you
> do it accidentally and can't figure out why all your keystrokes have a Ctrl
> character with them), but once used to it, it is easy to use.
this is a bug! We had the same thing on FAUmachine and I fixed it a
while ago. The problem is that an application has to release all keys
(internally) if focus is lost. Btw. Quake has the same problem, which is
very annoying. :-)))
> 3) Use some special Ctrl+a codes in the xterm that launched Qemu
> Another possible method, which Bochs uses, is you press Ctrl+Alt while the
> mouse is over the emulator (for example Ctrl+a Ctrl+F1 could send a
> Ctrl+Alt+F1, Ctrl+a F7 could send an Alt+F7 ...) This would maybe be easiest
> to implement (since Ctrl+a Ctrl+a already sends a Ctrl+a), but maybe the
> hardest to learn to use.
hrm. I am still for 1! :-)) I sweared to myself that I implement the
first thing in FAUmachine, but I never took the time to do it.
Thomas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS?
2004-02-07 15:13 ` Thomas Glanzmann
@ 2004-02-19 23:51 ` Fabrice Bellard
0 siblings, 0 replies; 8+ messages in thread
From: Fabrice Bellard @ 2004-02-19 23:51 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 308 bytes --]
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.
[-- Attachment #2: sdl.patch --]
[-- Type: text/plain, Size: 4192 bytes --]
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 <SDL.h>
+#if defined(__linux__)
+#define HAVE_X11
+#endif
+
+#ifdef HAVE_X11
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#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<saved_nb_keysyms;j++)
+ printf(" 0x%lx", saved_keysyms[k + j]);
+ printf("\n");
+ }
+#endif
+ new_keysyms = malloc(sizeof(KeySym) *
+ (KEYCODE_MAX - KEYCODE_MIN + 1) *
+ saved_nb_keysyms);
+ memcpy(new_keysyms, saved_keysyms,
+ sizeof(KeySym) *
+ (KEYCODE_MAX - KEYCODE_MIN + 1) * saved_nb_keysyms);
+ /* redefine the QEMU keycodes */
+ for(i = 0; i < NB_REDEFINED_KEYCODES; i++) {
+ k = (redefined_keycodes[i] - KEYCODE_MIN) * saved_nb_keysyms;
+ saved_keysyms[k] = qemu_keysyms[i];
+ for(j = 1; j < saved_nb_keysyms; j++)
+ saved_keysyms[k + j] = NoSymbol;
+ }
+ }
+
+ if (!mappings_modified) {
+ XChangeKeyboardMapping(x11_dpy,
+ KEYCODE_MIN,
+ saved_nb_keysyms,
+ new_keysyms,
+ KEYCODE_MAX - KEYCODE_MIN + 1);
+ XFlush(x11_dpy);
+ mappings_modified = 1;
+ }
+}
+
+static void restore_x11_mappings(void)
+{
+ if (mappings_modified) {
+ XChangeKeyboardMapping(x11_dpy,
+ KEYCODE_MIN,
+ saved_nb_keysyms,
+ saved_keysyms,
+ KEYCODE_MAX - KEYCODE_MIN + 1);
+ XFlush(x11_dpy);
+ mappings_modified = 0;
+ }
+}
+#endif
+
static void sdl_grab_start(void)
{
+#ifdef HAVE_X11
+ change_x11_mappings();
+#endif
SDL_WM_SetCaption("QEMU - Press Ctrl-Shift to exit grab", "QEMU");
SDL_ShowCursor(0);
SDL_WM_GrabInput(SDL_GRAB_ON);
@@ -180,6 +304,9 @@
SDL_WM_SetCaption("QEMU", "QEMU");
SDL_WM_GrabInput(SDL_GRAB_OFF);
SDL_ShowCursor(1);
+#ifdef HAVE_X11
+ restore_x11_mappings();
+#endif
gui_grab = 0;
}
@@ -260,6 +387,9 @@
static void sdl_cleanup(void)
{
+#ifdef HAVE_X11
+ restore_x11_mappings();
+#endif
SDL_Quit();
}
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2004-02-19 23:50 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-02-07 0:16 [Qemu-devel] How to send Ctrl+Alt+F1 to guest OS? Josh Metzler
2004-02-07 7:33 ` Lionel Ulmer
2004-02-07 7:58 ` Thomas Glanzmann
2004-02-07 8:32 ` Ian C. Blenke
2004-02-07 9:35 ` Thomas Glanzmann
2004-02-07 15:07 ` Josh Metzler
2004-02-07 15:13 ` Thomas Glanzmann
2004-02-19 23:51 ` Fabrice Bellard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).