QGamepad Class

A gamepad device connected to a system More...

Header: #include <QGamepad>
qmake: QT += gamepad

Properties

Public Functions

QGamepad(int deviceId = 0, QObject *parent = nullptr)
~QGamepad()
double axisLeftX() const
double axisLeftY() const
double axisRightX() const
double axisRightY() const
bool buttonL1() const
double buttonL2() const
bool buttonL3() const
bool buttonR1() const
double buttonR2() const
bool buttonR3() const
bool buttonA() const
bool buttonB() const
bool buttonCenter() const
bool buttonDown() const
bool buttonGuide() const
bool buttonLeft() const
bool buttonRight() const
bool buttonSelect() const
bool buttonStart() const
bool buttonUp() const
bool buttonX() const
bool buttonY() const
int deviceId() const
bool isConnected() const
QString name() const

Public Slots

void setDeviceId(int number)

Signals

void axisLeftXChanged(double value)
void axisLeftYChanged(double value)
void axisRightXChanged(double value)
void axisRightYChanged(double value)
void buttonAChanged(bool value)
void buttonBChanged(bool value)
void buttonCenterChanged(bool value)
void buttonDownChanged(bool value)
void buttonGuideChanged(bool value)
void buttonL1Changed(bool value)
void buttonL2Changed(double value)
void buttonL3Changed(bool value)
void buttonLeftChanged(bool value)
void buttonR1Changed(bool value)
void buttonR2Changed(double value)
void buttonR3Changed(bool value)
void buttonRightChanged(bool value)
void buttonSelectChanged(bool value)
void buttonStartChanged(bool value)
void buttonUpChanged(bool value)
void buttonXChanged(bool value)
void buttonYChanged(bool value)
void connectedChanged(bool value)
void deviceIdChanged(int value)
void nameChanged(QString value)

Detailed Description

A gamepad device connected to a system

QGamepad is used to access the current state of gamepad hardware connected to a system.

Property Documentation

axisLeftX : const double

This property holds the value of the left thumbstick's X axis. The range of axis values are from -1.0 to 1.0

Access functions:

double axisLeftX() const

Notifier signal:

void axisLeftXChanged(double value)

axisLeftY : const double

This property holds the value of the left thumbstick's Y axis. The range of axis values are from -1.0 to 1.0

Access functions:

double axisLeftY() const

Notifier signal:

void axisLeftYChanged(double value)

axisRightX : const double

This property holds the value of the right thumbstick's X axis. The range of axis values are from -1.0 to 1.0

Access functions:

double axisRightX() const

Notifier signal:

void axisRightXChanged(double value)

axisRightY : const double

This property holds the value of the right thumbstick's Y axis. The range of axis values are from -1.0 to 1.0

Access functions:

double axisRightY() const

Notifier signal:

void axisRightYChanged(double value)

buttonL1 : const bool

This property holds the state of the left shoulder button. True when pressed, false when not pressed.

Access functions:

bool buttonL1() const

Notifier signal:

void buttonL1Changed(bool value)

buttonL2 : const double

This property holds the value of the left trigger button. This trigger value ranges from 0.0 when not pressed to 1.0 when pressed completely.

Access functions:

double buttonL2() const

Notifier signal:

void buttonL2Changed(double value)

buttonL3 : const bool

This property holds the state of the left stick button. True when pressed, false when not pressed. This button is usually triggered by pressing the left joystick itself.

Access functions:

bool buttonL3() const

Notifier signal:

void buttonL3Changed(bool value)

buttonR1 : const bool

This property holds the state of the right shoulder button. True when pressed, false when not pressed.

Access functions:

bool buttonR1() const

Notifier signal:

void buttonR1Changed(bool value)

buttonR2 : const double

This property holds the value of the right trigger button. This trigger value ranges from 0.0 when not pressed to 1.0 when pressed completely.

Access functions:

double buttonR2() const

Notifier signal:

void buttonR2Changed(double value)

buttonR3 : const bool

This property holds the state of the right stick button. True when pressed, false when not pressed. This button is usually triggered by pressing the right joystick itself.

Access functions:

bool buttonR3() const

Notifier signal:

void buttonR3Changed(bool value)

buttonA : const bool

This property holds the state of the A button. True when pressed, false when not pressed.

Access functions:

bool buttonA() const

Notifier signal:

void buttonAChanged(bool value)

buttonB : const bool

This property holds the state of the B button. True when pressed, false when not pressed.

Access functions:

bool buttonB() const

Notifier signal:

void buttonBChanged(bool value)

buttonCenter : const bool

Access functions:

bool buttonCenter() const

Notifier signal:

void buttonCenterChanged(bool value)

buttonDown : const bool

This property holds the state of the direction pad down button. True when pressed, false when not pressed.

Access functions:

bool buttonDown() const

Notifier signal:

void buttonDownChanged(bool value)

buttonGuide : const bool

This property holds the state of the guide button. True when pressed, false when not pressed. This button is typically the one in the center of the gamepad with a logo. Some gamepads will not have a guide button.

Access functions:

bool buttonGuide() const

Notifier signal:

void buttonGuideChanged(bool value)

buttonLeft : const bool

This property holds the state of the direction pad left button. True when pressed, false when not pressed.

Access functions:

bool buttonLeft() const

Notifier signal:

void buttonLeftChanged(bool value)

buttonRight : const bool

This property holds the state of the direction pad right button. True when pressed, false when not pressed.

Access functions:

bool buttonRight() const

Notifier signal:

void buttonRightChanged(bool value)

buttonSelect : const bool

This property holds the state of the Select button. True when pressed, false when not pressed. This button can sometimes be labled as the Back button on some gamepads.

Access functions:

bool buttonSelect() const

Notifier signal:

void buttonSelectChanged(bool value)

buttonStart : const bool

This property holds the state of the Start button. True when pressed, false when not pressed. This button can sometimes be labled as the Forward button on some gamepads.

Access functions:

bool buttonStart() const

Notifier signal:

void buttonStartChanged(bool value)

buttonUp : const bool

This property holds the state of the direction pad up button. True when pressed, false when not pressed.

Access functions:

bool buttonUp() const

Notifier signal:

void buttonUpChanged(bool value)

buttonX : const bool

This property holds the state of the X button. True when pressed, false when not pressed.

Access functions:

bool buttonX() const

Notifier signal:

void buttonXChanged(bool value)

buttonY : const bool

This property holds the state of the Y button. True when pressed, false when not pressed.

Access functions:

bool buttonY() const

Notifier signal:

void buttonYChanged(bool value)

connected : const bool

Access functions:

bool isConnected() const

Notifier signal:

void connectedChanged(bool value)

deviceId : int

This property holds the deviceId of the gamepad device. It is possible for there to be multiple gamepad devices connected at any given time, so setting this property defines which gamepad to use.

Access functions:

int deviceId() const
void setDeviceId(int number)

Notifier signal:

void deviceIdChanged(int value)

name : const QString

This property holds the reported name of the gamepad if one is available.

Access functions:

QString name() const

Notifier signal:

void nameChanged(QString value)

Member Function Documentation

QGamepad::QGamepad(int deviceId = 0, QObject *parent = nullptr)

Constructs a QGamepad for deviceId. deviceId is the id of the gamepad you wish to see the state of parent

QGamepad::~QGamepad()

Destroys the QGamepad.