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
- Variables
- func NewAuto(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral
- func NewKeyboard(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral
- func NewPaddle(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral
- func NewStick(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral
- type Auto
- type Keyboard
- func (key *Keyboard) HandleEvent(event ports.Event, data ports.EventData) error
- func (key *Keyboard) Name() string
- func (key *Keyboard) Plumb(bus ports.PeripheralBus)
- func (key *Keyboard) Reset()
- func (key *Keyboard) Step()
- func (key *Keyboard) String() string
- func (key *Keyboard) Update(data bus.ChipData) bool
- type Paddle
- type Stick
Constants ¶
const (
UnhandledEvent = "unhandled event: %s does not support event %v"
)
Sentinal error returned if controller implementation does not understand event sent to HandleEvent().
Variables ¶
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 ¶
func NewAuto(id ports.PortID, bus ports.PeripheralBus) ports.Peripheral
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 ¶
HandleEvent implements the ports.Peripheral interface.
func (*Auto) Plumb ¶
func (aut *Auto) Plumb(bus ports.PeripheralBus)
Plumb implements the Peripheral interface.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
Keyboard represents the VCS keyboard (or keypad) type.
func (*Keyboard) HandleEvent ¶
HandleEvent 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.
type Paddle ¶
type Paddle struct {
// contains filtered or unexported fields
}
Paddle represents the VCS paddle controller type.
func (*Paddle) HandleEvent ¶
HandleEvent implements the ports.Peripheral interface.
func (*Paddle) Plumb ¶
func (pdl *Paddle) Plumb(bus ports.PeripheralBus)
Plumb 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 ¶
HandleEvent implements the ports.Peripheral interface.
func (*Stick) Plumb ¶
func (stk *Stick) Plumb(bus ports.PeripheralBus)
Plumb implements the ports.Peripheral interface.