libyggdrasil  v1.0.0
joystick.h
Go to the documentation of this file.
1  /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * _____.___. .___ .__.__ *
3  * \__ | | ____ ____ __| _/___________ _____|__| | *
4  * / | |/ ___\ / ___\ / __ |\_ __ \__ \ / ___/ | | *
5  * \____ / /_/ > /_/ > /_/ | | | \// __ \_\___ \| | |__ *
6  * / ______\___ /\___ /\____ | |__| (____ /____ >__|____/ *
7  * \/ /_____//_____/ \/ \/ \/ *
8  * - Yggdrasil - *
9  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
10  * This software can be used by students and other personal of the *
11  * Bern University of Applied Sciences under the terms of the MIT *
12  * license. *
13  * For other persons this software is under the terms of the GNU *
14  * General Public License version 2. *
15  * *
16  * Copyright © 2021, Bern University of Applied Sciences. *
17  * All rights reserved. *
18  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26 #pragma once
27 
28 #include <c/yggdrasil/types.h>
29 
33 struct Position {
34  i16 x;
35  i16 y;
36 };
37 
41 struct JoystickData {
42  struct Position pos;
43  u16 mag;
44  bool pressed;
45 };
46 
53 
61 
69 
76 
83 
JoystickData::mag
u16 mag
Magnitude / radius from the center.
Definition: joystick.h:43
u16
uint16_t u16
Definition: types.h:37
yggdrasil_Joystick_GetDeadzone
C_LINKAGE u8 yggdrasil_Joystick_GetDeadzone(void)
Get the current Joystick deadzone.
u8
uint8_t u8
Unsigned integer definitions.
Definition: types.h:36
yggdrasil_Joystick_GetRight
C_LINKAGE struct JoystickData yggdrasil_Joystick_GetRight()
Get the joystick data for the right joystick.
i16
int16_t i16
Definition: types.h:47
JoystickData::pressed
bool pressed
State of the joystick button.
Definition: joystick.h:44
Position::x
i16 x
X Axis.
Definition: joystick.h:34
yggdrasil_Joystick_Init
C_LINKAGE bool yggdrasil_Joystick_Init(void)
Initialization function.
Position
Signed position data.
Definition: joystick.h:33
yggdrasil_Joystick_GetLeft
C_LINKAGE struct JoystickData yggdrasil_Joystick_GetLeft()
Get the joystick data for the left joystick.
types.h
yggdrasil_Joystick_SetDeadzone
C_LINKAGE void yggdrasil_Joystick_SetDeadzone(u8 deadzone)
Set both joystick's deadzone.
JoystickData
Joystick data.
Definition: joystick.h:41
Position::y
i16 y
Y Axis.
Definition: joystick.h:35
JoystickData::pos
struct Position pos
Position.
Definition: joystick.h:42
C_LINKAGE
#define C_LINKAGE
Definition: attributes.h:43