Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
touchUtils.c File Reference

Functions

void getTouchCartesian (int32_t angle, int32_t radius, int32_t *x, int32_t *y)
 Convert touchpad angle and radius to cartesian coordinates.
 
touchJoystick_t getTouchJoystickZones (int32_t angle, int32_t radius, bool useCenter, bool useDiagonals)
 Convert touchpad angle and radius to a joystick enum, with either 4 or 8 directions and an optional center dead-zone.
 
void getTouchSpins (touchSpinState_t *state, int32_t angle, int32_t radius)
 Calculate the number of times the touchpad was circled.
 

Function Documentation

◆ getTouchCartesian()

void getTouchCartesian ( int32_t angle,
int32_t radius,
int32_t * x,
int32_t * y )

Convert touchpad angle and radius to cartesian coordinates.

Parameters
angleThe touchpad angle to convert
radiusThe touchpad radius to convert
[out]xA pointer to be set to the X touch coordinate, from 0 to 1023
[out]yA pointer to be set to the Y touch coordinate, from 0 to 1023

◆ getTouchJoystickZones()

touchJoystick_t getTouchJoystickZones ( int32_t angle,
int32_t radius,
bool useCenter,
bool useDiagonals )

Convert touchpad angle and radius to a joystick enum, with either 4 or 8 directions and an optional center dead-zone.

Parameters
angleThe touch angle reported by getTouchJoystick()
radiusThe touch radius reported by getTouchJoystick()
useCenterIf true, TB_CENTER will be returned if the stick is touched but inside the dead-zone
useDiagonalsIf true, diagonal directions will be returned as the bitwise OR of two directions
Returns
touchJoystick_t The joystick direction, or 0 if no direction could be determined.

◆ getTouchSpins()

void getTouchSpins ( touchSpinState_t * state,
int32_t angle,
int32_t radius )

Calculate the number of times the touchpad was circled.

When the touch is done, reset startSet to 0

Parameters
[in,out]stateA pointer to a touchSpinState_t to use for state.
angleThe current angle of the touch
radiusThe current radius of the touch