diff options
Diffstat (limited to 'lib/usbhost/USB_Host_Shield_2.0/hidescriptorparser.h')
-rw-r--r-- | lib/usbhost/USB_Host_Shield_2.0/hidescriptorparser.h | 176 |
1 files changed, 176 insertions, 0 deletions
diff --git a/lib/usbhost/USB_Host_Shield_2.0/hidescriptorparser.h b/lib/usbhost/USB_Host_Shield_2.0/hidescriptorparser.h new file mode 100644 index 000000000..f3b496ffa --- /dev/null +++ b/lib/usbhost/USB_Host_Shield_2.0/hidescriptorparser.h | |||
@@ -0,0 +1,176 @@ | |||
1 | /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. | ||
2 | |||
3 | This software may be distributed and modified under the terms of the GNU | ||
4 | General Public License version 2 (GPL2) as published by the Free Software | ||
5 | Foundation and appearing in the file GPL2.TXT included in the packaging of | ||
6 | this file. Please note that GPL2 Section 2[b] requires that all works based | ||
7 | on this software must also be made publicly available under the terms of | ||
8 | the GPL2 ("Copyleft"). | ||
9 | |||
10 | Contact information | ||
11 | ------------------- | ||
12 | |||
13 | Circuits At Home, LTD | ||
14 | Web : http://www.circuitsathome.com | ||
15 | e-mail : support@circuitsathome.com | ||
16 | */ | ||
17 | #if !defined(__HIDDESCRIPTORPARSER_H__) | ||
18 | #define __HIDDESCRIPTORPARSER_H__ | ||
19 | |||
20 | #include "hid.h" | ||
21 | |||
22 | class ReportDescParserBase : public USBReadParser { | ||
23 | public: | ||
24 | typedef void (*UsagePageFunc)(uint16_t usage); | ||
25 | |||
26 | static void PrintGenericDesktopPageUsage(uint16_t usage); | ||
27 | static void PrintSimulationControlsPageUsage(uint16_t usage); | ||
28 | static void PrintVRControlsPageUsage(uint16_t usage); | ||
29 | static void PrintSportsControlsPageUsage(uint16_t usage); | ||
30 | static void PrintGameControlsPageUsage(uint16_t usage); | ||
31 | static void PrintGenericDeviceControlsPageUsage(uint16_t usage); | ||
32 | static void PrintLEDPageUsage(uint16_t usage); | ||
33 | static void PrintButtonPageUsage(uint16_t usage); | ||
34 | static void PrintOrdinalPageUsage(uint16_t usage); | ||
35 | static void PrintTelephonyPageUsage(uint16_t usage); | ||
36 | static void PrintConsumerPageUsage(uint16_t usage); | ||
37 | static void PrintDigitizerPageUsage(uint16_t usage); | ||
38 | static void PrintAlphanumDisplayPageUsage(uint16_t usage); | ||
39 | static void PrintMedicalInstrumentPageUsage(uint16_t usage); | ||
40 | |||
41 | static void PrintValue(uint8_t *p, uint8_t len); | ||
42 | static void PrintByteValue(uint8_t data); | ||
43 | |||
44 | static void PrintItemTitle(uint8_t prefix); | ||
45 | |||
46 | static const char * const usagePageTitles0[]; | ||
47 | static const char * const usagePageTitles1[]; | ||
48 | static const char * const genDesktopTitles0[]; | ||
49 | static const char * const genDesktopTitles1[]; | ||
50 | static const char * const genDesktopTitles2[]; | ||
51 | static const char * const genDesktopTitles3[]; | ||
52 | static const char * const genDesktopTitles4[]; | ||
53 | static const char * const simuTitles0[]; | ||
54 | static const char * const simuTitles1[]; | ||
55 | static const char * const simuTitles2[]; | ||
56 | static const char * const vrTitles0[]; | ||
57 | static const char * const vrTitles1[]; | ||
58 | static const char * const sportsCtrlTitles0[]; | ||
59 | static const char * const sportsCtrlTitles1[]; | ||
60 | static const char * const sportsCtrlTitles2[]; | ||
61 | static const char * const gameTitles0[]; | ||
62 | static const char * const gameTitles1[]; | ||
63 | static const char * const genDevCtrlTitles[]; | ||
64 | static const char * const ledTitles[]; | ||
65 | static const char * const telTitles0[]; | ||
66 | static const char * const telTitles1[]; | ||
67 | static const char * const telTitles2[]; | ||
68 | static const char * const telTitles3[]; | ||
69 | static const char * const telTitles4[]; | ||
70 | static const char * const telTitles5[]; | ||
71 | static const char * const consTitles0[]; | ||
72 | static const char * const consTitles1[]; | ||
73 | static const char * const consTitles2[]; | ||
74 | static const char * const consTitles3[]; | ||
75 | static const char * const consTitles4[]; | ||
76 | static const char * const consTitles5[]; | ||
77 | static const char * const consTitles6[]; | ||
78 | static const char * const consTitles7[]; | ||
79 | static const char * const consTitles8[]; | ||
80 | static const char * const consTitles9[]; | ||
81 | static const char * const consTitlesA[]; | ||
82 | static const char * const consTitlesB[]; | ||
83 | static const char * const consTitlesC[]; | ||
84 | static const char * const consTitlesD[]; | ||
85 | static const char * const consTitlesE[]; | ||
86 | static const char * const digitTitles0[]; | ||
87 | static const char * const digitTitles1[]; | ||
88 | static const char * const digitTitles2[]; | ||
89 | static const char * const aplphanumTitles0[]; | ||
90 | static const char * const aplphanumTitles1[]; | ||
91 | static const char * const aplphanumTitles2[]; | ||
92 | static const char * const medInstrTitles0[]; | ||
93 | static const char * const medInstrTitles1[]; | ||
94 | static const char * const medInstrTitles2[]; | ||
95 | static const char * const medInstrTitles3[]; | ||
96 | static const char * const medInstrTitles4[]; | ||
97 | |||
98 | protected: | ||
99 | static UsagePageFunc usagePageFunctions[]; | ||
100 | |||
101 | MultiValueBuffer theBuffer; | ||
102 | MultiByteValueParser valParser; | ||
103 | ByteSkipper theSkipper; | ||
104 | uint8_t varBuffer[sizeof (USB_CONFIGURATION_DESCRIPTOR)]; | ||
105 | |||
106 | uint8_t itemParseState; // Item parser state variable | ||
107 | uint8_t itemSize; // Item size | ||
108 | uint8_t itemPrefix; // Item prefix (first byte) | ||
109 | uint8_t rptSize; // Report Size | ||
110 | uint8_t rptCount; // Report Count | ||
111 | |||
112 | uint16_t totalSize; // Report size in bits | ||
113 | |||
114 | // Method should be defined here if virtual. | ||
115 | virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); | ||
116 | |||
117 | UsagePageFunc pfUsage; | ||
118 | |||
119 | static void PrintUsagePage(uint16_t page); | ||
120 | void SetUsagePage(uint16_t page); | ||
121 | |||
122 | public: | ||
123 | |||
124 | ReportDescParserBase() : | ||
125 | itemParseState(0), | ||
126 | itemSize(0), | ||
127 | itemPrefix(0), | ||
128 | rptSize(0), | ||
129 | rptCount(0), | ||
130 | pfUsage(NULL) { | ||
131 | theBuffer.pValue = varBuffer; | ||
132 | valParser.Initialize(&theBuffer); | ||
133 | theSkipper.Initialize(&theBuffer); | ||
134 | }; | ||
135 | |||
136 | void Parse(const uint16_t len, const uint8_t *pbuf, const uint16_t &offset); | ||
137 | |||
138 | enum { | ||
139 | enErrorSuccess = 0 | ||
140 | , enErrorIncomplete // value or record is partialy read in buffer | ||
141 | , enErrorBufferTooSmall | ||
142 | }; | ||
143 | }; | ||
144 | |||
145 | class ReportDescParser : public ReportDescParserBase { | ||
146 | }; | ||
147 | |||
148 | class ReportDescParser2 : public ReportDescParserBase { | ||
149 | uint8_t rptId; // Report ID | ||
150 | uint8_t useMin; // Usage Minimum | ||
151 | uint8_t useMax; // Usage Maximum | ||
152 | uint8_t fieldCount; // Number of field being currently processed | ||
153 | |||
154 | void OnInputItem(uint8_t itm); // Method which is called every time Input item is found | ||
155 | |||
156 | uint8_t *pBuf; // Report buffer pointer | ||
157 | uint8_t bLen; // Report length | ||
158 | |||
159 | protected: | ||
160 | // Method should be defined here if virtual. | ||
161 | virtual uint8_t ParseItem(uint8_t **pp, uint16_t *pcntdn); | ||
162 | |||
163 | public: | ||
164 | |||
165 | ReportDescParser2(uint16_t len, uint8_t *pbuf) : | ||
166 | ReportDescParserBase(), rptId(0), useMin(0), useMax(0), fieldCount(0), pBuf(pbuf), bLen(len) { | ||
167 | }; | ||
168 | }; | ||
169 | |||
170 | class UniversalReportParser : public HIDReportParser { | ||
171 | public: | ||
172 | // Method should be defined here if virtual. | ||
173 | virtual void Parse(HID *hid, bool is_rpt_id, uint8_t len, uint8_t *buf); | ||
174 | }; | ||
175 | |||
176 | #endif // __HIDDESCRIPTORPARSER_H__ | ||