raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
raylib::Gamepad Class Reference

Input-related functions: gamepads. More...

#include <Gamepad.hpp>

Public Member Functions

 Gamepad (int gamepadNumber=0)
 
int GetAxisCount () const
 Return gamepad axis count for a gamepad. More...
 
float GetAxisMovement (int axis) const
 Return axis movement value for a gamepad axis. More...
 
std::string GetName () const
 Return gamepad internal name id. More...
 
int GetNumber () const
 Retrieves the number value for the object. More...
 
bool IsAvailable () const
 Detect if a gamepad is available. More...
 
bool IsButtonDown (int button) const
 Detect if a gamepad button is being pressed. More...
 
bool IsButtonPressed (int button) const
 Detect if a gamepad button has been pressed once. More...
 
bool IsButtonReleased (int button) const
 Detect if a gamepad button has been released once. More...
 
bool IsButtonUp (int button) const
 Detect if a gamepad button is NOT being pressed. More...
 
 operator int () const
 
 operator std::string () const
 Return gamepad internal name id. More...
 
Gamepadoperator= (const Gamepad &gamepad)
 
Gamepadoperator= (int gamepadNumber)
 
int SetMappings (const std::string_view mappings)
 
void SetNumber (int value)
 Sets the number value for the object. More...
 
void SetVibration (float leftMotor, float rightMotor, float duration) const
 Set gamepad vibration for both motors (duration in seconds) More...
 

Static Public Member Functions

static int GetButtonPressed ()
 Get the last gamepad button pressed. More...
 
static bool IsAvailable (int number)
 Detect if a gamepad is available. More...
 

Public Attributes

int number
 

Protected Member Functions

void set (int gamepadNumber)
 

Detailed Description

Input-related functions: gamepads.

Definition at line 14 of file Gamepad.hpp.

Constructor & Destructor Documentation

◆ Gamepad()

raylib::Gamepad::Gamepad ( int  gamepadNumber = 0)
inline

Definition at line 16 of file Gamepad.hpp.

Member Function Documentation

◆ GetAxisCount()

int raylib::Gamepad::GetAxisCount ( ) const
inline

Return gamepad axis count for a gamepad.

Definition at line 85 of file Gamepad.hpp.

◆ GetAxisMovement()

float raylib::Gamepad::GetAxisMovement ( int  axis) const
inline

Return axis movement value for a gamepad axis.

Definition at line 90 of file Gamepad.hpp.

◆ GetButtonPressed()

static int raylib::Gamepad::GetButtonPressed ( )
inlinestatic

Get the last gamepad button pressed.

Definition at line 80 of file Gamepad.hpp.

◆ GetName()

std::string raylib::Gamepad::GetName ( ) const
inline

Return gamepad internal name id.

Definition at line 50 of file Gamepad.hpp.

Referenced by operator std::string().

◆ GetNumber()

int raylib::Gamepad::GetNumber ( ) const
inline

Retrieves the number value for the object.

Returns
The number value of the object.

Definition at line 19 of file Gamepad.hpp.

◆ IsAvailable() [1/2]

bool raylib::Gamepad::IsAvailable ( ) const
inline

Detect if a gamepad is available.

Definition at line 40 of file Gamepad.hpp.

◆ IsAvailable() [2/2]

static bool raylib::Gamepad::IsAvailable ( int  number)
inlinestatic

Detect if a gamepad is available.

Definition at line 45 of file Gamepad.hpp.

◆ IsButtonDown()

bool raylib::Gamepad::IsButtonDown ( int  button) const
inline

Detect if a gamepad button is being pressed.

Definition at line 65 of file Gamepad.hpp.

◆ IsButtonPressed()

bool raylib::Gamepad::IsButtonPressed ( int  button) const
inline

Detect if a gamepad button has been pressed once.

Definition at line 60 of file Gamepad.hpp.

◆ IsButtonReleased()

bool raylib::Gamepad::IsButtonReleased ( int  button) const
inline

Detect if a gamepad button has been released once.

Definition at line 70 of file Gamepad.hpp.

◆ IsButtonUp()

bool raylib::Gamepad::IsButtonUp ( int  button) const
inline

Detect if a gamepad button is NOT being pressed.

Definition at line 75 of file Gamepad.hpp.

◆ operator int()

raylib::Gamepad::operator int ( ) const
inlineexplicit

Definition at line 35 of file Gamepad.hpp.

◆ operator std::string()

raylib::Gamepad::operator std::string ( ) const
inlineexplicit

Return gamepad internal name id.

Definition at line 55 of file Gamepad.hpp.

References GetName().

◆ operator=() [1/2]

Gamepad & raylib::Gamepad::operator= ( const Gamepad gamepad)
inline

Definition at line 21 of file Gamepad.hpp.

◆ operator=() [2/2]

Gamepad & raylib::Gamepad::operator= ( int  gamepadNumber)
inline

Definition at line 28 of file Gamepad.hpp.

◆ set()

void raylib::Gamepad::set ( int  gamepadNumber)
inlineprotected

Definition at line 103 of file Gamepad.hpp.

◆ SetMappings()

int raylib::Gamepad::SetMappings ( const std::string_view  mappings)
inline

Definition at line 92 of file Gamepad.hpp.

◆ SetNumber()

void raylib::Gamepad::SetNumber ( int  value)
inline

Sets the number value for the object.

Parameters
valueThe value of which to set number to.

Definition at line 19 of file Gamepad.hpp.

◆ SetVibration()

void raylib::Gamepad::SetVibration ( float  leftMotor,
float  rightMotor,
float  duration 
) const
inline

Set gamepad vibration for both motors (duration in seconds)

Definition at line 99 of file Gamepad.hpp.

Member Data Documentation

◆ number

int raylib::Gamepad::number

Definition at line 17 of file Gamepad.hpp.