VBoxManage guestcontrol & Keyboard layout

Discussions about using Linux guests in VirtualBox.
Post Reply
algee
Posts: 12
Joined: 28. Sep 2016, 09:09

VBoxManage guestcontrol & Keyboard layout

Post by algee »

Hi,

i am using VBoxManage guestcontrol keyboardputscancode & keyboardputstring functions to configure a pre-built VM, and its working great, except everything is written with US-keyboard layout (i am using german keyboard layout).

VBoxManage controlvm "machine" keyboardputstring "yes"
will output
"zes"

interestingly enough, when using scancodes from http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html, it will still try to write with german keyboard layout, resulting in wrong character being displayed.

VBoxManage controlvm "machine" keyboardputscancode 15 95
will output
"z"

i am able to convert most characters by just finding the right german key fitting to the corresponding US key.
but some can not be converted, like the @ character - the US keyboard has no function for the key i press on my german keyboard, though i am still able to get that one to work using keyboardputscancode and the codes for SHIFT+2.
what does not work at all, i can't write a | character, like there seem to be no scancode for the pipe-key that works when using keyboardputscancode...

i hope was able to explain my problem well enough...

a solution to use a german keyboard layout when working with keyboardputstring & keyboardputscancode would be highly appreciated.

otherwise, how am i supposed to use this thing?

thanks in advance.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VBoxManage guestcontrol & Keyboard layout

Post by mpack »

The host keyboard is not relevant to this discussion. All that is relevant is the scan code you send, and what character the guest translates that scan code into, which depends on the keyboard layout configured by the guest OS. Since you posted in a generic forum ("Using VirtualBox") and have not mentioned what your host or guest OSs are, I cannot comment on how the guest keyboard layout is configured.

Looking at the source code, the "keyboardputstring" function, which must of course convert a string into a series of scan codes, always assumes the US English mapping of character to scancode. I suggest finding a table somewhere that documents that mapping.

To reiterate: the fact that your host has a German keyboard has nothing to do with this, since the host keyboard is never involved in this transaction. To work the way you suggest would be very dangerous - it would be impossible to know exactly what the string of scancodes sent by random host would be.
algee
Posts: 12
Joined: 28. Sep 2016, 09:09

Re: VBoxManage guestcontrol & Keyboard layout

Post by algee »

hi,

thanks, i use this on exactly one guest, its an ubuntu 16.04 and when checking localectl status this shows up
Attachments
2018-08-06 13_22_05-opsi-cfg (initial) [Running] - Oracle VM VirtualBox.png
2018-08-06 13_22_05-opsi-cfg (initial) [Running] - Oracle VM VirtualBox.png (5.89 KiB) Viewed 2058 times
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: VBoxManage guestcontrol & Keyboard layout

Post by mpack »

Moved to "Linux Guests". I don't use Linux so I'll let others comment on whether that means you have the correct keyboard mapping in Ubuntu. Given what you say in your first post, I'd say that the function is working correctly.
Post Reply