Cocos2d-x  v3.17
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Controller Class Reference

A Controller object represents a connected physical game controller. More...

Public Types

enum  Key
 Controllers' standard key Controller receives only standard key which contained within enum Key by default.
 

Public Member Functions

const std::string & getDeviceName () const
 Gets the name of this Controller object.
 
int getDeviceId () const
 Gets the Controller id.
 
local getDeviceId ()
 Gets the Controller id.
 
bool isConnected () const
 Indicates whether the Controller is connected.
 
local isConnected ()
 Indicates whether the Controller is connected.
 
void receiveExternalKeyEvent (int externalKeyCode, bool receive)
 Activate receives key event from external key. More...
 
local receiveExternalKeyEvent ( local externalKeyCode, local receive)
 Activate receives key event from external key. More...
 
void setTag (int tag)
 Changes the tag that is used to identify the controller easily. More...
 
local setTag ( local tag)
 Changes the tag that is used to identify the controller easily. More...
 
int getTag () const
 Returns a tag that is used to identify the controller easily. More...
 
local getTag ()
 Returns a tag that is used to identify the controller easily. More...
 

Static Public Member Functions

static const std::vector
< Controller * > & 
getAllController ()
 Gets all Controller objects.
 
local getAllController ()
 Gets all Controller objects.
 
static ControllergetControllerByTag (int tag)
 Gets a Controller object with tag. More...
 
static ControllergetControllerByDeviceId (int deviceId)
 Gets a Controller object with device ID. More...
 
static void startDiscoveryController ()
 Start discovering new controllers. More...
 
local startDiscoveryController ()
 Start discovering new controllers. More...
 
static void stopDiscoveryController ()
 Stop the discovery process. More...
 

Detailed Description

A Controller object represents a connected physical game controller.

Member Function Documentation

static Controller*
getControllerByTag
( int  tag)
static

Gets a Controller object with tag.

Parameters
tagAn identifier to find the controller.
Returns
A Controller object.
local getControllerByTag ( local  tag)
static

Gets a Controller object with tag.

Parameters
tagAn identifier to find the controller.
Returns
A Controller object.
static Controller*
getControllerByDeviceId
( int  deviceId)
static

Gets a Controller object with device ID.

Parameters
deviceIdA unique identifier to find the controller.
Returns
A Controller object.
local getControllerByDeviceId ( local  deviceId)
static

Gets a Controller object with device ID.

Parameters
deviceIdA unique identifier to find the controller.
Returns
A Controller object.
static void
startDiscoveryController
( )
static

Start discovering new controllers.

Warning
The API has an empty implementation on Android.
local startDiscoveryController ( )
static

Start discovering new controllers.

Warning
The API has an empty implementation on Android.
static void stopDiscoveryController ( )
static

Stop the discovery process.

Warning
The API has an empty implementation on Android.
local stopDiscoveryController ( )
static

Stop the discovery process.

Warning
The API has an empty implementation on Android.
void receiveExternalKeyEvent ( int  externalKeyCode,
bool  receive 
)

Activate receives key event from external key.

e.g. back,menu. Controller receives only standard key which contained within enum Key by default.

Warning
The API only work on the android platform for support diversified game controller.
Parameters
externalKeyCodeExternal key code.
receiveTrue if external key event on this controller should be receive, false otherwise.
local receiveExternalKeyEvent ( local  externalKeyCode,
local  receive 
)

Activate receives key event from external key.

e.g. back,menu. Controller receives only standard key which contained within enum Key by default.

Warning
The API only work on the android platform for support diversified game controller.
Parameters
externalKeyCodeExternal key code.
receiveTrue if external key event on this controller should be receive, false otherwise.
void setTag ( int  tag)
inline

Changes the tag that is used to identify the controller easily.

Parameters
tagA integer that identifies the controller.
local setTag ( local  tag)
inline

Changes the tag that is used to identify the controller easily.

Parameters
tagA integer that identifies the controller.
int getTag ( ) const
inline

Returns a tag that is used to identify the controller easily.

Returns
An integer that identifies the controller.
local getTag ( )
inline

Returns a tag that is used to identify the controller easily.

Returns
An integer that identifies the controller.

The documentation for this class was generated from the following file: