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

Represents various input button types, including keyboard keys, mouse buttons, and gamepad buttons. More...

#include <BufferedRaylib.hpp>

Public Types

enum class  Type { Invalid = 0 , Keyboard , Mouse , Gamepad }
 

Public Member Functions

bool operator< (const Button &o) const
 Overloaded less-than operator for comparing buttons. More...
 

Static Public Member Functions

static Button btn (MouseButton button)
 Creates a button associated with a mouse buttion. More...
 
static Button gamepad_button (GamepadButton button, int gamepad=0)
 Creates a button associated with a gamepad buttion. More...
 
static bool IsPressed (const Button &button)
 Checks if the specified button is currently pressed. More...
 
static uint8_t IsSetPressed (const std::set< Button > &buttons)
 Checks if a set of buttons is pressed. More...
 
static Button joy (GamepadButton button, int gamepad=0)
 Creates a button associated with a gamepad buttion. More...
 
static Button key (KeyboardKey key)
 Creates a button associated with a keyboard key. More...
 
static Button mouse_button (MouseButton button)
 Creates a button associated with a mouse buttion. More...
 
static Button pad (GamepadButton button, int gamepad=0)
 Creates a button associated with a gamepad buttion. More...
 

Public Attributes

union {
   struct {
      GamepadButton   button
 
      int   id
 
   }   gamepad
 
   KeyboardKey   keyboard
 
   MouseButton   mouse
 
}; 
 
enum raylib::Button::Type type
 

Detailed Description

Represents various input button types, including keyboard keys, mouse buttons, and gamepad buttons.

Definition at line 37 of file BufferedRaylib.hpp.

Member Enumeration Documentation

◆ Type

enum class raylib::Button::Type
strong

Definition at line 39 of file BufferedRaylib.hpp.

Member Function Documentation

◆ btn()

static Button raylib::Button::btn ( MouseButton  button)
inlinestatic

Creates a button associated with a mouse buttion.

Parameters
buttonthe button
Returns
Button

Definition at line 93 of file BufferedRaylib.hpp.

Referenced by mouse_button().

◆ gamepad_button()

static Button raylib::Button::gamepad_button ( GamepadButton  button,
int  gamepad = 0 
)
inlinestatic

Creates a button associated with a gamepad buttion.

Parameters
buttonthe button
gamrpadthe gamepad the button is associated with (default 0)
Returns
Button
Note
same as joy

Definition at line 128 of file BufferedRaylib.hpp.

References pad().

◆ IsPressed()

bool raylib::Button::IsPressed ( const Button button)
static

Checks if the specified button is currently pressed.

Parameters
buttonThe button to check.
Returns
True if the button is pressed, false otherwise.

Definition at line 21 of file BufferedRaylib.cpp.

Referenced by IsSetPressed().

◆ IsSetPressed()

uint8_t raylib::Button::IsSetPressed ( const std::set< Button > &  buttons)
static

Checks if a set of buttons is pressed.

Parameters
buttonsThe set of buttons to check.
Returns
The state of the buttons (number of buttons pressed) in the set.

Definition at line 35 of file BufferedRaylib.cpp.

References IsPressed().

◆ joy()

static Button raylib::Button::joy ( GamepadButton  button,
int  gamepad = 0 
)
inlinestatic

Creates a button associated with a gamepad buttion.

Parameters
buttonthe button
gamrpadthe gamepad the button is associated with (default 0)
Returns
Button
Note
same as joy

Definition at line 119 of file BufferedRaylib.hpp.

References pad().

◆ key()

static Button raylib::Button::key ( KeyboardKey  key)
inlinestatic

Creates a button associated with a keyboard key.

Parameters
keythe key
Returns
Button

Definition at line 85 of file BufferedRaylib.hpp.

References key().

Referenced by key(), and raylib::Action::wasd().

◆ mouse_button()

static Button raylib::Button::mouse_button ( MouseButton  button)
inlinestatic

Creates a button associated with a mouse buttion.

Parameters
buttonthe button
Returns
Button
Note
The same as btn

Definition at line 101 of file BufferedRaylib.hpp.

References btn().

◆ operator<()

bool raylib::Button::operator< ( const Button o) const

Overloaded less-than operator for comparing buttons.

Parameters
oThe button to compare against.
Returns
True if this button is less than the given button, false otherwise.

Definition at line 14 of file BufferedRaylib.cpp.

◆ pad()

static Button raylib::Button::pad ( GamepadButton  button,
int  gamepad = 0 
)
inlinestatic

Creates a button associated with a gamepad buttion.

Parameters
buttonthe button
gamrpadthe gamepad the button is associated with (default 0)
Returns
Button

Definition at line 110 of file BufferedRaylib.hpp.

Referenced by gamepad_button(), and joy().

Member Data Documentation

◆ button

GamepadButton raylib::Button::button

Definition at line 53 of file BufferedRaylib.hpp.

◆ id

int raylib::Button::id

Definition at line 52 of file BufferedRaylib.hpp.

◆ keyboard

KeyboardKey raylib::Button::keyboard

Definition at line 49 of file BufferedRaylib.hpp.

◆ mouse

MouseButton raylib::Button::mouse

Definition at line 50 of file BufferedRaylib.hpp.