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...
|
| | 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)".
|
|
| 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.
◆ GamepadStickState()
| 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.
- Parameters
-
| 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. |
◆ Direction()
| StickDirection Gondwana.Input.Gamepad.GamepadStickState.Direction |
( |
float | threshold = 0::15f | ) |
|
Returns the primary stick direction(s) based on angle and threshold.
◆ FromRaw16()
| GamepadStickState Gondwana.Input.Gamepad.GamepadStickState.FromRaw16 |
( |
int | rawX, |
|
|
int | rawY ) |
|
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.
- Parameters
-
| rawX | The raw X-axis value, ranging from -32768 to 32767. |
| rawY | The raw Y-axis value, ranging from -32768 to 32767. |
- Returns
- A GamepadStickState representing the normalized stick position, with X and Y values clamped to the range [-1, 1], and the original raw values.
◆ FromRawUnsigned16()
| GamepadStickState Gondwana.Input.Gamepad.GamepadStickState.FromRawUnsigned16 |
( |
ushort | rawX, |
|
|
ushort | rawY ) |
|
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.
- Parameters
-
| 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. |
- Returns
- A GamepadStickState instance with normalized X and Y values in the range [-1, 1], along with the original raw input values.
◆ IsEngaged()
| bool Gondwana.Input.Gamepad.GamepadStickState.IsEngaged |
( |
float | threshold = 0.15f | ) |
|
Returns true if the stick is pushed beyond the threshold.
◆ ToString()
| 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)".
- Returns
- A string in the format "(X, Y)" where X and Y are formatted to two decimal places.
◆ WithDeadzone()
| GamepadStickState Gondwana.Input.Gamepad.GamepadStickState.WithDeadzone |
( |
float | threshold = 0::15f | ) |
|
Returns a new stick state with a deadzone applied.
◆ Angle
| float Gondwana.Input.Gamepad.GamepadStickState.Angle |
|
get |
Returns the angle (in radians) relative to (1, 0).
◆ Magnitude
| float Gondwana.Input.Gamepad.GamepadStickState.Magnitude |
|
get |
Returns the magnitude (0 to 1) of the stick position.
◆ RawX
| int Gondwana.Input.Gamepad.GamepadStickState.RawX |
|
get |
Raw horizontal value before normalization (e.g., from XInput or SDL2)
◆ RawY
| int Gondwana.Input.Gamepad.GamepadStickState.RawY |
|
get |
Raw vertical value before normalization (e.g., from XInput or SDL2)
| float Gondwana.Input.Gamepad.GamepadStickState.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 Gondwana.Input.Gamepad.GamepadStickState.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.