From bb8e7f78148c70999f7a788f35304c8d533aa67a Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Sun, 15 Sep 2013 21:04:25 -0700 Subject: [PATCH] Fix VirtualBox scancodes Support for the backspace, delete and F1-F12 keys was added in commit 6028a3c. However, that commit seems to have copied character codes from the vmware builder into the VirtualBox builder. Character codes are appropriate for VMware which communicates through a VNC. However, VirtualBox communicates through simulating raw keyboard input and therefore needs scancodes which are key press/key release sequences. This patch converts backspace, delete and F1-F10 to scancodes. F11 and F12 are not listed in the [scancode reference][scancodes] so they have been omitted. [scancodes]: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html --- builder/virtualbox/step_type_boot_command.go | 35 +++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/builder/virtualbox/step_type_boot_command.go b/builder/virtualbox/step_type_boot_command.go index 60c897ea9..e5fb442ea 100644 --- a/builder/virtualbox/step_type_boot_command.go +++ b/builder/virtualbox/step_type_boot_command.go @@ -92,29 +92,34 @@ func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction func (*stepTypeBootCommand) Cleanup(multistep.StateBag) {} func scancodes(message string) []string { + // Scancodes reference: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html + // + // Scancodes represent raw keyboard output and are fed to the VM by the + // VBoxManage controlvm keyboardputscancode program. + // + // Scancodes are recorded here in pairs. The first entry represents + // the key press and the second entry represents the key release and is + // derived from the first by the addition of 0x81. special := make(map[string][]string) - special[""] = []string{"ff", "08"} - special[""] = []string{"ff", "ff"} + special[""] = []string{"0e", "8e"} + special[""] = []string{"53", "d3"} special[""] = []string{"1c", "9c"} special[""] = []string{"01", "81"} - special[""] = []string{"ff", "be"} - special[""] = []string{"ff", "bf"} - special[""] = []string{"ff", "c0"} - special[""] = []string{"ff", "c1"} - special[""] = []string{"ff", "c2"} - special[""] = []string{"ff", "c3"} - special[""] = []string{"ff", "c4"} - special[""] = []string{"ff", "c5"} - special[""] = []string{"ff", "c6"} - special[""] = []string{"ff", "c7"} - special[""] = []string{"ff", "c8"} - special[""] = []string{"ff", "c9"} + special[""] = []string{"3b", "bb"} + special[""] = []string{"3c", "bc"} + special[""] = []string{"3d", "bd"} + special[""] = []string{"3e", "be"} + special[""] = []string{"3f", "bf"} + special[""] = []string{"40", "c0"} + special[""] = []string{"41", "c1"} + special[""] = []string{"42", "c2"} + special[""] = []string{"43", "c3"} + special[""] = []string{"44", "c4"} special[""] = []string{"1c", "9c"} special[""] = []string{"0f", "8f"} shiftedChars := "~!@#$%^&*()_+{}|:\"<>?" - // Scancodes reference: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html scancodeIndex := make(map[string]uint) scancodeIndex["1234567890-="] = 0x02 scancodeIndex["!@#$%^&*()_+"] = 0x02