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 ¶
- Variables
- func NewAuto(port plugging.PortID, bus ports.PeripheralBus) ports.Peripheral
- func NewKeypad(port plugging.PortID, bus ports.PeripheralBus) ports.Peripheral
- func NewPaddle(port plugging.PortID, bus ports.PeripheralBus) ports.Peripheral
- func NewStick(port plugging.PortID, bus ports.PeripheralBus) ports.Peripheral
- type Auto
- func (aut *Auto) AttachPlugMonitor(m plugging.PlugMonitor)
- func (aut *Auto) HandleEvent(event ports.Event, data ports.EventData) error
- func (aut *Auto) ID() plugging.PeripheralID
- func (aut *Auto) Plumb(bus ports.PeripheralBus)
- func (aut *Auto) PortID() plugging.PortID
- func (aut *Auto) Reset()
- func (aut *Auto) Step()
- func (aut *Auto) String() string
- func (aut *Auto) Update(data bus.ChipData) bool
- type Keypad
- func (key *Keypad) HandleEvent(event ports.Event, data ports.EventData) error
- func (key *Keypad) ID() plugging.PeripheralID
- func (key *Keypad) Plumb(bus ports.PeripheralBus)
- func (key *Keypad) PortID() plugging.PortID
- func (key *Keypad) Reset()
- func (key *Keypad) Step()
- func (key *Keypad) String() string
- func (key *Keypad) Update(data bus.ChipData) bool
- type Paddle
- func (pdl *Paddle) HandleEvent(event ports.Event, data ports.EventData) error
- func (pdl *Paddle) ID() plugging.PeripheralID
- func (pdl *Paddle) Plumb(bus ports.PeripheralBus)
- func (pdl *Paddle) PortID() plugging.PortID
- func (pdl *Paddle) Reset()
- func (pdl *Paddle) Step()
- func (pdl *Paddle) String() string
- func (pdl *Paddle) Update(data bus.ChipData) bool
- type Stick
- func (stk *Stick) HandleEvent(event ports.Event, data ports.EventData) error
- func (stk *Stick) ID() plugging.PeripheralID
- func (stk *Stick) Plumb(bus ports.PeripheralBus)
- func (stk *Stick) PortID() plugging.PortID
- func (stk *Stick) Reset()
- func (stk *Stick) Step()
- func (stk *Stick) String() string
- func (stk *Stick) Update(data bus.ChipData) bool
Constants ¶
This section is empty.
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(port plugging.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 NewKeypad ¶ added in v0.14.0
func NewKeypad(port plugging.PortID, bus ports.PeripheralBus) ports.Peripheral
NewKeypad 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(port plugging.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(port plugging.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) AttachPlugMonitor ¶ added in v0.10.1
func (aut *Auto) AttachPlugMonitor(m plugging.PlugMonitor)
AttachPlugMonitor implements the plugging.Monitorable interface.
func (*Auto) HandleEvent ¶
HandleEvent implements the ports.Peripheral interface.
func (*Auto) ID ¶ added in v0.14.0
func (aut *Auto) ID() plugging.PeripheralID
ID implements the ports.Peripheral interface.
func (*Auto) Plumb ¶
func (aut *Auto) Plumb(bus ports.PeripheralBus)
Plumb implements the Peripheral interface.
type Keypad ¶ added in v0.14.0
type Keypad struct {
// contains filtered or unexported fields
}
Keypad represents the VCS keypad type.
func (*Keypad) HandleEvent ¶ added in v0.14.0
HandleEvent implements the ports.Peripheral interface.
func (*Keypad) ID ¶ added in v0.14.0
func (key *Keypad) ID() plugging.PeripheralID
ID implements the ports.Peripheral interface.
func (*Keypad) Plumb ¶ added in v0.14.0
func (key *Keypad) Plumb(bus ports.PeripheralBus)
Plumb implements the ports.Peripheral interface.
func (*Keypad) Reset ¶ added in v0.14.0
func (key *Keypad) Reset()
Reset implements the ports.Peripheral interface.
func (*Keypad) Step ¶ added in v0.14.0
func (key *Keypad) Step()
Step 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) ID ¶ added in v0.14.0
func (pdl *Paddle) ID() plugging.PeripheralID
ID 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) ID ¶ added in v0.14.0
func (stk *Stick) ID() plugging.PeripheralID
ID implements the ports.Peripheral interface.
func (*Stick) Plumb ¶
func (stk *Stick) Plumb(bus ports.PeripheralBus)
Plumb implements the ports.Peripheral interface.