controllers

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2021 License: GPL-3.0, GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package controllers contains the implementations for all the emulated controllers for the VCS.

The Auto type handles flipping of the other controller types according to user input and the state of the machine. The Auto type will forward all functions to the "real" controller (ie. the stick, paddle or keyboard) transparently. So for example, ID() will return the ID() of the "real" controller. If you really need to know whether the real controller has been automatically selected via the Auto type then you can (test the Player 0 port, for example):

if _, ok := ports.Player0.(controllers.Auto); ok {
	// is auto
} else {
	// is not auto
}

Index

Constants

View Source
const (
	UnhandledEvent = "unhandled event: %s does not support event %v"
)

Sentinal error returned if controller implementation does not understand event sent to HandleEvent().

Variables

View Source
var ControllerList = []string{"Stick", "Paddle", "Keyboard"}

ControllerList is the list of controllers. These are the values that can be returned by the ID() function of the ports.Peripheral implementations in this package.

Functions

func NewAuto

NewAuto is the preferred method of initialisation for the Auto type. Satisifies the ports.NewPeripheral interface and can be used as an argument to ports.AttachPlayer0() and ports.AttachPlayer1().

func NewKeyboard

func NewKeyboard(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral

NewKeyboard is the preferred method of initialisation for the Keyboard type Satisifies the ports.NewPeripheral interface and can be used as an argument to ports.AttachPlayer0() and ports.AttachPlayer1().

func NewPaddle

func NewPaddle(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral

NewPaddle is the preferred method of initialisation for the Paddle type Satisifies the ports.NewPeripheral interface and can be used as an argument to ports.AttachPlayer0() and ports.AttachPlayer1().

func NewStick

func NewStick(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral

NewStick is the preferred method of initialisation for the Stick type Satisifies the ports.NewPeripheral interface and can be used as an argument to ports.AttachPlayer0() and ports.AttachPlayer1().

Types

type Auto

type Auto struct {
	// contains filtered or unexported fields
}

Auto handles the automatic switching between controller types.

func (*Auto) HandleEvent

func (aut *Auto) HandleEvent(event ports.Event, data ports.EventData) error

HandleEvent implements the ports.Peripheral interface.

func (*Auto) Name

func (aut *Auto) Name() string

Name implements the ports.Peripheral interface.

func (*Auto) Plumb

func (aut *Auto) Plumb(bus ports.PeripheralBus)

Plumb implements the Peripheral interface.

func (*Auto) Reset

func (aut *Auto) Reset()

Reset implements the ports.Peripheral interface.

func (*Auto) Step

func (aut *Auto) Step()

Step implements the ports.Peripheral interface.

func (*Auto) String

func (aut *Auto) String() string

String implements the ports.Peripheral interface.

func (*Auto) Update

func (aut *Auto) Update(data bus.ChipData) bool

Update implements the ports.Peripheral interface.

type Keyboard

type Keyboard struct {
	// contains filtered or unexported fields
}

Keyboard represents the VCS keyboard (or keypad) type.

func (*Keyboard) HandleEvent

func (key *Keyboard) HandleEvent(event ports.Event, data ports.EventData) error

HandleEvent implements the ports.Peripheral interface.

func (*Keyboard) Name

func (key *Keyboard) Name() string

Name implements the ports.Peripheral interface.

func (*Keyboard) Plumb

func (key *Keyboard) Plumb(bus ports.PeripheralBus)

Plumb implements the ports.Peripheral interface.

func (*Keyboard) Reset

func (key *Keyboard) Reset()

Reset implements the ports.Peripheral interface.

func (*Keyboard) Step

func (key *Keyboard) Step()

Step implements the ports.Peripheral interface.

func (*Keyboard) String

func (key *Keyboard) String() string

String implements the ports.Peripheral interface.

func (*Keyboard) Update

func (key *Keyboard) Update(data bus.ChipData) bool

Update implements the ports.Peripheral interface.

type Paddle

type Paddle struct {
	// contains filtered or unexported fields
}

Paddle represents the VCS paddle controller type.

func (*Paddle) HandleEvent

func (pdl *Paddle) HandleEvent(event ports.Event, data ports.EventData) error

HandleEvent implements the ports.Peripheral interface.

func (*Paddle) Name

func (pdl *Paddle) Name() string

Name implements the ports.Peripheral interface.

func (*Paddle) Plumb

func (pdl *Paddle) Plumb(bus ports.PeripheralBus)

Plumb implements the ports.Peripheral interface.

func (*Paddle) Reset

func (pdl *Paddle) Reset()

Reset implements the ports.Peripheral interface.

func (*Paddle) Step

func (pdl *Paddle) Step()

Step implements the ports.Peripheral interface.

func (*Paddle) String

func (pdl *Paddle) String() string

String implements the ports.Peripheral interface.

func (*Paddle) Update

func (pdl *Paddle) Update(data bus.ChipData) bool

Update implements the ports.Peripheral interface.

type Stick

type Stick struct {
	// contains filtered or unexported fields
}

Stick represents the VCS digital joystick controller.

func (*Stick) HandleEvent

func (stk *Stick) HandleEvent(event ports.Event, data ports.EventData) error

HandleEvent implements the ports.Peripheral interface.

func (*Stick) Name

func (stk *Stick) Name() string

Name implements the ports.Peripheral interface.

func (*Stick) Plumb

func (stk *Stick) Plumb(bus ports.PeripheralBus)

Plumb implements the ports.Peripheral interface.

func (*Stick) Reset

func (stk *Stick) Reset()

Reset implements the ports.Peripheral interface.

func (*Stick) Step

func (stk *Stick) Step()

Step implements the ports.Peripheral interface.

func (*Stick) String

func (stk *Stick) String() string

String implements the ports.Peripheral interface.

func (*Stick) Update

func (stk *Stick) Update(data bus.ChipData) bool

Update implements the ports.Peripheral interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL