Packagecitrus.input
Classpublic class Input
InheritanceInput Inheritance Object

A class managing input of any controllers that is an InputController. Actions are inspired by Midi signals, but they carry an InputAction object. "action signals" are either ON, OFF, or CHANGE. to track action status, and check whether action was just triggered or is still on, actions have phases (see InputAction).



Public Properties
 PropertyDefined By
  actionCHANGE : Signal
Input
  actionOFF : Signal
Input
  actionON : Signal
Input
  clearDisposedActionsInterval : uint = 480
time interval to clear the InputAction's disposed list automatically.
Input
  enabled : Boolean
Input
  keyboard : Keyboard
Input
  triggersEnabled : Boolean = true
Lets InputControllers trigger actions.
Input
Protected Properties
 PropertyDefined By
  _actions : Vector.<InputAction>
Input
  _ce : CitrusEngine
Input
  _controllers : Vector.<InputController>
Input
  _enabled : Boolean = true
Input
  _initialized : Boolean
Input
  _routeActions : Boolean = false
Input
  _routeChannel : uint
Input
  _timeActive : int = 0
Input
Public Methods
 MethodDefined By
  
Input
  
addAction(action:InputAction):void
Input
  
Input
  
addOrSetAction sets existing parameters of an action to new values or adds action if it doesn't exist.
Input
  
controllerExists(name:String):Boolean
Input
  
destroy():void
Input
  
Changes the value property of an action, or adds action to list if it doesn't exist.
Input
  
Sets action to phase 3.
Input
  
doActionON(action:InputAction):void
Adds a new action of phase 0 if it does not exist.
Input
  
getAction(name:String, channel:int = -1, controller:InputController = null, phase:int = -1):InputAction
get an action by name from the current 'active' actions , optionnally filtered by channel, controller or phase.
Input
  
getActions(channel:int = -1, controller:InputController = null, phase:int = -1):Vector.<InputAction>
Returns a list of active actions, optionnally filtered by channel, controller or phase.
Input
  
returns a Vector of all actions in current frame.
Input
  
Input
  
hasDone(actionName:String, channel:int = -1):InputAction
Returns the corresponding InputAction object if it has been triggered OFF in this frame or in the previous frame, or null.
Input
  
initialize():void
Input
  
isDoing(actionName:String, channel:int = -1):InputAction
Returns the corresponding InputAction object if it has been triggered on the previous frame or is still going, or null.
Input
  
isRouting():Boolean
Helps knowing if Input is routing actions or not.
Input
  
justDid(actionName:String, channel:int = -1):InputAction
Returns the corresponding InputAction object if it has been triggered on the previous frame.
Input
  
Input
  
Input
  
startRouting(channel:uint):void
Start routing all actions to a single channel - used for pause menus or generally overriding the Input system.
Input
  
stopActionsOf(controller:InputController, channel:int = -1):void
Input
  
Stop routing actions.
Input
Property Detail
_actionsproperty
protected var _actions:Vector.<InputAction>

_ceproperty 
protected var _ce:CitrusEngine

_controllersproperty 
protected var _controllers:Vector.<InputController>

_enabledproperty 
protected var _enabled:Boolean = true

_initializedproperty 
protected var _initialized:Boolean

_routeActionsproperty 
protected var _routeActions:Boolean = false

_routeChannelproperty 
protected var _routeChannel:uint

_timeActiveproperty 
protected var _timeActive:int = 0

actionCHANGEproperty 
public var actionCHANGE:Signal

actionOFFproperty 
public var actionOFF:Signal

actionONproperty 
public var actionON:Signal

clearDisposedActionsIntervalproperty 
public var clearDisposedActionsInterval:uint = 480

time interval to clear the InputAction's disposed list automatically.

enabledproperty 
enabled:Boolean


Implementation
    public function get enabled():Boolean
    public function set enabled(value:Boolean):void
keyboardproperty 
public var keyboard:Keyboard

triggersEnabledproperty 
public var triggersEnabled:Boolean = true

Lets InputControllers trigger actions.

Constructor Detail
Input()Constructor
public function Input()



Method Detail
addAction()method
public function addAction(action:InputAction):void

Parameters

action:InputAction

addController()method 
public function addController(controller:InputController):void

Parameters

controller:InputController

addOrSetAction()method 
public function addOrSetAction(action:InputAction):void

addOrSetAction sets existing parameters of an action to new values or adds action if it doesn't exist.

Parameters

action:InputAction

controllerExists()method 
public function controllerExists(name:String):Boolean

Parameters

name:String

Returns
Boolean
destroy()method 
public function destroy():void

doActionCHANGE()method 
public function doActionCHANGE(action:InputAction):void

Changes the value property of an action, or adds action to list if it doesn't exist. a continuous controller, can simply trigger ActionCHANGE and never have to trigger ActionON. this will take care adding the new action to the list, setting its phase to 0 so it will respond to justDid, and then only the value will be changed. - however your continous controller DOES have to end the action by triggering ActionOFF.

Parameters

action:InputAction

doActionOFF()method 
public function doActionOFF(action:InputAction):void

Sets action to phase 3. will be advanced to phase 4 in next update, and finally will be removed on the update after that.

Parameters

action:InputAction

doActionON()method 
public function doActionON(action:InputAction):void

Adds a new action of phase 0 if it does not exist.

Parameters

action:InputAction

getAction()method 
public function getAction(name:String, channel:int = -1, controller:InputController = null, phase:int = -1):InputAction

get an action by name from the current 'active' actions , optionnally filtered by channel, controller or phase. returns null if no actions are found. example : var action:InputAction = _ce.input.getAction("jump",-1,null,InputPhase.ON); if(action && action.time > 120) trace("the jump action lasted for more than 120 frames. its value is",action.value); keep doing the jump action for about 2 seconds (if running at 60 fps) and you'll see the trace.

Parameters

name:String
 
channel:int (default = -1) — -1 to include all channels.
 
controller:InputController (default = null) — null to include all controllers.
 
phase:int (default = -1) — -1 to include all phases.

Returns
InputAction — InputAction
getActions()method 
public function getActions(channel:int = -1, controller:InputController = null, phase:int = -1):Vector.<InputAction>

Returns a list of active actions, optionnally filtered by channel, controller or phase. return an empty Vector.<InputAction> if no actions are found.

Parameters

channel:int (default = -1) — -1 to include all channels.
 
controller:InputController (default = null) — null to include all controllers.
 
phase:int (default = -1) — -1 to include all phases.

Returns
Vector.<InputAction>
getActionsSnapshot()method 
public function getActionsSnapshot():Vector.<InputAction>

returns a Vector of all actions in current frame. actions are cloned (no longer active inside the input system) as opposed to using getActions().

Returns
Vector.<InputAction>
getControllerByName()method 
public function getControllerByName(name:String):InputController

Parameters

name:String

Returns
InputController
hasDone()method 
public function hasDone(actionName:String, channel:int = -1):InputAction

Returns the corresponding InputAction object if it has been triggered OFF in this frame or in the previous frame, or null.

Parameters

actionName:String
 
channel:int (default = -1)

Returns
InputAction
initialize()method 
public function initialize():void

isDoing()method 
public function isDoing(actionName:String, channel:int = -1):InputAction

Returns the corresponding InputAction object if it has been triggered on the previous frame or is still going, or null.

Parameters

actionName:String
 
channel:int (default = -1)

Returns
InputAction
isRouting()method 
public function isRouting():Boolean

Helps knowing if Input is routing actions or not.

Returns
Boolean
justDid()method 
public function justDid(actionName:String, channel:int = -1):InputAction

Returns the corresponding InputAction object if it has been triggered on the previous frame.

Parameters

actionName:String
 
channel:int (default = -1)

Returns
InputAction
removeController()method 
public function removeController(controller:InputController):void

Parameters

controller:InputController

resetActions()method 
public function resetActions():void

startRouting()method 
public function startRouting(channel:uint):void

Start routing all actions to a single channel - used for pause menus or generally overriding the Input system.

Parameters

channel:uint

stopActionsOf()method 
public function stopActionsOf(controller:InputController, channel:int = -1):void

Parameters

controller:InputController
 
channel:int (default = -1)

stopRouting()method 
public function stopRouting():void

Stop routing actions.

update()method 
citrus_internal function update():void

Input.update is called in the end of your state update. keep this in mind while you create new controllers - it acts only after everything else. update first updates all registered controllers then finally advances actions phases by one if not phase 2 (phase two can only be voluntarily advanced by doActionOFF.) and removes actions of phase 4 (this happens one frame after doActionOFF was called.)