Keyboard problem when running VBox inside a vnc server

Discussions related to using VirtualBox on Linux hosts.
Post Reply
christau
Posts: 6
Joined: 5. Mar 2009, 12:26

Keyboard problem when running VBox inside a vnc server

Post by christau »

Hi all,
i'm facing a weird problem.
I run the VirtualBox 2.1 (with a german WinXP guest) on a Kubuntu 8.04 with german locale settings.
If i start the VBox on my desktop everything works fine.
The problem occurs, when i do the following:
I start a vncserver with the following commandline

Code: Select all

Xvnc -geometry 1024x768 -depth 24 -rfbAuth vncpasswd :2
Then I start the VBox from the commandline as follows

Code: Select all

DISPLAY=:2 VBoxManage startvm myXP 
Then i connect myself to the vnc server by executing

Code: Select all

vncviewer :2
Now i can see the started VBox in my vnc session.
But the problem is: When i'm in the VBox, my keyboard layout is no longer german, it's english.
The weird thing is, if i start a xterm in the same vnc session, my keyboard layout is german. It's only english inside the VBox.
On the other hand, as i wrote, when i start the VBox directly on my desktop, everything works fine.
I checked the locale settings on my linux system, they are all 'de_DE.UTF-8'
I checked the locale settings on the winXP guest, they are all set to german (also the keyboard layout settings).

I hope, i could describe the problem as good as possible.
Can somebody explain to me, where the problem can be?
I just want to have a german keyboard layout when i run the VirtualBox inside a vncserver.

Many thanks in advance for any hints to a resolution!
Greetings, -chris-
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Keyboard problem when running VBox inside a vnc server

Post by Sasquatch »

Check the VB log of the VM. It might give some information on why it reverts to the default US English layout.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
christau
Posts: 6
Joined: 5. Mar 2009, 12:26

Re: Keyboard problem when running VBox inside a vnc server

Post by christau »

