usbdhidgamepad.h
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // usbdhidgame.h - The header information for using the USB libraries game pad
4 // device class.
5 //
6 // Copyright (c) 2013-2017 Texas Instruments Incorporated. All rights reserved.
7 // Software License Agreement
8 //
9 // Texas Instruments (TI) is supplying this software for use solely and
10 // exclusively on TI's microcontroller products. The software is owned by
11 // TI and/or its suppliers, and is protected under applicable copyright
12 // laws. You may not combine this software with "viral" open-source
13 // software in order to form a larger program.
14 //
15 // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
16 // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
17 // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
19 // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
20 // DAMAGES, FOR ANY REASON WHATSOEVER.
21 //
22 //*****************************************************************************
23 
24 #ifndef __USBDHIDGAME_H__
25 #define __USBDHIDGAME_H__
26 
27 //*****************************************************************************
28 //
29 // If building with a C++ compiler, make all of the definitions in this header
30 // have a C binding.
31 //
32 //*****************************************************************************
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37 
38 //*****************************************************************************
39 //
42 //
43 //*****************************************************************************
44 
45 //*****************************************************************************
46 //
47 // PRIVATE
48 //
49 // This enumeration holds the various states that the game pad can be in during
50 // normal operation. This should not be used by applications and is only
51 // here for memory allocation purposes.
52 //
53 //*****************************************************************************
54 typedef enum
55 {
56  //
57  // Not yet configured.
58  //
60 
61  //
62  // Nothing to transmit and not waiting on data to be sent.
63  //
65 
66  //
67  // Waiting on data to be sent.
68  //
70 }
72 
73 //*****************************************************************************
74 //
75 // PRIVATE
76 //
77 // This is the structure for an instance of a USB game pad device. This should
78 // not be used by applications and is only here for memory allocation purposes.
79 //
80 //*****************************************************************************
81 typedef struct
82 {
83  //
84  // This is needed for the lower level HID driver.
85  //
87 
88  //
89  // The current state of the game pad device.
90  //
91  tGamepadState iState;
92 
93  //
94  // The idle timeout control structure for our input report. This is
95  // required by the lower level HID driver.
96  //
99 
100 //*****************************************************************************
101 //
104 //
105 //*****************************************************************************
106 typedef struct
107 {
108  //
110  //
111  const uint16_t ui16VID;
112 
113  //
115  //
116  const uint16_t ui16PID;
117 
118  //
120  //
121  const uint16_t ui16MaxPowermA;
122 
123  //
128  //
129  const uint8_t ui8PwrAttributes;
130 
131  //
135  //
137 
138  //
141  //
142  void *pvCBData;
143 
144  //
155  //
156  const uint8_t * const *ppui8StringDescriptors;
157 
158  //
161  //
162  const uint32_t ui32NumStringDescriptors;
163 
164  //
167  //
168  const uint8_t *pui8ReportDescriptor;
169 
170  //
173  //
174  const uint32_t ui32ReportSize;
175 
176  //
180  //
182 }
184 
185 //*****************************************************************************
186 //
188 //
189 //*****************************************************************************
190 #define USBDGAMEPAD_SUCCESS 0
191 
192 //*****************************************************************************
193 //
196 //
197 //*****************************************************************************
198 #define USBDGAMEPAD_TX_ERROR 1
199 
200 //*****************************************************************************
201 //
203 //
204 //*****************************************************************************
205 #define USBDGAMEPAD_NOT_CONFIGURED \
206  2
207 
208 //*****************************************************************************
209 //
215 //
216 //*****************************************************************************
217 typedef struct
218 {
219  //
221  //
222  int8_t i8XPos;
223 
224  //
226  //
227  int8_t i8YPos;
228 
229  //
231  //
232  int8_t i8ZPos;
233 
234  //
236  //
237  uint8_t ui8Buttons;
238 }
239 PACKED tGamepadReport;
240 
241 //*****************************************************************************
242 //
243 // API Function Prototypes
244 //
245 //*****************************************************************************
246 extern tUSBDHIDGamepadDevice *USBDHIDGamepadInit(uint32_t ui32Index,
247  tUSBDHIDGamepadDevice *psHIDGamepad);
248 extern tUSBDHIDGamepadDevice *USBDHIDGamepadCompositeInit(uint32_t ui32Index,
249  tUSBDHIDGamepadDevice *psHIDGamepad,
250  tCompositeEntry *psCompEntry);
251 extern void USBDHIDGamepadTerm(tUSBDHIDGamepadDevice *psCompEntry);
252 
253 extern uint32_t USBDHIDGamepadSendReport(tUSBDHIDGamepadDevice *psHIDGamepad,
254  void *pvReport, uint32_t ui32Size);
255 
256 //*****************************************************************************
257 //
258 // Close the Doxygen group.
260 //
261 //*****************************************************************************
262 
263 //*****************************************************************************
264 //
265 // Mark the end of the C bindings section for C++ compilers.
266 //
267 //*****************************************************************************
268 #ifdef __cplusplus
269 }
270 #endif
271 
272 #endif
int8_t i8YPos
Signed 8-bit value (-128 to 127).
Definition: usbdhidgamepad.h:227
Definition: usbdhid.h:798
void * pvCBData
Definition: usbdhidgamepad.h:142
tUSBDHIDGamepadDevice * USBDHIDGamepadCompositeInit(uint32_t ui32Index, tUSBDHIDGamepadDevice *psGamepad, tCompositeEntry *psCompEntry)
Definition: usbdhidgamepad.c:627
Definition: usbdhidgamepad.h:81
const uint16_t ui16PID
The product ID that this device is to present in the device descriptor.
Definition: usbdhidgamepad.h:116
tUSBDGamepadInstance sPrivateData
Definition: usbdhidgamepad.h:181
Definition: usbdevice.h:135
Definition: usbdhid.h:839
tUSBDHIDGamepadDevice * USBDHIDGamepadInit(uint32_t ui32Index, tUSBDHIDGamepadDevice *psGamepad)
Definition: usbdhidgamepad.c:555
const uint32_t ui32ReportSize
Definition: usbdhidgamepad.h:174
void USBDHIDGamepadTerm(tUSBDHIDGamepadDevice *psGamepad)
Definition: usbdhidgamepad.c:814
const uint8_t ui8PwrAttributes
Definition: usbdhidgamepad.h:129
uint32_t USBDHIDGamepadSendReport(tUSBDHIDGamepadDevice *psHIDGamepad, void *pvReport, uint32_t ui32Size)
Definition: usbdhidgamepad.c:733
int8_t i8ZPos
Signed 8-bit value (-128 to 127).
Definition: usbdhidgamepad.h:232
tGamepadState
Definition: usbdhidgamepad.h:54
const uint8_t *const * ppui8StringDescriptors
Definition: usbdhidgamepad.h:156
tHIDReportIdle sReportIdle
Definition: usbdhidgamepad.h:97
tGamepadState iState
Definition: usbdhidgamepad.h:91
const uint32_t ui32NumStringDescriptors
Definition: usbdhidgamepad.h:162
uint32_t(* tUSBCallback)(void *pvCBData, uint32_t ui32Event, uint32_t ui32MsgParam, void *pvMsgData)
Definition: usblib.h:1220
Definition: usbdhidgamepad.h:69
tUSBDHIDDevice sHIDDevice
Definition: usbdhidgamepad.h:86
Definition: usbdhidgamepad.h:106
Definition: usbdhidgamepad.h:64
const tUSBCallback pfnCallback
Definition: usbdhidgamepad.h:136
uint8_t ui8Buttons
8-bit button mapping with button 1 in the LSB.
Definition: usbdhidgamepad.h:237
Definition: usbdhidgamepad.h:59
const uint16_t ui16MaxPowermA
The maximum power consumption of the device, expressed in milliamps.
Definition: usbdhidgamepad.h:121
const uint16_t ui16VID
The vendor ID that this device is to present in the device descriptor.
Definition: usbdhidgamepad.h:111
const uint8_t * pui8ReportDescriptor
Definition: usbdhidgamepad.h:168
USB_CDC_GET/SET_LINE_CODING request-specific data.
Definition: usbaudio.h:288
int8_t i8XPos
Signed 8-bit value (-128 to 127).
Definition: usbdhidgamepad.h:222
Copyright 2018, Texas Instruments Incorporated