ControllerDPad
A class in Root.Township, the global namespace.
Turns a hand's touchpad and thumbstick input into numbered directions and four-way swipes. Made by PlayerInput; call OnEnable and Update to drive it. Client side.
- Listed in Global namespace: C to D
Constructors
| Member | What it is |
|---|---|
ControllerDPad(PlayerInput playerInput) | Creates a ControllerDPad from playerInput. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private float broaderDirectionSensitivity | Squared half of the swipe sensitivity. |
private int buttonCount | Number of direction sectors around the pad. 12. |
private Vector2 currentTouchPad | Last touchpad position read. |
private Vector2 debugVector | Test input used instead of the touchpad when useDebugVector is on. |
private float innerRadius | Squared radius of the centre zone. |
private ControllerInput input | The raw controller input it reads. |
private bool isClockwiseForRightHand | Mirrors the angle for the right hand so directions run the same way on both hands. |
private int oldTouchPadDirection | Direction from the previous check, to detect changes. |
private PlayerInput playerInput | The hand's PlayerInput. |
private float rotationOffset | Angle offset in degrees applied before splitting into sectors. -90. |
private float swipeSensitivity | Squared minimum swipe length. |
private float[] swipeSentivityLevels | Swipe lengths for each settings level: 1.5, 1 and 0.5. |
private Vector2 touchStart | Touchpad position when the touch began. |
private bool useDebugVector | Use debugVector instead of the real touchpad. |
Properties
Events
Methods
5 private and internal methods
| Member | What it is |
|---|---|
private void CalculateGestureDirection() | Sets CurrentThumbStickDirection from the thumbstick angle, split into buttonCount sectors. |
private void CalculateSwipe(PlayerInput playerInput) | On touch release, works out the swipe direction (0 right, 1 up, 2 left, 3 down) and raises SwipeExecuted, or -1 if too short. |
private void CalculateSwipeDirection() | Sets CurrentDpadDirection from the touchpad position and raises TouchChanged when it changes. 0 is the centre. |
private void CheckForSwipeSensitivityLevelInSettings(GameSettings settings) | Reads the swipe sensitivity level from game settings and squares it for distance checks. |
private void PadTouched(PlayerInput playerInput) | On touch start, stores the start point and updates the direction. |
Used in
Members of other types that take, return or hold a ControllerDPad: