![]() |
Gondwana Game Engine Development (master) - 2.6.1
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
|
Represents the state of an analog stick on a gamepad, including both normalized floating-point values for convenient use in game logic and raw integer values from the underlying input system. This immutable struct provides methods for deadzone processing, direction detection, and magnitude calculation. More...
Public Member Functions | |
| GamepadStickState (float x, float y, int rawX=0, int rawY=0) | |
| Initializes a new instance of the GamepadStickState struct with the specified normalized and optional raw values. | |
| bool | IsEngaged (float threshold=0.15f) |
| Returns true if the stick is pushed beyond the threshold. | |
| StickDirection | Direction (float threshold=0.15f) |
| Returns the primary stick direction(s) based on angle and threshold. | |
| GamepadStickState | WithDeadzone (float threshold=0.15f) |
| Returns a new stick state with a deadzone applied. | |
| override string | ToString () |
| Returns a string representation of the normalized stick position showing the X and Y values formatted to two decimal places in the format "(X, Y)". | |
Static Public Member Functions | |
| static GamepadStickState | FromRaw16 (int rawX, int rawY) |
| Creates a GamepadStickState instance from raw 16-bit signed integer values. | |
| static GamepadStickState | FromRawUnsigned16 (ushort rawX, ushort rawY) |
| Creates a GamepadStickState instance from raw 16-bit unsigned integer values. | |
Properties | |
| float | X [get] |
| Gets the normalized horizontal position of the analog stick in the range [-1, 1], where -1 represents full left, 0 represents center, and 1 represents full right. | |
| float | Y [get] |
| Gets the normalized vertical position of the analog stick in the range [-1, 1], where -1 represents full down, 0 represents center, and 1 represents full up. | |
| int | RawX [get] |
| Raw horizontal value before normalization (e.g., from XInput or SDL2) | |
| int | RawY [get] |
| Raw vertical value before normalization (e.g., from XInput or SDL2) | |
| float | Magnitude [get] |
| Returns the magnitude (0 to 1) of the stick position. | |
| float | Angle [get] |
| Returns the angle (in radians) relative to (1, 0). | |
Represents the state of an analog stick on a gamepad, including both normalized floating-point values for convenient use in game logic and raw integer values from the underlying input system. This immutable struct provides methods for deadzone processing, direction detection, and magnitude calculation.
Definition at line 8 of file GamepadStickState.cs.
| Gondwana.Input.Gamepad.GamepadStickState.GamepadStickState | ( | float | x, |
| float | y, | ||
| int | rawX = 0, | ||
| int | rawY = 0 ) |
Initializes a new instance of the GamepadStickState struct with the specified normalized and optional raw values.
| x | The normalized horizontal position in the range [-1, 1], where -1 is full left, 0 is center, and 1 is full right. |
| y | The normalized vertical position in the range [-1, 1], where -1 is full down, 0 is center, and 1 is full up. |
| rawX | The raw horizontal value from the underlying input system. Default is 0. |
| rawY | The raw vertical value from the underlying input system. Default is 0. |
Definition at line 50 of file GamepadStickState.cs.
| StickDirection Gondwana.Input.Gamepad.GamepadStickState.Direction | ( | float | threshold = 0::15f | ) |
Returns the primary stick direction(s) based on angle and threshold.
| threshold | The threshold used for the comparison. |
Definition at line 113 of file GamepadStickState.cs.
|
static |
Creates a GamepadStickState instance from raw 16-bit signed integer values.
The method normalizes the raw input values to a floating-point range of [-1, 1] to represent the stick's position, while preserving the original raw values for reference.
| rawX | The raw X-axis value, ranging from -32768 to 32767. |
| rawY | The raw Y-axis value, ranging from -32768 to 32767. |
Definition at line 67 of file GamepadStickState.cs.
|
static |
Creates a GamepadStickState instance from raw 16-bit unsigned integer values.
The raw input values are normalized to the range [-1, 1] based on the assumption that the midpoint (32768) represents the neutral position, and the range extends from 0 to 65535.
| rawX | The raw X-axis value, represented as an unsigned 16-bit integer. |
| rawY | The raw Y-axis value, represented as an unsigned 16-bit integer. |
Definition at line 84 of file GamepadStickState.cs.
| bool Gondwana.Input.Gamepad.GamepadStickState.IsEngaged | ( | float | threshold = 0.15f | ) |
Returns true if the stick is pushed beyond the threshold.
| threshold | The threshold used for the comparison. |
true if the control is currently engaged; otherwise, false.| override string Gondwana.Input.Gamepad.GamepadStickState.ToString | ( | ) |
Returns a string representation of the normalized stick position showing the X and Y values formatted to two decimal places in the format "(X, Y)".
| GamepadStickState Gondwana.Input.Gamepad.GamepadStickState.WithDeadzone | ( | float | threshold = 0::15f | ) |
Returns a new stick state with a deadzone applied.
| threshold | The threshold used for the comparison. |
Definition at line 131 of file GamepadStickState.cs.
|
get |
Returns the angle (in radians) relative to (1, 0).
Definition at line 99 of file GamepadStickState.cs.
|
get |
Returns the magnitude (0 to 1) of the stick position.
Definition at line 94 of file GamepadStickState.cs.
|
get |
Raw horizontal value before normalization (e.g., from XInput or SDL2)
Definition at line 25 of file GamepadStickState.cs.
|
get |
Raw vertical value before normalization (e.g., from XInput or SDL2)
Definition at line 30 of file GamepadStickState.cs.
|
get |
Gets the normalized horizontal position of the analog stick in the range [-1, 1], where -1 represents full left, 0 represents center, and 1 represents full right.
Definition at line 14 of file GamepadStickState.cs.
|
get |
Gets the normalized vertical position of the analog stick in the range [-1, 1], where -1 represents full down, 0 represents center, and 1 represents full up.
Definition at line 20 of file GamepadStickState.cs.