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

#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
int getDeviceId () const
var getDeviceId ()
local getDeviceId ()
bool isConnected () const
var isConnected ()
local isConnected ()
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 ()
local getAllController ()
static ControllergetControllerByTag (int tag)
 Gets a controller with its tag. More...
 
var getControllerByTag ( var tag)
 Gets a controller with its tag. More...
 
local getControllerByTag ( local tag)
 Gets a controller with its tag. More...
 
static void startDiscoveryController ()
 To start discovering new controllers. More...
 
var startDiscoveryController ()
 To start discovering new controllers. More...
 
local startDiscoveryController ()
 To start discovering new controllers. More...
 
static void stopDiscoveryController ()
 End the discovery process. More...
 

Static Public Attributes

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

Friends

class ControllerImpl
class EventListenerController

Member Enumeration Documentation

enum Key

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

Enumerator
JOYSTICK_LEFT_X 
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 
var Key

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

Enumerator
JOYSTICK_LEFT_X 
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 
local Key

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

Enumerator
JOYSTICK_LEFT_X 
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 

Member Function Documentation

static const std::vector
<Controller*>
& getAllController
( )
inlinestatic
var getAllController ( )
inlinestatic
local getAllController ( )
inlinestatic
static Controller*
getControllerByTag
( int  tag)
static

Gets a controller with its tag.

Parameters
tagAn identifier to find the controller.
var getControllerByTag ( var  tag)
static

Gets a controller with its tag.

Parameters
tagAn identifier to find the controller.
local getControllerByTag ( local  tag)
static

Gets a controller with its tag.

Parameters
tagAn identifier to find the controller.
int getDeviceId ( ) const
inline
var getDeviceId ( )
inline
local getDeviceId ( )
inline
const std::string& getDeviceName ( ) const
inline
var getDeviceName ( )
inline
local getDeviceName ( )
inline
const KeyStatus& getKeyStatus ( int  keyCode)
var getKeyStatus ( var  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.
var getTag ( )
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
var isConnected ( )
local isConnected ( )
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.
var receiveExternalKeyEvent ( var  externalKeyCode,
var  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.
var setTag ( var  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

To start discovering new controllers.

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

To start discovering new controllers.

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

To start discovering new controllers.

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

End the discovery process.

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

End the discovery process.

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

End the discovery process.

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

Friends And Related Function Documentation

friend class ControllerImpl
friend
var ControllerImpl
friend
local ControllerImpl
friend
friend class
EventListenerController
friend

Member Data Documentation

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

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