fake

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package fake implements a fake input controller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewInputController

func NewInputController(ctx context.Context, conf resource.Config, logger logging.Logger) (input.Controller, error)

NewInputController returns a fake input.Controller.

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

type InputController struct {
	resource.Named
	// contains filtered or unexported fields
}

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.

Jump to

Keyboard shortcuts

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