QcGamepadMapping Namespace
What the pad does in the world and the arithmetic behind it (decision E-541), without state and without a session: the default bindings, the walking direction of the left stick, the turn of the right stick in one frame, the triggers as buttons and the hotbar steps of the shoulders. More...
| Header: | #include <clientcore/input/QcGamepadMapping.h> |
Classes
Types
| enum class | Action { Jump, Sprint, Sneak, Mine, Use, …, Count } |
Variables
| const std::size_t | actionCount |
| const std::array<QcGamepadMapping::Combo, 2> | combos |
| const qint64 | dropStackMs |
| const float | leadDeflection |
| const float | sprintForward |
| const QcGamepadButton | unbound |
Functions
| std::optional<QcGamepadMapping::Action> | actionFromName(const QString &name) |
| QString | actionName(QcGamepadMapping::Action action) |
| bool | bindable(QcGamepadButton button) |
| bool | clearlyDeflected(const QcGamepadState &raw) |
| std::optional<QcGamepadMapping::Combo> | comboOf(QcGamepadMapping::Action action) |
| bool | deflected(const QcGamepadState &shaped) |
| bool | held(QcGamepadMapping::Action action, const QcGamepadState &shaped, const QcGamepadMapping::Bindings &bindings, bool wasHeld, float press = pressThreshold) |
| int | hotbarStep(int slot, int steps, int size) |
| QPointF | lookDelta(const QcGamepadState &shaped, double lookSpeed, double seconds) |
| bool | rebindable(QcGamepadMapping::Action action) |
| float | releaseFor(float press) |
| bool | triggerHeld(float value, bool wasHeld, float press = pressThreshold) |
| bool | used(const QcGamepadState &raw) |
| QcGamepadMapping::Walk | walk(const QcGamepadState &shaped) |
| std::array<bool, actionCount> | withCombos(std::array<bool, actionCount> now, const std::array<bool, actionCount> &before, const QcGamepadState &shaped, const QcGamepadMapping::Bindings &bindings) |
Detailed Description
Classes
class Bindings
Default bindings (Auftrag point 40, decisions E-541 and E-580, after the console layout of the model): south jumps (double tap: creative flight), the left stick click sprints, the right stick click sneaks, the shoulders step through the hotbar; start pauses, north opens the inventory, east drops, west picks the block in view; the d-pad holds the radial menu (left), switches the camera (up), opens the chat (down) and the handbook (right); back holds the player list. More...
class Combo
A button combination (decision E-692): button pressed while the button of modifier is held runs action instead of the button's own action, for that whole press. More...
class Walk
Forward (positive) and strafe right (positive) from the shaped left stick (y positive down). More...
Type Documentation
enum class QcGamepadMapping::Action
The player's actions on a pad.
Mine and Use are the triggers, the others are buttons.
| Constant | Value | Description |
|---|---|---|
QcGamepadMapping::Action::Jump | 0 | jumps (double tap: creative flight) |
QcGamepadMapping::Action::Sprint | 1 | sprints |
QcGamepadMapping::Action::Sneak | 2 | sneaks |
QcGamepadMapping::Action::Mine | 3 | mines and attacks (right trigger) |
QcGamepadMapping::Action::Use | 4 | uses the held item (left trigger) |
QcGamepadMapping::Action::HotbarPrevious | 5 | the previous hotbar slot |
QcGamepadMapping::Action::HotbarNext | 6 | the next hotbar slot |
QcGamepadMapping::Action::Pause | 7 | The pause menu, the inventory, the chat line, the handbook, the camera view and the player list (held), as with their keys (QcGamepadControls::worldAction): opens the pause menu. |
QcGamepadMapping::Action::Inventory | 8 | opens the inventory |
QcGamepadMapping::Action::Chat | 9 | opens the chat line |
QcGamepadMapping::Action::Handbook | 10 | opens the handbook |
QcGamepadMapping::Action::CameraView | 11 | switches the camera view |
QcGamepadMapping::Action::PlayerList | 12 | shows the player list while held |
QcGamepadMapping::Action::Drop | 13 | Throws one item; held for dropStackMs, the rest of the stack. |
QcGamepadMapping::Action::PickBlock | 14 | The targeted block's item into the hand (the middle mouse button). |
QcGamepadMapping::Action::HotbarRadial | 15 | Held: the radial menu of the hotbar, chosen with the right stick (QcHotbarRadial). |
QcGamepadMapping::Action::HideHud | 16 | Photo mode (decision E-692), as with their keys: hides the HUD; without a button by default. |
QcGamepadMapping::Action::Screenshot | 17 | saves a screenshot; without a button by default |
QcGamepadMapping::Action::Count | 18 | the number of actions, not an action |
Variable Documentation
const std::size_t QcGamepadMapping::actionCount
Number of actions.
const std::array<QcGamepadMapping::Combo, 2> QcGamepadMapping::combos
The player list's button (Back) plus Y saves a screenshot, plus X hides the HUD; the player list shows while Back is held, as without the combination.
const qint64 QcGamepadMapping::dropStackMs
Holding the drop button this long throws the rest of the stack.
const float QcGamepadMapping::leadDeflection
A stick pushed further than this (raw, before the dead zone) is meant: it takes the lead from another pad, a drifting stick does not.
const float QcGamepadMapping::sprintForward
The walking stick must point at least this far forward to start or keep a sprint.
const QcGamepadButton QcGamepadMapping::unbound
The "button" of an action that has none (decision E-692): every button of a pad carries an action already, so the photo mode's actions start without one until the player gives them one.
Function Documentation
std::optional<QcGamepadMapping::Action> QcGamepadMapping::actionFromName(const QString &name)
Returns the action with the id name (actionName()); nullopt for an unknown id.
QString QcGamepadMapping::actionName(QcGamepadMapping::Action action)
Returns the id of action in settings files and in QML ("jump", "hotbarRadial", ...).
bool QcGamepadMapping::bindable(QcGamepadButton button)
Returns whether button may carry an action: all but Guide, which the system often takes itself.
bool QcGamepadMapping::clearlyDeflected(const QcGamepadState &raw)
Returns whether a stick of the raw state raw is pushed beyond leadDeflection.
std::optional<QcGamepadMapping::Combo> QcGamepadMapping::comboOf(QcGamepadMapping::Action action)
Returns the combination of action; nullopt for an action without one.
bool QcGamepadMapping::deflected(const QcGamepadState &shaped)
Returns whether a stick of the shaped state shaped is outside its dead zone (the pad walks or looks).
bool QcGamepadMapping::held(QcGamepadMapping::Action action, const QcGamepadState &shaped, const QcGamepadMapping::Bindings &bindings, bool wasHeld, float press = pressThreshold)
Returns whether action is held in shaped (triggers with the hysteresis above, from wasHeld). bindings map actions to buttons; press is the trigger threshold.
int QcGamepadMapping::hotbarStep(int slot, int steps, int size)
Returns the hotbar slot steps from slot, wrapping around the size slots.
QPointF QcGamepadMapping::lookDelta(const QcGamepadState &shaped, double lookSpeed, double seconds)
Returns the turn of one frame of seconds in degrees (x yaw to the right, y like a mouse moving down) from the shaped right stick of shaped: full deflection turns lookSpeed degrees per second. QcMouseLook applies it with sensitivity 1 and the invert setting.
bool QcGamepadMapping::rebindable(QcGamepadMapping::Action action)
Returns whether the player may give action another button: all but the triggers' actions.
float QcGamepadMapping::releaseFor(float press)
Returns the release point of a trigger pressed at press: 0.2 lower, at least 0.05.
bool QcGamepadMapping::triggerHeld(float value, bool wasHeld, float press = pressThreshold)
Returns whether the shaped trigger value holds the button, given whether it held it before (wasHeld): pressed above press, released again below releaseFor(press) (decision E-610).
bool QcGamepadMapping::used(const QcGamepadState &raw)
Returns whether the raw state raw shows a deliberate use: a button, a trigger beyond pressThreshold or a clearly pushed stick (the pad becomes the input in use, decisions E-583 and E-613).
QcGamepadMapping::Walk QcGamepadMapping::walk(const QcGamepadState &shaped)
Returns the walking direction of the shaped left stick in shaped.
std::array<bool, actionCount> QcGamepadMapping::withCombos(std::array<bool, actionCount> now, const std::array<bool, actionCount> &before, const QcGamepadState &shaped, const QcGamepadMapping::Bindings &bindings)
Returns the held actions now (from held(), before the previous state) with the combos applied: a combo's button pressed while its modifier is held holds the combo's action and not the button's own; a press that began before the modifier stays the button's own. A combo whose modifier has no button or the combo's button itself does nothing. shaped is the current state, bindings map actions to buttons.