![]() |
NDEVR
API Documentation
|
A joystick that allows the user to move around, reporting the vector of the stick, relative to the center of the joystick. More...
Public Member Functions | |
| Joystick (QWidget *parent=nullptr) | |
| Constructs a Joystick widget. | |
| void | addButton (Button *button) |
| Adds a custom button to the joystick widget. | |
| QRect | arrowRect (const Vector< 2, sint04 > &location, const Vector< 2, fltp04 > ¢er_point, fltp04 radius) const |
| Computes the bounding rectangle for an arrow button at the given location. | |
| Vector< 2, fltp04 > | centerPoint () const |
| Returns the center point of the joystick in widget coordinates. | |
| bool | event (QEvent *event) override |
| Processes generic events, including touch events for the joystick. | |
| bool | isDragging () const |
| Checks whether the joystick knob is currently being dragged. | |
| void | joystickButtonPressedSignal (const Vector< 2, fltp04 > &location) |
| Emitted when the joystick knob is initially pressed. | |
| void | joystickButtonReleasedSignal (const Vector< 2, fltp04 > &location) |
| Emitted when the joystick knob is released. | |
| void | joystickLocationChangedSignal (const Vector< 2, fltp04 > &location) |
| Emitted when the joystick position changes during dragging. | |
| Vector< 2, fltp04 > | knobLocation () const |
| Returns the current position of the joystick knob in widget coordinates. | |
| fltp04 | knobRadius () const |
| Returns the radius of the joystick knob. | |
| QSize | minimumSizeHint () const override |
| Returns the minimum size hint for the joystick widget. | |
| virtual void | mouseMoveEvent (QMouseEvent *ev) override |
| Handles mouse move events to update the joystick knob position. | |
| virtual void | mousePressEvent (QMouseEvent *ev) override |
| Handles mouse press events on the joystick. | |
| virtual void | mouseReleaseEvent (QMouseEvent *ev) override |
| Handles mouse release events on the joystick. | |
| fltp04 | outerRadius () const |
| Returns the radius of the outer joystick boundary. | |
| void | pressEvent (Vector< 2, fltp04 > mouse_location) |
| Simulates a press event at the given location. | |
| void | releaseEvent () |
| Simulates a release event, triggering the snap-back animation. | |
| void | setBackgroundColor (RGBColor inner, RGBColor outer) |
| Sets the gradient colors used to draw the joystick background. | |
| void | setDeadzone (fltp08 deadzone) |
| Sets the deadzone radius below which joystick input is ignored. | |
| void | setDrawDeadzone (bool draw_deadzone) |
| Sets whether the deadzone region is visually drawn on the joystick. | |
| void | setDrawSensitivity (bool draw_sense) |
| Sets whether the sensitivity region is visually drawn on the joystick. | |
| void | setJoystickSettingsName (const StringView &name) |
| Sets the INI settings name used for persisting joystick settings. | |
| void | setKnobColor (RGBColor inner, RGBColor outer) |
| Sets the gradient colors used to draw the joystick knob. | |
| void | setSettings (const JoystickSettings &mode) |
| Applies new joystick settings. | |
| void | setSnapBackPercent (float snap_percent) |
| Sets the snap-back animation progress percentage. | |
| const JoystickSettings & | settings () const |
| Returns the current joystick settings. | |
| void | setValue (const Vector< 2, fltp04 > &location) |
| Programmatically sets the joystick position. | |
| QSize | sizeHint () const override |
| Returns the preferred size hint for the joystick widget. | |
| float | snapBackPercent () const |
| Returns the current snap-back animation progress as a percentage. | |
Private Member Functions | |
| void | paintEvent (QPaintEvent *paint_event) override |
| Paints the joystick widget including background, knob, and buttons. | |
| void | resizeEvent (QResizeEvent *event) override |
| Handles resize events to recalculate joystick geometry. | |
A joystick that allows the user to move around, reporting the vector of the stick, relative to the center of the joystick.
Definition at line 87 of file Joystick.h.
|
explicit |
Constructs a Joystick widget.
| [in] | parent | The parent widget. |
| void Joystick::addButton | ( | Button * | button | ) |
Adds a custom button to the joystick widget.
| [in] | button | The button to add. |
| QRect Joystick::arrowRect | ( | const Vector< 2, sint04 > & | location, |
| const Vector< 2, fltp04 > & | center_point, | ||
| fltp04 | radius ) const |
Computes the bounding rectangle for an arrow button at the given location.
| [in] | location | The grid position of the arrow. |
| [in] | center_point | The center of the joystick. |
| [in] | radius | The radius used for positioning the arrow. |
Returns the center point of the joystick in widget coordinates.
|
override |
Processes generic events, including touch events for the joystick.
| [in] | event | The event to process. |
References event().
Referenced by event(), and resizeEvent().
| bool Joystick::isDragging | ( | ) | const |
Checks whether the joystick knob is currently being dragged.
Emitted when the joystick knob is initially pressed.
| [in] | location | The normalized joystick position at press time. |
Emitted when the joystick knob is released.
| [in] | location | The normalized joystick position at release time. |
Emitted when the joystick position changes during dragging.
| [in] | location | The current normalized joystick displacement. |
Returns the current position of the joystick knob in widget coordinates.
| fltp04 Joystick::knobRadius | ( | ) | const |
Returns the radius of the joystick knob.
|
override |
Returns the minimum size hint for the joystick widget.
|
overridevirtual |
Handles mouse move events to update the joystick knob position.
| [in] | ev | The mouse move event. |
|
overridevirtual |
Handles mouse press events on the joystick.
| [in] | ev | The mouse press event. |
|
overridevirtual |
Handles mouse release events on the joystick.
| [in] | ev | The mouse release event. |
| fltp04 Joystick::outerRadius | ( | ) | const |
Returns the radius of the outer joystick boundary.
|
overrideprivate |
Paints the joystick widget including background, knob, and buttons.
| [in] | paint_event | The paint event. |
Simulates a press event at the given location.
| [in] | mouse_location | The location of the press in widget coordinates. |
|
overrideprivate |
Sets the gradient colors used to draw the joystick background.
| [in] | inner | The inner color of the background gradient. |
| [in] | outer | The outer color of the background gradient. |
| void Joystick::setDeadzone | ( | fltp08 | deadzone | ) |
Sets the deadzone radius below which joystick input is ignored.
| [in] | deadzone | The deadzone radius as a fraction of the outer radius. |
| void Joystick::setDrawDeadzone | ( | bool | draw_deadzone | ) |
Sets whether the deadzone region is visually drawn on the joystick.
| [in] | draw_deadzone | True to draw the deadzone indicator. |
| void Joystick::setDrawSensitivity | ( | bool | draw_sense | ) |
Sets whether the sensitivity region is visually drawn on the joystick.
| [in] | draw_sense | True to draw the sensitivity indicator. |
| void Joystick::setJoystickSettingsName | ( | const StringView & | name | ) |
Sets the INI settings name used for persisting joystick settings.
| [in] | name | The settings name identifier. |
Sets the gradient colors used to draw the joystick knob.
| [in] | inner | The inner color of the knob gradient. |
| [in] | outer | The outer color of the knob gradient. |
| void Joystick::setSettings | ( | const JoystickSettings & | mode | ) |
Applies new joystick settings.
| [in] | mode | The settings to apply. |
| void Joystick::setSnapBackPercent | ( | float | snap_percent | ) |
Sets the snap-back animation progress percentage.
| [in] | snap_percent | The snap-back percentage to set. |
|
inline |
Returns the current joystick settings.
Definition at line 157 of file Joystick.h.
Programmatically sets the joystick position.
| [in] | location | The normalized joystick position to set. |
|
override |
Returns the preferred size hint for the joystick widget.
|
inline |
Returns the current snap-back animation progress as a percentage.
Definition at line 124 of file Joystick.h.