we're using PC-XT (set1) not PC-AT

This commit is contained in:
Matthew Hooker 2018-04-13 21:06:37 -07:00
parent c753391f43
commit 94129b7fe3
No known key found for this signature in database
GPG Key ID: 7B5F933D9CE8C6A1
5 changed files with 15 additions and 14 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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 {

View File

@ -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)
}

View File

@ -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 := "<rightShift><rightshiftoff><RIGHTSHIFTON>"
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)