Hi Sasquatch,
thanks for your suggestion!
I compared the logfiles of the normally started xp guest and the one which i started inside the vnc server.
There are almost no differences (just a few differing addresses).
Also i couldn't determine from the logfile, if the VBox chose a german or a english keyboard driver.
The only thing that i found was:
03:08:08.216 [/Devices/pckbd/] (level 2)
03:08:08.216
03:08:08.216 [/Devices/pckbd/0/] (level 3)
03:08:08.216 Trusted <integer> = 0x0000000000000001 (1)
03:08:08.216
03:08:08.216 [/Devices/pckbd/0/Config/] (level 4)
03:08:08.216
03:08:08.216 [/Devices/pckbd/0/LUN#0/] (level 4)
03:08:08.216 Driver <string> = "KeyboardQueue" (cch=14)
03:08:08.216
03:08:08.216 [/Devices/pckbd/0/LUN#0/Config/] (level 5)
03:08:08.216 QueueSize <integer> = 0x0000000000000040 (64)
03:08:08.216
03:08:08.216 [/Devices/pckbd/0/LUN#0/AttachedDriver/] (level 5)
03:08:08.216 Driver <string> = "MainKeyboard" (cch=13)
03:08:08.216
03:08:08.216 [/Devices/pckbd/0/LUN#0/AttachedDriver/Config/] (level 6)
03:08:08.216 Object <integer> = 0x00000000082537b0 (136656816)
and this section showed no differences in the both log files except for the last four digits in the line
Object <integer> = 0x00000000082537b0
Any suggestion on where to look next?
Greetings, -chris-
Sasquatch
Volunteer
Posts: 17798
Joined: 17. Mar 2008, 13:41
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Windows XP, Windows 7, Linux
Location: /dev/random

Re: Keyboard problem when running VBox inside a vnc server

Post by Sasquatch »

Try a different VNC server.
Read the Forum Posting Guide before opening a topic.
VirtualBox FAQ: Check this before asking questions.
Online User Manual: A must read if you want to know what we're talking about.
Howto: Install Linux Guest Additions
Howto: Use Shared Folders on Linux Guest
See the Tutorials and FAQ section at the top of the Forum for more guides.
Try searching the forums first with Google and add the site filter for this forum.
E.g. install guest additions site:forums.virtualbox.org

Retired from this Forum since OSSO introduction.
christau
Posts: 6
Joined: 5. Mar 2009, 12:26

Re: Keyboard problem when running VBox inside a vnc server

Post by christau »

I already did that, i tested all possible vnc servers for my ubuntu..
I guess it must be a problem of the VBox, because, as i described earlier, if i start a xterm inside the vncserver, i have the german keyboard layout. It's only wrong in VBox.
Greetings, -chris-
christau
Posts: 6
Joined: 5. Mar 2009, 12:26

Re: Keyboard problem when running VBox inside a vnc server

Post by christau »

Hi,
after some searching in the bugtracker of VBox, i stumbled upon this ticket.
There is suggested to start the VBox as follows:
LOG_KB_SECONDARY=1 VirtualBox -startvm <your VM name>
I did that and got the following message, when run normally (not in the vnc server)
...
Detected layout is "Germany", matches=48, seq=47
Finished mapping keyboard, matches=47, entries=48
If i did the same and started the VBox inside the vnc server, i got the following message:
Detected layout is "U.S. English", matches=47, seq=46
Finished mapping keyboard, matches=47, entries=48
Now i can be quite shure, that the VBox keyboard driver detects the wrong keyboard.
In this ticket, someone posted the source code of the keyboard driver.
I compiled this code and replaced the /usr/lib/virtualbox/VBoxKeyboard.so file. But it gave me a segfault after starting.
Anyway, i guess this keyboard driver is the spot where the layout is detected. I'll update this thread if i find a workable solution.

Greetings, -chris-
christau
Posts: 6
Joined: 5. Mar 2009, 12:26

Re: Keyboard problem when running VBox inside a vnc server

Post by christau »

Hi,
after some testing i managed to get the german keyboard layout in VBox.
I admit it's kind of hacky, but it works for this special requirement.
I checked out the sources for the keyboard detection of VBox.

Code: Select all

svn co http://www.virtualbox.org/svn/vbox/trunk/src/VBox/Frontends/VirtualBox/src/X11 X11
and changed the following line in the file keyboard-new.c

Code: Select all

return kbd_layout;
into

Code: Select all

return 98;
where 98 is the code for the german keyboard layout.
I compiled the library and copied it to /usr/lib/virtualbox/VBoxKeyboard.so

Since the keyboard layout of the vnc server is german too, i guess there's a problem with the keyboard layout detection in VBoxKeyboard.so.
Maybe someone can verify this and we can file a bug report on that.

Greetings, -chris-
junior79
Posts: 4
Joined: 18. Mar 2009, 17:46

Re: Keyboard problem when running VBox inside a vnc server

Post by junior79 »

Hi,

I have the same problem as above. Do anyone know the the code to the Swedish keyboard layout?
stkris
Posts: 27
Joined: 21. Mar 2009, 00:17
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win XP

Re: Keyboard problem when running VBox inside a vnc server

Post by stkris »

I had a small success adding additional keyboards to the XP installation using the language bar.

Host is debian squeeze, client is XP. And on the XP adding an additional "keyboard layout/IME" to the norwegian keyboard. The new layout would then be norwegian keyboard, US layout. When using that one the $ and \ keys work. But ÆØÅ does not. So it is a half baked solution.

Also my debian is installed with default language settings - only chose a norwegian keyboard during install.
The output from "locale -a" is
C
nb_NO.utf8
POSIX

I run virtualbox on my laptop, then use VBoxVRDP to start it, and rdesktop localhost:3389 to connect to the virtual XP machine.
stkris
Posts: 27
Joined: 21. Mar 2009, 00:17
Primary OS: Debian other
VBox Version: VirtualBox+Oracle ExtPack
Guest OSses: Win XP

Re: Keyboard problem when running VBox inside a vnc server

Post by stkris »

I finally got it working - by starting rdesktop like this:

rdesktop -k no -f -x l VirtualXP

So I specify keyboard "no" and not "no-nb"

Now all keys work as they should. And I do not need the language bar hack any more.
christau
Posts: 6
Joined: 5. Mar 2009, 12:26

Re: Keyboard problem when running VBox inside a vnc server

Post by christau »

My suggestion with changing the VBoxKeyboard code was wrong, it didn't work for the OSE version.
A colleague suggested me to dump the xmodmap keymap and transfer it to the vncserver, like this:

Code: Select all

DISPLAY=:0 xmodmap -pke > /tmp/keymap.de
DISPLAY=:2 xmodmap /tmp/keymap.de
But this only worked on kubuntu with the realvnc server.
The same did not work on open suse.
Still a big mystery for me.

Greetings, -chris-
Post Reply