Documentation ¶
Overview ¶
Package fake implements a fake input controller.
Index ¶
- func NewInputController(ctx context.Context, conf resource.Config, logger logging.Logger) (input.Controller, error)
- type Config
- type InputController
- func (c *InputController) Close(ctx context.Context) error
- func (c *InputController) Controls(ctx context.Context, extra map[string]interface{}) ([]input.Control, error)
- func (c *InputController) Events(ctx context.Context, extra map[string]interface{}) (map[input.Control]input.Event, error)
- func (c *InputController) Reconfigure(ctx context.Context, deps resource.Dependencies, conf resource.Config) error
- func (c *InputController) RegisterControlCallback(ctx context.Context, control input.Control, triggers []input.EventType, ...) error
- func (c *InputController) TriggerEvent(ctx context.Context, event input.Event, extra map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { resource.TriviallyValidateConfig // EventValue will dictate the value of the events returned. Random between -1 to 1 if unset. EventValue *float64 `json:"event_value,omitempty"` // CallbackDelaySec is the amount of time between callbacks getting triggered. Random between (1-2] sec if unset. // 0 is not valid and will be overwritten by a random delay. CallbackDelaySec float64 `json:"callback_delay_sec"` // contains filtered or unexported fields }
Config can list input structs (with their states), define event values and callback delays.
type InputController ¶
An InputController fakes an input.Controller.
func (*InputController) Close ¶ added in v0.2.24
func (c *InputController) Close(ctx context.Context) error
Close attempts to cleanly close the input controller.
func (*InputController) Controls ¶
func (c *InputController) Controls(ctx context.Context, extra map[string]interface{}) ([]input.Control, error)
Controls lists the inputs of the gamepad.
func (*InputController) Events ¶
func (c *InputController) Events(ctx context.Context, extra map[string]interface{}) (map[input.Control]input.Event, error)
Events returns the a specified or random input.Event (the current state) for AbsoluteX.
func (*InputController) Reconfigure ¶ added in v0.2.36
func (c *InputController) Reconfigure(ctx context.Context, deps resource.Dependencies, conf resource.Config) error
Reconfigure updates the config of the controller.
func (*InputController) RegisterControlCallback ¶
func (c *InputController) RegisterControlCallback( ctx context.Context, control input.Control, triggers []input.EventType, ctrlFunc input.ControlFunction, extra map[string]interface{}, ) error
RegisterControlCallback registers a callback function to be executed on the specified trigger Event. The fake implementation will trigger the callback at a random or user-specified interval with a random or user-specified value.
func (*InputController) TriggerEvent ¶
func (c *InputController) TriggerEvent(ctx context.Context, event input.Event, extra map[string]interface{}) error
TriggerEvent allows directly sending an Event (such as a button press) from external code.