diff --git a/builder/hyperv/common/step_type_boot_command.go b/builder/hyperv/common/step_type_boot_command.go index 5772ce1b9..9b8b08654 100644 --- a/builder/hyperv/common/step_type_boot_command.go +++ b/builder/hyperv/common/step_type_boot_command.go @@ -84,7 +84,7 @@ func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) scanCodesToSendString := strings.Join(codes, " ") return driver.TypeScanCodes(vmName, scanCodesToSendString) } - d := bootcommand.NewPCATDriver(sendCodes, -1) + d := bootcommand.NewPCXTDriver(sendCodes, -1) flatCommands := strings.Join(commands, "") seq, err := bootcommand.GenerateExpressionSequence(flatCommands) diff --git a/builder/parallels/common/step_type_boot_command.go b/builder/parallels/common/step_type_boot_command.go index 306182d6a..899462f15 100644 --- a/builder/parallels/common/step_type_boot_command.go +++ b/builder/parallels/common/step_type_boot_command.go @@ -81,7 +81,7 @@ func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) log.Printf("Sending scancodes: %#v", codes) return driver.SendKeyScanCodes(s.VMName, codes...) } - d := bootcommand.NewPCATDriver(sendCodes, -1) + d := bootcommand.NewPCXTDriver(sendCodes, -1) ui.Say("Typing the boot command...") for i, command := range s.BootCommand { diff --git a/builder/virtualbox/common/step_type_boot_command.go b/builder/virtualbox/common/step_type_boot_command.go index b979ef59f..cb0df4e40 100644 --- a/builder/virtualbox/common/step_type_boot_command.go +++ b/builder/virtualbox/common/step_type_boot_command.go @@ -64,7 +64,7 @@ func (s *StepTypeBootCommand) Run(ctx context.Context, state multistep.StateBag) return driver.VBoxManage(args...) } - d := bootcommand.NewPCATDriver(sendCodes, 25) + d := bootcommand.NewPCXTDriver(sendCodes, 25) ui.Say("Typing the boot command...") for i, command := range s.BootCommand { diff --git a/common/boot_command/pc_at_driver.go b/common/boot_command/pc_xt_driver.go similarity index 90% rename from common/boot_command/pc_at_driver.go rename to common/boot_command/pc_xt_driver.go index e227f3eca..9107f5b85 100644 --- a/common/boot_command/pc_at_driver.go +++ b/common/boot_command/pc_xt_driver.go @@ -15,7 +15,7 @@ import ( // SendCodeFunc will be called to send codes to the VM type SendCodeFunc func([]string) error -type pcATDriver struct { +type pcXTDriver struct { interval time.Duration sendImpl SendCodeFunc specialMap map[string][]string @@ -25,17 +25,18 @@ type pcATDriver struct { scancodeChunkSize int } -// NewPCATDriver creates a new boot command driver for VMs that expect PC-AT +// NewPCXTDriver creates a new boot command driver for VMs that expect PC-XT // keyboard codes. `send` should send its argument to the VM. `chunkSize` should // be the maximum number of keyboard codes to send to `send` at one time. -func NewPCATDriver(send SendCodeFunc, chunkSize int) *pcATDriver { +func NewPCXTDriver(send SendCodeFunc, chunkSize int) *pcXTDriver { // We delay (default 100ms) between each input event to allow for CPU or // network latency. See PackerKeyEnv for tuning. keyInterval := common.PackerKeyDefault if delay, err := time.ParseDuration(os.Getenv(common.PackerKeyEnv)); err == nil { keyInterval = delay } - // Scancodes reference: http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html + // Scancodes reference: https://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html + // https://www.win.tue.nl/~aeb/linux/kbd/scancodes-10.html // // Scancodes are recorded here in pairs. The first entry represents // the key press and the second entry represents the key release and is @@ -100,7 +101,7 @@ func NewPCATDriver(send SendCodeFunc, chunkSize int) *pcATDriver { } } - return &pcATDriver{ + return &pcXTDriver{ interval: keyInterval, sendImpl: send, specialMap: sMap, @@ -110,7 +111,7 @@ func NewPCATDriver(send SendCodeFunc, chunkSize int) *pcATDriver { } // Finalize flushes all scanecodes. -func (d *pcATDriver) Finalize() error { +func (d *pcXTDriver) Finalize() error { defer func() { d.buffer = nil }() @@ -127,7 +128,7 @@ func (d *pcATDriver) Finalize() error { return nil } -func (d *pcATDriver) SendKey(key rune, action KeyAction) error { +func (d *pcXTDriver) SendKey(key rune, action KeyAction) error { keyShift := unicode.IsUpper(key) || strings.ContainsRune(shiftedChars, key) @@ -157,7 +158,7 @@ func (d *pcATDriver) SendKey(key rune, action KeyAction) error { return nil } -func (d *pcATDriver) SendSpecial(special string, action KeyAction) error { +func (d *pcXTDriver) SendSpecial(special string, action KeyAction) error { keyCode, ok := d.specialMap[special] if !ok { return fmt.Errorf("special %s not found.", special) @@ -175,7 +176,7 @@ func (d *pcATDriver) SendSpecial(special string, action KeyAction) error { } // send stores the codes in an internal buffer. Use finalize to flush them. -func (d *pcATDriver) send(codes []string) { +func (d *pcXTDriver) send(codes []string) { d.buffer = append(d.buffer, codes) } diff --git a/common/boot_command/pc_at_driver_test.go b/common/boot_command/pc_xt_driver_test.go similarity index 94% rename from common/boot_command/pc_at_driver_test.go rename to common/boot_command/pc_xt_driver_test.go index f9323cfea..ca4f5eb3d 100644 --- a/common/boot_command/pc_at_driver_test.go +++ b/common/boot_command/pc_xt_driver_test.go @@ -71,7 +71,7 @@ func Test_chunkScanCodeError(t *testing.T) { assert.Error(t, err) } -func Test_pcatSpecialLookup(t *testing.T) { +func Test_pcxtSpecialLookup(t *testing.T) { in := "" expected := []string{"36", "b6", "b6", "36"} var codes []string @@ -79,7 +79,7 @@ func Test_pcatSpecialLookup(t *testing.T) { codes = c return nil } - d := NewPCATDriver(sendCodes, -1) + d := NewPCXTDriver(sendCodes, -1) seq, err := GenerateExpressionSequence(in) assert.NoError(t, err) err = seq.Do(context.Background(), d)