API reference
API reference
Select your platform
No SDKs available
No versions available

Controller Class

Extends ComponentBase
Modifiers: final
Represents Controller Data and properties that can be used to facilitate input.

Signature

class Controller(buttonState: Int = 0, changedButtons: Int = 0, isActive: Boolean = false, type: ControllerType = ControllerType.CONTROLLER, directTouchEnabled: Boolean = false, directTouchButtonState: Int = 0, laserEnabled: Boolean = true) : ComponentBase

Constructors

Controller ( buttonState , changedButtons , isActive , type , directTouchEnabled , directTouchButtonState , laserEnabled )
Signature
constructor(buttonState: Int = 0, changedButtons: Int = 0, isActive: Boolean = false, type: ControllerType = ControllerType.CONTROLLER, directTouchEnabled: Boolean = false, directTouchButtonState: Int = 0, laserEnabled: Boolean = true)
Parameters
buttonState: Int  The current state of the buttons being pressed represented by integer bits
changedButtons: Int  Which buttons (represented by integer bits) have been changed (pressed or unpressed)
isActive: Boolean  Whether the controller is active or not
type: ControllerType  What type of controller it is: 0->controller 1->hand
directTouchEnabled: Boolean  Whether direct touch is enabled or not
directTouchButtonState: Int  The state of the direct touch buttons
laserEnabled: Boolean  Whether the laser is enabled or not
Returns
Controller

Properties

buttonState : Int
[Get][Set]
The current state of the buttons being pressed represented by integer bits
Signature
var buttonState: Int
cachable : BuildConfig.COMPONENTCACHE_LEVEL >= 1
[Get][Set]
Signature
open override var cachable: BuildConfig.COMPONENTCACHE_LEVEL >= 1
changedButtons : Int
[Get][Set]
Which buttons (represented by integer bits) have been changed (pressed or unpressed since the last frame)
Signature
var changedButtons: Int
directTouchButtonState : Int
[Get][Set]
The state of the direct touch buttons
Signature
var directTouchButtonState: Int
directTouchEnabled : Boolean
[Get][Set]
Signature
var directTouchEnabled: Boolean
entID : Long
[Get][Set]
Signature
var entID: Long
isActive : Boolean
[Get][Set]
Signature
var isActive: Boolean
isDirty : Boolean
[Get][Set]
Signature
var isDirty: Boolean
laserEnabled : Boolean
[Get][Set]
Signature
var laserEnabled: Boolean
recycled : Boolean
[Get][Set]
Signature
var recycled: Boolean
timeStamp : Long
[Get][Set]
Signature
var timeStamp: Long
[Get][Set]
What type of controller it is: 0->controller 1->hand 2->eye
Signature
var type: ControllerType

Methods

companion ()
Gets the companion object for this component.
The companion object provides metadata about the component.
Signature
open override fun companion(): ComponentCompanion
Returns
ComponentCompanion  The component's companion object
Throws
RuntimeException  If the companion is not implemented
getComponentDataAttributeType ( key )
Gets the attribute type for the specified key.
Signature
fun getComponentDataAttributeType(key: Int): AttributePrimitive?
Parameters
key: Int  The integer key to look up
Returns
AttributePrimitive?  The attribute primitive type, or null if the key doesn't exist
getComponentDataAttributeType ( keyString )
Gets the attribute type for the specified string key.
Signature
fun getComponentDataAttributeType(keyString: String): AttributePrimitive?
Parameters
keyString: String  The string key to look up
Returns
AttributePrimitive?  The attribute primitive type
Throws
IllegalArgumentException  If the key doesn't exist
getComponentDataKey ( key )
Gets the integer key associated with the specified string key.
Signature
fun getComponentDataKey(key: String): Int?
Parameters
key: String  The string key to look up
Returns
Int?  The integer key, or null if the string key doesn't exist
getComponentDataValue ( key )
Gets the value for the specified key.
Signature
fun getComponentDataValue(key: Int): Any?
Parameters
key: Int  The integer key to look up
Returns
Any?  The value associated with the key, or null if the key doesn't exist
getComponentDataValue ( keyString )
Gets the value for the specified string key.
Signature
fun getComponentDataValue(keyString: String): Any?
Parameters
keyString: String  The string key to look up
Returns
Any?  The value associated with the key, or null if the key doesn't exist
Throws
IllegalArgumentException  If the key doesn't exist
getEnumClass ( key )
Gets the enum class associated with the specified string key.
Signature
fun getEnumClass(key: String): Class<out Enum<*>>?
Parameters
key: String  The string key to look up
Returns
Class?  The enum class, or null if the key doesn't exist or is not an enum
hasAttributeChanges ()
Returns true if any attribute has been modified since the last read/write sync.
This is a read-only check. To clear the flag, call Entity.setComponent which syncs changes to native and resets the dirty state.
Signature
fun hasAttributeChanges(): Boolean
Returns
Boolean
hasComponentData ( key )
Checks if this component has data for the specified key.
Signature
fun hasComponentData(key: Int): Boolean
Parameters
key: Int  The integer key to check
Returns
Boolean  True if the component has data for the key, false otherwise
hasComponentData ( keyString )
Checks if this component has data for the specified string key.
Signature
fun hasComponentData(keyString: String): Boolean
Parameters
keyString: String  The string key to check
Returns
Boolean  True if the component has data for the key, false otherwise
isDown ( buttonBits )
Checks if any of the specified buttons are currently being held down.
Signature
fun isDown(buttonBits: Int): Boolean
Parameters
buttonBits: Int  A bitmask of buttons to check (use ButtonBits constants).
Returns
Boolean  True if any of the specified buttons are currently pressed.
isPressed ( buttonBits )
Checks if any of the specified buttons were just pressed this frame.
A button is considered "pressed" when it transitions from not-pressed to pressed. This will return true only on the first frame the button is detected as down.
Signature
fun isPressed(buttonBits: Int): Boolean
Parameters
buttonBits: Int  A bitmask of buttons to check (use ButtonBits constants).
Returns
Boolean  True if any of the specified buttons were pressed this frame.
isReleased ( buttonBits )
Checks if any of the specified buttons were just released this frame.
A button is considered "released" when it transitions from pressed to not-pressed. This will return true only on the first frame the button is detected as up.
Signature
fun isReleased(buttonBits: Int): Boolean
Parameters
buttonBits: Int  A bitmask of buttons to check (use ButtonBits constants).
Returns
Boolean  True if any of the specified buttons were released this frame.
read ( e , cachable )
Reads component data from the specified entity.
Signature
fun read(e: Entity, cachable: Boolean)
Parameters
e: Entity  The entity to read data from
cachable: Boolean  Whether the component's data should be cached
recycle ()
Recycles this component by returning it to its pool.
If the component has a pool assigned, it will be returned to that pool for reuse.
Signature
fun recycle()
reset ()
Resets the component to its default state.
This method is called when a component is recycled to clear any state. Subclasses should override this method to reset their specific state.
Signature
open fun reset()
setComponentDataValue ( key , value )
Sets the value for the specified key.
Signature
fun setComponentDataValue(key: Int, value: Any): Boolean
Parameters
key: Int  The integer key to set
value: Any  The value to set
Returns
Boolean  True if the value was set successfully, false otherwise
setComponentDataValue ( keyString , value )
Sets the value for the specified string key.
Signature
fun setComponentDataValue(keyString: String, value: Any): Boolean
Parameters
keyString: String  The string key to set
value: Any  The value to set
Returns
Boolean  True if the key exists and the value was set, false otherwise
setPool ( pool , entID )
Sets the component pool and entity ID for this component.
This is used for component recycling to track which pool the component belongs to and which entity it was associated with.
Signature
fun setPool(pool: ComponentPool<*>, entID: Long)
Parameters
pool: ComponentPool  The component pool this component belongs to
entID: Long  The ID of the entity this component is associated with
toString ()
Signature
open override fun toString(): String
Returns
String
typeID ()
Returns the unique type ID of this component.
Each component type must have a unique ID for identification in the entity-component system.
Signature
open override fun typeID(): Int
Returns
Int  The unique type ID for this component
write ( e )
Writes this component's data to the specified entity.
Signature
fun write(e: Entity)
Parameters
e: Entity  The entity to write this component's data to

Companion Object

Properties

attributeKeys_ : IntArray
[Get]
Signature
val attributeKeys_: IntArray
attributeTypeCounts_ : IntArray
[Get]
Signature
val attributeTypeCounts_: IntArray
attributeTypes_ : IntArray
[Get]
Signature
val attributeTypes_: IntArray
attrMetaData_ : Map
[Get]
Signature
val attrMetaData_: Map
buttonStateData : IntAttributeData
[Get]
Signature
val buttonStateData: IntAttributeData
buttonStateId :
[Get]
Signature
val buttonStateId: 
changedButtonsData : IntAttributeData
[Get]
Signature
val changedButtonsData: IntAttributeData
changedButtonsId :
[Get]
Signature
val changedButtonsId: 
createDefaultInstance : Function0
[Get]
Signature
open override val createDefaultInstance: () -> Controller
directTouchButtonStateData : IntAttributeData
[Get]
Signature
val directTouchButtonStateData: IntAttributeData
directTouchButtonStateId :
[Get]
Signature
val directTouchButtonStateId: 
directTouchEnabledData : BooleanAttributeData
[Get]
Signature
val directTouchEnabledData: BooleanAttributeData
directTouchEnabledId :
[Get]
Signature
val directTouchEnabledId: 
enumClassesMap_ : Map
[Get]
Signature
val enumClassesMap_: Map<Int, Class<out Enum<*>>>
id :
[Get]
Signature
open override val id: 
isActiveData : BooleanAttributeData
[Get]
Signature
val isActiveData: BooleanAttributeData
isActiveId :
[Get]
Signature
val isActiveId: 
keyStringToKeyIntMap_ : Map
[Get]
Signature
val keyStringToKeyIntMap_: Map<String, Int>
laserEnabledData : BooleanAttributeData
[Get]
Signature
val laserEnabledData: BooleanAttributeData
laserEnabledId :
[Get]
Signature
val laserEnabledId: 
[Get]
Signature
val typeData: EnumAttributeData
typeId :
[Get]
Signature
val typeId: 

Methods

attributeKeys ()
Signature
open override fun attributeKeys(): IntArray
Returns
IntArray
attributeMetaData ()
Returns
Map
attributeTypeCountAvailable ()
Signature
open override fun attributeTypeCountAvailable(): Boolean
Returns
Boolean
attributeTypeCounts ()
Signature
open override fun attributeTypeCounts(): IntArray
Returns
IntArray
attributeTypes ()
Signature
open override fun attributeTypes(): IntArray
Returns
IntArray
dependents ()
Signature
open fun dependents(): IntArray
Returns
IntArray
enumClassesMap ()
Signature
open override fun enumClassesMap(): Map<Int, Class<out Enum<*>>>
Returns
Map
keyStringToKeyIntMap ( keyString )
Signature
open override fun keyStringToKeyIntMap(keyString: String): Int?
Parameters
keyString: String
Returns
Int?