ChaiLove API  0.28.0
Public Member Functions
love::joystick Class Reference

Provides an interface to connected joysticks. More...

Public Member Functions

std::vector< Joystick * > & getJoysticks ()
 Gets a list of connected Joysticks. More...
 
int getJoystickCount ()
 Gets the number of connected joysticks. More...
 
bool isDown (int joystick, int button)
 Checks if a button number is pressed on a joystick. More...
 
bool isDown (int joystick, const std::string &button)
 Checks if a button is pressed on a joystick. More...
 
Joystickoperator[] (int joystick)
 Retrieve the given joystick. More...
 

Detailed Description

Provides an interface to connected joysticks.

Member Function Documentation

◆ getJoystickCount()

int love::joystick::getJoystickCount ( )

Gets the number of connected joysticks.

Returns
The number of connected joysticks.

◆ getJoysticks()

std::vector<Joystick*>& love::joystick::getJoysticks ( )

Gets a list of connected Joysticks.

Returns
Gets a list of connected Joysticks.

◆ isDown() [1/2]

bool love::joystick::isDown ( int  joystick,
int  button 
)

Checks if a button number is pressed on a joystick.

Parameters
joystickThe joystick to be checked.
buttonThe button to be checked.
Returns
True if the joystick button is pressed.

◆ isDown() [2/2]

bool love::joystick::isDown ( int  joystick,
const std::string &  button 
)

Checks if a button is pressed on a joystick.

Example

if (love.joystick.isDown(0, "left")) {
love.graphics.print("Joystick is pushed LEFT", 100, 100)
}
Parameters
joystickThe joystick to be checked.
buttonThe button to be checked.
Returns
True if the joystick button is pressed.

◆ operator[]()

Joystick* love::joystick::operator[] ( int  joystick)

Retrieve the given joystick.

Example

if (love.joystick[0].isDown("left")) {
love.graphics.print("Joystick is pushed LEFT", 100, 100)
}
Parameters
joystickThe joystick index to be retrieved.
Returns
The joystick of the given player number.