#include <cPad.h>
Public Types | |
enum | Axes { AX_LR1, AX_UD1, AX_UD2, AX_LR2 } |
enum | Buttons { BT_SQUARE, BT_DELTA, BT_CROSS, BT_CIRCLE, BT_L1, BT_L2, BT_R1, BT_R2, BT_SELECT, BT_START, BT_J1B, BT_J2B, BT_HU, BT_HD, BT_HL, BT_HR } |
Public Member Functions | |
cPad () | |
void | reset () |
void | setAxis (Axes axis, int value) |
void | setAxis (Axes axis, float value) |
float | getAxis (Axes axis) |
void | setButton (Buttons button, bool enable) |
int | getButton (Buttons button) |
std::string | toString () |
char * | serialise (char *buffer) |
char * | deserialise (char *buffer) |
Emulation of a hardwired "universal" gamepad. It's Structure is like that of available Gamepads. A player and its data may be associated with the pad.
enum cPad::Axes |
Identifiers for single (analouge) Axes: UD1, LR1: Primary stick. UD2, LR2: Secondary stick.
enum cPad::Buttons |
Identifiers for single Buttons with groupings: HU, HD, HL, HR: CoolieHat or digital axes as of yesterdays. DELTA, CROSS, SQUARE, CIRCLE: Primary action buttons (up,dn,lt,rt). L1, L2: Left hand side buttons (top and bottom) [selections/camera/trigger]. R1, R2: Right hand side buttons (top and bottom) [selections/camera/trigger]. SELECT, START: Center buttons. J1B, J2B: Buttons of the analouge sticks (pressing them down).
cPad::cPad | ( | ) | [inline] |
A new instance of a pad will be initialised to all zeros.
char* cPad::deserialise | ( | char * | buffer | ) | [inline] |
Input playback for demo replay Just like input recording but reads a pad configuration from the buffer instead.
float cPad::getAxis | ( | Axes | axis | ) | [inline] |
Get the value of an axis indicated by an enum-constant. The returned value is in [-1.0,+1.0] range representing an internal range of [-127,+127].
int cPad::getButton | ( | Buttons | button | ) | [inline] |
Get the state of a button indicated by an enum-constant. A value of 1 (int) is equal to a pressed button - zero otherwise. Hint: Use the button state as a enabling factor in calculations.
void cPad::reset | ( | ) | [inline] |
Methods for setting and resetting axis and button value. Use the enum-constants of "Axes" and "Buttons" to access to individual axes and buttons.
Ranges in float for Axis are [-1,+1], whereas for int it is [-127,+127].
char* cPad::serialise | ( | char * | buffer | ) | [inline] |
Input recording. Takes a pointer to a buffer, puts in the current pad configuration, increments the buffer pointer by the size of the configuration and returns that incremented pointer to the buffer so that it can be used for the next call.
void cPad::setAxis | ( | Axes | axis, | |
float | value | |||
) | [inline] |
Set axis indicated by an enum-constant to a value in [-1.0,+1.0] range. The value is clamped to that [-1.0,+1.0] interval and then mapped to a [-127,+127] interval for internal storrage.
void cPad::setAxis | ( | Axes | axis, | |
int | value | |||
) | [inline] |
Set axis indicated by enum-constant to a value in [-127,+127] range. The value is clamped to that interval.
void cPad::setButton | ( | Buttons | button, | |
bool | enable | |||
) | [inline] |
Set a button indicated by an enum-constant to either un-/pressed. True (unequal zero) is equal to pressed.
std::string cPad::toString | ( | ) | [inline] |
Puts the current pad configuration into a string and returns it.