@@ -71,6 +71,8 @@ class SwitchProGamepadInputReport : public hid::report::base<hid::report::type::
7171 using Gyroscope = espp::gamepad::Gyroscope;
7272
7373protected:
74+ #pragma pack(push, 1)
75+
7476 // union for the input report data
7577 union {
7678 // struct for the input report and follow-up data such as IMU or command
@@ -130,14 +132,14 @@ class SwitchProGamepadInputReport : public hid::report::base<hid::report::type::
130132 uint16_t joy_ly : 12 ;
131133 uint16_t joy_rx : 12 ;
132134 uint16_t joy_ry : 12 ;
133- } __attribute__ ((packed)) ;
134- } __attribute__((packed)) ;
135+ };
136+ };
135137 // Byte 11: Vibrator input report.
136138 // Decides if next vibration pattern should be sent.
137139 uint8_t vibrator_input_report;
138- } __attribute__ ((packed)) ; // input report data struct
140+ }; // input report data struct
139141 uint8_t raw_input_report[12 ];
140- } __attribute__((packed)) ; // input report data union
142+ }; // input report data union
141143 // Union for post-input report data such as IMU or command replies
142144 union {
143145 // for report IDs 0x30, 0x31, 0x32, 0x33, this is 6-axis data. 3 frames of 2
@@ -155,25 +157,27 @@ class SwitchProGamepadInputReport : public hid::report::base<hid::report::type::
155157 // Frame 2
156158 Accelerometer acc_2;
157159 Gyroscope gyro_2;
158- } __attribute__ ((packed)) ;
159- } __attribute__((packed)) ;
160- } __attribute__ ((packed)) ; //
160+ };
161+ };
162+ }; //
161163 // 0x21 subcommand reply data; max len 35
162164 struct {
163165 uint8_t subcmd_ack;
164166 uint8_t subcmd_id;
165167 uint8_t subcmd_reply[35 ];
166- } __attribute__ ((packed)) ;
168+ };
167169 // TODO: for report ID 0x23, this is NFC/IR MCU FW update input report (max len 37)
168170 //
169171 // TODO: for report id 0x31, there are aditional 313 bytes of NFC/IR data input
170172 // after this.
171- } __attribute__((packed)) ; // data union
172- } __attribute__ ((packed)) ; // input report data struct
173+ }; // data union
174+ }; // input report data struct
173175 // this will ensure we always have enough space for the largest report
174176 // without having padding bytes defined anywhere.
175177 uint8_t raw_report[63 ];
176- } __attribute__((packed));
178+ };
179+
180+ #pragma pack(pop)
177181
178182 static constexpr size_t num_data_bytes = 63 ;
179183
@@ -306,7 +310,7 @@ class SwitchProGamepadInputReport : public hid::report::base<hid::report::type::
306310 constexpr void set_left_trigger (float value) { set_trigger_axis (0 , value); }
307311
308312 // / Set the right trigger value
309- // / @param value The value to set the right trigger to.
313+ // / @param pressed Whether the right trigger is pressed or not
310314 constexpr void set_left_trigger (bool pressed) { btn_zl = pressed; }
311315
312316 // / Set the right trigger value
@@ -315,7 +319,7 @@ class SwitchProGamepadInputReport : public hid::report::base<hid::report::type::
315319 constexpr void set_right_trigger (float value) { set_trigger_axis (1 , value); }
316320
317321 // / Set the right trigger value
318- // / @param value The value to set the right trigger to.
322+ // / @param pressed Whether the right trigger is pressed or not
319323 constexpr void set_right_trigger (bool pressed) { btn_zr = pressed; }
320324
321325 // / Set the brake trigger value
0 commit comments