#include <gInputPlayer.h>
|
| | gInputPlayer (gInputManager *manager, int playerindex) |
| |
| | ~gInputPlayer () |
| |
| int | getPlayerIndex () const |
| |
| void | setKeyboardMouseAssigned (bool assigned) |
| |
| bool | isKeyboardMouseAssigned () const |
| |
| void | setGamepadId (int id) |
| |
| int | getGamepadId () const |
| |
| bool | hasGamepad () const |
| |
| void | setDeadzone (float dz) |
| |
| float | getDeadzone () const |
| |
| void | addActionBinding (const std::string &action, int keyCode) |
| |
| void | removeActionBinding (const std::string &action, int keyCode) |
| |
| void | clearActionBindings (const std::string &action) |
| |
| void | rebindAction (const std::string &action, int keyCode) |
| |
| void | addGamepadActionBinding (const std::string &action, int buttonId) |
| |
| void | removeGamepadActionBinding (const std::string &action, int buttonId) |
| |
| void | clearGamepadActionBindings (const std::string &action) |
| |
| void | addAxisBinding (const std::string &axis, int negativeKey, int positiveKey) |
| |
| void | removeAxisBinding (const std::string &axis, int negativeKey, int positiveKey) |
| |
| void | clearAxisBindings (const std::string &axis) |
| |
| void | rebindAxis (const std::string &axis, int negativeKey, int positiveKey) |
| |
| void | addGamepadAxisBinding (const std::string &axis, int gamepadAxisId, bool inverted=false) |
| |
| void | removeGamepadAxisBinding (const std::string &axis, int gamepadAxisId) |
| |
| void | clearGamepadAxisBindings (const std::string &axis) |
| |
| void | addGamepadButtonAxisBinding (const std::string &axis, int negativeButtonId, int positiveButtonId) |
| |
| void | removeGamepadButtonAxisBinding (const std::string &axis, int negativeButtonId, int positiveButtonId) |
| |
| void | clearGamepadButtonAxisBindings (const std::string &axis) |
| |
| bool | isActionPressed (const std::string &action) const |
| |
| bool | isActionJustPressed (const std::string &action) const |
| |
| float | getAxisValue (const std::string &axis) const |
| |
| void | getMouseDelta (float &dx, float &dy) const |
| |
| const std::vector< int > & | getActionBindings (const std::string &action) const |
| |
| const std::vector< AxisBinding > & | getAxisBindings (const std::string &axis) const |
| |
Per-player input context with device assignment and bindings.
Each player can be assigned keyboard+mouse, a specific gamepad, or both. Bindings are per-player, so multiple players can use the same action/axis names with different devices.
Example - single player with keyboard + gamepad:
#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 setup:
◆ gInputPlayer()
| gInputPlayer::gInputPlayer |
( |
gInputManager * |
manager, |
|
|
int |
playerindex |
|
) |
| |
◆ ~gInputPlayer()
| gInputPlayer::~gInputPlayer |
( |
| ) |
|
◆ addActionBinding()
| void gInputPlayer::addActionBinding |
( |
const std::string & |
action, |
|
|
int |
keyCode |
|
) |
| |
◆ addAxisBinding()
| void gInputPlayer::addAxisBinding |
( |
const std::string & |
axis, |
|
|
int |
negativeKey, |
|
|
int |
positiveKey |
|
) |
| |
◆ addGamepadActionBinding()
| void gInputPlayer::addGamepadActionBinding |
( |
const std::string & |
action, |
|
|
int |
buttonId |
|
) |
| |
◆ addGamepadAxisBinding()
| void gInputPlayer::addGamepadAxisBinding |
( |
const std::string & |
axis, |
|
|
int |
gamepadAxisId, |
|
|
bool |
inverted = false |
|
) |
| |
Binds a gamepad analog axis (stick or trigger) to a named axis. Set inverted=true to negate the value (e.g. Y-axis where up is negative).
◆ addGamepadButtonAxisBinding()
| void gInputPlayer::addGamepadButtonAxisBinding |
( |
const std::string & |
axis, |
|
|
int |
negativeButtonId, |
|
|
int |
positiveButtonId |
|
) |
| |
◆ clearActionBindings()
| void gInputPlayer::clearActionBindings |
( |
const std::string & |
action | ) |
|
◆ clearAxisBindings()
| void gInputPlayer::clearAxisBindings |
( |
const std::string & |
axis | ) |
|
◆ clearGamepadActionBindings()
| void gInputPlayer::clearGamepadActionBindings |
( |
const std::string & |
action | ) |
|
◆ clearGamepadAxisBindings()
| void gInputPlayer::clearGamepadAxisBindings |
( |
const std::string & |
axis | ) |
|
◆ clearGamepadButtonAxisBindings()
| void gInputPlayer::clearGamepadButtonAxisBindings |
( |
const std::string & |
axis | ) |
|
◆ getActionBindings()
| const std::vector< int > & gInputPlayer::getActionBindings |
( |
const std::string & |
action | ) |
const |
◆ getAxisBindings()
| const std::vector< AxisBinding > & gInputPlayer::getAxisBindings |
( |
const std::string & |
axis | ) |
const |
◆ getAxisValue()
| float gInputPlayer::getAxisValue |
( |
const std::string & |
axis | ) |
const |
Returns combined axis value in [-1, +1] from all binding types. Keyboard keys contribute +/-1, gamepad analog uses deadzone, gamepad buttons contribute +/-1.
◆ getDeadzone()
| float gInputPlayer::getDeadzone |
( |
| ) |
const |
◆ getGamepadId()
| int gInputPlayer::getGamepadId |
( |
| ) |
const |
◆ getMouseDelta()
| void gInputPlayer::getMouseDelta |
( |
float & |
dx, |
|
|
float & |
dy |
|
) |
| const |
Returns mouse delta if this player has KB+M assigned, otherwise (0, 0).
◆ getPlayerIndex()
| int gInputPlayer::getPlayerIndex |
( |
| ) |
const |
◆ hasGamepad()
| bool gInputPlayer::hasGamepad |
( |
| ) |
const |
◆ isActionJustPressed()
| bool gInputPlayer::isActionJustPressed |
( |
const std::string & |
action | ) |
const |
Returns true if the action was first pressed this frame.
◆ isActionPressed()
| bool gInputPlayer::isActionPressed |
( |
const std::string & |
action | ) |
const |
Returns true if the action is pressed via any bound source (keyboard key if KB+M assigned, gamepad button if gamepad assigned).
◆ isKeyboardMouseAssigned()
| bool gInputPlayer::isKeyboardMouseAssigned |
( |
| ) |
const |
◆ rebindAction()
| void gInputPlayer::rebindAction |
( |
const std::string & |
action, |
|
|
int |
keyCode |
|
) |
| |
◆ rebindAxis()
| void gInputPlayer::rebindAxis |
( |
const std::string & |
axis, |
|
|
int |
negativeKey, |
|
|
int |
positiveKey |
|
) |
| |
◆ removeActionBinding()
| void gInputPlayer::removeActionBinding |
( |
const std::string & |
action, |
|
|
int |
keyCode |
|
) |
| |
◆ removeAxisBinding()
| void gInputPlayer::removeAxisBinding |
( |
const std::string & |
axis, |
|
|
int |
negativeKey, |
|
|
int |
positiveKey |
|
) |
| |
◆ removeGamepadActionBinding()
| void gInputPlayer::removeGamepadActionBinding |
( |
const std::string & |
action, |
|
|
int |
buttonId |
|
) |
| |
◆ removeGamepadAxisBinding()
| void gInputPlayer::removeGamepadAxisBinding |
( |
const std::string & |
axis, |
|
|
int |
gamepadAxisId |
|
) |
| |
◆ removeGamepadButtonAxisBinding()
| void gInputPlayer::removeGamepadButtonAxisBinding |
( |
const std::string & |
axis, |
|
|
int |
negativeButtonId, |
|
|
int |
positiveButtonId |
|
) |
| |
◆ setDeadzone()
| void gInputPlayer::setDeadzone |
( |
float |
dz | ) |
|
Analog stick deadzone. Values below this threshold read as 0. Default: 0.1
◆ setGamepadId()
| void gInputPlayer::setGamepadId |
( |
int |
id | ) |
|
Assigns a gamepad by GLFW joystick ID (0-15). Pass -1 to unassign.
◆ setKeyboardMouseAssigned()
| void gInputPlayer::setKeyboardMouseAssigned |
( |
bool |
assigned | ) |
|
Assigns or unassigns keyboard+mouse to this player. Only player 0 has KB+M assigned by default.
The documentation for this class was generated from the following file: