The Input component converts raw input data from devices into consistent data presented in a platform independent API. The state of inputs can be checked for their current value or a user can listen for input events.
The Input component has the following responsibilities:
- Provide interfaces for mouse, keyboard, controllers, and peripheral sensors.
- Allows users to refine raw input via clamping and filtering.
- Allow users to define complex inputs to be used along side normal inputs
- An input that is triggered when ANY sub-inputs are triggered
- An input that is triggered when ALL sub-inputs are triggered
- An input gesture (sequence of inputs in a given time span)
- An input that is made up of X and Y axis inputs
- Notify user when interfaces are available, connect, and disconnect.
- Provide a way to map inputs to actions (input contexts).
- Provide a way to control which contexts are active in game.
- A stack of contexts that can be pushed/popped based on the active UI elements
- Provide a way to capture user input for mapping actions to inputs.
- Ensure an input is only involved in one action at a time.
- Provide a way for the user to control input timing (delays, press intervals, etc)
- None
- None
Input
: The state of any given input (key, mouse, joystick axis, etc).InputAll
: A compound input which is triggered when ALL sub inputs are down.InputAny
: A compound input which is triggered when ANY sub inputs are down.InputFiltered
: A filtered view of an input.InputRange
: A view of an input which depends on the raw input being between a minimum and maximum value.InputGesture
: A combination of inputs that must occur without interruption in a certain order in a certain time frame.InputAxis
: An input with x and y axis inputs.Key
: A key on a keyboard.KeyInput
: An input for a key (and has a character).KeyEngine
: Initializes and updates key inputs and provides other settings.MouseInput
: An input for mouse buttons that keeps track of where the mouse button was pressed.MouseState
: Contains information on where the mouse is.MouseEngine
: Initializes and updates mouse input and provides other settings.Controller
: A game pad that may or may not be connected.ControllerEngine
: Initializes and updates controller input and provides other settings.InputListener
: A function which is notified when an event occurs on some input.InputEventType
: A way which input can change.InputEvent
: A grouping between an Input, an InputEventType, and an InputListener.InputContext
: A context to which inputs are mapped to actions. InputContexts change based on screens and the UI, and multiple may be active at a time.Inputs
: Manages input contexts and provides functions for combining & decorating inputs.
- input: int
- window: int // an identifier for which window the input was last changed
- down: boolean // is the input in a non-default state?
- value: float // the current value of the input (calculated from trigger min/max, raw, & filter)
- raw: float // the raw input value
- frames: int // the number of frames the input has been in this state
- time: long // the amount of time the input has been in this state
- seconds: float // the amount of time in seconds the input has been in this state
- presses: int // the number of press events generated for this input since it has been down
- press: boolean // whether a press event should be triggered this frame
- changeTime: long // the exact time this input changed state
- lastUpdate: long // the last time this input state updated
- name: string // the name of the input, assigned by the system or specified by the user
- source: byte // the source of the input - each source (key, mouse, controllers) have their own ID
- isDown(): boolean
- isUp(): boolean
- isPress(): boolean
- isChange(): boolean
- setDown( down: boolean, inputTime: long ): void
- update( currentTime: long, pressDelay: float, pressInterval: float ): void
- inputs: Input[] // the inputs to look at
- inputs: Input[] // the inputs to look at
- input: Input // the input to filter
- filterArray: float[] // the last N raw input values to use to calculate the filtered value
- filterIndex: int // the index to the last raw input into filterArray
- input: Input // the input the modify
- min: float // the minimum value the raw input must be to trigger a down state
- max: float // the upper bound used to normalize the input value
- inputs: Input[]
- manager: Inputs
- currentInput: int
- timeFrame: float
- startTime: long
- x: InputRange
- y: InputRange
- up: Input
- down: Input
- left: Input
- right: Input
- normalX: float
- normalY: float
- magnitude: float
- action: A
- context: InputContext< A >
- getInput( index: int ): Input
- getInputCount(): int
- getSource(): byte
- A, B, C, etc
- key: Key
- character: char
- update( currentTime: long ): void
- getKey( key: Key ): KeyInput
- getShift(): KeyInput
- getControl(): KeyInput
- getMeta(): KeyInput
- getCommand(): KeyInput
- getAlt(): KeyInput
- getQueue() Queue< KeyInput >
- setPressInterval( pressInterval: float ): void
- getPressInterval(): float
- setPressDelay( pressDelay: float ): void
- getPressDelay(): float
- x: int
- y: int
- x: int
- y: int
- dx: int
- dy: int
- delta: InputAxis
- sdx: int
- sdy: int
- wheel: int
- swheel: int
- inside: Input
- BUTTON_COUNT: int = 16
- update( currentTime: long ): void
- getButton( index: int ): MouseInput
- getMouse(): Mouse
- getQueue(): Queue< MouseInput >
- setGrabbed( grabbed: boolean ): void
- isGrabbed(): boolean
- setHidden( hidden: boolean ): void
- isHidden(): boolean
- setPressInterval( pressInterval: float ): void
- getPressInterval(): float
- setPressDelay( pressDelay: float ): void
- getPressDelay(): float
- AXIS_COUNT: int = 8
- BUTTON_COUNT: int = 32
- getConnectOrder(): int
- isConnected(): boolean
- getButton( index: int ): Input
- getButtonCount(): int
- getAxis( index: int ): InputAxis
- getAxisCount(): int
- CONTROLLER_COUNT: int = 16
- update( currentTime: long ): void
- forEachConnected( consumer: Consumer< Controller > ): int
- getController( index: int ): Controller
- getControllerCount(): int
- setPressInterval( pressInterval: float ): void
- getPressInterval(): float
- setPressDelay( pressDelay: float ): void
- getPressDelay(): float
- ( input: S, type: InputEventType ): void
- Up
- Down
- Change
- Press
- Held
- isType( input: Input ): boolean
- type: InputEventType
- input: Input
- listener: InputListener
- isTriggered(): boolean
- id: int
- name: string
- active: boolean
- events: InputEvent[]
- defaultListener: InputListener
- setAction( action: A, input: Input, type: InputEventType, listener: InputListener ): void
- getActionEvent( action: A ): InputEvent
- update( currentTime: long ): void
- onCapture( changed: Input, accumulated: InputAll ): boolean
- mouse: MouseEngine
- keys: KeyEngine
- controllers: ControllerEngine
- contexts: InputContext[]
- pushed: boolean[]
- changeHistory: ListCircular< Input >
- capturer: InputCapturer
- update( currentTime: long ): void
- filtered( input: Input, samples: int ): InputFiltered
- range( input: Input, min: float, max: float ): InputRange
- axis( x: Input, y: Input ): InputAxis
- gesture( timeFrame: float, inputs: Input[] ): InputGesture
- any( inputs: Input[] ): InputAll
- all( inputs: Input[] ): InputAny
- capture( capturer: InputCapturer ): void
- addChange( input: Input ): void
- forEachDown( consumer: Consumer< Input > ): int
- newContext( name: string = null ): InputContext
- setContext( id: int ): boolean
- addContext( id: int ): boolean
- pushContext( id: int ): boolean
- popContext(): boolean
- clearContexts(): void