Documentation ¶
Overview ¶
Package input contains a gRPC based input controller client.
Package input provides human input, such as buttons, switches, knobs, gamepads, joysticks, keyboards, mice, etc.
Package input contains a gRPC based input controller service server.
Index ¶
- Constants
- Variables
- func CreateStatus(ctx context.Context, resource interface{}) (*pb.Status, error)
- func Named(name string) resource.Name
- func NamesFromRobot(r robot.Robot) []string
- func NewServer(s subtype.Service) pb.InputControllerServiceServer
- func WrapWithReconfigurable(r interface{}) (resource.Reconfigurable, error)
- type Control
- type ControlFunction
- type Controller
- type Event
- type EventType
- type Triggerable
Constants ¶
const SubtypeName = resource.SubtypeName("input_controller")
SubtypeName is a constant that identifies the component resource subtype string input.
Variables ¶
var Subtype = resource.NewSubtype( resource.ResourceNamespaceRDK, resource.ResourceTypeComponent, SubtypeName, )
Subtype is a constant that identifies the component resource subtype.
Functions ¶
func CreateStatus ¶
CreateStatus creates a status from the input controller.
func NamesFromRobot ¶
NamesFromRobot is a helper for getting all input controller names from the given Robot.
func NewServer ¶
func NewServer(s subtype.Service) pb.InputControllerServiceServer
NewServer constructs an input controller gRPC service server.
func WrapWithReconfigurable ¶
func WrapWithReconfigurable(r interface{}) (resource.Reconfigurable, error)
WrapWithReconfigurable wraps a Controller with a reconfigurable and locking interface.
Types ¶
type Control ¶
type Control string
Control identifies the input (specific Axis or Button) of a controller.
const ( // Axes. AbsoluteX Control = "AbsoluteX" AbsoluteY Control = "AbsoluteY" AbsoluteZ Control = "AbsoluteZ" AbsoluteRX Control = "AbsoluteRX" AbsoluteRY Control = "AbsoluteRY" AbsoluteRZ Control = "AbsoluteRZ" AbsoluteHat0X Control = "AbsoluteHat0X" AbsoluteHat0Y Control = "AbsoluteHat0Y" // Buttons. ButtonSouth Control = "ButtonSouth" ButtonEast Control = "ButtonEast" ButtonWest Control = "ButtonWest" ButtonNorth Control = "ButtonNorth" ButtonLT Control = "ButtonLT" ButtonRT Control = "ButtonRT" ButtonLT2 Control = "ButtonLT2" ButtonRT2 Control = "ButtonRT2" ButtonLThumb Control = "ButtonLThumb" ButtonRThumb Control = "ButtonRThumb" ButtonSelect Control = "ButtonSelect" ButtonStart Control = "ButtonStart" ButtonMenu Control = "ButtonMenu" ButtonRecord Control = "ButtonRecord" ButtonEStop Control = "ButtonEStop" )
Controls, to be expanded as new input devices are developed.
type ControlFunction ¶
ControlFunction is a callback passed to RegisterControlCallback.
type Controller ¶
type Controller interface { // GetControls returns a list of GetControls provided by the Controller GetControls(ctx context.Context) ([]Control, error) // LastEvent returns most recent Event for each input (which should be the current state) GetEvents(ctx context.Context) (map[Control]Event, error) // RegisterCallback registers a callback that will fire on given EventTypes for a given Control RegisterControlCallback(ctx context.Context, control Control, triggers []EventType, ctrlFunc ControlFunction) error generic.Generic }
Controller is a logical "container" more than an actual device Could be a single gamepad, or a collection of digitalInterrupts and analogReaders, a keyboard, etc.
func FromDependencies ¶
func FromDependencies(deps registry.Dependencies, name string) (Controller, error)
FromDependencies is a helper for getting the named input controller from a collection of dependencies.
func FromRobot ¶
func FromRobot(r robot.Robot, name string) (Controller, error)
FromRobot is a helper for getting the named input controller from the given Robot.
func NewClientFromConn ¶
func NewClientFromConn(ctx context.Context, conn rpc.ClientConn, name string, logger golog.Logger) Controller
NewClientFromConn constructs a new Client from connection passed in.
type Event ¶
type Event struct { Time time.Time Event EventType Control Control // Key or Axis Value float64 // 0 or 1 for buttons, -1.0 to +1.0 for axes }
Event is passed to the registered ControlFunction or returned by State().
type EventType ¶
type EventType string
EventType represents the type of input event, and is returned by LastEvent() or passed to ControlFunction callbacks.
const ( // Callbacks registered for this event will be called in ADDITION to other registered event callbacks. AllEvents EventType = "AllEvents" // Sent at controller initialization, and on reconnects. Connect EventType = "Connect" // If unplugged, or wireless/network times out. Disconnect EventType = "Disconnect" // Typical key press. ButtonPress EventType = "ButtonPress" // Key release. ButtonRelease EventType = "ButtonRelease" // Key is held down. This will likely be a repeated event. ButtonHold EventType = "ButtonHold" // Both up and down for convenience during registration, not typically emitted. ButtonChange EventType = "ButtonChange" // Absolute position is reported via Value, a la joysticks. PositionChangeAbs EventType = "PositionChangeAbs" // Relative position is reported via Value, a la mice, or simulating axes with up/down buttons. PositionChangeRel EventType = "PositionChangeRel" )
EventType list, to be expanded as new input devices are developed.
Directories ¶
Path | Synopsis |
---|---|
Package fake implements a fake input controller.
|
Package fake implements a fake input controller. |
Package gamepad implements a linux gamepad as an input controller.
|
Package gamepad implements a linux gamepad as an input controller. |
Package gpio implements a gpio/adc based input.Controller.
|
Package gpio implements a gpio/adc based input.Controller. |
Package mux implements a multiplexed input controller.
|
Package mux implements a multiplexed input controller. |
Package register registers all relevant inputs
|
Package register registers all relevant inputs |
Package webgamepad implements a web based input controller.
|
Package webgamepad implements a web based input controller. |