Documentation
¶
Overview ¶
Package input represents the input/output part of the RIOT (the IO in RIOT). Note that the output aspect of the RIOT is minimal and so the package is appropriately called input.
The main type in the package, the Input type, contains references to the three input devices - the panel and the two hand controller ports.
The HandController type handles the input from all types of hand controllers (although, currently, joystick and paddle only)
The Panel type handles the input from the VCS's front panel switches.
The Panel and HandController types satisfy the Port type.
Physical controllers for the emulation can interact with the Panel and HandController types throught the Handle() function and pass the correct Event to indicate the desired effect.
An alternative to the Handle() function is the Playback interface. The Port interface can have a Playback instance attached to it with the AttachPlayback() function. The CheckInput function of the Playback interface can then be used to check for Events.
The Playback interface is intended as the counterpart to the EventRecorder interface, but it could theoretically be used in other contexts.
EventRecorders intercept all events issued to either of the Port implementations and handle those events in their own way. The intended purpose is for the events to be recorded to disk for future playback. Note that events issued by Playback implementations are also passed through attached Event Recorders.
Index ¶
- Variables
- type ControllerType
- type Event
- type EventData
- type EventRecorder
- type HandController
- func (p *HandController) AttachEventRecorder(scribe EventRecorder)
- func (p *HandController) AttachPlayback(playback Playback)
- func (p *HandController) CheckInput() error
- func (hc *HandController) Handle(event Event, value EventData) error
- func (hc *HandController) Reset()
- func (hc *HandController) SetAuto(auto bool)
- func (hc *HandController) String() string
- func (hc *HandController) SwitchType(newType ControllerType) error
- type ID
- type Input
- type Panel
- type Playback
- type Port
- type VBlankBits
Constants ¶
This section is empty.
Variables ¶
var ControllerTypeList = []string{"Joystick", "Paddle", "Keypad"}
ControllerTypeList is a list of all possible string representations of the Interval type
Functions ¶
This section is empty.
Types ¶
type ControllerType ¶
type ControllerType int
ControllerType keeps track of which controller type is being used at any given moment. we need this so that we don't ground/recharge the paddle if it is not being used. if we did then joystick input would be wrong.
we default to the joystick type which should be fine. for non-joystick games, the paddle/keypad will be activated once the user starts using the corresponding controls.
if a paddle/keypad ROM requires paddle/keypad probing from the instant the machine starts (are there any examples of this?) then we will need to initialise the hand controller accordingly, using the setup system.
const ( JoystickType ControllerType = iota PaddleType KeypadType )
List of allowed ControllerTypes
func (ControllerType) String ¶
func (c ControllerType) String() string
type Event ¶
type Event string
Event represents the possible actions that can be performed by the user when interacting with the console
const ( NoEvent Event = "NoEvent" // nil // the controller has been unplugged Unplug Event = "Unplug" // nil // joystick Fire Event = "Fire" // bool Up Event = "Up" // bool Down Event = "Down" // bool Left Event = "Left" // bool Right Event = "Right" // bool // panel PanelSelect Event = "PanelSelect" // bool PanelReset Event = "PanelReset" // bool PanelSetColor Event = "PanelSetColor" // bool PanelSetPlayer0Pro Event = "PanelSetPlayer0Pro" // bool PanelSetPlayer1Pro Event = "PanelSetPlayer1Pro" // bool PanelToggleColor Event = "PanelToggleColor" // nil PanelTogglePlayer0Pro Event = "PanelTogglePlayer0Pro" // nil PanelTogglePlayer1Pro Event = "PanelTogglePlayer1Pro" // nil // paddles PaddleFire Event = "PaddleFire" // bool PaddleSet Event = "PaddleSet" // float64 // keypad (only need down event) KeypadDown Event = "KeypadDown" // rune KeypadUp Event = "KeypadUp" // nil PanelPowerOff Event = "PanelPowerOff" // nil )
List of defined events
type EventData ¶
type EventData interface{}
EventData is the value associated with the event. The underlying type should be restricted to bool, float32, or int. string is also acceptable but for simplicity of playback parsers, "true" or "false" should not be used and numbers should be represented by float32 or int.
type EventRecorder ¶
EventRecorder implementations mirror an incoming event.
Implementations should be able to handle being attached to more than one peripheral at once. The ID parameter of the EventRecord() function will help to differentiate between multiple devices.
type HandController ¶
type HandController struct {
// the current controller type. use SwitchType() to set.
ControllerType ControllerType
// whether SwitchType() should respond to automatic switching. use
// SetAuto() to set.
AutoControllerType bool
// contains filtered or unexported fields
}
HandController represents the "joystick" port on the VCS. The different devices (joysticks, paddles, etc.) send events to the Handle() function.
Note that handcontrollers need access to TIA memory as well as RIOT memory.
func NewHandController0 ¶
func NewHandController0(mem *inputMemory, control *VBlankBits) *HandController
NewHandController0 is the preferred method of creating a new instance of HandController for representing hand controller zero
func NewHandController1 ¶
func NewHandController1(mem *inputMemory, control *VBlankBits) *HandController
NewHandController1 is the preferred method of creating a new instance of HandController for representing hand controller one
func (*HandController) AttachEventRecorder ¶
func (p *HandController) AttachEventRecorder(scribe EventRecorder)
AttachEventRecorder to the port. An EventRecorder value of nil will remove the recorder from the port.
func (*HandController) AttachPlayback ¶
func (p *HandController) AttachPlayback(playback Playback)
Attach a Playback implementation to the port. Events can still be pushed to the port by using the port's Handle() function directly. a Playback of nill will remove an existing playback from the port.
func (*HandController) CheckInput ¶
func (p *HandController) CheckInput() error
CheckInput polls the attached playback for an Event
func (*HandController) Handle ¶
func (hc *HandController) Handle(event Event, value EventData) error
Handle implements Port interface
func (*HandController) SetAuto ¶
func (hc *HandController) SetAuto(auto bool)
SetAuto turns automatic controller switching on or off. Note that calling SwitchType() with a different type to what has been automatically selected will also turn auto-switching off.
func (*HandController) String ¶
func (hc *HandController) String() string
String implements the Port interface
func (*HandController) SwitchType ¶
func (hc *HandController) SwitchType(newType ControllerType) error
SwitchType causes the HandController to swich controller type. If the type is switched or if the type is already of the requested type then true is returned.
type Input ¶
type Input struct {
VBlankBits VBlankBits
Panel *Panel
HandController0 *HandController
HandController1 *HandController
// contains filtered or unexported fields
}
Input implements the input/output part of the RIOT (the IO in RIOT)
func NewInput ¶
NewInput is the preferred method of initialisation of the Input type. Note that input devices require access to TIA memory as well as RIOT memory, breaking the abstraction somewhat, but it can't be helped. The NewInput() function therefore requires two arguments one to the RIOT chip bus and one to the TIA chip bus.
type Panel ¶
type Panel struct {
// contains filtered or unexported fields
}
Panel represents the console's front control panel
func NewPanel ¶
func NewPanel(mem *inputMemory) *Panel
NewPanel is the preferred method of initialisation for the Panel type
func (*Panel) AttachEventRecorder ¶
func (p *Panel) AttachEventRecorder(scribe EventRecorder)
AttachEventRecorder to the port. An EventRecorder value of nil will remove the recorder from the port.
func (*Panel) AttachPlayback ¶
func (p *Panel) AttachPlayback(playback Playback)
Attach a Playback implementation to the port. Events can still be pushed to the port by using the port's Handle() function directly. a Playback of nill will remove an existing playback from the port.
func (*Panel) CheckInput ¶
func (p *Panel) CheckInput() error
CheckInput polls the attached playback for an Event
type Playback ¶
type Playback interface {
// note the type restrictions on EventData in the type definition's
// commentary
CheckInput(id ID) (Event, EventData, error)
}
Playback implementations feed controller Events to the device on request with the CheckInput() function.
Intended for playback of controller events previously recorded to a file on disk but usable for many purposes I suspect. For example, AI control.
type Port ¶
type Port interface {
String() string
Handle(Event, EventData) error
AttachPlayback(Playback)
AttachEventRecorder(EventRecorder)
}
Port conceptualises the I/O ports as described in the Stella Programmer's Guide (page 13). Port B is the VCS's switches on its front panel, while Port A allows the various hand controllers to be attached.
See the HandController and Panel types for more information
type VBlankBits ¶
type VBlankBits struct {
// contains filtered or unexported fields
}
VBlankBits represents the bits in the VBLANK register that control paddle-grounding and joystick-latching. The VBLANK address is handled by the TIA but these bits in that register are needed by the input system.
VBlankBits is instantiated by NewInput() and then a reference given to the TIA (by NewVCS() in the hardware package)
func (*VBlankBits) SetGroundPaddles ¶
func (c *VBlankBits) SetGroundPaddles(v bool)
SetGroundPaddles sets the state of the groundPaddles value
func (*VBlankBits) SetLatchFireButton ¶
func (c *VBlankBits) SetLatchFireButton(v bool)
SetLatchFireButton sets the state of the latchFireButton value