Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

GamepadController Class Reference

Listens to Gamepad events coming in from the gamepad port. More...

#include <GamepadController.h>

Inheritance diagram for GamepadController:

Detailed Description

Listens to Gamepad events coming in from the gamepad port.

The communication protocol is a simple, 5-byte group. The first byte indicates which button/joystick had a state change, and the next 4 bytes indicate the new state value for that input:

  • <char: input indicator>
  • <float: value>

Definition at line 20 of file GamepadController.h.

List of all members.

Public Member Functions

 GamepadController ()
virtual ~GamepadController ()
virtual void start ()
 Calling this signals that the behavior should start running. It will increment the reference counter, add to the registry, and call the subclass hooks (preStart() / doStart() postStart() ).
virtual void stop ()
 Calling this signals the behavior to stop running. In turn, this calls doStop(), then removes the behavior from the registry and subtracts from the reference counter Ñ thus may delete the object if no other references remain.
virtual void doEvent ()
 Delegate function for event processing, the event itself is pointed to (only for the duration of the doEvent() call!) by event.
virtual std::string getDescription () const
 Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).

Static Public Member Functions

static int input_callback (char *buf, int bytes)
 Called when new data comes in over wireless.
static std::string getClassDescription ()
 Gives a short description of what this class of behaviors does... you should override this (but don't have to).

Static Public Attributes

static GamepadControllertheOne = NULL

Protected Types

enum  {
  X_BUTTON = 1, Y_BUTTON, A_BUTTON, B_BUTTON,
  START_BUTTON, SELECT_BUTTON, LJOY_X, LJOY_Y,
  RJOY_X, RJOY_Y, DPAD_X, DPAD_Y,
  L_BUMPER, R_BUMPER
}
 

The input indicator values.

More...

Private Member Functions

void shutdown ()
 Closes the server socket.
void processInput (unsigned char *buf)
 Processes a received packet.
void checkInputMapping (int thisVal, int enumVal)
 GamepadController (const GamepadController &)
 don't call
GamepadController operator= (const GamepadController &)
 don't call

Private Attributes

GamepadControllertheLastOne
 The last GamepadController that was theOne.
Socketinputsock
 The input stream socket.
int sock
 The actual socket.

Member Enumeration Documentation

anonymous enum [protected]

The input indicator values.

Enumerator:
X_BUTTON 
Y_BUTTON 
A_BUTTON 
B_BUTTON 
START_BUTTON 
SELECT_BUTTON 
LJOY_X 
LJOY_Y 
RJOY_X 
RJOY_Y 
DPAD_X 
DPAD_Y 
L_BUMPER 
R_BUMPER 

Definition at line 29 of file GamepadController.h.


Constructor & Destructor Documentation

GamepadController::GamepadController ( const GamepadController  )  [private]

don't call

GamepadController::GamepadController (  ) 

Definition at line 67 of file GamepadController.h.

virtual GamepadController::~GamepadController (  )  [virtual]

Definition at line 90 of file GamepadController.h.


Member Function Documentation

void GamepadController::checkInputMapping ( int  thisVal,
int  enumVal 
) [private]

Definition at line 15 of file GamepadController.cc.

Referenced by GamepadController().

virtual void GamepadController::doEvent (  )  [virtual]

Delegate function for event processing, the event itself is pointed to (only for the duration of the doEvent() call!) by event.

Default implementation watches for 'private' text message events (those forwarded by a BehaviorSwitchControl from ControllerGUI input) and will publically rebroadcast them. The idea is that your own processEvent gets first dibs, but if the behavior doesn't handle the text message, it will be handed off for others.

Reimplemented from BehaviorBase.

Definition at line 96 of file GamepadController.h.

static std::string GamepadController::getClassDescription (  )  [static]

Gives a short description of what this class of behaviors does... you should override this (but don't have to).

If you do override this, also consider overriding getDescription() to return it

Reimplemented from BehaviorBase.

Definition at line 104 of file GamepadController.h.

Referenced by getDescription().

virtual std::string GamepadController::getDescription (  )  const [virtual]

Gives a short description of what this particular instantiation does (in case a more specific description is needed on an individual basis).

By default simply returns getName(), because any calls from a BehaviorBase function to getClassDescription() are going to call BehaviorBase::getClassDescription(), not ~YourSubClass~getClassDescription(), because static functions can't be virtual in C++ (doh!)

This means that getDescription called on a pointer to a BehaviorBase of unknown subtype would always return an empty string, which is pretty useless. So instead we return the name in this situation. If you want getDescription to return getClassDescription, you'll have to override it in your subclass to do so.

Reimplemented from BehaviorBase.

Definition at line 109 of file GamepadController.h.

int GamepadController::input_callback ( char *  buf,
int  bytes 
) [static]

Called when new data comes in over wireless.

Definition at line 100 of file GamepadController.cc.

Referenced by start().

GamepadController GamepadController::operator= ( const GamepadController  )  [private]

don't call

void GamepadController::processInput ( unsigned char *  buf  )  [private]

Processes a received packet.

Definition at line 19 of file GamepadController.cc.

Referenced by input_callback().

void GamepadController::shutdown (  )  [private]

Closes the server socket.

Definition at line 82 of file GamepadController.cc.

Referenced by doEvent(), and stop().

void GamepadController::start (  )  [virtual]

Calling this signals that the behavior should start running. It will increment the reference counter, add to the registry, and call the subclass hooks (preStart() / doStart() postStart() ).

Generally you shouldn't override this -- override some combination of preStart(), doStart(), and postStart() instead.

Reimplemented from BehaviorBase.

Definition at line 68 of file GamepadController.cc.

void GamepadController::stop (  )  [virtual]

Calling this signals the behavior to stop running. In turn, this calls doStop(), then removes the behavior from the registry and subtracts from the reference counter Ñ thus may delete the object if no other references remain.

You shouldn't override this — override doStop instead.
Warning: if you do override, call this at the end of your stop(), not beginning (as it might delete this !)

Reimplemented from BehaviorBase.

Definition at line 94 of file GamepadController.cc.

Referenced by doEvent().


Member Data Documentation

The input stream socket.

Definition at line 51 of file GamepadController.h.

Referenced by shutdown(), and start().

int GamepadController::sock [private]

The actual socket.

Definition at line 53 of file GamepadController.h.

Referenced by shutdown(), and start().

The last GamepadController that was theOne.

Definition at line 48 of file GamepadController.h.

Referenced by shutdown(), start(), and ~GamepadController().

Points to the one GamepadController object that the input stream is talking to.

Definition at line 24 of file GamepadController.h.

Referenced by shutdown(), start(), and ~GamepadController().


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

Tekkotsu v5.1CVS
Generated Mon May 9 04:59:08 2016 by Doxygen 1.6.3