Gamedev Framework (gf) 1.2.0
A C++17 framework for 2D games
Public Member Functions | Static Public Member Functions | List of all members
gf::Gamepad Class Reference

Some gamepad related functions. More...

#include <gf/Gamepad.h>

Public Member Functions

 Gamepad ()=delete
 Deleted constructor. More...
 

Static Public Member Functions

static const char * getAxisName (GamepadAxis axis)
 Get the axis name. More...
 
static const char * getButtonName (GamepadButton button)
 Get the button name. More...
 
static void initialize ()
 Initialize the already connected gamepads. More...
 
Gamepad management
static GamepadId open (GamepadHwId hwid)
 Open a gamepad. More...
 
static bool isAttached (GamepadId id)
 Check if a gamepad is attached. More...
 
static void close (GamepadId id)
 Close a gamepad. More...
 
static const char * getName (GamepadId id)
 Get the name of the gamepad. More...
 

Detailed Description

Some gamepad related functions.

Constructor & Destructor Documentation

◆ Gamepad()

gf::Gamepad::Gamepad ( )
delete

Deleted constructor.

Member Function Documentation

◆ close()

static void gf::Gamepad::close ( GamepadId  id)
static

Close a gamepad.

Generally, this function is called after a GamepadDisconnected event.

Example:

gf::Gamepad::close(event.gamepadDisconnection.id);
}
static void close(GamepadId id)
Close a gamepad.
@ GamepadDisconnected
A gamepad was disconnected (data in event.gamepadDisconnection)
Parameters
idThe gamepad id
See also
open()

◆ getAxisName()

static const char * gf::Gamepad::getAxisName ( GamepadAxis  axis)
static

Get the axis name.

Parameters
axisA gamepad axis
Returns
A string representation of the axis

◆ getButtonName()

static const char * gf::Gamepad::getButtonName ( GamepadButton  button)
static

Get the button name.

Parameters
buttonA gamepad button
Returns
A string representation of the button

◆ getName()

static const char * gf::Gamepad::getName ( GamepadId  id)
static

Get the name of the gamepad.

Parameters
idThe gamepad id
Returns
A string representation of the gamepad

◆ initialize()

static void gf::Gamepad::initialize ( )
static

Initialize the already connected gamepads.

◆ isAttached()

static bool gf::Gamepad::isAttached ( GamepadId  id)
static

Check if a gamepad is attached.

Parameters
idThe gamepad id
Returns
True if the gamepad is attached

◆ open()

static GamepadId gf::Gamepad::open ( GamepadHwId  hwid)
static

Open a gamepad.

Generally, this function is called after a GamepadConnected event.

Example:

if (event.type == gf::EventType::GamepadConnected) {
gf::GamepadId id = gf::Gamepad::open(event.gamepadConnection.id);
// do something with id
}
static GamepadId open(GamepadHwId hwid)
Open a gamepad.
GamepadId
A gamepad identifier.
Definition: Gamepad.h:123
@ GamepadConnected
A gamepad was connected (data in event.gamepadConnection)
Parameters
hwidThe hardware identifier
Returns
The identifier of the gamepad
See also
close()