Documentation ¶
Overview ¶
Pacakge input coordinates all the different types of input into the VCS. The types of input handled by the package include:
1) Immediate input from the user (see userinput package) 2) Playback for a previously recorded script (see recorder package) 3) Driven events from a driver emulation (see below)) 4) Pushed events
In addition it also coordinates the passing of input to other packages that need to know about an input event.
1) The RIOT ports (see Ports package) 2) Events to be recorded to a playback script (see recorder package) 3) Events to be driven to a passenger emulation (see below)
The input package will handle impossible situations are return an error when appropriate. For example, it is not possible for an emulation to be a playback and a recorder at the same time.
Points 1 in both lists is the normal type of input you would expect in an emultor that allows people to play games and as such, won't be discussed further.
Points 2 in the lists is well covered by the recorder package.
Points 3 in both lists above refer to driven events and driver & passenger emulations. This system is a way os synchronising two emulations such that the input of one drives the input of the other. The input package ensures that input events occur in bothe emulations at the same time - time being measure by the coordinates of the TV instances attached to the emulations.
For an example of a driven emulation see the comparison package.
Lastly, pushed events, as refered to in point 4, are events that have arrived from a different goroutine. For an example of pushed events see the various bot implementations in the bots package.
Note that for performance reasons, pushed events will not be serviced unless AllowPushedEvents(true) has been called. Also, pushed events will only be serviced at the beginning of every frame. (This might change depending on need in the future).
Index ¶
- type EventPlayback
- type EventRecorder
- type Input
- func (inp *Input) AllowPushedEvents(allow bool)
- func (inp *Input) AttachDriver(passenger chan ports.TimedInputEvent) error
- func (inp *Input) AttachPassenger(driver chan ports.TimedInputEvent) error
- func (inp *Input) AttachPlayback(pb EventPlayback) error
- func (inp *Input) AttachRecorder(r EventRecorder) error
- func (inp *Input) HandleInputEvent(ev ports.InputEvent) (bool, error)
- func (inp *Input) NewFrame(_ television.FrameInfo) error
- func (inp *Input) PeripheralID(id plugging.PortID) plugging.PeripheralID
- func (inp *Input) Plumb(ports *ports.Ports)
- func (inp *Input) PushEvent(ev ports.InputEvent) error
- type TV
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventPlayback ¶
type EventPlayback interface { // note the type restrictions on EventData in the type definition's // commentary GetPlayback() (ports.TimedInputEvent, 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 EventRecorder ¶
type EventRecorder interface {
RecordEvent(ports.TimedInputEvent) error
}
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 Input ¶
type Input struct { // Handle function should be called every VCS step Handle func() error // contains filtered or unexported fields }
Input handles all forms of input into the VCS.
func (*Input) AllowPushedEvents ¶
AllowPushedEvents or not. Should not be allowed unless absolutely necessary.
func (*Input) AttachDriver ¶
func (inp *Input) AttachDriver(passenger chan ports.TimedInputEvent) error
AttachDriver should be called by an emulation that is prepared to drive another emulation.
func (*Input) AttachPassenger ¶
func (inp *Input) AttachPassenger(driver chan ports.TimedInputEvent) error
AttachPassenger should be called by an emulation that wants to be driven by another emulation.
func (*Input) AttachPlayback ¶
func (inp *Input) AttachPlayback(pb EventPlayback) error
AttachPlayback attaches an EventPlayback implementation to the Input sub-system. EventPlayback can be nil in order to remove the playback.
func (*Input) AttachRecorder ¶
func (inp *Input) AttachRecorder(r EventRecorder) error
AttachEventRecorder attaches an EventRecorder implementation.
func (*Input) HandleInputEvent ¶
func (inp *Input) HandleInputEvent(ev ports.InputEvent) (bool, error)
HandleInputEvent forwards an input event to VCS Ports.
If a playback is currently active the input will not be handled and false will be returned.
func (*Input) NewFrame ¶
func (inp *Input) NewFrame(_ television.FrameInfo) error
See NewFrame() comment for PixelRenderer interface.
func (*Input) PeripheralID ¶
func (inp *Input) PeripheralID(id plugging.PortID) plugging.PeripheralID
PeripheralID forwards a request of the PeripheralID of the PortID to VCS Ports.
type TV ¶
type TV interface { GetCoords() coords.TelevisionCoords AddFrameTrigger(television.FrameTrigger) RemoveFrameTrigger(television.FrameTrigger) }
TV defines the television functions required by the Input system.