1 /* |
|
2 * Copyright (c) 2004-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Declares hid report class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_HIDREPORTROOT_H |
|
20 #define C_HIDREPORTROOT_H |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 #include "hidfield.h" |
|
25 #include "hidcollection.h" |
|
26 |
|
27 #include "hidvalues.h" |
|
28 |
|
29 class CReportRoot; |
|
30 |
|
31 |
|
32 |
|
33 /** |
|
34 * Hid field finder class |
|
35 * The MHidFieldFinder class defines the call-back interface used by |
|
36 * THidFieldSearch. A device driver uses THidFieldSearch::SearchL() |
|
37 * along with a custom MHidFieldFinder object to determine whether it |
|
38 * is compatible with a given report descriptor. |
|
39 * |
|
40 * @lib generichid.lib |
|
41 * @since S60 v5.0 |
|
42 */ |
|
43 class MHidFieldFinder |
|
44 { |
|
45 public: |
|
46 |
|
47 /** |
|
48 * Called by THidFieldSearch::SearchL() during traversal of the |
|
49 * report descriptor tree when a CCollection is encountered. It |
|
50 * will be called once, and only once, for every CCollection in the |
|
51 * descriptor. It is not called for the root collection |
|
52 * (the CReportRoot). |
|
53 * |
|
54 * @since S60 v5.0 |
|
55 * @param aCollection A pointer to the collection object. |
|
56 * @return ETrue if the contents of this collection (any child CField |
|
57 * or CCollection objects) should be examined. A driver would return |
|
58 * EFalse if a collection was not of a compatible type, for |
|
59 * example if the usage page was inappropriate. |
|
60 */ |
|
61 virtual TBool BeginCollection(const CCollection *aCollection) = 0; |
|
62 |
|
63 /** |
|
64 * Called by THidFieldSearch::SearchL() during traversal of the |
|
65 * report descriptor tree when all CFields and child CCollections |
|
66 * of a CCollection have been examined. It will be called once, |
|
67 * and only once, for every CCollection in the descriptor. It is |
|
68 * not called for the root collection (the CReportRoot). |
|
69 * |
|
70 * @since S60 v5.0 |
|
71 * @param aCollection A pointer to the collection object. |
|
72 * @return ETrue if the search (tree traversal) should |
|
73 * continue. A driver returns EFalse if it has finished examining |
|
74 * the whole descriptor, in general this will be if it has |
|
75 * established that it is compatible with the report descriptor. |
|
76 */ |
|
77 virtual TBool EndCollection(const CCollection *aCollection) = 0; |
|
78 |
|
79 /** |
|
80 * Called once for each CField in a CCollection by |
|
81 * THidFieldSearch::SearchL() during the traversal of a report |
|
82 * descriptor tree. |
|
83 * |
|
84 * @since S60 v5.0 |
|
85 * @param aField The pointer to field |
|
86 * @return None. |
|
87 */ |
|
88 virtual void Field(const CField* aField) = 0; |
|
89 }; |
|
90 |
|
91 |
|
92 /** |
|
93 * Report Size |
|
94 * |
|
95 * @lib generichid.lib |
|
96 * @since S60 v5.0 |
|
97 */ |
|
98 class TReportSize |
|
99 { |
|
100 public: |
|
101 |
|
102 /** |
|
103 * Constructor. |
|
104 * |
|
105 * @since S60 v5.0 |
|
106 * @param aReportId The report id |
|
107 * @param aType Field type |
|
108 * @return Pointer to report size object |
|
109 */ |
|
110 TReportSize(TInt aReportId, CField::TType aType); |
|
111 |
|
112 |
|
113 /** |
|
114 * TReportSize comparision |
|
115 * |
|
116 * @since S60 v5.0 |
|
117 * @param aFirst first report size to be compared. |
|
118 * @param aSecond second report size to be compared |
|
119 * @return None |
|
120 */ |
|
121 static TBool Match(const TReportSize& aFirst, |
|
122 const TReportSize& aSecond); |
|
123 |
|
124 /** |
|
125 * Report id |
|
126 */ |
|
127 TInt iReportId; |
|
128 |
|
129 /** |
|
130 * Fiel type |
|
131 */ |
|
132 CField::TType iType; |
|
133 |
|
134 /** |
|
135 * Report size |
|
136 */ |
|
137 TInt iSize; |
|
138 }; |
|
139 |
|
140 |
|
141 /** |
|
142 * Hid field search |
|
143 * THidFieldSearch provides a mechanism for traversing a parsed report |
|
144 * descriptor tree (a CReportRoot object). It is intended for a device |
|
145 * driver to use when it is looking to see if it is compatible with a |
|
146 * newly connected device, i.e. provides the appropriate types of |
|
147 * report. The driver must provide an object of a class that implements |
|
148 * the MHidFieldFinder interface. |
|
149 * |
|
150 * @since S60 v5.0 |
|
151 */ |
|
152 class THidFieldSearch |
|
153 { |
|
154 public: |
|
155 |
|
156 /** |
|
157 * Traverse a parsed report descriptor (a tree of CCollections |
|
158 * and CFields) calling the MHidFieldFinder member functions as |
|
159 * appropriate. |
|
160 * |
|
161 * @since S60 v5.0 |
|
162 * @param aReportRoot THe pointer to field |
|
163 * @param aFinder An object that will establish if the report |
|
164 * descriptor is suitable. |
|
165 * @return None. |
|
166 */ |
|
167 IMPORT_C void SearchL(const CReportRoot* aReportRoot, |
|
168 MHidFieldFinder* aFinder); |
|
169 |
|
170 private: |
|
171 |
|
172 /** |
|
173 * Traverse a parsed report descriptor (a tree of CCollections |
|
174 * and CFields) calling the MHidFieldFinder member functions as |
|
175 * appropriate. |
|
176 * |
|
177 * @since S60 v5.0 |
|
178 * @param aReportRoot THe pointer to field |
|
179 * @return ETrue when search is done. |
|
180 */ |
|
181 TBool DoSearchL(const CCollection* aCollection); |
|
182 |
|
183 private: |
|
184 MHidFieldFinder* iFinder; |
|
185 }; |
|
186 |
|
187 /** |
|
188 * Root report |
|
189 * The top level of the tree of fields and collections in a HID |
|
190 * report descriptor. |
|
191 * |
|
192 * @lib generichid.lib |
|
193 * @since S60 v5.0 |
|
194 */ |
|
195 class CReportRoot : public CCollection |
|
196 { |
|
197 public: |
|
198 static CReportRoot* NewLC(); |
|
199 static CReportRoot* NewL(); |
|
200 |
|
201 /** |
|
202 * Destructor |
|
203 */ |
|
204 virtual ~CReportRoot(); |
|
205 |
|
206 /** |
|
207 * Increase the size of a given report by a given number of bits |
|
208 * |
|
209 * @since S60 v5.0 |
|
210 * @param aReportId The report id, which size shoud be increased |
|
211 * @param aType a Type of field |
|
212 * @param aIncrement size of increase |
|
213 * @return None |
|
214 */ |
|
215 void IncrementReportSizeL(TInt aReportId, |
|
216 CField::TType aType, TInt aIncrement); |
|
217 |
|
218 /** |
|
219 * Get the size of a given report in bits |
|
220 * |
|
221 * @since S60 v5.0 |
|
222 * @param aReportId The report id, which size shoud be increased |
|
223 * @param aType a Type of field |
|
224 * @return Size of report in bits |
|
225 */ |
|
226 TInt ReportSize(TInt aReportId, CField::TType aType) const; |
|
227 |
|
228 /** |
|
229 * Get the size of a given report in bytes |
|
230 * |
|
231 * @since S60 v5.0 |
|
232 * @param aReportId The report id, which size shoud be increased |
|
233 * @param aType a Type of field |
|
234 * @return Size of report in bytys |
|
235 */ |
|
236 IMPORT_C TInt ReportSizeBytes(TInt aReportId, CField::TType aType) const; |
|
237 |
|
238 /** |
|
239 * Get the number of reports |
|
240 * |
|
241 * @since S60 v5.0 |
|
242 * @return number of reports |
|
243 */ |
|
244 TInt NumberOfReports() const; |
|
245 |
|
246 /** |
|
247 * Get the size of a given report by array index, rather than type & ID |
|
248 * |
|
249 * @since S60 v5.0 |
|
250 * @param aIndex report index |
|
251 * @return report size |
|
252 */ |
|
253 TInt ReportSize(TInt aIndex) const; |
|
254 |
|
255 private: |
|
256 CReportRoot(); |
|
257 |
|
258 /** |
|
259 * Find report index |
|
260 * |
|
261 * @since S60 v5.0 |
|
262 * @param aReportId The report id to be found |
|
263 * @param aType a Type of field |
|
264 * @return report size |
|
265 */ |
|
266 TInt FindReportSizeIndex(TInt aReportId, CField::TType aType) const; |
|
267 |
|
268 /** |
|
269 * Array to store the size of each report |
|
270 */ |
|
271 RArray<TReportSize> iSizes; |
|
272 }; |
|
273 |
|
274 #endif |
|