Harmonic Flow Framework (libhffwk)
Cross platform C++ 2D Game Engine Framework
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
HFCore::GamePad Class Reference

Interface for input type GamePad / Joystick. More...

#include <GamePad.h>

Inheritance diagram for HFCore::GamePad:
Inheritance graph
[legend]

Classes

struct  GamePadAxisInfo
 A structure that contains GamePad / Joystick axis motion event information. More...
 
struct  GamePadBallInfo
 A structure that contains GamePad / Joystick trackball motion event information. More...
 
struct  GamePadButtonInfo
 A structure that contains GamePad / Joystick button event information. More...
 
struct  GamePadHatInfo
 A structure that contains GamePad / Joystick hat position change event information. More...
 

Public Types

enum  Hat {
  HAT_LEFTUP = 0, HAT_LEFT, HAT_LEFTDOWN, HAT_UP,
  HAT_CENTERED, HAT_DOWN, HAT_RIGHTUP, HAT_RIGHT,
  HAT_RIGHTDOWN
}
 GamePad Hat enum. More...
 
enum  Button {
  BUTTON_0 = 0, BUTTON_1 = 1, BUTTON_2 = 2, BUTTON_3 = 3,
  BUTTON_L_SHOULDER = 4, BUTTON_R_SHOULDER = 5, BUTTON_BACK = 6, BUTTON_START = 7,
  BUTTON_HOME = 8, BUTTON_L_STICK = 9, BUTTON_R_STICK = 10, BUTTON_COUNT = 10,
  BUTTON_UNKNOWN = 0xff
}
 GamePad button enum. More...
 

Public Member Functions

 GamePad (int32_hf id)
 Constructor. More...
 
virtual ~GamePad ()
 Destructor.
 
int32_hf getId ()
 Get the ID. More...
 
void addListener (GamePadListener *listener)
 Add a new listener class to receive GamePadListener callbacks. More...
 
void removeListener (GamePadListener *listener)
 Remove a listener class from receiving further GamePadListener callbacks. More...
 
void fireAxisMotionEvent (GamePadAxisInfo axis)
 Called internally when a GamePad axis motion event occurs. It calls GamePadListener::gamePadAxisMotion(). More...
 
void fireBallMotionEvent (GamePadBallInfo ball)
 Called internally when a GamePad ball event occurs. It calls GamePadListener::gamePadBallMotion()). More...
 
void fireHatMotionEvent (GamePadHatInfo hat)
 Called internally when a GamePad hat event occurs. It calls GamePadListener::gamePadHatMotion(). More...
 
void fireButtonDownEvent (GamePadButtonInfo button)
 Called internally when a GamePad button down event occurs. It calls GamePadListener::gamePadButtonDown(). More...
 
void fireButtonUpEvent (GamePadButtonInfo button)
 Called internally when a GamePad button up event occurs. It calls GamePadListener::gamePadButtonUp(). More...
 
virtual std::string getName ()
 Get GamePad name. More...
 
virtual int32_hf getInstanceId ()
 Get GamePad instance id. More...
 
virtual int32_hf getNumAxis ()
 Get number of GamePad axis available. More...
 
virtual int32_hf getNumBalls ()
 Get number of GamePad balls available. More...
 
virtual int32_hf getNumButtons ()
 Get number of GamePad buttons available. More...
 
virtual int32_hf getNumHats ()
 Get number of GamePad hats available. More...
 
virtual void setEnabled (bool enabled)
 Set controller enabled or disabled. More...
 
virtual void setConnected (bool connected)
 Set controller connected or disconnected. More...
 
- Public Member Functions inherited from HFCore::Controller
 Controller ()
 Constructor.
 
virtual ~Controller ()
 Destructor.
 
virtual bool isEnabled ()
 Check whether controller is enabled. More...
 
virtual bool isConnected ()
 Check whether controller is connected. More...
 

Protected Attributes

std::vector< GamePadListener * > mListeners
 Vector holding GamePadListener classes.
 
int32_hf mId
 GamePad ID.
 
int32_hf mInstanceId
 GamePad instance id.
 
std::string mName
 GamePad name.
 
int32_hf mNumAxis
 Number of GamePad axis.
 
int32_hf mNumBalls
 Number of GamePad balls.
 
int32_hf mNumButtons
 Number of GamePad buttons.
 
int32_hf mNumHats
 Number of GamePad hats.
 

Detailed Description

Interface for input type GamePad / Joystick.

See GamePadListener for methods available as callbacks for registered listeners.

Definition at line 40 of file GamePad.h.

Member Enumeration Documentation

◆ Button

GamePad button enum.

Enumerator
BUTTON_0 

Button 0.

BUTTON_1 

Button 1.

BUTTON_2 

Button 2.

BUTTON_3 

Button 3.

BUTTON_L_SHOULDER 

Left shoulder.

BUTTON_R_SHOULDER 

Right shoulder.

BUTTON_BACK 

Back.

BUTTON_START 

Start.

BUTTON_HOME 

Home.

BUTTON_L_STICK 

Left stick.

BUTTON_R_STICK 

Right stick.

BUTTON_COUNT 

