mozaSdk
hid_struct.h
1 #ifndef HID_STRUCT_H
2 #define HID_STRUCT_H
3 #include <vector>
4 
5 
6 enum ROCKERMODE
7 {
8  UNKNOW = 0,
9  CROSSKEY,
10  KEY,
11 };
12 enum KNOBMODE
13 {
14  UNKNOWKNOB = 0,
15  KNOB,
16  MULTIKEY,
17 };
18 
19 enum CLUTCHPICKMODE
20 {
21  UNKNOWCLUTCHPICK = 0,
22  COMPOSITEAXIS,
23  INDEPENDENTAXIS,
24 };
25 
26 enum ROCKEREDIR
27 {
28  UP = 0,
29  RIGHTUP,
30  RIGHT,
31  RIGHTDOWM,
32  DOWM,
33  LEFTDOWM,
34  LEFT,
35  LEFTUP,
36  NONEDIR
37 };
38 
39 //enum ERRORCODE
40 //{
41 // NORMAL = 0,
42 // NOINSTALLSDK,
43 // NODEVICES,
44 // COLLECTIONCYCLEDATALOSS,
45 //};
46 
47 struct HIDButton
48 {
49  bool startValue = 0;
50  int changeNum = -1;
51  bool isPressed() const{
52  if(changeNum == -1)
53  return startValue;
54  return startValue || changeNum;
55  };
56  bool lastPressState() const{
57  return (changeNum & 1) == 0 ? startValue : !startValue;
58  }
59 };
60 
61 //没有操作为空,8同样表示没有操作,但vector第一个数据不会为8
62 struct HIDRocker
63 {
64  std::vector<ROCKEREDIR> rockerDatas;
65  ROCKEREDIR lastDir() const
66  {
67  return rockerDatas.empty()? NONEDIR : rockerDatas.back();
68  }
69 };
70 
71 struct HIDKnob
72 {
73  std::vector<int> knobDatas;
74  int getOffset() const{
75  int res = 0;
76  for(auto var : knobDatas)
77  res += var;
78  return res;
79  }
80 };
81 
83 {
84  int getLastKey() const
85  {
86  return knobDatas.empty()? 0 : knobDatas.back();
87  }
88 };
89 
90 enum GEAR
91 {
92  R = 0,
93  GEAR1st,
94  GEAR2nd,
95  GEAR3rf,
96  GEAR4th,
97  GEAR5th,
98  GEAR6th,
99  GEAR7th,
100  GEAR0th,
101 };
102 
103 struct HIDData
104 {
105  float fSteeringWheelAngle = NAN;//返回角度
106  int16_t steeringWheelAxle = 0x8001;
107  int16_t clutchSynthesisShaft = 0x8001;
108 
109  int16_t clutchIndependentShaftL = 0x8001;
110  int16_t clutchIndependentShaftR = 0x8001;
111 
112  int16_t throttle = 0x8000;
113  int16_t clutch = 0x8000;
114  int16_t brake = 0x8000;
115  int16_t handbrake = 0x8001;
116 
118 
121 
124 // HIDKnob knob2L;
125 // HIDKnob knob2R;
126 
132 
133  GEAR shift = GEAR0th;
134  bool buttonHandbrake = false;
135 };
136 
137 #endif // HID_STRUCT_H
ROCKEREDIR lastDir() const
Definition: hid_struct.h:65
HIDRocker rightRocker9_12
Definition: hid_struct.h:120
Definition: hid_struct.h:62
GEAR shift
Definition: hid_struct.h:133
std::vector< ROCKEREDIR > rockerDatas
Definition: hid_struct.h:64
bool isPressed() const
Definition: hid_struct.h:51
int16_t clutch
Definition: hid_struct.h:113
int16_t throttle
Definition: hid_struct.h:112
HIDMultiSegmentKnob multiSegmentKnob26_27or53_64
Definition: hid_struct.h:127
int16_t brake
Definition: hid_struct.h:114
int16_t handbrake
Definition: hid_struct.h:115
Definition: hid_struct.h:82
HIDKnob knobR47_48
Definition: hid_struct.h:123
int getLastKey() const
Definition: hid_struct.h:84
float fSteeringWheelAngle
Definition: hid_struct.h:105
HIDMultiSegmentKnob multiSegmentKnob39_40or89_100
Definition: hid_struct.h:130
HIDButton buttons[128]
Definition: hid_struct.h:117
HIDMultiSegmentKnob multiSegmentKnob43_44or101_112
Definition: hid_struct.h:131
HIDKnob knobL45_46
Definition: hid_struct.h:122
int changeNum
Definition: hid_struct.h:50
int16_t clutchSynthesisShaft
Definition: hid_struct.h:107
HIDRocker leftRocker5_8
Definition: hid_struct.h:119
bool buttonHandbrake
Definition: hid_struct.h:134
int16_t clutchIndependentShaftR
Definition: hid_struct.h:110
std::vector< int > knobDatas
Definition: hid_struct.h:73
bool startValue
Definition: hid_struct.h:49
Definition: hid_struct.h:103
int16_t steeringWheelAxle
Definition: hid_struct.h:106
Definition: hid_struct.h:71
int16_t clutchIndependentShaftL
Definition: hid_struct.h:109
int getOffset() const
Definition: hid_struct.h:74
HIDMultiSegmentKnob multiSegmentKnob30_31or77_88
Definition: hid_struct.h:129
Definition: hid_struct.h:47
bool lastPressState() const
Definition: hid_struct.h:56
HIDMultiSegmentKnob multiSegmentKnob28_29or65_76
Definition: hid_struct.h:128