cocos2d-x  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Controller Class Reference

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

#include <CCController.h>

Public Types

enum  Key {
  JOYSTICK_LEFT_X = 1000, JOYSTICK_LEFT_Y, JOYSTICK_RIGHT_X, JOYSTICK_RIGHT_Y,
  BUTTON_A, BUTTON_B, BUTTON_C, BUTTON_X,
  BUTTON_Y, BUTTON_Z, BUTTON_DPAD_UP, BUTTON_DPAD_DOWN,
  BUTTON_DPAD_LEFT, BUTTON_DPAD_RIGHT, BUTTON_DPAD_CENTER, BUTTON_LEFT_SHOULDER,
  BUTTON_RIGHT_SHOULDER, AXIS_LEFT_TRIGGER, AXIS_RIGHT_TRIGGER, BUTTON_LEFT_THUMBSTICK,
  BUTTON_RIGHT_THUMBSTICK, BUTTON_START, BUTTON_SELECT, BUTTON_PAUSE,
  KEY_MAX
}
 Controllers' standard key Controller receives only standard key which contained within enum Key by default. More...
 

Public Member Functions

const std::string & getDeviceName () const
 Gets the name of this Controller object. More...
 
local getDeviceName ()
 Gets the name of this Controller object. More...
 
int getDeviceId () const
 Gets the Controller id. More...
 
bool isConnected () const
 Indicates whether the Controller is connected. More...
 
local isConnected ()
 Indicates whether the Controller is connected. More...
 
const KeyStatusgetKeyStatus (int keyCode)
local getKeyStatus ( local keyCode)
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...
 
int getTag () const
 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. More...
 
local getAllController ()
 Gets all Controller objects. More...
 
static ControllergetControllerByTag (int tag)
 Gets a Controller object with tag. More...
 
static void startDiscoveryController ()
 Start discovering new controllers. More...
 
local startDiscoveryController ()
 Start discovering new controllers. More...
 
static void stopDiscoveryController ()
 Stop the discovery process. More...
 
local stopDiscoveryController ()
 Stop the discovery process. More...
 

Static Public Attributes

static const int TAG_UNSET = -1
local TAG_UNSET = -1

Friends

class ControllerImpl
class EventListenerController

Detailed Description

A Controller object represents a connected physical game controller.

Member Function Documentation

static const std::vector
<Controller*>
& getAllController
( )
inlinestatic

Gets all Controller objects.

local getAllController ( )
inlinestatic

Gets all Controller objects.

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.
int getDeviceId ( ) const
inline

Gets the Controller id.

local getDeviceId ( )
inline

Gets the Controller id.

const std::string& getDeviceName ( ) const
inline

Gets the name of this Controller object.

local getDeviceName ( )
inline

Gets the name of this Controller object.

const KeyStatus& getKeyStatus ( int  keyCode)
local getKeyStatus ( local  keyCode)
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.
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.

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.
static void
startDiscoveryController
( )
static

Start discovering new controllers.

Warning
The API only work on the IOS platform. Empty implementation on other platform.
local startDiscoveryController ( )
static

Start discovering new controllers.

Warning
The API only work on the IOS platform. Empty implementation on other platform.
static void stopDiscoveryController ( )
static

Stop the discovery process.

Warning
The API only work on the IOS platform.Empty implementation on other platform.
local stopDiscoveryController ( )
static

Stop the discovery process.

Warning
The API only work on the IOS platform.Empty implementation on other platform.

Friends And Related Function Documentation

friend class ControllerImpl
friend
local ControllerImpl
friend
friend class
EventListenerController
friend

Member Data Documentation

const int TAG_UNSET = -1
static
local TAG_UNSET = -1
static

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