forked from hoantv/VNWheel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FfbWheel.cpp
83 lines (60 loc) · 1.48 KB
/
FfbWheel.cpp
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "WHID.h"
#include "FfbWheelDescriptor.h"
#include "FfbWheel.h"
Wheel_::Wheel_(void)
{
static HIDSubDescriptor node(_hidReportDescriptor, sizeof(_hidReportDescriptor));
HID().AppendDescriptor(&node);
}
void Wheel_::SendReport(void* data, int length) {
HID().SendReport(HID_REPORTID_WHEEL, data, length);
}
int Wheel_::RecvReport(void* data, int len)
{
return HID().RecvReport(&data, len);
}
uint8_t Wheel_::AvailableReport()
{
return HID().AvailableReport();
}
void Wheel_::RecvFfbReport() {
HID().RecvFfbReport();
}
void Wheel_::begin(void) {
// release all buttons
ffbEngine.SetFfb(&HID().ffbReportHandler);
ffbEngine.SetGain(wheelConfig);
encoder.setConfig(wheelConfig);
end();
}
void Wheel_::end(void) {
memset(&_wheelReport, 0x00, sizeof(_wheelReport));
SendReport(&_wheelReport, sizeof(_wheelReport));
}
void Wheel_::write(void) {
SendReport(&_wheelReport, sizeof(_wheelReport));
}
void Wheel_::press(uint8_t b) {
_wheelReport.buttons |= (uint8_t)1 << (b - 1);
}
void Wheel_::release(uint8_t b) {
_wheelReport.buttons &= ~((uint8_t)1 << (b - 1));
}
void Wheel_::releaseAll(void) {
memset(&_wheelReport, 0x00, sizeof(_wheelReport));
}
void Wheel_::buttons(uint8_t b) {
_wheelReport.buttons = b;
}
void Wheel_::xAxis(int16_t a) {
_wheelReport.xAxis = a;
}
void Wheel_::yAxis(int16_t a) {
_wheelReport.yAxis = a;
}
void Wheel_::zAxis(int16_t a) {
_wheelReport.zAxis = a;
}
void Wheel_::rxAxis(int16_t a) {
_wheelReport.rxAxis = a;
}