Button count.

BUTTON_UNKNOWN 

No button pressed.

Definition at line 62 of file GamePad.h.

◆ Hat

GamePad Hat enum.

Enumerator
HAT_LEFTUP 

Left up.

HAT_LEFT 

Left.

HAT_LEFTDOWN 

Left down.

HAT_UP 

Up.

HAT_CENTERED 

Centered.

HAT_DOWN 

Down.

HAT_RIGHTUP 

Right up.

HAT_RIGHT 

Right.

HAT_RIGHTDOWN 

Right down.

Definition at line 46 of file GamePad.h.

Constructor & Destructor Documentation

◆ GamePad()

GamePad::GamePad ( int32_hf  id)

Constructor.

Parameters
idGamePad ID.

Definition at line 37 of file GamePad.cpp.

Member Function Documentation

◆ addListener()

void GamePad::addListener ( GamePadListener listener)

Add a new listener class to receive GamePadListener callbacks.

Parameters
listenerClass to add as listener.
See also
removeListener()

Definition at line 52 of file GamePad.cpp.

◆ fireAxisMotionEvent()

void GamePad::fireAxisMotionEvent ( GamePadAxisInfo  axis)

Called internally when a GamePad axis motion event occurs. It calls GamePadListener::gamePadAxisMotion().

Parameters
axisGamePadAxisInfo structure.
See also
GamePadListener::gamePadAxisMotion()

Definition at line 64 of file GamePad.cpp.

◆ fireBallMotionEvent()

void GamePad::fireBallMotionEvent ( GamePadBallInfo  ball)

Called internally when a GamePad ball event occurs. It calls GamePadListener::gamePadBallMotion()).

Parameters
ballGamePadBallInfo structure.
See also
GamePadListener::gamePadBallMotion()

Definition at line 77 of file GamePad.cpp.

◆ fireButtonDownEvent()

void GamePad::fireButtonDownEvent ( GamePadButtonInfo  button)

Called internally when a GamePad button down event occurs. It calls GamePadListener::gamePadButtonDown().

Parameters
buttonGamePadButtonInfo structure.
See also
GamePadListener::gamePadButtonDown()

Definition at line 103 of file GamePad.cpp.

◆ fireButtonUpEvent()

void GamePad::fireButtonUpEvent ( GamePadButtonInfo  button)

Called internally when a GamePad button up event occurs. It calls GamePadListener::gamePadButtonUp().

Parameters
buttonGamePadButtonInfo structure.
See also
GamePadListener::gamePadButtonUp()

Definition at line 116 of file GamePad.cpp.

◆ fireHatMotionEvent()

void GamePad::fireHatMotionEvent ( GamePadHatInfo  hat)

Called internally when a GamePad hat event occurs. It calls GamePadListener::gamePadHatMotion().

Parameters
hatGamePadHatInfo structure.
See also
GamePadListener::gamePadHatMotion()

Definition at line 90 of file GamePad.cpp.

◆ getId()

int32_hf HFCore::GamePad::getId ( )
inline

Get the ID.

Returns
GamePad ID.

Definition at line 149 of file GamePad.h.

◆ getInstanceId()

int32_hf GamePad::getInstanceId ( )
virtual

Get GamePad instance id.

Returns
GamePad instance id.

Definition at line 134 of file GamePad.cpp.

◆ getName()

std::string GamePad::getName ( )
virtual

Get GamePad name.

Returns
GamePad name.

Definition at line 129 of file GamePad.cpp.

◆ getNumAxis()

int32_hf GamePad::getNumAxis ( )
virtual

Get number of GamePad axis available.

Returns
Number of GamePad axis.

Definition at line 139 of file GamePad.cpp.

◆ getNumBalls()

int32_hf GamePad::getNumBalls ( )
virtual

Get number of GamePad balls available.

Returns
Number of GamePad balls available.

Definition at line 144 of file GamePad.cpp.

◆ getNumButtons()

int32_hf GamePad::getNumButtons ( )
virtual

Get number of GamePad buttons available.

Returns
Number of GamePad buttons available.

Definition at line 149 of file GamePad.cpp.

◆ getNumHats()

int32_hf GamePad::getNumHats ( )
virtual

Get number of GamePad hats available.

Returns
Number of GamePad hats available.

Definition at line 154 of file GamePad.cpp.

◆ removeListener()

void GamePad::removeListener ( GamePadListener listener)

Remove a listener class from receiving further GamePadListener callbacks.

Parameters
listenerClass to remove as listener.
See also
addListener()

Definition at line 58 of file GamePad.cpp.

◆ setConnected()

void GamePad::setConnected ( bool  connected)
virtual

Set controller connected or disconnected.

Parameters
connectedtrue if connected, else false.
See also
isConnected()

Reimplemented from HFCore::Controller.

Definition at line 164 of file GamePad.cpp.

◆ setEnabled()

void GamePad::setEnabled ( bool  enabled)
virtual

Set controller enabled or disabled.

Parameters
enabledtrue to enable, else false.
See also
isEnabled()

Reimplemented from HFCore::Controller.

Definition at line 159 of file GamePad.cpp.


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