GlistEngine
Loading...
Searching...
No Matches
gInputManager Class Reference

#include <gInputManager.h>

Inheritance diagram for gInputManager:
Collaboration diagram for gInputManager:

Public Types

typedef gInputPlayer::AxisBinding AxisBinding
 

Public Member Functions

 gInputManager ()
 
 ~gInputManager ()
 
gInputPlayergetPlayer (int playerIndex)
 
int getPlayerCount () const
 
bool isKeyPressed (int keyCode) const
 
bool isKeyJustPressed (int keyCode) const
 
void getMouseDelta (float &dx, float &dy) const
 
bool isGamepadConnected (int gamepadId) const
 
bool isGamepadButtonPressed (int gamepadId, int buttonId) const
 
bool isGamepadButtonJustPressed (int gamepadId, int buttonId) const
 
float getGamepadAxisValue (int gamepadId, int axisId) const
 
void update ()
 
- Public Member Functions inherited from gEventHook
 gEventHook ()
 
virtual ~gEventHook ()
 

Static Public Attributes

static const int MAXGAMEPADS = 16
 
static const int MAXGAMEPADBUTTONS = 15
 
static const int MAXGAMEPADAXES = 6
 
- Static Public Attributes inherited from gEventHook
static std::list< gEventHook * > hooks
 

Detailed Description

Central input manager that tracks raw device state and manages per-player input contexts. Supports keyboard+mouse and up to 16 gamepads.

Player 0 is created automatically and assigned to keyboard+mouse. Additional players can be created for local co-op.

Example - single player with keyboard + gamepad fallback:

p->addAxisBinding("horizontal", G_KEY_A, G_KEY_D);
gInputPlayer * getPlayer(int playerIndex)
Definition gInputPlayer.h:42
void addAxisBinding(const std::string &axis, int negativeKey, int positiveKey)
void addGamepadAxisBinding(const std::string &axis, int gamepadAxisId, bool inverted=false)
void setGamepadId(int id)
gInputManager * inputmanager
#define G_KEY_A
Definition gKeyCode.h:25
#define G_GAMEPAD_AXIS_LEFT_X
Definition gKeyCode.h:152
#define G_KEY_D
Definition gKeyCode.h:28

Example - local co-op:

p1->setGamepadId(0);
void addGamepadActionBinding(const std::string &action, int buttonId)
#define G_GAMEPAD_BUTTON_A
Definition gKeyCode.h:131

Member Typedef Documentation

◆ AxisBinding

Constructor & Destructor Documentation

◆ gInputManager()

gInputManager::gInputManager ( )

◆ ~gInputManager()

gInputManager::~gInputManager ( )

Member Function Documentation

◆ getGamepadAxisValue()

float gInputManager::getGamepadAxisValue ( int  gamepadId,
int  axisId 
) const

◆ getMouseDelta()

void gInputManager::getMouseDelta ( float &  dx,
float &  dy 
) const

◆ getPlayer()

gInputPlayer * gInputManager::getPlayer ( int  playerIndex)

Returns the player at the given index. Creates it if it doesn't exist. Player 0 always exists and has KB+M assigned by default.

◆ getPlayerCount()

int gInputManager::getPlayerCount ( ) const

Returns the number of players currently created.

◆ isGamepadButtonJustPressed()

bool gInputManager::isGamepadButtonJustPressed ( int  gamepadId,
int  buttonId 
) const

◆ isGamepadButtonPressed()

bool gInputManager::isGamepadButtonPressed ( int  gamepadId,
int  buttonId 
) const

◆ isGamepadConnected()

bool gInputManager::isGamepadConnected ( int  gamepadId) const

◆ isKeyJustPressed()

bool gInputManager::isKeyJustPressed ( int  keyCode) const

◆ isKeyPressed()

bool gInputManager::isKeyPressed ( int  keyCode) const

◆ update()

void gInputManager::update ( )

Resets per-frame state and polls gamepads. Called by gAppManager at the start of each tick.

Member Data Documentation

◆ MAXGAMEPADAXES

const int gInputManager::MAXGAMEPADAXES = 6
static

◆ MAXGAMEPADBUTTONS

const int gInputManager::MAXGAMEPADBUTTONS = 15
static

◆ MAXGAMEPADS

const int gInputManager::MAXGAMEPADS = 16
static

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