{"modulePath":"github.com/weakpixel/engine","version":"v0.0.0-20261205071607-94fff0387040","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package input\n\nPackage input turns keyboard, mouse, gamepad and touch input into named actions. Game code reads actions (\"jump\", \"move\"), never keys; which control drives an action is data.\n\nThe pieces:\n\n  - [Actions](#Actions): the action table, declared in Go (Button, Axis, Vec2).\n  - [Bindings](#Bindings): a bindings file ([BindingsFile](#BindingsFile), JSON) compiled against the actions: mapping contexts with bindings, composites, modifiers, processors, interactions and touch regions. [ParseBindings](#ParseBindings) reports every problem at once with GOD-style paths.\n  - [Router](#Router): polls a [Source](#Source) once per tick and evaluates every [Player](#Player): its devices, its stack of active mappings, its [Profile](#Profile) overrides. The result is one [State](#State) per player.\n  - [Profile](#Profile): per-player settings and rebinding overrides, saved as JSON.\n\nThe package imports only the standard library, so it runs headless: tests and replays drive it with [ManualSource](#ManualSource) and [ReplaySource](#ReplaySource). input/ebiteninput reads Ebiten; input/inputsys connects the Router to an ecs World and loads bindings files through the asset system. The guide is doc/guide/engine/input.md.\n\n## Constants\n\n```go\nconst (\n\tMaxRawButtons = 64\n\tMaxRawAxes    = 8\n)\n```\nLimits of the raw gamepad fallback (padraw:).\n\n```go\nconst (\n\t// MaxPads is the number of gamepads a Frame carries.\n\tMaxPads = 8\n\t// MaxTouches is the number of simultaneous touches a Frame carries.\n\tMaxTouches = 10\n)\n```\nFrame size limits.\n\n```go\nconst KeyCount = int(numKeys) - 1\n```\nKeyCount is the number of keys; valid keys are 1..KeyCount.\n\n```go\nconst MaxPlayers = 8\n```\nMaxPlayers is the largest number of player slots a Router has.\n\n```go\nconst TouchAny = 0xFFFF\n```\nTouchAny is the Code of touch:any, which is down while any touch is.\n\n## Variables\n\n```go\nvar (\n\tKeyEscapeControl = Control{Type: CtrlKey, Code: uint16(KeyEscape)}\n\tPadStartControl  = Control{Type: CtrlPadButton, Code: uint16(PadStart)}\n)\n```\nCommon controls, for Listen cancel lists and tests.\n\n## Functions\n\n```go\nfunc BindingsSchema() []byte\n```\nBindingsSchema returns schema/bindings.schema.json: the JSON shape of a bindings file in the GOD TypeSchema dialect. Tools such as \\`wpix schema\\` convert it for editors. The slice is a copy.\n\n## Types\n\n```go\ntype Action uint16\n```\nAction identifies one declared action. IDs are dense and start at 1; the zero Action means \"none\" and reads as zero everywhere.\n\n```go\ntype ActionOption func(*actionInfo)\n```\nActionOption changes how an action is declared.\n\n```go\nfunc AllowMods() ActionOption\n```\nAllowMods lets rebinding capture modifier+key combinations (Ctrl+S) for the action. Without it a captured key is bound without modifiers.\n\n```go\nfunc Delta() ActionOption\n```\nDelta marks a Vec2 action whose value is a per-tick delta (mouse look, touch drag). Its length may exceed 1, and the profile's sensitivity setting scales it.\n\n```go\ntype Actions struct {\n\t// contains filtered or unexported fields\n}\n```\nActions is the game's action table. Declare every action at startup (package-level vars are the usual place), then [Actions.Freeze](#Actions.Freeze) it before building a [Router](#Router) or parsing bindings. The zero value is ready to use.\n\nDeclaring panics with \"input: \" for an empty or duplicate name and after Freeze. Actions is not safe for concurrent declaration; once frozen it is read-only and safe to share (asset workers read it while decoding).\n\n```go\nfunc (a *Actions) AllowsMods(id Action) bool\n```\nAllowsMods reports whether the action was declared with [AllowMods](#AllowMods).\n\n```go\nfunc (a *Actions) Axis(name, doc string, opts ...ActionOption) Action\n```\nAxis declares an Axis action.\n\n```go\nfunc (a *Actions) Button(name, doc string, opts ...ActionOption) Action\n```\nButton declares a Button action and returns its ID. doc is shown in rebinding menus and generated docs.\n\n```go\nfunc (a *Actions) Doc(id Action) string\n```\nDoc returns the action's doc string.\n\n```go\nfunc (a *Actions) Freeze()\n```\nFreeze ends declaration. It is idempotent.\n\n```go\nfunc (a *Actions) Frozen() bool\n```\nFrozen reports whether Freeze was called.\n\n```go\nfunc (a *Actions) IsDelta(id Action) bool\n```\nIsDelta reports whether the action was declared with [Delta](#Delta).\n\n```go\nfunc (a *Actions) Kind(id Action) Kind\n```\nKind returns the action's kind.\n\n```go\nfunc (a *Actions) Len() int\n```\nLen returns the number of declared actions. Valid IDs are 1..Len.\n\n```go\nfunc (a *Actions) Lookup(name string) (Action, bool)\n```\nLookup returns the action declared under name.\n\n```go\nfunc (a *Actions) Name(id Action) string\n```\nName returns the action's name. Panics with \"input: unknown action\" for an ID that was not declared.\n\n```go\nfunc (a *Actions) Vec2(name, doc string, opts ...ActionOption) Action\n```\nVec2 declares a Vec2 action.\n\n```go\ntype AssignPolicy uint8\n```\nAssignPolicy decides which player a device drives.\n\n```go\nconst (\n\t// AssignSingle gives every device to player 0. Single-player games.\n\tAssignSingle AssignPolicy = iota\n\t// AssignJoin leaves devices unassigned until they press the join\n\t// action, which claims the lowest free player slot. Unassigned devices\n\t// drive the lobby player ([Router.Lobby]), so menus work before anyone\n\t// joined.\n\tAssignJoin\n)\n```\nAssign policies.\n\n```go\ntype BindingSpec struct {\n\t// Control is a single control (\"key:Space\", \"pad:leftstick\").\n\tControl string `json:\"control,omitempty\"`\n\t// Composite builds the value from several controls: \"axis\" (Neg, Pos),\n\t// \"dpad\" (Up, Down, Left, Right) or \"chord\" (Controls).\n\tComposite string `json:\"composite,omitempty\"`\n\tNeg       string `json:\"neg,omitempty\"`\n\tPos       string `json:\"pos,omitempty\"`\n\tUp        string `json:\"up,omitempty\"`\n\tDown      string `json:\"down,omitempty\"`\n\tLeft      string `json:\"left,omitempty\"`\n\tRight     string `json:\"right,omitempty\"`\n\t// Controls are the controls of a chord, 2 to 4.\n\tControls []string `json:\"controls,omitempty\"`\n\t// WhichWins decides axis and dpad composites when both directions of an\n\t// axis are down: \"\" or \"none\" gives 0, \"last\" the one pressed last.\n\tWhichWins string `json:\"whichWins,omitempty\"`\n\t// Mods are modifier groups (\"mod:ctrl\") that must be down.\n\tMods []string `json:\"mods,omitempty\"`\n\t// Processors run in order on the binding's value.\n\tProcessors []ProcessorSpec `json:\"processors,omitempty\"`\n\t// Interaction decides when a Button action fires; Axis and Vec2 actions\n\t// accept press and repeat. Absent means press.\n\tInteraction *InteractionSpec `json:\"interaction,omitempty\"`\n\t// Threshold is the value at which an analog control presses a Button\n\t// action. Zero means 0.5.\n\tThreshold float32 `json:\"threshold,omitempty\"`\n\t// Locked keeps the binding out of rebinding and conflict resolution.\n\tLocked bool `json:\"locked,omitempty\"`\n}\n```\nBindingSpec is one binding. Exactly one of Control and Composite is set.\n\n```go\ntype Bindings struct {\n\t// contains filtered or unexported fields\n}\n```\nBindings are compiled bindings: the default bindings of a game (from [ParseBindings](#ParseBindings)) or a player's effective bindings (defaults plus profile overrides). They are immutable once built and safe to share between players and goroutines.\n\n```go\nfunc CompileBindings(f BindingsFile, acts *Actions) (*Bindings, error)\n```\nCompileBindings validates and compiles a decoded bindings file, like [ParseBindings](#ParseBindings).\n\n```go\nfunc NewBindings(acts *Actions) *Bindings\n```\nNewBindings returns empty bindings for acts: every action reads zero. It is the placeholder while the bindings file loads. Panics with \"input: \" if acts is nil or not frozen.\n\n```go\nfunc ParseBindings(data []byte, acts *Actions) (*Bindings, error)\n```\nParseBindings decodes, validates and compiles a bindings file against acts. It reports every problem at once ([errors.Join](/errors#Join)), each prefixed with its path in the file:\n\n\t$.mappings.gameplay.bindings.jump[1].control: unknown control \"pad:soth\"\n\nPanics with \"input: \" if acts is nil or not frozen.\n\n```go\nfunc (b *Bindings) Actions() *Actions\n```\nActions returns the action table the bindings were compiled against.\n\n```go\nfunc (b *Bindings) ControlString(c Control) string\n```\nControlString returns the file form of c, with touch region names.\n\n```go\nfunc (b *Bindings) File() BindingsFile\n```\nFile returns the decoded file the bindings were compiled from. Treat it as read-only.\n\n```go\nfunc (b *Bindings) HasMapping(name string) bool\n```\nHasMapping reports whether the bindings define the mapping name.\n\n```go\nfunc (b *Bindings) MappingNames() []string\n```\nMappingNames returns the mapping names, sorted.\n\n```go\ntype BindingsFile struct {\n\t// Version is the format version, currently 1.\n\tVersion int `json:\"version\"`\n\t// Groups names sets of mappings that can be active at the same time.\n\t// Rebinding checks conflicts inside a mapping and its groups.\n\tGroups map[string][]string `json:\"groups,omitempty\"`\n\t// Mappings are the mapping contexts by name.\n\tMappings map[string]MappingSpec `json:\"mappings\"`\n}\n```\nBindingsFile is the JSON form of a bindings file (input/bindings.json): the default bindings a game ships. Decode it with [ParseBindings](#ParseBindings), which validates it against an [Actions](#Actions) table and compiles it. The JSON shape follows encoding/json rules and is described in the GOD TypeSchema subset by schema/bindings.schema.json.\n\n```go\ntype Capture struct {\n\tPlayer int\n\tTarget Slot\n\t// Control is the captured control, Mods the modifier groups held with\n\t// it (bit per Mod; only for actions declared with AllowMods).\n\tControl Control\n\tMods    uint8\n\t// Canceled is set when a cancel control ended the listen.\n\tCanceled bool\n}\n```\nCapture is the result of a listen, delivered in [Events.Captured](#Events.Captured).\n\n```go\ntype Conflict struct {\n\tSlot\n\tLocked bool\n}\n```\nConflict is a binding that uses the same control (with the same modifiers) as a rebind target, in the target's mapping or a mapping of one of its groups.\n\n```go\ntype Control struct {\n\tType ControlType\n\tPart Part\n\t// Code is the Key, Mod, MouseButton, PadButton, Stick, raw index or\n\t// touch region index (TouchAny for touch:any), depending on Type.\n\tCode uint16\n}\n```\nControl is one physical input of one device class: a key, a mouse button, a stick half, a touch region. It is 4 bytes, comparable and pointer-free. Files spell it as a string, see [ParseControl](#ParseControl) and [Control.String](#Control.String).\n\n```go\nfunc KeyControl(k Key) Control\n```\nKeyControl returns the control of key k.\n\n```go\nfunc MouseButtonControl(b MouseButton) Control\n```\nMouseButtonControl returns the control of mouse button b.\n\n```go\nfunc PadButtonControl(b PadButton) Control\n```\nPadButtonControl returns the control of gamepad button b.\n\n```go\nfunc ParseControl(s string, region func(name string) (uint16, bool)) (Control, error)\n```\nParseControl parses the file form of a control. region resolves a touch region name to its index; nil rejects every touch control except touch:any.\n\n```go\nfunc (c Control) Class() DeviceClass\n```\nClass returns the device class the control belongs to.\n\n```go\nfunc (c Control) IsZero() bool\n```\nIsZero reports whether c is the zero Control (\"no control\").\n\n```go\nfunc (c Control) String() string\n```\nString returns the file form of c (\"key:Space\", \"pad:leftstickY-\"). Touch regions print as \"touch:#\\\u003cindex\u003e\" because the name lives in the bindings; use [Bindings.ControlString](#Bindings.ControlString) for the authored form.\n\n```go\ntype ControlType uint8\n```\nControlType says which family a [Control](#Control) belongs to.\n\n```go\nconst (\n\tCtrlKey          ControlType = iota + 1 // key:\u003cKey\u003e\n\tCtrlMod                                 // mod:shift|ctrl|alt|meta (either side)\n\tCtrlMouseButton                         // mouse:left|right|middle|back|forward\n\tCtrlMouseWheel                          // mouse:wheel (Vec2, per tick)\n\tCtrlMouseDelta                          // mouse:delta (Vec2, logical px per tick)\n\tCtrlPadButton                           // pad:\u003cbutton\u003e, standard layout\n\tCtrlPadStick                            // pad:leftstick|rightstick\n\tCtrlPadRawButton                        // padraw:b\u003cn\u003e\n\tCtrlPadRawAxis                          // padraw:a\u003cn\u003e\n\tCtrlTouch                               // touch:\u003cregion\u003e or touch:any\n)\n```\nControl types.\n\n```go\ntype DeviceChanges struct {\n\tConnected    []DeviceInfo\n\tDisconnected []DeviceID\n}\n```\nDeviceChanges are the pads a [Source](#Source) saw connect and disconnect since its last Poll. The router resets it before each Poll.\n\n```go\ntype DeviceClass uint8\n```\nDeviceClass is a kind of device.\n\n```go\nconst (\n\tKeyboard DeviceClass = iota + 1\n\tMouse\n\tGamepad\n\tTouch\n)\n```\nDevice classes.\n\n```go\nfunc (c DeviceClass) String() string\n```\nString returns \"keyboard\", \"mouse\", \"gamepad\" or \"touch\".\n\n```go\ntype DeviceID uint16\n```\nDeviceID identifies a device for the life of a [Router](#Router). Keyboard, mouse and touch screen have fixed IDs; a [Source](#Source) assigns pad IDs (at least FirstPadDevice) and may reuse one only after its pad disconnected.\n\n```go\nconst (\n\tKeyboardDevice DeviceID = 1\n\tMouseDevice    DeviceID = 2\n\tTouchDevice    DeviceID = 3\n\tFirstPadDevice DeviceID = 16\n)\n```\nFixed device IDs.\n\n```go\ntype DeviceInfo struct {\n\tID    DeviceID\n\tClass DeviceClass\n\t// Name is the device's name (\"Xbox Wireless Controller\").\n\tName string\n\t// GUID is the SDL GUID of a gamepad; with Name it matches a reconnected\n\t// pad to its player.\n\tGUID   string\n\tFamily Family\n}\n```\nDeviceInfo describes a connected device.\n\n```go\ntype Events struct {\n\t// DevicesConnected and DevicesDisconnected list pad hot-plugs.\n\tDevicesConnected    []DeviceInfo\n\tDevicesDisconnected []DeviceInfo\n\t// PlayersJoined and PlayersLeft list player indices (Join policy and\n\t// Player.Leave).\n\tPlayersJoined []int\n\tPlayersLeft   []int\n\t// DevicesLost lists devices that disconnected while assigned to a\n\t// player; the player keeps its slot. DevicesRestored lists lost pads\n\t// that came back (same GUID and name) and were reattached.\n\tDevicesLost     []PlayerDevice\n\tDevicesRestored []PlayerDevice\n\t// ActiveDeviceChanged lists players whose last-used device changed:\n\t// time to switch prompt glyphs.\n\tActiveDeviceChanged []int\n\t// Captured holds the results of rebinding listens (see Player.Listen).\n\tCaptured []Capture\n}\n```\nEvents are what happened during one [Router.Update](#Router.Update). The slices are reset (length 0, capacity kept) at the start of every Update, so the pointer from [Router.Events](#Router.Events) is stable and the contents are valid until the next Update.\n\n```go\ntype Family uint8\n```\nFamily is a device family; prompts pick glyphs and names by it.\n\n```go\nconst (\n\tFamilyGeneric Family = iota\n\tFamilyXbox\n\tFamilyPlayStation\n\tFamilyNintendo\n\tFamilyKeyboard // keyboard and mouse\n\tFamilyTouch\n)\n```\nFamilies.\n\n```go\nfunc FamilyOf(name string) Family\n```\nFamilyOf guesses a gamepad's family from its name.\n\n```go\nfunc (f Family) String() string\n```\nString returns the family's short name (\"xbox\", \"kbm\"), as used in glyph keys.\n\n```go\ntype Frame struct {\n\t// Unfocused is set while the window has no keyboard focus; the router\n\t// then treats every control as up. The zero Frame is focused.\n\tUnfocused bool\n\t// Width and Height are the logical screen size, for touch regions.\n\tWidth, Height uint16\n\t// Keys holds the keys that are down.\n\tKeys  KeySet\n\tMouse MouseFrame\n\t// Pads[:NPads] are the connected gamepads.\n\tPads  [MaxPads]PadFrame\n\tNPads uint8\n\t// Touches[:NTouches] are the active touches.\n\tTouches  [MaxTouches]TouchFrame\n\tNTouches uint8\n}\n```\nFrame is one tick of raw device state. It is plain data with fixed-size arrays and no pointers: a [Source](#Source) fills it, tests build it by hand, a [Recorder](#Recorder) stores it. Positions are in logical (Layout) pixels.\n\n```go\ntype InteractionSpec struct {\n\t// Press is down while the control is (the default).\n\tPress bool `json:\"press,omitempty\"`\n\t// Release fires for one tick when the control goes up.\n\tRelease bool `json:\"release,omitempty\"`\n\t// Hold is down once the control has been down this long.\n\tHold string `json:\"hold,omitempty\"`\n\t// Tap fires for one tick on release if the control was down less than\n\t// this long.\n\tTap string `json:\"tap,omitempty\"`\n\t// DoubleTap fires on a second press within this window.\n\tDoubleTap string `json:\"doubleTap,omitempty\"`\n\t// Repeat fires on the press and then periodically while held.\n\tRepeat *RepeatSpec `json:\"repeat,omitempty\"`\n}\n```\nInteractionSpec is one interaction. Exactly one field is set. Durations are Go duration strings (\"350ms\").\n\n```go\ntype Key uint8\n```\nKey is a physical keyboard key, named by its position on a US layout (\"W\" stays the key below \"2\" on AZERTY). The names are the same as Ebiten's key names without the \"Key\" prefix; \\[KeyName] and [ParseKey](#ParseKey) convert. The zero Key is \"none\".\n\n```go\nconst (\n\tKeyA Key = iota + 1\n\tKeyB\n\tKeyC\n\tKeyD\n\tKeyE\n\tKeyF\n\tKeyG\n\tKeyH\n\tKeyI\n\tKeyJ\n\tKeyK\n\tKeyL\n\tKeyM\n\tKeyN\n\tKeyO\n\tKeyP\n\tKeyQ\n\tKeyR\n\tKeyS\n\tKeyT\n\tKeyU\n\tKeyV\n\tKeyW\n\tKeyX\n\tKeyY\n\tKeyZ\n\tKeyAltLeft\n\tKeyAltRight\n\tKeyArrowDown\n\tKeyArrowLeft\n\tKeyArrowRight\n\tKeyArrowUp\n\tKeyBackquote\n\tKeyBackslash\n\tKeyBackspace\n\tKeyBracketLeft\n\tKeyBracketRight\n\tKeyCapsLock\n\tKeyComma\n\tKeyContextMenu\n\tKeyControlLeft\n\tKeyControlRight\n\tKeyDelete\n\tKeyDigit0\n\tKeyDigit1\n\tKeyDigit2\n\tKeyDigit3\n\tKeyDigit4\n\tKeyDigit5\n\tKeyDigit6\n\tKeyDigit7\n\tKeyDigit8\n\tKeyDigit9\n\tKeyEnd\n\tKeyEnter\n\tKeyEqual\n\tKeyEscape\n\tKeyF1\n\tKeyF2\n\tKeyF3\n\tKeyF4\n\tKeyF5\n\tKeyF6\n\tKeyF7\n\tKeyF8\n\tKeyF9\n\tKeyF10\n\tKeyF11\n\tKeyF12\n\tKeyF13\n\tKeyF14\n\tKeyF15\n\tKeyF16\n\tKeyF17\n\tKeyF18\n\tKeyF19\n\tKeyF20\n\tKeyF21\n\tKeyF22\n\tKeyF23\n\tKeyF24\n\tKeyHome\n\tKeyInsert\n\tKeyIntlBackslash\n\tKeyMetaLeft\n\tKeyMetaRight\n\tKeyMinus\n\tKeyNumLock\n\tKeyNumpad0\n\tKeyNumpad1\n\tKeyNumpad2\n\tKeyNumpad3\n\tKeyNumpad4\n\tKeyNumpad5\n\tKeyNumpad6\n\tKeyNumpad7\n\tKeyNumpad8\n\tKeyNumpad9\n\tKeyNumpadAdd\n\tKeyNumpadDecimal\n\tKeyNumpadDivide\n\tKeyNumpadEnter\n\tKeyNumpadEqual\n\tKeyNumpadMultiply\n\tKeyNumpadSubtract\n\tKeyPageDown\n\tKeyPageUp\n\tKeyPause\n\tKeyPeriod\n\tKeyPrintScreen\n\tKeyQuote\n\tKeyScrollLock\n\tKeySemicolon\n\tKeyShiftLeft\n\tKeyShiftRight\n\tKeySlash\n\tKeySpace\n\tKeyTab\n)\n```\nKeys. The order is part of the recording format (see [Recorder](#Recorder)); append new keys at the end.\n\n```go\nfunc ParseKey(name string) (Key, bool)\n```\nParseKey returns the key named name (case-sensitive, as [Key.String](#Key.String) writes it).\n\n```go\nfunc (k Key) String() string\n```\nString returns the key's name (\"Space\", \"ArrowUp\"), or \"\" for an invalid key.\n\n```go\ntype KeySet [2]uint64\n```\nKeySet is the set of keys that are down: one bit per key, no pointers, so a Frame stays a plain value that can be copied and recorded.\n\n```go\nfunc (s *KeySet) Clear(k Key)\n```\nClear removes k from the set.\n\n```go\nfunc (s *KeySet) Empty() bool\n```\nEmpty reports whether no key is down.\n\n```go\nfunc (s *KeySet) Has(k Key) bool\n```\nHas reports whether k is in the set.\n\n```go\nfunc (s *KeySet) Reset()\n```\nReset empties the set.\n\n```go\nfunc (s *KeySet) Set(k Key)\n```\nSet adds k to the set. The zero Key is ignored.\n\n```go\ntype Kind uint8\n```\nKind says what value an action carries.\n\n```go\nconst (\n\t// Button is digital: down or up, with edges and held ticks. Analog\n\t// controls press it when they cross the binding's threshold.\n\tButton Kind = iota + 1\n\t// Axis is one float: [-1, 1] from an axis composite or a stick half,\n\t// [0, 1] from a trigger.\n\tAxis\n\t// Vec2 is two floats: a stick, a dpad composite, the mouse delta.\n\tVec2\n)\n```\nAction kinds.\n\n```go\nfunc (k Kind) String() string\n```\nString returns \"Button\", \"Axis\" or \"Vec2\".\n\n```go\ntype ListenOptions struct {\n\t// Target is the slot being rebound. Its Class decides which devices\n\t// may be captured: kbm takes keys and mouse buttons, gamepad takes pad\n\t// buttons, sticks and triggers. Touch slots cannot be captured.\n\tTarget Slot\n\t// Cancel are controls that end listening without a result. nil means\n\t// Escape and the Start button.\n\tCancel []Control\n}\n```\nListenOptions configure [Player.Listen](#Player.Listen).\n\n```go\ntype ManualSource struct {\n\tFrame   Frame\n\tChanges DeviceChanges\n\t// Names maps keys to layout labels for KeyName; nil uses Key.String.\n\tNames map[Key]string\n\t// Vibrations records every Vibrate call.\n\tVibrations []Vibration\n}\n```\nManualSource is a [Source](#Source) whose next frame the caller sets: tests, bots, network clients. Set Frame and Changes before each Router.Update. Changes are delivered once and then cleared; Frame stays until changed.\n\n```go\nfunc (m *ManualSource) KeyName(k Key) string\n```\nKeyName implements [Source](#Source).\n\n```go\nfunc (m *ManualSource) Poll(f *Frame, ch *DeviceChanges)\n```\nPoll implements [Source](#Source).\n\n```go\nfunc (m *ManualSource) Vibrate(id DeviceID, strong, weak float32, d time.Duration)\n```\nVibrate implements [Source](#Source).\n\n```go\ntype MappingSpec struct {\n\t// Priority orders active mappings: higher is evaluated first.\n\tPriority int `json:\"priority,omitempty\"`\n\t// Block stops evaluation of every mapping below this one.\n\tBlock bool `json:\"block,omitempty\"`\n\t// StrictMods makes bindings without mods ignore their control while\n\t// any modifier the binding does not list is down.\n\tStrictMods bool `json:\"strictMods,omitempty\"`\n\t// Bindings lists the bindings of each action by action name.\n\tBindings map[string][]BindingSpec `json:\"bindings\"`\n\t// Touch declares the touch regions that touch:\u003cname\u003e controls of this\n\t// mapping refer to.\n\tTouch map[string]TouchRegionSpec `json:\"touch,omitempty\"`\n}\n```\nMappingSpec is one mapping context in a [BindingsFile](#BindingsFile).\n\n```go\ntype Mod uint8\n```\nMod is a modifier group: either the left or the right key.\n\n```go\nconst (\n\tModShift Mod = iota\n\tModCtrl\n\tModAlt\n\tModMeta\n)\n```\nModifier groups, also used as bits in a binding's modifier mask.\n\n```go\ntype MouseButton uint8\n```\nMouseButton is a mouse button. The values match Ebiten's MouseButton0..4.\n\n```go\nconst (\n\tMouseLeft MouseButton = iota\n\tMouseMiddle\n\tMouseRight\n\tMouseBack\n\tMouseForward\n)\n```\nMouse buttons.\n\n```go\ntype MouseFrame struct {\n\t// X and Y are the cursor position in logical pixels.\n\tX, Y float32\n\t// WheelX and WheelY are this tick's wheel movement.\n\tWheelX, WheelY float32\n\t// Buttons has bit b set while MouseButton b is down.\n\tButtons uint8\n}\n```\nMouseFrame is the mouse part of a [Frame](#Frame).\n\n```go\nfunc (m *MouseFrame) Down(b MouseButton) bool\n```\nDown reports whether button b is down.\n\n```go\nfunc (m *MouseFrame) SetDown(b MouseButton, down bool)\n```\nSetDown sets or clears button b.\n\n```go\ntype Options struct {\n\t// Actions is the frozen action table. Required.\n\tActions *Actions\n\t// Bindings are the default bindings. nil means [NewBindings]: nothing\n\t// is bound until [Router.SetBindings].\n\tBindings *Bindings\n\t// Players is the number of player slots, 1..MaxPlayers. 0 means 1.\n\tPlayers int\n\t// Assign is the device assignment policy.\n\tAssign AssignPolicy\n\t// JoinAction is the Button action that claims a slot (AssignJoin).\n\tJoinAction Action\n\t// TPS is the tick rate interaction durations are converted with. 0\n\t// means 60.\n\tTPS int\n\t// OnError receives profile problems that are skipped (an override for\n\t// an action that no longer exists). nil logs them.\n\tOnError func(error)\n}\n```\nOptions configure a [Router](#Router).\n\n```go\ntype Override struct {\n\tMapping string `json:\"mapping\"`\n\tAction  string `json:\"action\"`\n\t// Class is \"kbm\", \"gamepad\" or \"touch\".\n\tClass string `json:\"class\"`\n\tSlot  int    `json:\"slot\"`\n\t// Part names a composite part (\"up\", \"neg\"); Control or Unbind then\n\t// apply to that part only.\n\tPart string `json:\"part,omitempty\"`\n\t// Binding replaces the whole binding (or adds it, past the last slot).\n\tBinding *BindingSpec `json:\"binding,omitempty\"`\n\t// Control replaces the control of Part.\n\tControl string `json:\"control,omitempty\"`\n\t// Unbind removes the binding or part on purpose.\n\tUnbind bool `json:\"unbind,omitempty\"`\n}\n```\nOverride changes one slot: the Slot-th binding of class Class of an action in a mapping. Exactly one of Binding, Control and Unbind is set.\n\n```go\ntype PadButton uint8\n```\nPadButton is a gamepad button in the standard layout, named by position: South is A on Xbox, Cross on PlayStation and B on Nintendo pads. The order matches Ebiten's StandardGamepadButton.\n\n```go\nconst (\n\tPadSouth  PadButton = iota // right cluster, bottom\n\tPadEast                    // right cluster, right\n\tPadWest                    // right cluster, left\n\tPadNorth                   // right cluster, top\n\tPadLB                      // front top left (bumper)\n\tPadRB                      // front top right\n\tPadLT                      // front bottom left (trigger, analog 0..1)\n\tPadRT                      // front bottom right (trigger, analog 0..1)\n\tPadSelect                  // center left (Back, View, Share, Minus)\n\tPadStart                   // center right (Start, Menu, Options, Plus)\n\tPadLS                      // left stick press\n\tPadRS                      // right stick press\n\tPadUp                      // dpad\n\tPadDown\n\tPadLeft\n\tPadRight\n\tPadHome // center (Guide, PS, Home)\n\tPadButtonCount\n)\n```\nGamepad buttons.\n\n```go\ntype PadFrame struct {\n\t// Device identifies the pad; it must match a connected DeviceInfo.\n\tDevice DeviceID\n\t// Standard is set when the pad has a standard-layout mapping, so\n\t// Buttons, Triggers and Axes are meaningful. Otherwise only the raw\n\t// fields are.\n\tStandard bool\n\t// Buttons has bit b set while PadButton b is down.\n\tButtons uint32\n\t// Triggers are LT and RT, 0..1.\n\tTriggers [2]float32\n\t// Axes are left X, left Y, right X, right Y, -1..1, Y down positive.\n\tAxes [4]float32\n\t// RawButtons and RawAxes are the unmapped values, for padraw: controls.\n\tRawButtons uint64\n\tRawAxes    [MaxRawAxes]float32\n}\n```\nPadFrame is one gamepad in a [Frame](#Frame).\n\n```go\nfunc (p *PadFrame) Down(b PadButton) bool\n```\nDown reports whether button b is down.\n\n```go\nfunc (p *PadFrame) SetDown(b PadButton, down bool)\n```\nSetDown sets or clears button b.\n\n```go\ntype Part uint8\n```\nPart selects one component of a two-dimensional or signed control.\n\n```go\nconst (\n\tPartWhole Part = iota\n\tPartX          // -1..1\n\tPartY          // -1..1, down positive\n\tPartXPos       // 0..1, right half\n\tPartXNeg       // 0..1, left half\n\tPartYPos       // 0..1, lower half\n\tPartYNeg       // 0..1, upper half\n)\n```\nParts. PartWhole is the control's natural value.\n\n```go\ntype Player struct {\n\t// contains filtered or unexported fields\n}\n```\nPlayer is one player slot: assigned devices, a stack of active mappings, a profile and the resulting [State](#State). Get one with [Router.Player](#Router.Player) or [Router.Lobby](#Router.Lobby).\n\n```go\nfunc (p *Player) ActiveDevice() DeviceInfo\n```\nActiveDevice returns the device that last produced input for this player: prompts follow its Family. Before any input it is the first assigned device.\n\n```go\nfunc (p *Player) Assign(id DeviceID)\n```\nAssign gives device id to p, taking it from whoever has it, and marks p joined. Unknown devices are ignored.\n\n```go\nfunc (p *Player) Bind(t Slot, c Control, mods uint8, policy ResolvePolicy) error\n```\nBind binds control c (with modifiers mods) to slot t, records the change as profile overrides and rebuilds the player's bindings. Conflicts (see [Player.Conflicts](#Player.Conflicts)) are resolved by policy. It returns an error, and changes nothing, when the mapping or slot class doesn't fit, the target is locked, a Replace or Swap would touch a locked binding, or the target is a composite and t.Part is empty.\n\n```go\nfunc (p *Player) Bindings() *Bindings\n```\nBindings returns the player's effective bindings: the defaults with the profile's overrides applied.\n\n```go\nfunc (p *Player) CancelListen()\n```\nCancelListen stops listening without a result.\n\n```go\nfunc (p *Player) Conflicts(t Slot, c Control, mods uint8) []Conflict\n```\nConflicts returns the bindings that already use c with modifiers mods in the target's mapping and the mappings that share a group with it. The target slot itself is not reported.\n\n```go\nfunc (p *Player) ConsumePress(a Action)\n```\nConsumePress uses up the press of the Button action a: [State.PressedWithin](#State.PressedWithin) reports false until a goes down again, and [State.JustPressed](#State.JustPressed) reports false for the rest of this tick, so a second reader does not act on the same press. Down and HeldTicks are unchanged, and so is [Router.Any](#Router.Any). Panics like the State queries for an unknown action or one that is not a Button.\n\n```go\nfunc (p *Player) Devices() []DeviceID\n```\nDevices returns the devices assigned to p. Valid until the next change.\n\n```go\nfunc (p *Player) Index() int\n```\nIndex returns the slot index, or -1 for the lobby.\n\n```go\nfunc (p *Player) IsActive(name string) bool\n```\nIsActive reports whether the mapping name is on the stack.\n\n```go\nfunc (p *Player) Joined() bool\n```\nJoined reports whether the slot is taken. With AssignSingle player 0 is always joined.\n\n```go\nfunc (p *Player) Leave()\n```\nLeave returns all of p's devices to the lobby, forgets its lost devices and frees the slot (PlayersLeft event). The lobby cannot leave.\n\n```go\nfunc (p *Player) Listen(opts ListenOptions)\n```\nListen starts capturing the next control for opts.Target. While listening, every action of the player reads zero, and presses buffered before (see [State.PressedWithin](#State.PressedWithin)) are forgotten. It first waits until every capturable control is up (so the click on \"Rebind\" is not captured), then takes the first control that goes down. The result arrives in [Events.Captured](#Events.Captured) of a later tick.\n\nPanics with \"input: \" if the player is already listening, the target action is not declared, or the target class is touch.\n\n```go\nfunc (p *Player) Listening() bool\n```\nListening reports whether the player is listening.\n\n```go\nfunc (p *Player) Mappings() []string\n```\nMappings returns the active mapping names in push order. Valid until the next change.\n\n```go\nfunc (p *Player) Pop(name string)\n```\nPop removes the mapping name from the stack, wherever it is. It is a no-op if the mapping is not active.\n\n```go\nfunc (p *Player) Profile() *Profile\n```\nProfile returns the player's profile. Settings may be changed in place and apply at the next Update; after changing Overrides directly, call SetProfile.\n\n```go\nfunc (p *Player) Push(name string)\n```\nPush activates the mapping name on top of the stack (moving it to the top if it is active already). Mappings the bindings do not define are kept on the stack and stay inactive until bindings that define them are set. The change takes effect at the next Update, so every system in a tick sees the same state.\n\n```go\nfunc (p *Player) Reset(mapping string, a Action)\n```\nReset drops the player's overrides of action a in mapping, so the defaults apply again.\n\n```go\nfunc (p *Player) ResetAll()\n```\nResetAll drops every override of the player. Settings are kept.\n\n```go\nfunc (p *Player) Rumble(strong, weak float32, d time.Duration)\n```\nRumble asks the player's gamepads to vibrate with motor strengths 0..1. Requests within one tick merge to the strongest; the next Update sends them, scaled by the profile's Vibration setting.\n\n```go\nfunc (p *Player) SetMappings(names ...string)\n```\nSetMappings replaces the stack.\n\n```go\nfunc (p *Player) SetProfile(prof *Profile)\n```\nSetProfile replaces the player's profile (nil means an empty one) and rebuilds its bindings. Overrides that don't apply are skipped and reported to Options.OnError.\n\n```go\nfunc (p *Player) Slots(mapping string, a Action) []SlotInfo\n```\nSlots lists the bindings of action a in mapping, in slot order per class.\n\n```go\nfunc (p *Player) State() *State\n```\nState returns the player's action state. The pointer is stable for the life of the Router.\n\n```go\nfunc (p *Player) Unassign(id DeviceID)\n```\nUnassign returns device id to the lobby.\n\n```go\ntype PlayerDevice struct {\n\tPlayer int\n\tDevice DeviceInfo\n}\n```\nPlayerDevice pairs a player index with a device.\n\n```go\ntype Pointer struct {\n\tX, Y float32\n\t// Valid is false when the player has neither mouse nor touch.\n\tValid bool\n\t// Touch is set when the position comes from a touch.\n\tTouch bool\n}\n```\nPointer is a screen position in logical pixels.\n\n```go\ntype ProcessorSpec struct {\n\t// Deadzone zeroes values below it and rescales the rest to start at 0:\n\t// radial for Vec2, per axis for Axis.\n\tDeadzone *float32 `json:\"deadzone,omitempty\"`\n\t// Max is the value that maps to 1 (default 1).\n\tMax *float32 `json:\"max,omitempty\"`\n\t// Invert negates \"x\", \"y\" or \"xy\".\n\tInvert string `json:\"invert,omitempty\"`\n\t// Scale multiplies: one value for both axes or [x, y].\n\tScale []float32 `json:\"scale,omitempty\"`\n\t// Normalize clamps a Vec2's length to 1.\n\tNormalize bool `json:\"normalize,omitempty\"`\n\t// Sensitivity applies the profile's look settings: Sensitivity and\n\t// InvertY.\n\tSensitivity bool `json:\"sensitivity,omitempty\"`\n\t// Curve is \"linear\", \"quadratic\" or \"cubic\": finer control near the\n\t// center.\n\tCurve string `json:\"curve,omitempty\"`\n}\n```\nProcessorSpec is one processor. Exactly one field is set (Max only together with Deadzone).\n\n```go\ntype Profile struct {\n\t// Version is the format version, currently 1. Marshal sets it.\n\tVersion   int        `json:\"version\"`\n\tSettings  Settings   `json:\"settings\"`\n\tOverrides []Override `json:\"overrides,omitempty\"`\n}\n```\nProfile is one player's input preferences: settings plus binding overrides on top of the default bindings. It is also the JSON form of a profile file (input.json in the user's config directory); see [ParseProfile](#ParseProfile) and [Profile.Marshal](#Profile.Marshal). Only the diff to the defaults is stored, so a changed default reaches every action the player never rebound.\n\n```go\nfunc ParseProfile(data []byte) (*Profile, error)\n```\nParseProfile decodes and checks a profile file, reporting every problem at once. Overrides that name a mapping or action the bindings don't have are not errors here: they are skipped (and reported to Options.OnError) when the profile is applied, so old saves still load.\n\n```go\nfunc (p *Profile) Marshal() ([]byte, error)\n```\nMarshal returns the profile as indented JSON, with Version set to 1.\n\n```go\ntype Recorder struct {\n\n\t// MaxTicks caps the recording: when it is exceeded the oldest entries\n\t// are dropped. 0 means no limit.\n\tMaxTicks int\n\t// contains filtered or unexported fields\n}\n```\nRecorder keeps the raw input of every tick, for replays, bug reports and simulation tests. Attach it with [Router.Record](#Router.Record); play it back with [NewReplaySource](#NewReplaySource). Because every interaction is counted in ticks, a replay reproduces the same State sequence.\n\nTicks whose frame equals the previous one and carry no device changes are stored as a repeat count, so idle stretches cost nothing. A changed tick appends one entry (a few hundred bytes), which allocates while recording.\n\n```go\nfunc ReadRecording(rd io.Reader) (*Recorder, error)\n```\nReadRecording reads a recording written by [Recorder.WriteTo](#Recorder.WriteTo).\n\n```go\nfunc (r *Recorder) Ticks() int\n```\nTicks returns the number of recorded ticks.\n\n```go\nfunc (r *Recorder) WriteTo(w io.Writer) (int64, error)\n```\nWriteTo writes the recording with encoding/gob.\n\n```go\ntype RepeatSpec struct {\n\t// Delay is the time from the press to the first repeat.\n\tDelay string `json:\"delay\"`\n\t// Every is the time between repeats.\n\tEvery string `json:\"every\"`\n}\n```\nRepeatSpec configures the repeat interaction.\n\n```go\ntype ReplaySource struct {\n\n\t// Names maps keys to layout labels for KeyName; nil uses Key.String.\n\tNames map[Key]string\n\t// contains filtered or unexported fields\n}\n```\nReplaySource plays a [Recorder](#Recorder) back as a [Source](#Source). After the last tick it keeps returning the last frame with every control released.\n\n```go\nfunc NewReplaySource(rec *Recorder) *ReplaySource\n```\nNewReplaySource returns a source that replays rec from its first tick.\n\n```go\nfunc (s *ReplaySource) Done() bool\n```\nDone reports whether every recorded tick has been played.\n\n```go\nfunc (s *ReplaySource) KeyName(k Key) string\n```\nKeyName implements [Source](#Source).\n\n```go\nfunc (s *ReplaySource) Poll(f *Frame, ch *DeviceChanges)\n```\nPoll implements [Source](#Source).\n\n```go\nfunc (s *ReplaySource) Vibrate(DeviceID, float32, float32, time.Duration)\n```\nVibrate implements [Source](#Source); a replay does not rumble.\n\n```go\ntype ResolvePolicy uint8\n```\nResolvePolicy decides what [Player.Bind](#Player.Bind) does with conflicts.\n\n```go\nconst (\n\t// Keep leaves conflicting bindings as they are: both actions fire.\n\tKeep ResolvePolicy = iota\n\t// Replace unbinds the conflicting bindings.\n\tReplace\n\t// Swap gives the conflicting bindings the target's old control.\n\tSwap\n)\n```\nConflict policies.\n\n```go\ntype Router struct {\n\t// contains filtered or unexported fields\n}\n```\nRouter turns raw device input into per-player action [State](#State). It is the World resource of the input system: [Router.Update](#Router.Update) runs once per tick (inputsys.InputSystem does it), systems read player states.\n\nA Router is single-goroutine, like the World.\n\n```go\nfunc NewRouter(src Source, opts Options) *Router\n```\nNewRouter returns a Router reading src. Panics with \"input: \" if src is nil, Options.Actions is nil or not frozen, Players is out of range, or the Join policy has no Button JoinAction.\n\n```go\nfunc (r *Router) Actions() *Actions\n```\nActions returns the action table.\n\n```go\nfunc (r *Router) Any() *State\n```\nAny returns the combined state of every joined player and the lobby: buttons are ORed, axes take the largest magnitude. For title screens and \"press any button\" prompts. Edges are computed on the combined value.\n\n```go\nfunc (r *Router) BindingName(c Control, mods uint8, fam Family) string\n```\nBindingName is ControlName with the modifiers in front: \"Ctrl+S\".\n\n```go\nfunc (r *Router) Bindings() *Bindings\n```\nBindings returns the default bindings.\n\n```go\nfunc (r *Router) ControlName(c Control, fam Family) string\n```\nControlName returns a label for c in prompts and rebinding menus. Keys use the current keyboard layout (the key at the US \"Q\" position shows \"A\" on AZERTY); gamepad buttons use the family's names (\"A\" on Xbox, \"Cross\" on PlayStation); FamilyGeneric uses Xbox names.\n\n```go\nfunc (r *Router) Device(id DeviceID) (DeviceInfo, bool)\n```\nDevice returns the info of a connected device.\n\n```go\nfunc (r *Router) Devices() []DeviceInfo\n```\nDevices returns the connected devices. Valid until the next Update.\n\n```go\nfunc (r *Router) Events() *Events\n```\nEvents returns this tick's events. The pointer is stable.\n\n```go\nfunc (r *Router) Frame() *Frame\n```\nFrame returns the raw frame of the current tick (after focus handling).\n\n```go\nfunc (r *Router) GlyphKey(c Control, fam Family) string\n```\nGlyphKey returns a stable key for the prompt glyph of c on a device of family fam: \"\\\u003cfamily\u003e/\\\u003ccontrol\u003e\" with ':' replaced by '\\_', for example \"xbox/pad\\_south\" or \"kbm/key\\_Space\". Games map it to a sprite in their prompt atlas.\n\n```go\nfunc (r *Router) Lobby() *Player\n```\nLobby returns the player that owns every unassigned device. With AssignSingle it owns nothing. Push mappings on it like on any player (title and join screens).\n\n```go\nfunc (r *Router) Player(i int) *Player\n```\nPlayer returns player slot i. Panics with \"input: player index out of range\".\n\n```go\nfunc (r *Router) Players() int\n```\nPlayers returns the number of player slots.\n\n```go\nfunc (r *Router) Record(rec *Recorder)\n```\nRecord makes every following Update append its raw input to rec; nil stops recording.\n\n```go\nfunc (r *Router) SetBindings(b *Bindings)\n```\nSetBindings replaces the default bindings (a loaded or hot-reloaded file). Every player's profile is applied again; action states are kept, so held actions don't fire a new press. Panics with \"input: \" if b was compiled for another Actions table.\n\n```go\nfunc (r *Router) Source() Source\n```\nSource returns the source the router polls.\n\n```go\nfunc (r *Router) TPS() int\n```\nTPS returns the tick rate durations are converted with.\n\n```go\nfunc (r *Router) Tick() uint64\n```\nTick returns the number of completed Updates.\n\n```go\nfunc (r *Router) Update()\n```\nUpdate polls the source once and evaluates every player. Call it once per tick, before any system reads a State. 0 allocs in steady state.\n\n```go\ntype Settings struct {\n\t// Deadzone replaces the deadzone of every deadzone processor when it\n\t// is greater than 0 (and below the processor's max).\n\tDeadzone float32 `json:\"deadzone,omitempty\"`\n\t// InvertY flips Y in bindings with the sensitivity processor.\n\tInvertY bool `json:\"invertY,omitempty\"`\n\t// Sensitivity scales bindings with the sensitivity processor. Zero\n\t// means 1.\n\tSensitivity float32 `json:\"sensitivity,omitempty\"`\n\t// Vibration scales rumble. Zero means 1; negative turns it off.\n\tVibration float32 `json:\"vibration,omitempty\"`\n}\n```\nSettings are per-player options read every tick, so changing them takes effect at the next Update without rebuilding anything.\n\n```go\ntype Slot struct {\n\tMapping string\n\tAction  Action\n\tClass   SlotClass\n\tSlot    int\n\tPart    string\n}\n```\nSlot names one rebindable slot: the Slot-th binding of class Class of an action in a mapping, or one Part of it (\"up\" of a dpad, \"neg\" of an axis).\n\n```go\ntype SlotClass uint8\n```\nSlotClass groups bindings for rebinding menus: each action has numbered slots per class (keyboard and mouse primary and secondary, gamepad).\n\n```go\nconst (\n\tSlotKBM SlotClass = iota + 1 // keyboard and mouse\n\tSlotGamepad\n\tSlotTouch\n)\n```\nSlot classes.\n\n```go\nfunc ParseSlotClass(s string) (SlotClass, bool)\n```\nParseSlotClass is the inverse of [SlotClass.String](#SlotClass.String).\n\n```go\nfunc SlotClassOf(c DeviceClass) SlotClass\n```\nSlotClassOf returns the slot class a device class binds through: keyboard and mouse share kbm. Use it to rebind for the player's active device: SlotClassOf(p.ActiveDevice().Class).\n\n```go\nfunc (c SlotClass) String() string\n```\nString returns \"kbm\", \"gamepad\" or \"touch\".\n\n```go\ntype SlotInfo struct {\n\tSlot\n\t// Control is the control of a single binding, Mods its modifiers.\n\tControl Control\n\tMods    uint8\n\t// Parts are the part names and controls of a composite.\n\tParts    []string\n\tControls []Control\n\tLocked   bool\n\t// Unbound is set for a slot the player cleared.\n\tUnbound bool\n}\n```\nSlotInfo describes one binding of an action for a rebinding menu.\n\n```go\ntype Source interface {\n\t// Poll fills f with the current device state (f is zeroed first) and\n\t// appends pad connects and disconnects to ch.\n\tPoll(f *Frame, ch *DeviceChanges)\n\t// KeyName returns the label of k on the current keyboard layout, or \"\"\n\t// when unknown.\n\tKeyName(k Key) string\n\t// Vibrate rumbles the pad d for duration d with motor strengths 0..1.\n\tVibrate(id DeviceID, strong, weak float32, d time.Duration)\n}\n```\nSource produces Frames. ebiteninput.Source reads Ebiten; [ManualSource](#ManualSource) and [ReplaySource](#ReplaySource) serve tests and replays. All methods are called on the game goroutine.\n\n```go\ntype State struct {\n\t// contains filtered or unexported fields\n}\n```\nState is one player's action values for the current tick. It is written by [Router.Update](#Router.Update) and read-only to game code; the pointer from [Player.State](#Player.State) is stable for the life of the Router, so systems cache it.\n\nQueries are an index and a mask: 0 allocs. Asking for an action of the wrong kind panics with \\`input: action \"jump\" is Button, not Vec2\\`; an ID that was never declared panics with \"input: unknown action\". Actions the bindings never mention read as zero.\n\n```go\nfunc (s *State) Axis(a Action) float32\n```\nAxis returns the value of the Axis action a.\n\n```go\nfunc (s *State) Down(a Action) bool\n```\nDown reports whether the Button action a is down.\n\n```go\nfunc (s *State) HeldTicks(a Action) uint32\n```\nHeldTicks returns for how many ticks a has been down, counting this one; 0 while it is up.\n\n```go\nfunc (s *State) JustPressed(a Action) bool\n```\nJustPressed reports whether a went down this tick.\n\n```go\nfunc (s *State) JustReleased(a Action) bool\n```\nJustReleased reports whether a went up this tick. It also fires when a mapping that held a down was blocked or popped.\n\n```go\nfunc (s *State) Pointer() Pointer\n```\nPointer returns the pointer of this player: the mouse cursor when the player has the mouse, else the first touch.\n\n```go\nfunc (s *State) PressedWithin(a Action, ticks uint32) bool\n```\nPressedWithin reports whether a went down in the last ticks ticks, counting this one, and that press was not consumed with [Player.ConsumePress](#Player.ConsumePress). PressedWithin(a, 1) equals JustPressed(a); 0 ticks is always false. Use it for input buffering: a Jump pressed a few ticks before landing still jumps.\n\n```go\nfunc (s *State) Progress(a Action) float32\n```\nProgress returns how far a hold interaction of a is, 0..1, for a fill ring.\n\n```go\nfunc (s *State) Strength(a Action) float32\n```\nStrength returns how far the strongest binding of a is pressed, 0..1: 1 for digital controls, the trigger or stick value for analog ones.\n\n```go\nfunc (s *State) Touch() []TouchControl\n```\nTouch returns the live geometry of the touch regions of this player's active mappings, for drawing virtual controls. Empty unless the player has the touch screen. Valid until the next Update.\n\n```go\nfunc (s *State) Vec2(a Action) (x, y float32)\n```\nVec2 returns the value of the Vec2 action a. Y is down positive.\n\n```go\ntype Stick uint8\n```\nStick is a gamepad stick.\n\n```go\nconst (\n\tLeftStick Stick = iota\n\tRightStick\n)\n```\nSticks.\n\n```go\ntype TouchControl struct {\n\t// Name and Mapping identify the region in the bindings file.\n\tName, Mapping string\n\tKind          TouchKind\n\t// X0, Y0, X1, Y1 bound the region.\n\tX0, Y0, X1, Y1 float32\n\t// Circle is set for circular regions; CX, CY, R are then the circle.\n\t// For sticks CX, CY is the stick's base and R its travel.\n\tCircle    bool\n\tCX, CY, R float32\n\t// KnobX, KnobY is where a stick's knob is drawn.\n\tKnobX, KnobY float32\n\t// Pressed is set while a touch owns the region.\n\tPressed bool\n}\n```\nTouchControl is the live geometry of one touch region, in logical pixels, for drawing virtual controls (inputsys.TouchControlsExtract does).\n\n```go\ntype TouchFrame struct {\n\t// ID is stable while the finger stays down.\n\tID   int32\n\tX, Y float32\n}\n```\nTouchFrame is one active touch in a [Frame](#Frame).\n\n```go\ntype TouchKind uint8\n```\nTouchKind is the kind of a touch region.\n\n```go\nconst (\n\t// TouchButton is digital: down while a touch that started in it lasts.\n\tTouchButton TouchKind = iota\n\t// TouchStick is a Vec2 from the stick's base to the touch, clamped to\n\t// its radius.\n\tTouchStick\n\t// TouchDrag is a Vec2 delta in logical pixels per tick, like the mouse.\n\tTouchDrag\n)\n```\nTouch region kinds.\n\n```go\ntype TouchRegionSpec struct {\n\t// Kind is \"button\", \"stick\" or \"drag\".\n\tKind string `json:\"kind\"`\n\t// Area is [x0, y0, x1, y1]. One of Area and Circle is required.\n\tArea []float32 `json:\"area,omitempty\"`\n\t// Circle is [cx, cy, r].\n\tCircle []float32 `json:\"circle,omitempty\"`\n\t// Radius is a stick's travel. Zero means 0.1.\n\tRadius float32 `json:\"radius,omitempty\"`\n\t// Floating centers a stick where the touch starts instead of at the\n\t// center of its area.\n\tFloating bool `json:\"floating,omitempty\"`\n}\n```\nTouchRegionSpec is a touch region in normalized screen coordinates (0..1 of the logical width and height; radii are fractions of the height).\n\n```go\ntype Vibration struct {\n\tDevice       DeviceID\n\tStrong, Weak float32\n\tDuration     time.Duration\n}\n```\nVibration is one recorded [Source.Vibrate](#Source.Vibrate) call.\n\n","path":"github.com/weakpixel/engine/input","name":"input","synopsis":"Package input turns keyboard, mouse, gamepad and touch input into named actions.","isRedistributable":true}
