QtCraft API C++ classes QML types Handbook

QcGamepadState Class

One pad's buttons and axes at one moment, normalised and independent of the backend. More...

Header: #include <clientcore/input/QcGamepadState.h>

Public Functions

float axis(QcGamepadAxis axis) const
bool pressed(QcGamepadButton button) const
void setAxis(QcGamepadAxis axis, float value)
void setPressed(QcGamepadButton button, bool pressed)

Static Public Members

bool isTrigger(QcGamepadAxis axis)
enum class QcGamepadAxis { LeftX, LeftY, RightX, RightY, LeftTrigger, …, Count }
enum class QcGamepadButton { South, East, West, North, Back, …, Count }
enum class QcGamepadType { Generic, Xbox, PlayStation, SwitchPro }
const std::size_t qcGamepadAxisCount
const std::size_t qcGamepadButtonCount

Detailed Description

Member Function Documentation

float QcGamepadState::axis(QcGamepadAxis axis) const

Returns the value of axis.

See also setAxis().

[static] bool QcGamepadState::isTrigger(QcGamepadAxis axis)

Returns whether axis is a trigger (range [0, 1]).

bool QcGamepadState::pressed(QcGamepadButton button) const

Returns whether button is pressed.

See also setPressed().

void QcGamepadState::setAxis(QcGamepadAxis axis, float value)

Sets axis to value, clamped to [-1, 1] for the sticks and [0, 1] for the triggers; NaN counts as 0.

See also axis().

void QcGamepadState::setPressed(QcGamepadButton button, bool pressed)

Sets whether button is pressed.

See also pressed().

Related Non-Members

enum class QcGamepadAxis

The analogue inputs: sticks in [-1, 1] (x positive to the right, y positive downwards, as SDL and most pads report them), triggers in [0, 1].

ConstantValueDescription
QcGamepadState::QcGamepadAxis::LeftX0left stick, horizontal
QcGamepadState::QcGamepadAxis::LeftY1left stick, vertical
QcGamepadState::QcGamepadAxis::RightX2right stick, horizontal
QcGamepadState::QcGamepadAxis::RightY3right stick, vertical
QcGamepadState::QcGamepadAxis::LeftTrigger4left trigger
QcGamepadState::QcGamepadAxis::RightTrigger5right trigger
QcGamepadState::QcGamepadAxis::Count6the number of axes, not an axis

enum class QcGamepadButton

The buttons of a gamepad by position, not by label (decision E-540): South is A on an Xbox pad, Cross on a PlayStation pad and B on a Switch Pro pad.

The triggers are axes.

ConstantValueDescription
QcGamepadState::QcGamepadButton::South0bottom face button
QcGamepadState::QcGamepadButton::East1right face button
QcGamepadState::QcGamepadButton::West2left face button
QcGamepadState::QcGamepadButton::North3top face button
QcGamepadState::QcGamepadButton::Back4the left middle button (Back, Share, Minus)
QcGamepadState::QcGamepadButton::Guide5the logo button
QcGamepadState::QcGamepadButton::Start6the right middle button (Start, Options, Plus)
QcGamepadState::QcGamepadButton::LeftStick7pressing the left stick
QcGamepadState::QcGamepadButton::RightStick8pressing the right stick
QcGamepadState::QcGamepadButton::LeftShoulder9left bumper
QcGamepadState::QcGamepadButton::RightShoulder10right bumper
QcGamepadState::QcGamepadButton::DpadUp11d-pad up
QcGamepadState::QcGamepadButton::DpadDown12d-pad down
QcGamepadState::QcGamepadButton::DpadLeft13d-pad left
QcGamepadState::QcGamepadButton::DpadRight14d-pad right
QcGamepadState::QcGamepadButton::Count15the number of buttons, not a button

enum class QcGamepadType

The family of a pad, for button symbols in HUD and help texts.

ConstantValueDescription
QcGamepadState::QcGamepadType::Generic0unknown family: generic symbols
QcGamepadState::QcGamepadType::Xbox1Xbox and compatible pads
QcGamepadState::QcGamepadType::PlayStation2PlayStation pads
QcGamepadState::QcGamepadType::SwitchPro3Nintendo Switch Pro pads

const std::size_t qcGamepadAxisCount

Number of axes.

const std::size_t qcGamepadButtonCount

Number of buttons.