QcGamepadSource Class
The gamepads the client sees, behind one interface (decision E-540): the SDL3 backend of the game (QcSdlGamepadSource in src/app/input, polled on a Qt timer) and the virtual pads of tests and the control interface (QcVirtualGamepadSource) look the same to the input mapping. More...
| Header: | #include <clientcore/input/QcGamepadSource.h> |
| Inherits: | QObject |
| Inherited By: |
Public Functions
| QcGamepadSource(const QcGamepadSource &) | |
| QcGamepadSource(QcGamepadSource &&) | |
| virtual QString | backendName() const = 0 |
| bool | contains(int id) const |
| std::optional<QcGamepadInfo> | info(int id) const |
| virtual bool | isAvailable() const = 0 |
| QList<QcGamepadInfo> | pads() const |
| virtual void | poll() |
| virtual bool | rumble(int id, float strength, int durationMs) |
| QcGamepadState | state(int id) const |
| QcGamepadSource & | operator=(QcGamepadSource &&) |
| QcGamepadSource & | operator=(const QcGamepadSource &) |
Signals
| void | padConnected(int id) |
| void | padDisconnected(int id) |
| void | stateChanged(int id) |
Protected Functions
| int | addPad(QcGamepadInfo info) |
| void | removePad(int id) |
| void | updateState(int id, const QcGamepadState &state) |
Detailed Description
The base keeps the pads and their last state; a backend reports changes through the protected functions, which emit the signals. Ids are positive and never reused by one source. Lives on one thread.
Member Function Documentation
[delete] QcGamepadSource::QcGamepadSource(const QcGamepadSource &)
Copy-constructs an instance of QcGamepadSource. This function is deleted.
[delete] QcGamepadSource::QcGamepadSource(QcGamepadSource &&)
Move-constructs an instance of QcGamepadSource. This function is deleted.
[protected] int QcGamepadSource::addPad(QcGamepadInfo info)
Adds a pad with a released state and returns its new id (the id of info is ignored).
[pure virtual] QString QcGamepadSource::backendName() const
Returns a short name of the backend for logs and debug screens ("sdl3", "virtual").
bool QcGamepadSource::contains(int id) const
Returns whether pad id is connected.
std::optional<QcGamepadInfo> QcGamepadSource::info(int id) const
Returns the connected pad id; nullopt for an unknown id.
[pure virtual] bool QcGamepadSource::isAvailable() const
Returns whether the backend runs (SDL initialised); a source that is not available has no pads.
[signal] void QcGamepadSource::padConnected(int id)
Pad id connected.
[signal] void QcGamepadSource::padDisconnected(int id)
Pad id disconnected.
QList<QcGamepadInfo> QcGamepadSource::pads() const
Returns the connected pads in the order they were connected.
[virtual] void QcGamepadSource::poll()
Reads the hardware now (a no-op for sources that are fed from outside).
[protected] void QcGamepadSource::removePad(int id)
Removes pad id and emits padDisconnected.
[virtual] bool QcGamepadSource::rumble(int id, float strength, int durationMs)
Lets pad id vibrate with strength (0..1) for durationMs (decision E-615). Returns false when it cannot or the id is unknown. A new call replaces a running one.
QcGamepadState QcGamepadSource::state(int id) const
Returns the last state of pad id; all released and centred for an unknown id.
[signal] void QcGamepadSource::stateChanged(int id)
Emitted when the buttons or axes of pad id changed (raw values, before dead zone and curve).
[protected] void QcGamepadSource::updateState(int id, const QcGamepadState &state)
Stores state for pad id and emits stateChanged when it differs from the last one.
[delete] QcGamepadSource &QcGamepadSource::operator=(QcGamepadSource &&)
Move-assigns other to this QcGamepadSource instance. This function is deleted.
[delete] QcGamepadSource &QcGamepadSource::operator=(const QcGamepadSource &)
Copy-assigns other to this QcGamepadSource instance. This function is deleted.