File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,24 @@ struct HIDKeyboard {
1515 uint8_t modifier;
1616 uint8_t keycode[6 ];
1717
18+ HIDKeyboard operator +(const HIDKeyboard& b) {
19+ HIDKeyboard c;
20+ c.modifier = this ->modifier | b.modifier ;
21+ int j = 0 ;
22+ for (int i = 0 ; i < 5 ; i++) {
23+ if (this ->keycode [i]>0 )
24+ {
25+ c.keycode [i] = this ->keycode [i];
26+ }
27+ else
28+ {
29+ c.keycode [i] = b.keycode [j];
30+ j++;
31+ }
32+ }
33+ return c;
34+ }
35+
1836 bool operator != (const HIDKeyboard &c2)
1937 {
2038 return !(*this == c2);
@@ -41,6 +59,16 @@ struct HIDMouse {
4159 int8_t wheel;
4260 int8_t pan;
4361
62+ HIDMouse operator +(const HIDMouse& b) {
63+ HIDMouse c;
64+ c.buttons = this ->buttons | b.buttons ;
65+ c.x = this ->x +b.x ;
66+ c.y = this ->y +b.y ;
67+ c.wheel = this ->wheel + b.wheel ;
68+ c.pan = this ->pan + b.pan ;
69+ return c;
70+ }
71+
4472 bool operator != (const HIDMouse &c2)
4573 {
4674 return !(*this == c2);
@@ -60,6 +88,12 @@ struct HIDMouse {
6088struct HIDConsumer {
6189 uint16_t usage_code;
6290
91+ HIDConsumer operator +(const HIDConsumer& b) {
92+ HIDConsumer c;
93+ c.usage_code = (this ->usage_code > b.usage_code )?this ->usage_code :b.usage_code ;
94+ return c;
95+ }
96+
6397 bool operator != (const HIDConsumer &c2)
6498 {
6599 return !(*this == c2);
@@ -80,6 +114,17 @@ struct HIDGamepad {
80114 int8_t rx;
81115 int8_t r;
82116
117+ HIDGamepad operator +(const HIDGamepad& b) {
118+ HIDGamepad c;
119+ c.x = this ->x +b.x ;
120+ c.y = this ->y +b.y ;
121+ c.z = this ->z +b.z ;
122+ c.rx = this ->rx +b.rx ;
123+ c.r = this ->r +b.r ;
124+ c.rz = this ->rz +b.rz ;
125+ return c;
126+ }
127+
83128 bool operator != (const HIDGamepad &c2)
84129 {
85130 return !(*this == c2);
You can’t perform that action at this time.
0 commit comments