34#include <NDEVR/INIInterface.h>
35#include <NDEVR/Vector.h>
36#include <NDEVR/RGBColor.h>
38class QPropertyAnimation;
87 class NDEVR_WIDGETS_API
Joystick :
public QWidget
195 void updateButton(
uint04 button);
197 void updateButtons();
211 Button* m_settings_button;
220 fltp04 m_snap_back_percent = 0.0f;
221 QPropertyAnimation* m_joystick_release_animation;
225 bool m_draw_deadzone;
226 bool m_draw_sensitivity;
The equivelent of std::vector but with a bit more control.
Contains methods for easily reading and writing to an INI file including efficient casting,...
INIInterface()
Constructs an INIInterface with no default INI file.
A dialog which allows the user to set sensitivity and other properties of a Joystick object.
Settings that define how a Joystick will behave.
bool uses_knob
Whether the draggable knob is enabled on the joystick.
SensitivityMode sensitivity_mode
The curve used to map displacement to output.
SensitivityMode
The method used to map raw joystick displacement to output sensitivity.
@ e_exponential
Exponential mapping, giving finer control near center.
@ e_linear
Linear mapping from displacement to output.
@ e_sinusoidal
Sinusoidal mapping for smooth acceleration curve.
bool uses_buttons
Whether directional arrow buttons are enabled on the joystick.
bool operator==(const JoystickSettings &settings) const
Checks equality between two JoystickSettings objects.
void getINI(INIFactory &factory) override
Serializes or deserializes the joystick settings to or from an INI file.
fltp04 sensitivity
The overall sensitivity multiplier applied to joystick output.
void resetToDefaults()
Resets all joystick settings to their default values.
fltp04 deadzone
The minimum displacement threshold before input is registered.
void setDrawDeadzone(bool draw_deadzone)
Sets whether the deadzone region is visually drawn on the joystick.
void resizeEvent(QResizeEvent *event) override
Handles resize events to recalculate joystick geometry.
void pressEvent(Vector< 2, fltp04 > mouse_location)
Simulates a press event at the given location.
void setJoystickSettingsName(const StringView &name)
Sets the INI settings name used for persisting joystick settings.
void releaseEvent()
Simulates a release event, triggering the snap-back animation.
void setKnobColor(RGBColor inner, RGBColor outer)
Sets the gradient colors used to draw the joystick knob.
virtual void mousePressEvent(QMouseEvent *ev) override
Handles mouse press events on the joystick.
void paintEvent(QPaintEvent *paint_event) override
Paints the joystick widget including background, knob, and buttons.
void setSettings(const JoystickSettings &mode)
Applies new joystick settings.
const JoystickSettings & settings() const
Returns the current joystick settings.
QSize minimumSizeHint() const override
Returns the minimum size hint for the joystick widget.
void joystickLocationChangedSignal(const Vector< 2, fltp04 > &location)
Emitted when the joystick position changes during dragging.
void setBackgroundColor(RGBColor inner, RGBColor outer)
Sets the gradient colors used to draw the joystick background.
fltp04 knobRadius() const
Returns the radius of the joystick knob.
QSize sizeHint() const override
Returns the preferred size hint for 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.
void setSnapBackPercent(float snap_percent)
Sets the snap-back animation progress percentage.
void joystickButtonReleasedSignal(const Vector< 2, fltp04 > &location)
Emitted when the joystick knob is released.
Joystick(QWidget *parent=nullptr)
Constructs a Joystick widget.
void setDrawSensitivity(bool draw_sense)
Sets whether the sensitivity region is visually drawn on the joystick.
fltp04 outerRadius() const
Returns the radius of the outer joystick boundary.
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.
virtual void mouseReleaseEvent(QMouseEvent *ev) override
Handles mouse release events on the joystick.
void joystickButtonPressedSignal(const Vector< 2, fltp04 > &location)
Emitted when the joystick knob is initially pressed.
void setValue(const Vector< 2, fltp04 > &location)
Programmatically sets the joystick position.
Vector< 2, fltp04 > knobLocation() const
Returns the current position of the joystick knob in widget coordinates.
virtual void mouseMoveEvent(QMouseEvent *ev) override
Handles mouse move events to update the joystick knob position.
void addButton(Button *button)
Adds a custom button to the joystick widget.
bool isDragging() const
Checks whether the joystick knob is currently being dragged.
void setDeadzone(fltp08 deadzone)
Sets the deadzone radius below which joystick input is ignored.
float snapBackPercent() const
Returns the current snap-back animation progress as a percentage.
Represents a color in the RGB space with optional alpha transparency.
The core String View class for the NDEVR API.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.