Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
touchUtils.h
Go to the documentation of this file.
1#ifndef _TOUCH_UTILS_H_
2#define _TOUCH_UTILS_H_
3
4#include <stdbool.h>
5#include <stdint.h>
6
10typedef enum __attribute__((packed))
11{
12 TB_CENTER = 0x0100,
13 TB_RIGHT = 0x0200,
14 TB_UP = 0x0400,
15 TB_LEFT = 0x0800,
16 TB_DOWN = 0x1000,
17 TB_UP_RIGHT = 0x0600,
18 TB_UP_LEFT = 0x0C00,
19 TB_DOWN_LEFT = 0x1800,
20 TB_DOWN_RIGHT = 0x1200,
22
23typedef struct
24{
26 int32_t startAngle;
27 int32_t startRadius;
28
29 int32_t lastAngle;
30 int32_t lastRadius;
31
32 int32_t spins;
33 int32_t remainder;
35
36void getTouchCartesian(int32_t angle, int32_t radius, int32_t* x, int32_t* y);
37touchJoystick_t getTouchJoystickZones(int32_t angle, int32_t radius, bool useCenter, bool useDiagonals);
38void getTouchSpins(touchSpinState_t* state, int32_t angle, int32_t radius);
39
40#endif
int32_t startRadius
Definition touchUtils.h:27
bool startSet
Definition touchUtils.h:25
int32_t lastRadius
Definition touchUtils.h:30
void getTouchCartesian(int32_t angle, int32_t radius, int32_t *x, int32_t *y)
Convert touchpad angle and radius to cartesian coordinates.
Definition touchUtils.c:18
int32_t spins
The number of complete CCW spins made. Negative indicates clockwise spins.
Definition touchUtils.h:32
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 c...
Definition touchUtils.c:42
touchJoystick_t
Bitmask values for all the virtual joystick positions of getTouchJoystickZones()
Definition touchUtils.h:11
@ TB_UP_RIGHT
Definition touchUtils.h:17
@ TB_RIGHT
Definition touchUtils.h:13
@ TB_UP_LEFT
Definition touchUtils.h:18
@ TB_DOWN_RIGHT
Definition touchUtils.h:20
@ TB_LEFT
Definition touchUtils.h:15
@ TB_UP
Definition touchUtils.h:14
@ TB_DOWN
Definition touchUtils.h:16
@ TB_CENTER
Definition touchUtils.h:12
@ TB_DOWN_LEFT
Definition touchUtils.h:19
int32_t lastAngle
Definition touchUtils.h:29
int32_t startAngle
Definition touchUtils.h:26
int32_t remainder
The angle of the partial CCW spin, or negative for a CW spin.
Definition touchUtils.h:33
void getTouchSpins(touchSpinState_t *state, int32_t angle, int32_t radius)
Calculate the number of times the touchpad was circled.
Definition touchUtils.c:87
Definition touchUtils.h:24