cocos2d-x  3.3
 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
 
bool isConnected () const
 
const KeyStatusgetKeyStatus (int keyCode)
 
void receiveExternalKeyEvent (int externalKeyCode, bool 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 ()
 
static ControllergetControllerByTag (int tag)
 Gets a controller with its tag. More...
 
static void startDiscoveryController ()
 To start discovering new controllers. More...
 
static void stopDiscoveryController ()
 End the discovery process. More...
 

Static Public Attributes

static const int 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 

Member Function Documentation

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

Gets a controller with its tag.

Parameters
tagAn identifier to find the controller.
int getDeviceId ( ) const
inline
const std::string& getDeviceName ( ) const
inline
const KeyStatus& getKeyStatus ( int  keyCode)
int getTag ( ) const
inline

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

Returns
An integer that identifies the controller.
bool isConnected ( ) const
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.
void setTag ( int  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
static void 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
friend class EventListenerController
friend

Member Data Documentation

const int TAG_UNSET = -1
static

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