File syn_joystick.h¶
FileList > input > syn_joystick.h
Go to the source code of this file
Generic Analog Joystick & Multi-Axis Potentiometer Driver.
#include "../common/syn_defs.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_Joystick Generic Analog Joystick Context. |
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_JoystickDir 8-Way D-Pad Directional State. |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_joystick_feed_adc (SYN_Joystick * joy, uint16_t raw_x, uint16_t raw_y, bool btn) Feed raw ADC readings for X and Y axes. |
| SYN_JoystickDir | syn_joystick_get_dir (const SYN_Joystick * joy) Get 8-way directional state. |
| int16_t | syn_joystick_get_x_pct (const SYN_Joystick * joy) Get X axis position percentage (-100% to +100%). |
| int16_t | syn_joystick_get_y_pct (const SYN_Joystick * joy) Get Y axis position percentage (-100% to +100%). |
| SYN_Status | syn_joystick_init (SYN_Joystick * joy, uint16_t center_x, uint16_t center_y, uint16_t adc_max, uint16_t deadband) Initialize Analog Joystick instance. |
Public Types Documentation¶
enum SYN_JoystickDir¶
8-Way D-Pad Directional State.
enum SYN_JoystickDir {
SYN_JOYSTICK_DIR_CENTER = 0,
SYN_JOYSTICK_DIR_UP = 1,
SYN_JOYSTICK_DIR_UP_RIGHT = 2,
SYN_JOYSTICK_DIR_RIGHT = 3,
SYN_JOYSTICK_DIR_DOWN_RIGHT = 4,
SYN_JOYSTICK_DIR_DOWN = 5,
SYN_JOYSTICK_DIR_DOWN_LEFT = 6,
SYN_JOYSTICK_DIR_LEFT = 7,
SYN_JOYSTICK_DIR_UP_LEFT = 8
};
Public Functions Documentation¶
function syn_joystick_feed_adc¶
Feed raw ADC readings for X and Y axes.
Parameters:
joyJoystick context.raw_xRaw X axis ADC sample.raw_yRaw Y axis ADC sample.btnPushbutton logical state.
function syn_joystick_get_dir¶
Get 8-way directional state.
Parameters:
joyJoystick context.
Returns:
Directional state enum.
function syn_joystick_get_x_pct¶
Get X axis position percentage (-100% to +100%).
Parameters:
joyJoystick context.
Returns:
X percentage.
function syn_joystick_get_y_pct¶
Get Y axis position percentage (-100% to +100%).
Parameters:
joyJoystick context.
Returns:
Y percentage.
function syn_joystick_init¶
Initialize Analog Joystick instance.
SYN_Status syn_joystick_init (
SYN_Joystick * joy,
uint16_t center_x,
uint16_t center_y,
uint16_t adc_max,
uint16_t deadband
)
Parameters:
joyJoystick context.center_xExpected center X raw ADC reading.center_yExpected center Y raw ADC reading.adc_maxMax ADC full-scale value (e.g. 4095 for 12-bit ADC).deadbandDeadband threshold radius (e.g. 100).
Returns:
SYN_OK on success.
The documentation for this class was generated from the following file src/syntropic/input/syn_joystick.h