input

package
v0.30.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: GPL-3.0 Imports: 5 Imported by: 0

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.

Index

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 NewInput

func NewInput(tv TV, p *ports.Ports) *Input

func (*Input) AddRecorder added in v0.21.0

func (inp *Input) AddRecorder(r EventRecorder) error

AttachEventRecorder attaches an EventRecorder implementation.

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) ClearRecorders added in v0.21.0

func (inp *Input) ClearRecorders()

ClearRecorders removes all registered event recorders.

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.

func (*Input) Plumb

func (inp *Input) Plumb(tv TV, ports *ports.Ports)

Plumb a new ports instances into the Input.

func (*Input) PushEvent

func (inp *Input) PushEvent(ev ports.InputEvent) error

PushEvent pushes an InputEvent onto the queue. Will drop the event and return an error if queue is full.

type TV

type TV interface {
	GetCoords() coords.TelevisionCoords
	AddFrameTrigger(television.FrameTrigger)
	RemoveFrameTrigger(television.FrameTrigger)
}

TV defines the television functions required by the Input system.

Jump to

Keyboard shortcuts

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