Mana
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Joystick Class Reference

#include <joystick.h>

Public Types

enum  { MAX_BUTTONS = 6 }
 Number of buttons we can handle. More...
 
enum  { UP = 1 , DOWN = 2 , LEFT = 4 , RIGHT = 8 }
 Directions, to be used as bitmask values. More...
 

Public Member Functions

 Joystick (int no)
 Constructor, pass the number of the joystick the new object should access.
 
 ~Joystick ()
 
bool isEnabled () const
 
void setEnabled (bool enabled)
 
void update ()
 Updates the direction and button information.
 
void startCalibration ()
 
void finishCalibration ()
 
bool isCalibrating () const
 
bool buttonPressed (unsigned char no) const
 
bool isUp () const
 
bool isDown () const
 
bool isLeft () const
 
bool isRight () const
 

Static Public Member Functions

static void init ()
 Initializes the joystick subsystem.
 
static int getNumberOfJoysticks ()
 Returns the number of available joysticks.
 

Protected Member Functions

void doCalibration ()
 

Protected Attributes

unsigned char mDirection
 
bool mButtons [MAX_BUTTONS]
 
SDL_Joystick * mJoystick
 
int mUpTolerance
 
int mDownTolerance
 
int mLeftTolerance
 
int mRightTolerance
 
bool mCalibrating
 
bool mEnabled
 

Static Protected Attributes

static int joystickCount = 0
 

Detailed Description

Definition at line 26 of file joystick.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Number of buttons we can handle.

Enumerator
MAX_BUTTONS 

Definition at line 32 of file joystick.h.

◆ anonymous enum

anonymous enum

Directions, to be used as bitmask values.

Enumerator
UP 
DOWN 
LEFT 
RIGHT 

Definition at line 40 of file joystick.h.

Constructor & Destructor Documentation

◆ Joystick()

Joystick::Joystick ( int  no)

Constructor, pass the number of the joystick the new object should access.

Definition at line 44 of file joystick.cpp.

◆ ~Joystick()

Joystick::~Joystick ( )

Definition at line 70 of file joystick.cpp.

Member Function Documentation

◆ buttonPressed()

bool Joystick::buttonPressed ( unsigned char  no) const

Definition at line 143 of file joystick.cpp.

◆ doCalibration()

void Joystick::doCalibration ( )
protected

Definition at line 117 of file joystick.cpp.

◆ finishCalibration()

void Joystick::finishCalibration ( )

Definition at line 134 of file joystick.cpp.

◆ getNumberOfJoysticks()

static int Joystick::getNumberOfJoysticks ( )
inlinestatic

Returns the number of available joysticks.

Definition at line 56 of file joystick.h.

◆ init()

void Joystick::init ( )
static

Initializes the joystick subsystem.

Definition at line 31 of file joystick.cpp.

◆ isCalibrating()

bool Joystick::isCalibrating ( ) const
inline

Definition at line 79 of file joystick.h.

◆ isDown()

bool Joystick::isDown ( ) const
inline

Definition at line 84 of file joystick.h.

◆ isEnabled()

bool Joystick::isEnabled ( ) const
inline

Definition at line 66 of file joystick.h.

◆ isLeft()

bool Joystick::isLeft ( ) const
inline

Definition at line 85 of file joystick.h.

◆ isRight()

bool Joystick::isRight ( ) const
inline

Definition at line 86 of file joystick.h.

◆ isUp()

bool Joystick::isUp ( ) const
inline

Definition at line 83 of file joystick.h.

◆ setEnabled()

void Joystick::setEnabled ( bool  enabled)
inline

Definition at line 68 of file joystick.h.

◆ startCalibration()

void Joystick::startCalibration ( )

Definition at line 108 of file joystick.cpp.

◆ update()

void Joystick::update ( )

Updates the direction and button information.

Definition at line 75 of file joystick.cpp.

Member Data Documentation

◆ joystickCount

int Joystick::joystickCount = 0
staticprotected

Definition at line 97 of file joystick.h.

◆ mButtons

bool Joystick::mButtons[MAX_BUTTONS]
protected

Definition at line 90 of file joystick.h.

◆ mCalibrating

bool Joystick::mCalibrating
protected

Definition at line 94 of file joystick.h.

◆ mDirection

unsigned char Joystick::mDirection
protected

Definition at line 89 of file joystick.h.

◆ mDownTolerance

int Joystick::mDownTolerance
protected

Definition at line 93 of file joystick.h.

◆ mEnabled

bool Joystick::mEnabled
protected

Definition at line 95 of file joystick.h.

◆ mJoystick

SDL_Joystick* Joystick::mJoystick
protected

Definition at line 91 of file joystick.h.

◆ mLeftTolerance

int Joystick::mLeftTolerance
protected

Definition at line 93 of file joystick.h.

◆ mRightTolerance

int Joystick::mRightTolerance
protected

Definition at line 93 of file joystick.h.

◆ mUpTolerance

int Joystick::mUpTolerance
protected

Definition at line 93 of file joystick.h.


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