|
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 main application class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_GENERICHID_H |
|
20 #define C_GENERICHID_H |
|
21 |
|
22 #include <hidinterfaces.h> |
|
23 |
|
24 class CDriverListItem; |
|
25 class TElement; |
|
26 class CParser; |
|
27 class CReportRoot; |
|
28 class CConnectionInfo; |
|
29 |
|
30 /** |
|
31 * |
|
32 * Generic HID main class |
|
33 * Generic HID layer, allowing the HID Transport layers and device drivers to |
|
34 * pass data to the Generic HID |
|
35 * |
|
36 * @lib generichid.lib |
|
37 * @since S60 v5.0 |
|
38 */ |
|
39 class CGenericHid : public CHidTransport, public MDriverAccess |
|
40 { |
|
41 public: |
|
42 virtual ~CGenericHid(); |
|
43 |
|
44 /** |
|
45 * Constructs a generic HID layer with a reference to the owner so commands can |
|
46 * be sent to connected devices |
|
47 * |
|
48 * @since S60 v5.0 |
|
49 * @param aTransportLayer The owning transport layer |
|
50 * @return a Pointer to an instantiated Generic HID layer |
|
51 */ |
|
52 IMPORT_C static CGenericHid* NewL(MTransportLayer* aTransportLayer); |
|
53 |
|
54 /** |
|
55 * Constructs a generic HID layer with a reference to the owner so commands can |
|
56 * be sent to connected devices |
|
57 * |
|
58 * @since S60 v5.0 |
|
59 * @param aTransportLayer The owning transport layer |
|
60 * @return a Pointer to an instantiated Generic HID layer |
|
61 */ |
|
62 IMPORT_C static CGenericHid* NewLC(MTransportLayer* aTransportLayer); |
|
63 |
|
64 /** |
|
65 * Fromm class MDriverAccess |
|
66 * Retrieves the country code for the HID device |
|
67 * |
|
68 * @since S60 v5.0 |
|
69 * @param aConnectionID The device identifier |
|
70 * @return a country code |
|
71 */ |
|
72 TUint CountryCodeL(TInt aConnectionID); |
|
73 |
|
74 /** |
|
75 * Fromm class MDriverAccess |
|
76 * Retrieves the country code for the HID device |
|
77 * |
|
78 * @since S60 v5.0 |
|
79 * @param aConnectionId The device identifier |
|
80 * @return a vendor ir |
|
81 */ |
|
82 TUint VendorIdL(TInt aConnectionId); |
|
83 |
|
84 /** |
|
85 * Fromm class MDriverAccess |
|
86 * Retrieves the product identifier for the HID device |
|
87 * |
|
88 * @since S60 v5.0 |
|
89 * @param aConnectionId The device identifier |
|
90 * @return a prodcut id |
|
91 */ |
|
92 TUint ProductIdL(TInt aConnectionId); |
|
93 |
|
94 |
|
95 /** |
|
96 * Fromm class MDriverAccess |
|
97 * Sets the protocol to be used for reports. |
|
98 * Leaves KErrInUse The request was not successful because the |
|
99 * transport layer is busy with a previous request, |
|
100 * KErrNotReady The request failed because the device |
|
101 * is currently unavailable and KErrNotFound The request |
|
102 * was unsuccessful |
|
103 * |
|
104 * @since S60 v5.0 |
|
105 * @param aConnectionId The device identifier |
|
106 * @param aInterface The device interface being used by the driver |
|
107 * @param aProtocol The requested report protocol (boot or report) |
|
108 * @parem aDriver Calling driver |
|
109 * @return None. |
|
110 */ |
|
111 void SetProtocolL(TInt aConnectionId, TUint16 aInterface, |
|
112 MDriverAccess::TProtocols aProtocol, CHidDriver* aDriver); |
|
113 |
|
114 |
|
115 /** |
|
116 * Fromm class MDriverAccess |
|
117 * Requests the current protocol from the HID device. This is an asynchronous |
|
118 * request. The protocol value will come through at a later time |
|
119 * |
|
120 * @since S60 v5.0 |
|
121 * @param aConnectionId The device identifier |
|
122 * @param aInterface The hid interface |
|
123 * @return None. |
|
124 */ |
|
125 void GetProtocolL(TInt aConnectionId, TUint16 aInterface); |
|
126 |
|
127 /** |
|
128 * Fromm class MDriverAccess |
|
129 * A request for a report from the device. This is an asynchronous request. |
|
130 * The report will come through at a later time |
|
131 * |
|
132 * @since S60 v5.0 |
|
133 * @param aConnectionId The device identifier |
|
134 * @param aReportId report id to be get |
|
135 * @param aInterface The device interface being used by the driver |
|
136 * @param aLength report lenght |
|
137 * @return None. |
|
138 */ |
|
139 void GetReportL(TInt aConnectionId, TUint8 aReportId, |
|
140 TUint16 aInterface, TUint16 aLength); |
|
141 |
|
142 /** |
|
143 * Fromm class MDriverAccess |
|
144 * A request to send a report payload to the HID device |
|
145 * Leaves whit KErrInUse The request was not successful because the transport |
|
146 * layer is busy with previous request and KErrNotReady The request failed |
|
147 * because the device is currently unavailable |
|
148 * |
|
149 * @since S60 v5.0 |
|
150 * @param aConnectionId The device ID |
|
151 * @param aReportId The report id |
|
152 * @param aReportType Type of report (input/output/feature) |
|
153 * @param aPayload The report containing the device setup packet |
|
154 * @param aInterface The device interface being used by the driver |
|
155 * @parem aDriver Calling driver |
|
156 * @return None. |
|
157 */ |
|
158 void SetReportL(TInt aConnectionId, |
|
159 TUint8 aReportId, MDriverAccess::TReportType aReportType, |
|
160 const TDesC8& aPayload, TUint16 aInterface, CHidDriver* aDriver); |
|
161 |
|
162 /** |
|
163 * Fromm class MDriverAccess |
|
164 * A request to send a report payload to the HID device in Interrupt Channel |
|
165 * Leaves whit KErrInUse The request was not successful because the transport |
|
166 * layer is busy with previous request and KErrNotReady The request failed |
|
167 * because the device is currently unavailable |
|
168 * |
|
169 * @since S60 v5.0 |
|
170 * @param aConnectionId The device ID |
|
171 * @param aReportId report id which payload to be send |
|
172 * @param aPayload The report containing the device setup packet |
|
173 * @param aInterface The device interface being used by the driver |
|
174 * @return None. |
|
175 */ |
|
176 void DataOutL(TInt aConnectionId, TUint8 aReportId, |
|
177 const TDesC8& aPayload, TUint16 aInterface); |
|
178 |
|
179 /** |
|
180 * Fromm class MDriverAccess |
|
181 * Request for the current idle setting for the device |
|
182 * This is an asynchronous request. The idle value will come through at a |
|
183 * later time. Leaves whit KErrInUse The request was not successful because the transport |
|
184 * layer is busy with previous request and KErrNotReady The request failed |
|
185 * because the device is currently unavailable |
|
186 * |
|
187 * @since S60 v5.0 |
|
188 * @param aConnectionId The device identifier |
|
189 * @param aReportId The report ID for which we want the idle rate |
|
190 * @param aInterface The device interface being used by the driver |
|
191 * @return None. |
|
192 */ |
|
193 void GetIdleL(TInt aConnectionId, TUint8 aReportId, TUint16 aInterface); |
|
194 |
|
195 /** |
|
196 * Fromm class MDriverAccess |
|
197 * Request to the HID device to set the specified idle rate |
|
198 * A request to send a report payload to the HID device |
|
199 * Leaves whit KErrInUse The request was not successful because the transport |
|
200 * layer is busy with previous request and KErrNotReady The request failed |
|
201 * because the device is currently unavailable |
|
202 * |
|
203 * @since S60 v5.0 |
|
204 * @param aConnectionId The device ID |
|
205 * @param aDuration The number of 0.04ms intervals to wait between reports |
|
206 * @param aReportId The report for which the idle rate is being set |
|
207 * @param aInterface The device interface being used by the driver |
|
208 * @parem aDriver Calling driver |
|
209 * @return None. |
|
210 */ |
|
211 void SetIdleL(TInt aConnectionId, TUint8 aDuration, |
|
212 TUint8 aReportId, TUint16 aInterface, CHidDriver* aDriver); |
|
213 |
|
214 /** |
|
215 * From class CHidTransport |
|
216 * Called by the transport layers to inform the generic HID of the success of |
|
217 * the last Set... command. |
|
218 * |
|
219 * @since S60 v5.0 |
|
220 * @param aConnectionId The device ID |
|
221 * @param aCmdAck Status of the last Set... command |
|
222 * @return None. |
|
223 */ |
|
224 void CommandResult(TInt aConnectionId, TInt aCmdAck); |
|
225 |
|
226 /** |
|
227 * From class MDriverAccess |
|
228 * Gives the device driver access to the results of the report |
|
229 * descriptor parsing |
|
230 * |
|
231 * @since S60 v5.0 |
|
232 * @param aConnectionId The device ID |
|
233 * @return A pointer to the parsed descriptor object. |
|
234 */ |
|
235 CReportRoot* ReportDescriptor(TInt aConnectionId); |
|
236 |
|
237 /** |
|
238 * From class CHidTransport |
|
239 * Called by a transport layer when a device has connected and the report |
|
240 * descriptors have been obtained |
|
241 * |
|
242 * @since S60 v5.0 |
|
243 * @param aConnectionId The tansport-layer enumeration for the connection |
|
244 * @param aDescriptor The report descriptor for the connected HID device |
|
245 * @return KErrNone if a driver was found, otherwise an error code |
|
246 */ |
|
247 TInt ConnectedL(TInt aConnectionId, const TDesC8& aDescriptor); |
|
248 |
|
249 /** |
|
250 * From class CHidTransport |
|
251 * Called by a transport layer when a device has been disconnected |
|
252 * |
|
253 * @since S60 v5.0 |
|
254 * @param aConnectionId The tansport-layer enumeration for the connection |
|
255 * @return KErrNone if a driver was found, otherwise an error code |
|
256 */ |
|
257 TInt Disconnected(TInt aConnectionId); |
|
258 |
|
259 /** |
|
260 * From class CHidTransport |
|
261 * Called by the transport layer when a device has sent a report on the |
|
262 * interrupt or control channel |
|
263 * |
|
264 * @since S60 v5.0 |
|
265 * @param aConnectionId The tansport-layer enumeration for the connection |
|
266 * @param aChannel Channel ID (Interrupt or Control) |
|
267 * @param aPayload The complete report payload |
|
268 * @return KErrNone if the data was handled by the driver, otherwise an error code |
|
269 */ |
|
270 virtual TInt DataIn(TInt aConnectionId, |
|
271 CHidTransport::THidChannelType aChannel, const TDesC8& aPayload); |
|
272 |
|
273 /** |
|
274 * From class CHidTransport |
|
275 * Called by the transport layer to suspend or resume a driver |
|
276 * |
|
277 * @since S60 v5.0 |
|
278 * @param aConnectionId The tansport-layer enumeration for the connection |
|
279 * @param aActive EActive to start the driver(s), ESuspend to suspend |
|
280 * @return KErrNone if the driver was successfully activated, otherwise an error code |
|
281 */ |
|
282 TInt DriverActive(TInt aConnectionId, |
|
283 CHidTransport::TDriverState aActive); |
|
284 |
|
285 protected: |
|
286 CGenericHid(MTransportLayer* aTransportLayer); |
|
287 void ConstructL(); |
|
288 |
|
289 private: |
|
290 |
|
291 /** |
|
292 * Remove drivers |
|
293 * |
|
294 * @since S60 v5.0 |
|
295 * @return None |
|
296 */ |
|
297 void RemoveDrivers(); |
|
298 |
|
299 /** |
|
300 * Attempts to find a driver that is handling reports from the HID device |
|
301 * |
|
302 * @since S60 v5.0 |
|
303 * @return Connection information |
|
304 */ |
|
305 CConnectionInfo* SeekConnectionInfo(TInt aConnectionId); |
|
306 |
|
307 private: |
|
308 |
|
309 /** |
|
310 * Instantiated driver list |
|
311 */ |
|
312 TSglQue<CDriverListItem> iDriverList; |
|
313 |
|
314 /** |
|
315 * Parser |
|
316 * Own. |
|
317 */ |
|
318 CParser* iParser; |
|
319 |
|
320 /** |
|
321 * Parser |
|
322 * Not own. |
|
323 */ |
|
324 MTransportLayer* iTransportLayer; |
|
325 |
|
326 /** |
|
327 * Connection information |
|
328 */ |
|
329 RPointerArray<CConnectionInfo> iConnectionInfo; |
|
330 |
|
331 /** |
|
332 * Input data handling registry |
|
333 * Own. |
|
334 */ |
|
335 CHidInputDataHandlingReg* iInputHandlingReg; |
|
336 |
|
337 }; |
|
338 |
|
339 #endif |