Class Game Controller


This class represents the game controller used for input. This will poll the physical controller, as well at keep some time memory to determine if a button was tapped recently or if a tap is now a double-tap.


static const int NUM_BUT : Number of available buttons, including directionals. Used to define arrays
static const int UP… : represents the index values of each button
double POLL_MAX : to scale values polled from the joysticks. This must like up with the polling value of the device
double A_THRESH : any motion of the axis beneath A_THRESH will not regiser
double DBL_TAP_LMT: if a button is tapped twice within this time, it it registered as a double tap
double TAP_LMT : a tap will be remembered for this period of time


HRESULT connect : connection state of the controller
double tapTmr[NUM_BUT], dblTapTmr[NUM_BUT] : timers to track taps and double taps
bool pressed[NUM_BUT] : true for an index if the button is currently pressed
SPoint lStick, rStick; vectors relating to the axes of the joysticks
int pNum : index of associated player to this controller
c_GameController* last : pointer to the last state the controller was in

void c_GameController::CloneToLast()

Copies the current state of the controller into the 'last' pointer

void c_GameController::Process(double timeLapsed)

Updates the timers according to the time lasped

void c_GameController::SetButton(int i, BYTE v)

sets a button at index i to true or false depending on BYTE v. BYTE is used as it is polled from the controller

bool c_GameController::TappedThisFrame(int t)

Returns true if the button specified by 't' was tapped this frame. (immediate feedback)

bool c_GameController::Tapped(int t)

returns true if the 'tapped' timer for the button 't' is still active, indicating it was tapped recently.

bool c_GameController::DoubleTapped(int t)

returns true if the button was double tapped this frame

bool c_GameController::StickTapped();

returns true if a stick was tapped; tapping the stick involves rapid motion to the end of the poll axis.