-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathHID.c
More file actions
61 lines (51 loc) · 1.19 KB
/
HID.c
File metadata and controls
61 lines (51 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include "HID.h"
#include "EasyCon_API.h"
USB_JoystickReport_Input_t next_report;
// Reset report to default.
void ResetReport(void)
{
memset((void *)&next_report, 0, sizeof(USB_JoystickReport_Input_t));
next_report.LX = STICK_CENTER;
next_report.LY = STICK_CENTER;
next_report.RX = STICK_CENTER;
next_report.RY = STICK_CENTER;
next_report.HAT = HAT_CENTER;
}
void SetButtons(const uint16_t Button)
{
next_report.Button = Button;
}
void PressButtons(const uint16_t Button)
{
next_report.Button |= Button;
}
void ReleaseButtons(const uint16_t Button)
{
next_report.Button &= ~(Button);
}
void SetHATSwitch(const uint8_t HAT)
{
next_report.HAT = HAT;
}
void SetLeftStick(const uint8_t LX, const uint8_t LY)
{
next_report.LX = LX; next_report.LY = LY;
}
void SetRightStick(const uint8_t RX, const uint8_t RY)
{
next_report.RX = RX; next_report.RY = RY;
}
void HIDInit(void)
{
ResetReport();
usbd_send((uint8_t *)&next_report, TAG_SEND_INIT_BUF);
}
void HIDTask(void)
{
// We need to run our task to process and deliver data for our IN and OUT endpoints.
if(EasyCon_need_send_report())
{
usbd_send((uint8_t *)&next_report, TAG_SEND_BUF);
EasyCon_report_send_callback();
}
}