QcGamepadControls Class
A gamepad steering the player (decision E-541): the left stick walks with stepless speed, the right stick looks, the triggers mine (right, also attacks) and use (left), the shoulders step through the hotbar, the stick clicks sprint (left) and toggle sneaking (right; held while flying, where it descends), south jumps and a double tap of it toggles creative flight. More...
| Header: | #include <clientcore/input/QcGamepadControls.h> |
| Inherits: | QObject |
Public Functions
| QcGamepadControls(const QcGamepadControls &) | |
| QcGamepadControls(QcGamepadControls &&) | |
| int | activePad() const |
| void | applyFrame(QcClientSession &session, float seconds, bool active) |
| void | keyboardOrMouseUsed() |
| bool | padInUse() const |
| qsizetype | pendingPresses() const |
| const QcGamepadProfile & | profile() const |
| bool | radialOpen() const |
| int | radialSlot() const |
| void | reset() |
| void | setSettings(const QcGamepadSettings &settings) |
| void | setSource(QcGamepadSource *source) |
| void | setWindowActive(bool active) |
| const QcGamepadSettings & | settings() const |
| bool | sneakToggled() const |
| void | suspend(QcClientSession *session) |
| QcGamepadControls & | operator=(QcGamepadControls &&) |
| QcGamepadControls & | operator=(const QcGamepadControls &) |
Signals
| void | profileChanged() |
| void | radialChanged() |
| void | worldAction(QcKeyBindings::Action action, bool pressed) |
Static Public Members
| const double | fullRumbleDamage |
| const qsizetype | maxPresses |
| const int | rumbleMs |
Detailed Description
Dead zones and curve come from the settings (QcGamepadCurve). A second writer of the session's intent beside the keyboard and mouse: the pad sets walking, jump, sneak and sprint only while it uses them and gives them back once (zero, false) when it stops, so the keyboard's values hold otherwise and the device last used wins without the two fighting; looking adds to the mouse. Presses are taken from the source's signals with their time, so a click shorter than one poll of the source (8 ms with SDL) still counts; they act at the next frame. They are queued only while the frames are active (world shown, window focused) and at most maxPresses of them: SDL reports pads in the background too, and a press there never waits for the window to come back. The pad that last pressed something or clearly pushed a stick leads. Driven once per frame (QcFrameDriver) or per tick (the control interface); lives in one thread. Beyond walking and acting (decision E-580): east drops (held: the stack), west picks the block in view, the screens and the player list are asked for with worldAction() like their keys, and a held button opens the hotbar's radial menu (QcHotbarRadial), where the right stick chooses a slot instead of looking.
Member Function Documentation
[delete] QcGamepadControls::QcGamepadControls(const QcGamepadControls &)
Copy-constructs an instance of QcGamepadControls. This function is deleted.
[delete] QcGamepadControls::QcGamepadControls(QcGamepadControls &&)
Move-constructs an instance of QcGamepadControls. This function is deleted.
int QcGamepadControls::activePad() const
Returns the pad that leads (0: none).
void QcGamepadControls::applyFrame(QcClientSession &session, float seconds, bool active)
One frame of seconds for session: the presses since the last frame act and the sticks walk and look. While not active, presses are dropped; the first inactive frame gives back what the pad holds (mining, a drawn bow, walking, jump, sneak, sprint). A toggled sneak stays on across inactive frames (screens, focus) and ends with the player's death.
void QcGamepadControls::keyboardOrMouseUsed()
A key, a click or a moved mouse (QcGamepadUi hands the input back): the pad is no longer in use.
bool QcGamepadControls::padInUse() const
Returns whether the leading pad is the device in use: it pressed a button, a trigger or clearly pushed a stick since it leads and since keyboardOrMouseUsed(). Only then does it vibrate, and only then does its disconnecting open the pause menu (decisions E-613, E-615).
qsizetype QcGamepadControls::pendingPresses() const
Returns the number of presses waiting for the next frame.
const QcGamepadProfile &QcGamepadControls::profile() const
Returns the profile of the leading pad (the standard one without a pad).
[signal] void QcGamepadControls::profileChanged()
Another pad leads (or none), or the settings changed: profile() may differ.
[signal] void QcGamepadControls::radialChanged()
The radial menu opened, closed or highlights another slot.
bool QcGamepadControls::radialOpen() const
Returns whether the radial menu of the hotbar is held open.
int QcGamepadControls::radialSlot() const
Returns the highlighted slot of the radial menu; -1 while closed.
void QcGamepadControls::reset()
Forgets everything without a session (the session ended or changed), a toggled sneak too.
void QcGamepadControls::setSettings(const QcGamepadSettings &settings)
Sets settings, the settings of all pads; each pad uses the profile of its model (decision E-611).
See also settings().
void QcGamepadControls::setSource(QcGamepadSource *source)
Sets the pads to follow, source (nullptr: none); it must outlive this object or be set to another.
void QcGamepadControls::setWindowActive(bool active)
Sets whether the game's window has the focus (active; true without a window): the pad does not vibrate in the background.
const QcGamepadSettings &QcGamepadControls::settings() const
Returns the settings of all pads.
bool QcGamepadControls::sneakToggled() const
Returns whether a click of the sneak button toggled sneaking on.
void QcGamepadControls::suspend(QcClientSession *session)
The frames stop or turn inactive without one being drawn (the window lost the focus or was minimised): gives back to session (null: none) what the pad holds and queues nothing until the next active frame.
[signal] void QcGamepadControls::worldAction(QcKeyBindings::Action action, bool pressed)
Emitted when the key action of the world was pressed (or, for the held player list, released): Pause, Inventory, Chat, Handbook, CameraView or PlayerList. The game opens the screen as with the key. The leading pad disconnecting in the world asks for Pause too (decision E-613).
[delete] QcGamepadControls &QcGamepadControls::operator=(QcGamepadControls &&)
Move-assigns other to this QcGamepadControls instance. This function is deleted.
[delete] QcGamepadControls &QcGamepadControls::operator=(const QcGamepadControls &)
Copy-assigns other to this QcGamepadControls instance. This function is deleted.
Member Variable Documentation
const double QcGamepadControls::fullRumbleDamage
Damage of this many health points or more vibrates at full strength (decision E-615).
const qsizetype QcGamepadControls::maxPresses
The most presses waiting for a frame; beyond it the oldest go.
const int QcGamepadControls::rumbleMs
How long a hurt vibrates, in milliseconds.