@@ -143,6 +143,97 @@ typedef enum
143
143
144
144
/** @} */
145
145
146
+ //--------------------------------------------------------------------+
147
+ // GAMEPAD
148
+ //--------------------------------------------------------------------+
149
+ /** \addtogroup ClassDriver_HID_Gamepad Gamepad
150
+ * @{ */
151
+
152
+ /* From https://www.kernel.org/doc/html/latest/input/gamepad.html
153
+ ____________________________ __
154
+ / [__ZL__] [__ZR__] \ |
155
+ / [__ TL __] [__ TR __] \ | Front Triggers
156
+ __/________________________________\__ __|
157
+ / _ \ |
158
+ / /\ __ (N) \ |
159
+ / || __ |MO| __ _ _ \ | Main Pad
160
+ | <===DP===> |SE| |ST| (W) -|- (E) | |
161
+ \ || ___ ___ _ / |
162
+ /\ \/ / \ / \ (S) /\ __|
163
+ / \________ | LS | ____ | RS | ________/ \ |
164
+ | / \ \___/ / \ \___/ / \ | | Control Sticks
165
+ | / \_____/ \_____/ \ | __|
166
+ | / \ |
167
+ \_____/ \_____/
168
+
169
+ |________|______| |______|___________|
170
+ D-Pad Left Right Action Pad
171
+ Stick Stick
172
+
173
+ |_____________|
174
+ Menu Pad
175
+
176
+ Most gamepads have the following features:
177
+ - Action-Pad 4 buttons in diamonds-shape (on the right side) NORTH, SOUTH, WEST and EAST.
178
+ - D-Pad (Direction-pad) 4 buttons (on the left side) that point up, down, left and right.
179
+ - Menu-Pad Different constellations, but most-times 2 buttons: SELECT - START.
180
+ - Analog-Sticks provide freely moveable sticks to control directions, Analog-sticks may also
181
+ provide a digital button if you press them.
182
+ - Triggers are located on the upper-side of the pad in vertical direction. The upper buttons
183
+ are normally named Left- and Right-Triggers, the lower buttons Z-Left and Z-Right.
184
+ - Rumble Many devices provide force-feedback features. But are mostly just simple rumble motors.
185
+ */
186
+
187
+ /// HID Gamepad Protocol Report.
188
+ typedef struct TU_ATTR_PACKED
189
+ {
190
+ int8_t x ; ///< Delta x movement of left analog-stick
191
+ int8_t y ; ///< Delta y movement of left analog-stick
192
+ int8_t z ; ///< Delta z movement of right analog-joystick
193
+ int8_t rz ; ///< Delta Rz movement of right analog-joystick
194
+ int8_t rx ; ///< Delta Rx movement of analog left trigger
195
+ int8_t ry ; ///< Delta Ry movement of analog right trigger
196
+ uint8_t hat ; ///< Buttons mask for currently pressed buttons in the DPad/hat
197
+ uint16_t buttons ; ///< Buttons mask for currently pressed buttons
198
+ }hid_gamepad_report_t ;
199
+
200
+ /// Standard Gamepad Buttons Bitmap (from Linux input event codes)
201
+ typedef enum
202
+ {
203
+ GAMEPAD_BUTTON_A = TU_BIT (0 ), ///< A/South button
204
+ GAMEPAD_BUTTON_B = TU_BIT (1 ), ///< B/East button
205
+ GAMEPAD_BUTTON_C = TU_BIT (2 ), ///< C button
206
+ GAMEPAD_BUTTON_X = TU_BIT (3 ), ///< X/North button
207
+ GAMEPAD_BUTTON_Y = TU_BIT (4 ), ///< Y/West button
208
+ GAMEPAD_BUTTON_Z = TU_BIT (5 ), ///< Z button
209
+ GAMEPAD_BUTTON_TL = TU_BIT (6 ), ///< L1 button
210
+ GAMEPAD_BUTTON_TR = TU_BIT (7 ), ///< R1 button
211
+ GAMEPAD_BUTTON_TL2 = TU_BIT (8 ), ///< L2 button
212
+ GAMEPAD_BUTTON_TR2 = TU_BIT (9 ), ///< R2 button
213
+ GAMEPAD_BUTTON_SELECT = TU_BIT (10 ), ///< Select button
214
+ GAMEPAD_BUTTON_START = TU_BIT (11 ), ///< Start button
215
+ GAMEPAD_BUTTON_MODE = TU_BIT (12 ), ///< Mode button
216
+ GAMEPAD_BUTTON_THUMBL = TU_BIT (13 ), ///< L3 button
217
+ GAMEPAD_BUTTON_THUMBR = TU_BIT (14 ), ///< R3 button
218
+ //GAMEPAD_BUTTON_ = TU_BIT(15), ///< Undefined button
219
+ }hid_gamepad_button_bm_t ;
220
+
221
+ /// Standard Gamepad HAT/DPAD Buttons Bitmap (from Linux input event codes)
222
+ typedef enum
223
+ {
224
+ GAMEPAD_HAT_CENTERED = 0 , ///< DPAD_CENTERED
225
+ GAMEPAD_HAT_UP = 1 , ///< DPAD_UP
226
+ GAMEPAD_HAT_UP_RIGHT = 2 , ///< DPAD_UP_RIGHT
227
+ GAMEPAD_HAT_RIGHT = 3 , ///< DPAD_RIGHT
228
+ GAMEPAD_HAT_DOWN_RIGHT = 4 , ///< DPAD_DOWN_RIGHT
229
+ GAMEPAD_HAT_DOWN = 5 , ///< DPAD_DOWN
230
+ GAMEPAD_HAT_DOWN_LEFT = 6 , ///< DPAD_DOWN_LEFT
231
+ GAMEPAD_HAT_LEFT = 7 , ///< DPAD_LEFT
232
+ GAMEPAD_HAT_UP_LEFT = 8 , ///< DPAD_UP_LEFT
233
+ }hid_gamepad_hat_bm_t ;
234
+
235
+ /// @}
236
+
146
237
//--------------------------------------------------------------------+
147
238
// MOUSE
148
239
//--------------------------------------------------------------------+
@@ -157,7 +248,7 @@ typedef struct TU_ATTR_PACKED
157
248
int8_t y ; /**< Current delta y movement on the mouse. */
158
249
int8_t wheel ; /**< Current delta wheel movement on the mouse. */
159
250
int8_t pan ; // using AC Pan
160
- } hid_mouse_report_t ;
251
+ }hid_mouse_report_t ;
161
252
162
253
/// Standard Mouse Buttons Bitmap
163
254
typedef enum
0 commit comments