1 /* |
|
2 * Copyright (c) 2008 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: Plugin for handling vibe command packages. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <ecom/implementationproxy.h> |
|
19 #include <badesca.h> |
|
20 #include <hwrmhaptics.h> |
|
21 |
|
22 #include "hwrmhapticsvibepacketizer.h" |
|
23 #include "hwrmhapticsvibepackets.h" |
|
24 #include "hwrmhapticsvibeconstants.h" |
|
25 |
|
26 // Default request message size (enough for any request message) |
|
27 const TInt KMsgDefaultSize = 80; |
|
28 |
|
29 // const for shifts |
|
30 const TInt KShiftByte = 8; |
|
31 const TInt KShift2Bytes = 16; |
|
32 const TInt KShift3Bytes = 24; |
|
33 |
|
34 const TInt KArrayElements = 10; |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Two phased constructor. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CHWRMHapticsVibePacketizer* CHWRMHapticsVibePacketizer::NewL() |
|
41 { |
|
42 CHWRMHapticsVibePacketizer* self = |
|
43 new ( ELeave ) CHWRMHapticsVibePacketizer(); |
|
44 CleanupStack::PushL( self ); |
|
45 self->ConstructL(); |
|
46 CleanupStack::Pop( self ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Destructor. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CHWRMHapticsVibePacketizer::~CHWRMHapticsVibePacketizer() |
|
55 { |
|
56 iReqBuf.Close(); |
|
57 iDataBuf.Close(); |
|
58 |
|
59 if( iReturnArray ) |
|
60 { |
|
61 delete iReturnArray; |
|
62 iReturnArray = NULL; |
|
63 } |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // Constructor. |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CHWRMHapticsVibePacketizer::CHWRMHapticsVibePacketizer() |
|
71 : iDeviceHandle( KErrNotFound ) |
|
72 { |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // 2nd phase constructor. |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 void CHWRMHapticsVibePacketizer::ConstructL() |
|
80 { |
|
81 User::LeaveIfError( iReqBuf.CreateMax( KMsgDefaultSize ) ); |
|
82 User::LeaveIfError( iDataBuf.CreateMax( KMsgDefaultSize ) ); |
|
83 |
|
84 iReturnArray = new (ELeave) CDesC8ArraySeg( KArrayElements ); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 // --------------------------------------------------------------------------- |
|
90 // |
|
91 TInt CHWRMHapticsVibePacketizer::EncOpenDeviceReq( |
|
92 THWRMLogicalActuators aLogicalActuator, RBuf8& aBuffer ) |
|
93 { |
|
94 TVibePacketOpenDeviceRequest* pReq = |
|
95 reinterpret_cast<TVibePacketOpenDeviceRequest*> |
|
96 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
97 |
|
98 if ( pReq ) |
|
99 { |
|
100 pReq->iCmdCode = KVibeCmdOpenDevice; |
|
101 pReq->iDeviceIndex_7_0 = |
|
102 static_cast<TUint8>( aLogicalActuator & 0xFF ); |
|
103 pReq->iDeviceIndex_15_8 = |
|
104 static_cast<TUint8>( ( aLogicalActuator >> KShiftByte ) & 0xFF ); |
|
105 pReq->iDeviceIndex_23_16 = |
|
106 static_cast<TUint8>( |
|
107 ( aLogicalActuator >> KShift2Bytes ) & 0xFF ); |
|
108 pReq->iDeviceIndex_31_24 = |
|
109 static_cast<TUint8>( |
|
110 ( aLogicalActuator >> KShift3Bytes ) & 0xFF ); |
|
111 iReqBuf.SetLength( sizeof ( TVibePacketOpenDeviceRequest ) ); |
|
112 } |
|
113 else |
|
114 { |
|
115 iReqBuf.SetLength( 0 ); |
|
116 } |
|
117 |
|
118 return aBuffer.Create( iReqBuf ); |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 TInt CHWRMHapticsVibePacketizer::EncCloseDeviceReq( TInt aDeviceHandle, |
|
126 RBuf8& aBuffer ) |
|
127 { |
|
128 TVibePacketCloseDeviceRequest* pReq = |
|
129 reinterpret_cast<TVibePacketCloseDeviceRequest*> |
|
130 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
131 |
|
132 if ( pReq ) |
|
133 { |
|
134 pReq->iCmdCode = KVibeCmdCloseDevice; |
|
135 pReq->iDeviceHandle_7_0 = |
|
136 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
137 pReq->iDeviceHandle_15_8 = |
|
138 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
139 pReq->iDeviceHandle_23_16 = |
|
140 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes) & 0xFF ); |
|
141 pReq->iDeviceHandle_31_24 = |
|
142 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes) & 0xFF ); |
|
143 iReqBuf.SetLength( sizeof( TVibePacketCloseDeviceRequest ) ); |
|
144 } |
|
145 else |
|
146 { |
|
147 iReqBuf.SetLength( 0 ); |
|
148 } |
|
149 |
|
150 return aBuffer.Create( iReqBuf ); |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 // --------------------------------------------------------------------------- |
|
156 // |
|
157 TInt CHWRMHapticsVibePacketizer::EncPlayMagSweepEffectReq( |
|
158 TInt aDeviceHandle, CHWRMHaptics::THWRMHapticsMagSweepEffect aEffect, |
|
159 RBuf8& aBuffer ) |
|
160 { |
|
161 TVibePacketPlayBasisEffectRequest* pReq = |
|
162 reinterpret_cast<TVibePacketPlayBasisEffectRequest*> |
|
163 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
164 |
|
165 if ( pReq ) |
|
166 { |
|
167 pReq->iCmdCode = KVibeCmdPlayMagSweepEffect; |
|
168 pReq->iDeviceHandle_7_0 = |
|
169 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
170 pReq->iDeviceHandle_15_8 = |
|
171 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
172 pReq->iDeviceHandle_23_16 = |
|
173 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
174 pReq->iDeviceHandle_31_24 = |
|
175 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
176 pReq->iDuration_7_0 = |
|
177 static_cast<TUint8>( aEffect.iDuration & 0xFF ); |
|
178 pReq->iDuration_15_8 = |
|
179 static_cast<TUint8>( ( aEffect.iDuration >> KShiftByte ) & 0xFF ); |
|
180 pReq->iDuration_23_16 = |
|
181 static_cast<TUint8>( |
|
182 ( aEffect.iDuration >> KShift2Bytes ) & 0xFF ); |
|
183 pReq->iDuration_31_24 = |
|
184 static_cast<TUint8>( |
|
185 ( aEffect.iDuration >> KShift3Bytes ) & 0xFF ); |
|
186 pReq->iMagnitude_7_0 = |
|
187 static_cast<TUint8>( aEffect.iMagnitude & 0xFF ); |
|
188 pReq->iMagnitude_15_8 = |
|
189 static_cast<TUint8>( |
|
190 ( aEffect.iMagnitude >> KShiftByte ) & 0xFF ); |
|
191 pReq->iMagnitude_23_16 = |
|
192 static_cast<TUint8>( |
|
193 ( aEffect.iMagnitude >> KShift2Bytes ) & 0xFF ); |
|
194 pReq->iMagnitude_31_24 = |
|
195 static_cast<TUint8>( |
|
196 ( aEffect.iMagnitude >> KShift3Bytes ) & 0xFF ); |
|
197 pReq->iEffectTypeStyle = |
|
198 static_cast<TUint8>( ( aEffect.iStyle << 4 ) & 0xF0 ); |
|
199 pReq->iPeriod_7_0 = 0x0; |
|
200 pReq->iPeriod_15_8 = 0x0; |
|
201 pReq->iPeriod_23_16 = 0x0; |
|
202 pReq->iPeriod_31_24 = 0x0; |
|
203 pReq->iImpulseTime_7_0 = |
|
204 static_cast<TUint8>( aEffect.iAttackTime & 0xFF ); |
|
205 pReq->iImpulseTime_15_8 = |
|
206 static_cast<TUint8>( |
|
207 ( aEffect.iAttackTime >> KShiftByte ) & 0xFF ); |
|
208 pReq->iImpulseTime_23_16 = |
|
209 static_cast<TUint8>( |
|
210 ( aEffect.iAttackTime >> KShift2Bytes ) & 0xFF ); |
|
211 pReq->iImpulseTime_31_24 = |
|
212 static_cast<TUint8>( |
|
213 ( aEffect.iAttackTime >> KShift3Bytes ) & 0xFF ); |
|
214 pReq->iImpulseLevel_7_0 = |
|
215 static_cast<TUint8>( aEffect.iAttackLevel & 0xFF ); |
|
216 pReq->iImpulseLevel_15_8 = |
|
217 static_cast<TUint8>( |
|
218 ( aEffect.iAttackLevel >> KShiftByte ) & 0xFF ); |
|
219 pReq->iImpulseLevel_23_16 = |
|
220 static_cast<TUint8>( |
|
221 ( aEffect.iAttackLevel >> KShift2Bytes ) & 0xFF ); |
|
222 pReq->iImpulseLevel_31_24 = |
|
223 static_cast<TUint8>( |
|
224 ( aEffect.iAttackLevel >> KShift3Bytes ) & 0xFF ); |
|
225 pReq->iFadeTime_7_0 = |
|
226 static_cast<TUint8>( aEffect.iFadeTime & 0xFF ); |
|
227 pReq->iFadeTime_15_8 = |
|
228 static_cast<TUint8>( ( aEffect.iFadeTime >> KShiftByte ) & 0xFF ); |
|
229 pReq->iFadeTime_23_16 = |
|
230 static_cast<TUint8>( |
|
231 ( aEffect.iFadeTime >> KShift2Bytes ) & 0xFF ); |
|
232 pReq->iFadeTime_31_24 = |
|
233 static_cast<TUint8>( |
|
234 ( aEffect.iFadeTime >> KShift3Bytes ) & 0xFF ); |
|
235 pReq->iFadeLevel_7_0 = |
|
236 static_cast<TUint8>( aEffect.iFadeLevel & 0xFF ); |
|
237 pReq->iFadeLevel_15_8 = |
|
238 static_cast<TUint8>( |
|
239 ( aEffect.iFadeLevel >> KShiftByte ) & 0xFF ); |
|
240 pReq->iFadeLevel_23_16 = |
|
241 static_cast<TUint8>( |
|
242 ( aEffect.iFadeLevel >> KShift2Bytes ) & 0xFF ); |
|
243 pReq->iFadeLevel_31_24 = |
|
244 static_cast<TUint8>( |
|
245 ( aEffect.iFadeLevel >> KShift3Bytes ) & 0xFF ); |
|
246 iReqBuf.SetLength( sizeof( TVibePacketPlayBasisEffectRequest ) ); |
|
247 } |
|
248 else |
|
249 { |
|
250 iReqBuf.SetLength( 0 ); |
|
251 } |
|
252 |
|
253 return aBuffer.Create( iReqBuf ); |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 // --------------------------------------------------------------------------- |
|
259 // |
|
260 TInt CHWRMHapticsVibePacketizer::EncPlayPeriodicEffectReq( TInt aDeviceHandle, |
|
261 CHWRMHaptics::THWRMHapticsPeriodicEffect aEffect, RBuf8& aBuffer ) |
|
262 { |
|
263 TVibePacketPlayBasisEffectRequest* pReq = |
|
264 reinterpret_cast<TVibePacketPlayBasisEffectRequest*> |
|
265 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
266 |
|
267 if ( pReq ) |
|
268 { |
|
269 pReq->iCmdCode = KVibeCmdPlayPeriodicEffect; |
|
270 pReq->iDeviceHandle_7_0 = |
|
271 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
272 pReq->iDeviceHandle_15_8 = |
|
273 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
274 pReq->iDeviceHandle_23_16 = |
|
275 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
276 pReq->iDeviceHandle_31_24 = |
|
277 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
278 pReq->iDuration_7_0 = |
|
279 static_cast<TUint8>( aEffect.iDuration & 0xFF ); |
|
280 pReq->iDuration_15_8 = |
|
281 static_cast<TUint8>( ( aEffect.iDuration >> KShiftByte ) & 0xFF ); |
|
282 pReq->iDuration_23_16 = |
|
283 static_cast<TUint8>( |
|
284 ( aEffect.iDuration >> KShift2Bytes ) & 0xFF ); |
|
285 pReq->iDuration_31_24 = |
|
286 static_cast<TUint8>( |
|
287 ( aEffect.iDuration >> KShift3Bytes ) & 0xFF ); |
|
288 pReq->iMagnitude_7_0 = |
|
289 static_cast<TUint8>( aEffect.iMagnitude & 0xFF ); |
|
290 pReq->iMagnitude_15_8 = |
|
291 static_cast<TUint8>( |
|
292 ( aEffect.iMagnitude >> KShiftByte ) & 0xFF ); |
|
293 pReq->iMagnitude_23_16 = |
|
294 static_cast<TUint8>( |
|
295 ( aEffect.iMagnitude >> KShift2Bytes ) & 0xFF ); |
|
296 pReq->iMagnitude_31_24 = |
|
297 static_cast<TUint8>( |
|
298 ( aEffect.iMagnitude >> KShift3Bytes ) & 0xFF ); |
|
299 pReq->iEffectTypeStyle = |
|
300 static_cast<TUint8>( ( ( aEffect.iStyle << 4 ) & 0xF0 ) | 0x01 ); |
|
301 pReq->iPeriod_7_0 = |
|
302 static_cast<TUint8>( aEffect.iPeriod & 0xFF ); |
|
303 pReq->iPeriod_15_8 = |
|
304 static_cast<TUint8>( ( aEffect.iPeriod >> KShiftByte ) & 0xFF ); |
|
305 pReq->iPeriod_23_16 = |
|
306 static_cast<TUint8>( ( aEffect.iPeriod >> KShift2Bytes ) & 0xFF ); |
|
307 pReq->iPeriod_31_24 = |
|
308 static_cast<TUint8>( ( aEffect.iPeriod >> KShift3Bytes ) & 0xFF ); |
|
309 pReq->iImpulseTime_7_0 = |
|
310 static_cast<TUint8>( aEffect.iAttackTime & 0xFF ); |
|
311 pReq->iImpulseTime_15_8 = |
|
312 static_cast<TUint8>( |
|
313 ( aEffect.iAttackTime >> KShiftByte ) & 0xFF ); |
|
314 pReq->iImpulseTime_23_16 = |
|
315 static_cast<TUint8>( |
|
316 ( aEffect.iAttackTime >> KShift2Bytes ) & 0xFF ); |
|
317 pReq->iImpulseTime_31_24 = |
|
318 static_cast<TUint8>( |
|
319 ( aEffect.iAttackTime >> KShift3Bytes ) & 0xFF ); |
|
320 pReq->iImpulseLevel_7_0 = |
|
321 static_cast<TUint8>( aEffect.iAttackLevel & 0xFF ); |
|
322 pReq->iImpulseLevel_15_8 = |
|
323 static_cast<TUint8>( |
|
324 ( aEffect.iAttackLevel >> KShiftByte ) & 0xFF ); |
|
325 pReq->iImpulseLevel_23_16 = |
|
326 static_cast<TUint8>( |
|
327 ( aEffect.iAttackLevel >> KShift2Bytes ) & 0xFF ); |
|
328 pReq->iImpulseLevel_31_24 = |
|
329 static_cast<TUint8>( |
|
330 ( aEffect.iAttackLevel >> KShift3Bytes ) & 0xFF ); |
|
331 pReq->iFadeTime_7_0 = |
|
332 static_cast<TUint8>( aEffect.iFadeTime & 0xFF ); |
|
333 pReq->iFadeTime_15_8 = |
|
334 static_cast<TUint8>( ( aEffect.iFadeTime >> KShiftByte ) & 0xFF ); |
|
335 pReq->iFadeTime_23_16 = |
|
336 static_cast<TUint8>( |
|
337 ( aEffect.iFadeTime >> KShift2Bytes ) & 0xFF ); |
|
338 pReq->iFadeTime_31_24 = |
|
339 static_cast<TUint8>( |
|
340 ( aEffect.iFadeTime >> KShift3Bytes ) & 0xFF ); |
|
341 pReq->iFadeLevel_7_0 = |
|
342 static_cast<TUint8>( aEffect.iFadeLevel & 0xFF ); |
|
343 pReq->iFadeLevel_15_8 = |
|
344 static_cast<TUint8>( |
|
345 ( aEffect.iFadeLevel >> KShiftByte ) & 0xFF ); |
|
346 pReq->iFadeLevel_23_16 = |
|
347 static_cast<TUint8>( |
|
348 ( aEffect.iFadeLevel >> KShift2Bytes ) & 0xFF ); |
|
349 pReq->iFadeLevel_31_24 = |
|
350 static_cast<TUint8>( |
|
351 ( aEffect.iFadeLevel >> KShift3Bytes ) & 0xFF ); |
|
352 iReqBuf.SetLength( sizeof( TVibePacketPlayBasisEffectRequest ) ); |
|
353 } |
|
354 else |
|
355 { |
|
356 iReqBuf.SetLength( 0 ); |
|
357 } |
|
358 |
|
359 return aBuffer.Create( iReqBuf ); |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 TInt CHWRMHapticsVibePacketizer::EncModifyPlayingMagSweepEffectReq( |
|
367 TInt aDeviceHandle, TInt aEffectHandle, |
|
368 CHWRMHaptics::THWRMHapticsMagSweepEffect aEffect, RBuf8& aBuffer ) |
|
369 { |
|
370 TVibePacketModifyBasisEffectRequest* pReq = |
|
371 reinterpret_cast<TVibePacketModifyBasisEffectRequest*> |
|
372 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
373 |
|
374 if ( pReq ) |
|
375 { |
|
376 pReq->iCmdCode = KVibeCmdModifyPlayingMagSweepEffect; |
|
377 pReq->iDeviceHandle_7_0 = |
|
378 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
379 pReq->iDeviceHandle_15_8 = |
|
380 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
381 pReq->iDeviceHandle_23_16 = |
|
382 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
383 pReq->iDeviceHandle_31_24 = |
|
384 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
385 pReq->iEffectHandle_7_0 = |
|
386 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
387 pReq->iEffectHandle_15_8 = |
|
388 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
389 pReq->iEffectHandle_23_16 = |
|
390 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
391 pReq->iEffectHandle_31_24 = |
|
392 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
393 pReq->iDuration_7_0 = |
|
394 static_cast<TUint8>( aEffect.iDuration & 0xFF ); |
|
395 pReq->iDuration_15_8 = |
|
396 static_cast<TUint8>( ( aEffect.iDuration >> KShiftByte ) & 0xFF ); |
|
397 pReq->iDuration_23_16 = |
|
398 static_cast<TUint8>( |
|
399 ( aEffect.iDuration >> KShift2Bytes ) & 0xFF ); |
|
400 pReq->iDuration_31_24 = |
|
401 static_cast<TUint8>( |
|
402 ( aEffect.iDuration >> KShift3Bytes ) & 0xFF ); |
|
403 pReq->iMagnitude_7_0 = |
|
404 static_cast<TUint8>( aEffect.iMagnitude & 0xFF ); |
|
405 pReq->iMagnitude_15_8 = |
|
406 static_cast<TUint8>( |
|
407 ( aEffect.iMagnitude >> KShiftByte ) & 0xFF ); |
|
408 pReq->iMagnitude_23_16 = |
|
409 static_cast<TUint8>( |
|
410 ( aEffect.iMagnitude >> KShift2Bytes ) & 0xFF ); |
|
411 pReq->iMagnitude_31_24 = |
|
412 static_cast<TUint8>( |
|
413 ( aEffect.iMagnitude >> KShift3Bytes ) & 0xFF ); |
|
414 pReq->iEffectTypeStyle = |
|
415 static_cast<TUint8>( ( aEffect.iStyle << 4 ) & 0xF0 ); |
|
416 pReq->iPeriod_7_0 = 0x0; |
|
417 pReq->iPeriod_15_8 = 0x0; |
|
418 pReq->iPeriod_23_16 = 0x0; |
|
419 pReq->iPeriod_31_24 = 0x0; |
|
420 pReq->iImpulseTime_7_0 = |
|
421 static_cast<TUint8>( aEffect.iAttackTime & 0xFF ); |
|
422 pReq->iImpulseTime_15_8 = |
|
423 static_cast<TUint8>( |
|
424 ( aEffect.iAttackTime >> KShiftByte ) & 0xFF ); |
|
425 pReq->iImpulseTime_23_16 = |
|
426 static_cast<TUint8>( |
|
427 ( aEffect.iAttackTime >> KShift2Bytes ) & 0xFF ); |
|
428 pReq->iImpulseTime_31_24 = |
|
429 static_cast<TUint8>( |
|
430 ( aEffect.iAttackTime >> KShift3Bytes ) & 0xFF ); |
|
431 pReq->iImpulseLevel_7_0 = |
|
432 static_cast<TUint8>( aEffect.iAttackLevel & 0xFF ); |
|
433 pReq->iImpulseLevel_15_8 = |
|
434 static_cast<TUint8>( |
|
435 ( aEffect.iAttackLevel >> KShiftByte ) & 0xFF ); |
|
436 pReq->iImpulseLevel_23_16 = |
|
437 static_cast<TUint8>( |
|
438 ( aEffect.iAttackLevel >> KShift2Bytes ) & 0xFF ); |
|
439 pReq->iImpulseLevel_31_24 = |
|
440 static_cast<TUint8>( |
|
441 ( aEffect.iAttackLevel >> KShift3Bytes ) & 0xFF ); |
|
442 pReq->iFadeTime_7_0 = |
|
443 static_cast<TUint8>( aEffect.iFadeTime & 0xFF ); |
|
444 pReq->iFadeTime_15_8 = |
|
445 static_cast<TUint8>( ( aEffect.iFadeTime >> KShiftByte ) & 0xFF ); |
|
446 pReq->iFadeTime_23_16 = |
|
447 static_cast<TUint8>( |
|
448 ( aEffect.iFadeTime >> KShift2Bytes ) & 0xFF ); |
|
449 pReq->iFadeTime_31_24 = |
|
450 static_cast<TUint8>( |
|
451 ( aEffect.iFadeTime >> KShift3Bytes ) & 0xFF ); |
|
452 pReq->iFadeLevel_7_0 = |
|
453 static_cast<TUint8>( aEffect.iFadeLevel & 0xFF ); |
|
454 pReq->iFadeLevel_15_8 = |
|
455 static_cast<TUint8>( |
|
456 ( aEffect.iFadeLevel >> KShiftByte ) & 0xFF ); |
|
457 pReq->iFadeLevel_23_16 = |
|
458 static_cast<TUint8>( |
|
459 ( aEffect.iFadeLevel >> KShift2Bytes ) & 0xFF ); |
|
460 pReq->iFadeLevel_31_24 = |
|
461 static_cast<TUint8>( |
|
462 ( aEffect.iFadeLevel >> KShift3Bytes ) & 0xFF ); |
|
463 iReqBuf.SetLength( sizeof( TVibePacketModifyBasisEffectRequest ) ); |
|
464 } |
|
465 else |
|
466 { |
|
467 iReqBuf.SetLength( 0 ); |
|
468 } |
|
469 |
|
470 return aBuffer.Create( iReqBuf ); |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 TInt CHWRMHapticsVibePacketizer::EncModifyPlayingPeriodicEffectReq( |
|
478 TInt aDeviceHandle, TInt aEffectHandle, |
|
479 CHWRMHaptics::THWRMHapticsPeriodicEffect aEffect, RBuf8& aBuffer ) |
|
480 { |
|
481 TVibePacketModifyBasisEffectRequest* pReq = |
|
482 reinterpret_cast<TVibePacketModifyBasisEffectRequest*> |
|
483 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
484 |
|
485 if ( pReq ) |
|
486 { |
|
487 pReq->iCmdCode = KVibeCmdModifyPlayingPeriodicEffect; |
|
488 pReq->iDeviceHandle_7_0 = |
|
489 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
490 pReq->iDeviceHandle_15_8 = |
|
491 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
492 pReq->iDeviceHandle_23_16 = |
|
493 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
494 pReq->iDeviceHandle_31_24 = |
|
495 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
496 pReq->iEffectHandle_7_0 = |
|
497 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
498 pReq->iEffectHandle_15_8 = |
|
499 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
500 pReq->iEffectHandle_23_16 = |
|
501 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
502 pReq->iEffectHandle_31_24 = |
|
503 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
504 pReq->iDuration_7_0 = |
|
505 static_cast<TUint8>( aEffect.iDuration & 0xFF ); |
|
506 pReq->iDuration_15_8 = |
|
507 static_cast<TUint8>( |
|
508 ( aEffect.iDuration >> KShiftByte ) & 0xFF ); |
|
509 pReq->iDuration_23_16 = |
|
510 static_cast<TUint8>( |
|
511 ( aEffect.iDuration >> KShift2Bytes ) & 0xFF ); |
|
512 pReq->iDuration_31_24 = |
|
513 static_cast<TUint8>( |
|
514 ( aEffect.iDuration >> KShift3Bytes ) & 0xFF ); |
|
515 pReq->iMagnitude_7_0 = |
|
516 static_cast<TUint8>( aEffect.iMagnitude & 0xFF ); |
|
517 pReq->iMagnitude_15_8 = |
|
518 static_cast<TUint8>( |
|
519 ( aEffect.iMagnitude >> KShiftByte ) & 0xFF ); |
|
520 pReq->iMagnitude_23_16 = |
|
521 static_cast<TUint8>( |
|
522 ( aEffect.iMagnitude >> KShift2Bytes ) & 0xFF ); |
|
523 pReq->iMagnitude_31_24 = |
|
524 static_cast<TUint8>( |
|
525 ( aEffect.iMagnitude >> KShift3Bytes ) & 0xFF ); |
|
526 pReq->iEffectTypeStyle = |
|
527 static_cast<TUint8>( ( ( aEffect.iStyle << 4 ) & 0xF0 ) | 0x01 ); |
|
528 pReq->iPeriod_7_0 = |
|
529 static_cast<TUint8>( aEffect.iPeriod & 0xFF ); |
|
530 pReq->iPeriod_15_8 = |
|
531 static_cast<TUint8>( ( aEffect.iPeriod >> KShiftByte ) & 0xFF ); |
|
532 pReq->iPeriod_23_16 = |
|
533 static_cast<TUint8>( ( aEffect.iPeriod >> KShift2Bytes ) & 0xFF ); |
|
534 pReq->iPeriod_31_24 = |
|
535 static_cast<TUint8>( ( aEffect.iPeriod >> KShift3Bytes ) & 0xFF ); |
|
536 pReq->iImpulseTime_7_0 = |
|
537 static_cast<TUint8>( aEffect.iAttackTime & 0xFF ); |
|
538 pReq->iImpulseTime_15_8 = |
|
539 static_cast<TUint8>( |
|
540 ( aEffect.iAttackTime >> KShiftByte ) & 0xFF ); |
|
541 pReq->iImpulseTime_23_16 = |
|
542 static_cast<TUint8>( |
|
543 ( aEffect.iAttackTime >> KShift2Bytes ) & 0xFF ); |
|
544 pReq->iImpulseTime_31_24 = |
|
545 static_cast<TUint8>( |
|
546 ( aEffect.iAttackTime >> KShift3Bytes ) & 0xFF ); |
|
547 pReq->iImpulseLevel_7_0 = |
|
548 static_cast<TUint8>( aEffect.iAttackLevel & 0xFF ); |
|
549 pReq->iImpulseLevel_15_8 = |
|
550 static_cast<TUint8>( |
|
551 ( aEffect.iAttackLevel >> KShiftByte ) & 0xFF ); |
|
552 pReq->iImpulseLevel_23_16 = |
|
553 static_cast<TUint8>( |
|
554 ( aEffect.iAttackLevel >> KShift2Bytes ) & 0xFF ); |
|
555 pReq->iImpulseLevel_31_24 = |
|
556 static_cast<TUint8>( |
|
557 ( aEffect.iAttackLevel >> KShift3Bytes ) & 0xFF ); |
|
558 pReq->iFadeTime_7_0 = |
|
559 static_cast<TUint8>( aEffect.iFadeTime & 0xFF ); |
|
560 pReq->iFadeTime_15_8 = |
|
561 static_cast<TUint8>( ( aEffect.iFadeTime >> KShiftByte ) & 0xFF ); |
|
562 pReq->iFadeTime_23_16 = |
|
563 static_cast<TUint8>( |
|
564 ( aEffect.iFadeTime >> KShift2Bytes ) & 0xFF ); |
|
565 pReq->iFadeTime_31_24 = |
|
566 static_cast<TUint8>( |
|
567 ( aEffect.iFadeTime >> KShift3Bytes ) & 0xFF ); |
|
568 pReq->iFadeLevel_7_0 = |
|
569 static_cast<TUint8>( aEffect.iFadeLevel & 0xFF ); |
|
570 pReq->iFadeLevel_15_8 = |
|
571 static_cast<TUint8>( |
|
572 ( aEffect.iFadeLevel >> KShiftByte ) & 0xFF ); |
|
573 pReq->iFadeLevel_23_16 = |
|
574 static_cast<TUint8>( |
|
575 ( aEffect.iFadeLevel >> KShift2Bytes ) & 0xFF ); |
|
576 pReq->iFadeLevel_31_24 = |
|
577 static_cast<TUint8>( |
|
578 ( aEffect.iFadeLevel >> KShift3Bytes ) & 0xFF ); |
|
579 iReqBuf.SetLength( sizeof( TVibePacketModifyBasisEffectRequest ) ); |
|
580 } |
|
581 else |
|
582 { |
|
583 iReqBuf.SetLength( 0 ); |
|
584 } |
|
585 |
|
586 return aBuffer.Create( iReqBuf ); |
|
587 } |
|
588 |
|
589 // --------------------------------------------------------------------------- |
|
590 // |
|
591 // --------------------------------------------------------------------------- |
|
592 // |
|
593 TInt CHWRMHapticsVibePacketizer::EncPausePlayingEffectReq( |
|
594 TInt aDeviceHandle, TInt aEffectHandle, RBuf8& aBuffer ) |
|
595 { |
|
596 TVibePacketPausePlayingEffectRequest* pReq = |
|
597 reinterpret_cast<TVibePacketPausePlayingEffectRequest*> |
|
598 (const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
599 |
|
600 if ( pReq ) |
|
601 { |
|
602 pReq->iCmdCode = KVibeCmdPausePlayingEffect; |
|
603 pReq->iEffectHandle_7_0 = |
|
604 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
605 pReq->iEffectHandle_15_8 = |
|
606 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
607 pReq->iEffectHandle_23_16 = |
|
608 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
609 pReq->iEffectHandle_31_24 = |
|
610 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
611 pReq->iDeviceHandle_7_0 = |
|
612 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
613 pReq->iDeviceHandle_15_8 = |
|
614 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
615 pReq->iDeviceHandle_23_16 = |
|
616 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
617 pReq->iDeviceHandle_31_24 = |
|
618 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
619 iReqBuf.SetLength( sizeof( TVibePacketPausePlayingEffectRequest ) ); |
|
620 } |
|
621 else |
|
622 { |
|
623 iReqBuf.SetLength( 0 ); |
|
624 } |
|
625 |
|
626 return aBuffer.Create( iReqBuf ); |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // |
|
631 // --------------------------------------------------------------------------- |
|
632 // |
|
633 TInt CHWRMHapticsVibePacketizer::EncResumePausedEffectReq( |
|
634 TInt aDeviceHandle, TInt aEffectHandle, RBuf8& aBuffer ) |
|
635 { |
|
636 TVibePacketResumePlayingEffectRequest* pReq = |
|
637 reinterpret_cast<TVibePacketResumePlayingEffectRequest*> |
|
638 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
639 |
|
640 if ( pReq ) |
|
641 { |
|
642 pReq->iCmdCode = KVibeCmdResumePausedEffect; |
|
643 pReq->iEffectHandle_7_0 = |
|
644 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
645 pReq->iEffectHandle_15_8 = |
|
646 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
647 pReq->iEffectHandle_23_16 = |
|
648 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
649 pReq->iEffectHandle_31_24 = |
|
650 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
651 pReq->iDeviceHandle_7_0 = |
|
652 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
653 pReq->iDeviceHandle_15_8 = |
|
654 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
655 pReq->iDeviceHandle_23_16 = |
|
656 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
657 pReq->iDeviceHandle_31_24 = |
|
658 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
659 iReqBuf.SetLength( sizeof( TVibePacketResumePlayingEffectRequest ) ); |
|
660 } |
|
661 else |
|
662 { |
|
663 iReqBuf.SetLength( 0 ); |
|
664 } |
|
665 |
|
666 return aBuffer.Create( iReqBuf ); |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 TInt CHWRMHapticsVibePacketizer::EncStopPlayingEffectReq( |
|
674 TInt aDeviceHandle, TInt aEffectHandle, RBuf8& aBuffer ) |
|
675 { |
|
676 TVibePacketStopEffectRequest* pReq = |
|
677 reinterpret_cast<TVibePacketStopEffectRequest*> |
|
678 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
679 |
|
680 if ( pReq ) |
|
681 { |
|
682 pReq->iCmdCode = KVibeCmdStopEffect; |
|
683 pReq->iDeviceHandle_7_0 = |
|
684 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
685 pReq->iDeviceHandle_15_8 = |
|
686 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
687 pReq->iDeviceHandle_23_16 = |
|
688 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
689 pReq->iDeviceHandle_31_24 = |
|
690 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
691 pReq->iEffectHandle_7_0 = |
|
692 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
693 pReq->iEffectHandle_15_8 = |
|
694 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
695 pReq->iEffectHandle_23_16 = |
|
696 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
697 pReq->iEffectHandle_31_24 = |
|
698 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
699 iReqBuf.SetLength( sizeof( TVibePacketStopEffectRequest ) ); |
|
700 } |
|
701 else |
|
702 { |
|
703 iReqBuf.SetLength( 0 ); |
|
704 } |
|
705 |
|
706 return aBuffer.Create( iReqBuf ); |
|
707 } |
|
708 |
|
709 // --------------------------------------------------------------------------- |
|
710 // |
|
711 // --------------------------------------------------------------------------- |
|
712 // |
|
713 TInt CHWRMHapticsVibePacketizer::EncStopAllPlayingEffectsReq( |
|
714 TInt aDeviceHandle, RBuf8& aBuffer ) |
|
715 { |
|
716 TVibePacketStopAllEffectsRequest* pReq = |
|
717 reinterpret_cast<TVibePacketStopAllEffectsRequest*> |
|
718 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
719 |
|
720 if ( pReq ) |
|
721 { |
|
722 pReq->iCmdCode = KVibeCmdStopAllEffects; |
|
723 pReq->iDeviceHandle_7_0 = |
|
724 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
725 pReq->iDeviceHandle_15_8 = |
|
726 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
727 pReq->iDeviceHandle_23_16 = |
|
728 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
729 pReq->iDeviceHandle_31_24 = |
|
730 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
731 iReqBuf.SetLength( sizeof( TVibePacketStopAllEffectsRequest ) ); |
|
732 } |
|
733 else |
|
734 { |
|
735 iReqBuf.SetLength( 0 ); |
|
736 } |
|
737 |
|
738 return aBuffer.Create( iReqBuf ); |
|
739 } |
|
740 |
|
741 // --------------------------------------------------------------------------- |
|
742 // |
|
743 // --------------------------------------------------------------------------- |
|
744 // |
|
745 TInt CHWRMHapticsVibePacketizer::EncPlayEffectIncludeEffectDataReq( |
|
746 TInt aDeviceHandle, const TDesC8& aData, TInt aEffectIndex, |
|
747 RBuf8& aBuffer ) |
|
748 { |
|
749 iDataBuf.Close(); |
|
750 TInt err = iDataBuf.Create( aData.Size() + KMsgDefaultSize ); |
|
751 |
|
752 TVibePacketPlayIVTEffectRequest* pReq = |
|
753 reinterpret_cast<TVibePacketPlayIVTEffectRequest*> |
|
754 ( const_cast<TUint8*>( iDataBuf.Ptr() ) ); |
|
755 |
|
756 if ( !err && pReq && |
|
757 ( ( aData.Size() + KMsgDefaultSize ) <= KVibePacketMaxSize ) ) |
|
758 { |
|
759 pReq->iCmdCode = KVibeCmdPlayIVTEffectIncludeData; |
|
760 pReq->iIvtDataSize = aData.Size(); |
|
761 pReq->iDeviceHandle_7_0 = |
|
762 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
763 pReq->iDeviceHandle_15_8 = |
|
764 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
765 pReq->iDeviceHandle_23_16 = |
|
766 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
767 pReq->iDeviceHandle_31_24 = |
|
768 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
769 pReq->iIvtIndex_7_0 = |
|
770 static_cast<TUint8>( aEffectIndex & 0xFF ); |
|
771 pReq->iIvtIndex_15_8 = |
|
772 static_cast<TUint8>( ( aEffectIndex >> KShiftByte ) & 0xFF ); |
|
773 pReq->iRepeat = 0x0; |
|
774 |
|
775 memcpy( pReq->iIvtData, aData.Ptr(), aData.Size() ); |
|
776 |
|
777 // the data buffer length is set to the size of the request packet |
|
778 // plus size of the data minus 1 (minus 1, because first byte of the |
|
779 // data is already calculated as part of the request packet size). |
|
780 iDataBuf.SetLength( |
|
781 sizeof( TVibePacketPlayIVTEffectRequest ) + aData.Size() -1 ); |
|
782 } |
|
783 else |
|
784 { |
|
785 iDataBuf.SetLength( 0 ); |
|
786 } |
|
787 |
|
788 return aBuffer.Create( iDataBuf ); |
|
789 } |
|
790 |
|
791 // --------------------------------------------------------------------------- |
|
792 // |
|
793 // --------------------------------------------------------------------------- |
|
794 // |
|
795 TInt CHWRMHapticsVibePacketizer::EncPlayEffectRepeatIncludeEffectDataReq( |
|
796 TInt aDeviceHandle, const TDesC8& aData, TInt aEffectIndex, |
|
797 TUint8 aRepeat, RBuf8& aBuffer ) |
|
798 { |
|
799 iDataBuf.Close(); |
|
800 TInt err = iDataBuf.Create( aData.Size() + KMsgDefaultSize ); |
|
801 |
|
802 TVibePacketPlayIVTEffectRequest* pReq = |
|
803 reinterpret_cast<TVibePacketPlayIVTEffectRequest*> |
|
804 ( const_cast<TUint8*>( iDataBuf.Ptr() ) ); |
|
805 |
|
806 if ( !err && pReq && |
|
807 ( ( aData.Size() + KMsgDefaultSize ) <= KVibePacketMaxSize ) ) |
|
808 { |
|
809 pReq->iCmdCode = KVibeCmdPlayIVTEffectIncludeData; |
|
810 pReq->iIvtDataSize = aData.Size(); |
|
811 pReq->iDeviceHandle_7_0 = |
|
812 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
813 pReq->iDeviceHandle_15_8 = |
|
814 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
815 pReq->iDeviceHandle_23_16 = |
|
816 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
817 pReq->iDeviceHandle_31_24 = |
|
818 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
819 pReq->iIvtIndex_7_0 = |
|
820 static_cast<TUint8>( aEffectIndex & 0xFF ); |
|
821 pReq->iIvtIndex_15_8 = |
|
822 static_cast<TUint8>( ( aEffectIndex >> KShiftByte ) & 0xFF ); |
|
823 pReq->iRepeat = aRepeat; |
|
824 |
|
825 memcpy( pReq->iIvtData, aData.Ptr(), aData.Size() ); |
|
826 |
|
827 // the data buffer length is set to the size of the request packet |
|
828 // plus size of the data minus 1 (minus 1, because first byte of the |
|
829 // data is already calculated as part of the request packet size). |
|
830 iDataBuf.SetLength( |
|
831 sizeof( TVibePacketPlayIVTEffectRequest ) + aData.Size() -1 ); |
|
832 } |
|
833 else |
|
834 { |
|
835 iDataBuf.SetLength( 0 ); |
|
836 } |
|
837 |
|
838 return aBuffer.Create( iDataBuf ); |
|
839 } |
|
840 |
|
841 // --------------------------------------------------------------------------- |
|
842 // |
|
843 // --------------------------------------------------------------------------- |
|
844 // |
|
845 TInt CHWRMHapticsVibePacketizer::EncPlayEffectRepeatNoDataReq( |
|
846 TInt aDeviceHandle, TInt aEffectIndex, TUint8 aRepeat, RBuf8& aBuffer ) |
|
847 { |
|
848 TVibePacketPlayIVTEffectRequest* pReq = |
|
849 reinterpret_cast<TVibePacketPlayIVTEffectRequest*> |
|
850 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
851 |
|
852 if ( pReq ) |
|
853 { |
|
854 pReq->iCmdCode = KVibeCmdPlayIVTEffectNoData; |
|
855 pReq->iIvtDataSize = 0x0; |
|
856 pReq->iDeviceHandle_7_0 = |
|
857 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
858 pReq->iDeviceHandle_15_8 = |
|
859 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
860 pReq->iDeviceHandle_23_16 = |
|
861 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
862 pReq->iDeviceHandle_31_24 = |
|
863 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
864 pReq->iIvtIndex_7_0 = |
|
865 static_cast<TUint8>( aEffectIndex & 0xFF ); |
|
866 pReq->iIvtIndex_15_8 = |
|
867 static_cast<TUint8>( ( aEffectIndex >> KShiftByte ) & 0xFF ); |
|
868 pReq->iRepeat = aRepeat; |
|
869 iReqBuf.SetLength( sizeof( TVibePacketPlayIVTEffectRequest ) ); |
|
870 } |
|
871 else |
|
872 { |
|
873 iReqBuf.SetLength( 0 ); |
|
874 } |
|
875 |
|
876 return aBuffer.Create( iReqBuf ); |
|
877 } |
|
878 |
|
879 // --------------------------------------------------------------------------- |
|
880 // |
|
881 // --------------------------------------------------------------------------- |
|
882 // |
|
883 TInt CHWRMHapticsVibePacketizer::EncPlayEffectNoDataReq( |
|
884 TInt aDeviceHandle, TInt aEffectIndex, RBuf8& aBuffer ) |
|
885 { |
|
886 TVibePacketPlayIVTEffectRequest* pReq = |
|
887 reinterpret_cast<TVibePacketPlayIVTEffectRequest*> |
|
888 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
889 |
|
890 if ( pReq ) |
|
891 { |
|
892 pReq->iCmdCode = KVibeCmdPlayIVTEffectNoData; |
|
893 pReq->iIvtDataSize = 0x0; |
|
894 pReq->iDeviceHandle_7_0 = |
|
895 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
896 pReq->iDeviceHandle_15_8 = |
|
897 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
898 pReq->iDeviceHandle_23_16 = |
|
899 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
900 pReq->iDeviceHandle_31_24 = |
|
901 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
902 pReq->iIvtIndex_7_0 = |
|
903 static_cast<TUint8>( aEffectIndex & 0xFF ); |
|
904 pReq->iIvtIndex_15_8 = |
|
905 static_cast<TUint8>( ( aEffectIndex >> KShiftByte ) & 0xFF ); |
|
906 pReq->iRepeat = 0x0; |
|
907 iReqBuf.SetLength( sizeof( TVibePacketPlayIVTEffectRequest ) ); |
|
908 } |
|
909 else |
|
910 { |
|
911 iReqBuf.SetLength( 0 ); |
|
912 } |
|
913 |
|
914 return aBuffer.Create( iReqBuf ); |
|
915 } |
|
916 |
|
917 // --------------------------------------------------------------------------- |
|
918 // |
|
919 // --------------------------------------------------------------------------- |
|
920 // |
|
921 TInt CHWRMHapticsVibePacketizer::EncCreateStreamingEffectReq( |
|
922 TInt aDeviceHandle, RBuf8& aBuffer ) |
|
923 { |
|
924 TVibePacketCreateStreamingEffectRequest* pReq = |
|
925 reinterpret_cast<TVibePacketCreateStreamingEffectRequest*> |
|
926 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
927 |
|
928 if ( pReq ) |
|
929 { |
|
930 pReq->iCmdCode = KVibeCmdCreateStreamingEffect; |
|
931 pReq->iDeviceHandle_7_0 = |
|
932 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
933 pReq->iDeviceHandle_15_8 = |
|
934 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
935 pReq->iDeviceHandle_23_16 = |
|
936 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
937 pReq->iDeviceHandle_31_24 = |
|
938 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
939 iReqBuf.SetLength( |
|
940 sizeof( TVibePacketCreateStreamingEffectRequest ) ); |
|
941 } |
|
942 else |
|
943 { |
|
944 iReqBuf.SetLength( 0 ); |
|
945 } |
|
946 |
|
947 return aBuffer.Create( iReqBuf ); |
|
948 } |
|
949 |
|
950 // --------------------------------------------------------------------------- |
|
951 // |
|
952 // --------------------------------------------------------------------------- |
|
953 // |
|
954 TInt CHWRMHapticsVibePacketizer::EncDestroyStreamingEffectReq( |
|
955 TInt aDeviceHandle, TInt aEffectHandle, RBuf8& aBuffer ) |
|
956 { |
|
957 TVibePacketDestroyStreamingEffectRequest* pReq = |
|
958 reinterpret_cast<TVibePacketDestroyStreamingEffectRequest*> |
|
959 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
960 |
|
961 if ( pReq ) |
|
962 { |
|
963 pReq->iCmdCode = KVibeCmdDestroyStreamingEffect; |
|
964 pReq->iEffectHandle_7_0 = |
|
965 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
966 pReq->iEffectHandle_15_8 = |
|
967 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
968 pReq->iEffectHandle_23_16 = |
|
969 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
970 pReq->iEffectHandle_31_24 = |
|
971 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
972 pReq->iDeviceHandle_7_0 = |
|
973 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
974 pReq->iDeviceHandle_15_8 = |
|
975 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
976 pReq->iDeviceHandle_23_16 = |
|
977 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
978 pReq->iDeviceHandle_31_24 = |
|
979 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
980 iReqBuf.SetLength( |
|
981 sizeof( TVibePacketDestroyStreamingEffectRequest ) ); |
|
982 } |
|
983 else |
|
984 { |
|
985 iReqBuf.SetLength( 0 ); |
|
986 } |
|
987 |
|
988 return aBuffer.Create( iReqBuf ); |
|
989 } |
|
990 |
|
991 // --------------------------------------------------------------------------- |
|
992 // |
|
993 // --------------------------------------------------------------------------- |
|
994 // |
|
995 TInt CHWRMHapticsVibePacketizer::EncPlayStreamingSampleReq( |
|
996 TInt aDeviceHandle, const TDesC8& aStreamingSample, TInt aEffectHandle, |
|
997 RBuf8& aBuffer ) |
|
998 { |
|
999 return EncPlayStreamingSampleInternal( aDeviceHandle, |
|
1000 aEffectHandle, |
|
1001 aStreamingSample, |
|
1002 0, aBuffer ); |
|
1003 } |
|
1004 |
|
1005 // --------------------------------------------------------------------------- |
|
1006 // |
|
1007 // --------------------------------------------------------------------------- |
|
1008 // |
|
1009 TInt CHWRMHapticsVibePacketizer::EncPlayStreamingSampleWithOffsetReq( |
|
1010 TInt aDeviceHandle, const TDesC8& aStreamingSample, TInt aOffsetTime, |
|
1011 TInt aEffectHandle, RBuf8& aBuffer ) |
|
1012 { |
|
1013 return EncPlayStreamingSampleInternal( aDeviceHandle, |
|
1014 aEffectHandle, |
|
1015 aStreamingSample, |
|
1016 aOffsetTime, |
|
1017 aBuffer ); |
|
1018 } |
|
1019 |
|
1020 // --------------------------------------------------------------------------- |
|
1021 // |
|
1022 // --------------------------------------------------------------------------- |
|
1023 // |
|
1024 TInt CHWRMHapticsVibePacketizer::EncGetEffectStateReq( |
|
1025 TInt aDeviceHandle, TInt aEffectHandle, RBuf8& aBuffer ) |
|
1026 { |
|
1027 TVibePacketGetEffectStateRequest* pReq = |
|
1028 reinterpret_cast<TVibePacketGetEffectStateRequest*> |
|
1029 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
1030 |
|
1031 if ( pReq ) |
|
1032 { |
|
1033 pReq->iCmdCode = KVibeCmdGetEffectState; |
|
1034 pReq->iEffectHandle_7_0 = |
|
1035 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
1036 pReq->iEffectHandle_15_8 = |
|
1037 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
1038 pReq->iEffectHandle_23_16 = |
|
1039 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
1040 pReq->iEffectHandle_31_24 = |
|
1041 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
1042 pReq->iDeviceHandle_7_0 = |
|
1043 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
1044 pReq->iDeviceHandle_15_8 = |
|
1045 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
1046 pReq->iDeviceHandle_23_16 = |
|
1047 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
1048 pReq->iDeviceHandle_31_24 = |
|
1049 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
1050 iReqBuf.SetLength( sizeof( TVibePacketGetEffectStateRequest ) ); |
|
1051 } |
|
1052 else |
|
1053 { |
|
1054 iReqBuf.SetLength( 0 ); |
|
1055 } |
|
1056 |
|
1057 return aBuffer.Create( iReqBuf ); |
|
1058 } |
|
1059 |
|
1060 // --------------------------------------------------------------------------- |
|
1061 // |
|
1062 // --------------------------------------------------------------------------- |
|
1063 // |
|
1064 TInt CHWRMHapticsVibePacketizer::EncSetDevicePropertyBoolReq( |
|
1065 TInt aDeviceHandle, TBool aDevPropValue, TInt aDevPropType, |
|
1066 RBuf8& aBuffer ) |
|
1067 { |
|
1068 TVibePacketSetDevicePropertyRequest* pReq = |
|
1069 reinterpret_cast<TVibePacketSetDevicePropertyRequest*> |
|
1070 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
1071 |
|
1072 if ( pReq ) |
|
1073 { |
|
1074 pReq->iCmdCode = KVibeCmdSetDeviceProperty; |
|
1075 pReq->iDeviceHandle_7_0 = |
|
1076 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
1077 pReq->iDeviceHandle_15_8 = |
|
1078 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
1079 pReq->iDeviceHandle_23_16 = |
|
1080 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
1081 pReq->iDeviceHandle_31_24 = |
|
1082 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
1083 pReq->iPropertyType_7_0 = |
|
1084 static_cast<TUint8>( aDevPropType & 0xFF ); |
|
1085 pReq->iPropertyType_15_8 = |
|
1086 static_cast<TUint8>( ( aDevPropType >> KShiftByte ) & 0xFF ); |
|
1087 pReq->iPropertyType_23_16 = |
|
1088 static_cast<TUint8>( ( aDevPropType >> KShift2Bytes ) & 0xFF ); |
|
1089 pReq->iPropertyType_31_24 = |
|
1090 static_cast<TUint8>( ( aDevPropType >> KShift3Bytes ) & 0xFF ); |
|
1091 pReq->iPropertyValueType = |
|
1092 static_cast<TUint8>( KVibeValuetypeBool ); |
|
1093 pReq->iSize = 1; // size of bool data is 1 byte |
|
1094 pReq->iPropertyValue[0] = |
|
1095 static_cast<TUint8>( aDevPropValue ); |
|
1096 iReqBuf.SetLength( sizeof( TVibePacketSetDevicePropertyRequest ) ); |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 iReqBuf.SetLength( 0 ); |
|
1101 } |
|
1102 |
|
1103 return aBuffer.Create( iReqBuf ); |
|
1104 } |
|
1105 |
|
1106 // --------------------------------------------------------------------------- |
|
1107 // |
|
1108 // --------------------------------------------------------------------------- |
|
1109 // |
|
1110 TInt CHWRMHapticsVibePacketizer::EncSetDevicePropertyIntReq( |
|
1111 TInt aDeviceHandle, TInt aDevPropValue, TInt aDevPropType, |
|
1112 RBuf8& aBuffer ) |
|
1113 { |
|
1114 TVibePacketSetDevicePropertyRequest* pReq = |
|
1115 reinterpret_cast<TVibePacketSetDevicePropertyRequest*> |
|
1116 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
1117 |
|
1118 if ( pReq ) |
|
1119 { |
|
1120 pReq->iCmdCode = KVibeCmdSetDeviceProperty; |
|
1121 pReq->iDeviceHandle_7_0 = |
|
1122 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
1123 pReq->iDeviceHandle_15_8 = |
|
1124 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
1125 pReq->iDeviceHandle_23_16 = |
|
1126 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
1127 pReq->iDeviceHandle_31_24 = |
|
1128 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
1129 pReq->iPropertyType_7_0 = |
|
1130 static_cast<TUint8>( aDevPropType & 0xFF ); |
|
1131 pReq->iPropertyType_15_8 = |
|
1132 static_cast<TUint8>( ( aDevPropType >> KShiftByte ) & 0xFF ); |
|
1133 pReq->iPropertyType_23_16 = |
|
1134 static_cast<TUint8>( ( aDevPropType >> KShift2Bytes ) & 0xFF ); |
|
1135 pReq->iPropertyType_31_24 = |
|
1136 static_cast<TUint8>( ( aDevPropType >> KShift3Bytes ) & 0xFF ); |
|
1137 pReq->iPropertyValueType = |
|
1138 static_cast<TUint8>( KVibeValuetypeInt32 ); |
|
1139 pReq->iSize = 4; // Size of int32 value is 4 bytes |
|
1140 pReq->iPropertyValue[0] = |
|
1141 static_cast<TUint8>( aDevPropValue & 0xFF ); |
|
1142 pReq->iPropertyValue[1] = |
|
1143 static_cast<TUint8>( ( aDevPropValue >> KShiftByte ) & 0xFF ); |
|
1144 pReq->iPropertyValue[2] = |
|
1145 static_cast<TUint8>( ( aDevPropValue >> KShift2Bytes ) & 0xFF ); |
|
1146 pReq->iPropertyValue[3] = |
|
1147 static_cast<TUint8>( ( aDevPropValue >> KShift3Bytes ) & 0xFF ); |
|
1148 // the data buffer length is set to the size of the request packet |
|
1149 // plus size of the data minus 1. Since int32 type data is always |
|
1150 // 4 bytes, the extra size needed for data is 3 bytes (4-1). |
|
1151 iReqBuf.SetLength( |
|
1152 sizeof( TVibePacketSetDevicePropertyRequest ) +3 ); |
|
1153 } |
|
1154 else |
|
1155 { |
|
1156 iReqBuf.SetLength( 0 ); |
|
1157 } |
|
1158 |
|
1159 return aBuffer.Create( iReqBuf ); |
|
1160 } |
|
1161 |
|
1162 // --------------------------------------------------------------------------- |
|
1163 // |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // |
|
1166 TInt CHWRMHapticsVibePacketizer::EncSetDevicePropertyStringReq( |
|
1167 TInt aDeviceHandle, const TDesC8& aDevPropValue, TInt aDevPropType, |
|
1168 RBuf8& aBuffer ) |
|
1169 { |
|
1170 iDataBuf.Close(); |
|
1171 TInt err = iDataBuf.Create( aDevPropValue.Size() + KMsgDefaultSize ); |
|
1172 |
|
1173 TVibePacketSetDevicePropertyRequest* pReq = |
|
1174 reinterpret_cast<TVibePacketSetDevicePropertyRequest*> |
|
1175 ( const_cast<TUint8*>( iDataBuf.Ptr() ) ); |
|
1176 |
|
1177 if ( !err && pReq && |
|
1178 ( ( aDevPropValue.Size() + KMsgDefaultSize ) <= KVibePacketMaxSize ) ) |
|
1179 { |
|
1180 pReq->iCmdCode = KVibeCmdSetDeviceProperty; |
|
1181 pReq->iDeviceHandle_7_0 = |
|
1182 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
1183 pReq->iDeviceHandle_15_8 = |
|
1184 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
1185 pReq->iDeviceHandle_23_16 = |
|
1186 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
1187 pReq->iDeviceHandle_31_24 = |
|
1188 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
1189 pReq->iPropertyType_7_0 = |
|
1190 static_cast<TUint8>( aDevPropType & 0xFF ); |
|
1191 pReq->iPropertyType_15_8 = |
|
1192 static_cast<TUint8>( ( aDevPropType >> KShiftByte ) & 0xFF ); |
|
1193 pReq->iPropertyType_23_16 = |
|
1194 static_cast<TUint8>( ( aDevPropType >> KShift2Bytes ) & 0xFF ); |
|
1195 pReq->iPropertyType_31_24 = |
|
1196 static_cast<TUint8>( ( aDevPropType >> KShift3Bytes ) & 0xFF ); |
|
1197 pReq->iPropertyValueType = |
|
1198 static_cast<TUint8>( KVibeValuetypeString ); |
|
1199 pReq->iSize = |
|
1200 static_cast<TUint8>( aDevPropValue.Size() ); |
|
1201 |
|
1202 memcpy ( pReq->iPropertyValue, |
|
1203 reinterpret_cast<TUint8*>( |
|
1204 const_cast<TUint8*>( aDevPropValue.Ptr() ) ), |
|
1205 aDevPropValue.Size() ); |
|
1206 |
|
1207 // the data buffer length is set to the size of the request packet |
|
1208 // plus size of the data minus 1 (minus 1, because first byte of the |
|
1209 // data is already calculated as part of the request packet size). |
|
1210 iDataBuf.SetLength( |
|
1211 sizeof( TVibePacketSetDevicePropertyRequest ) + pReq->iSize -1 ); |
|
1212 } |
|
1213 else |
|
1214 { |
|
1215 iDataBuf.SetLength( 0 ); |
|
1216 } |
|
1217 |
|
1218 return aBuffer.Create( iDataBuf ); |
|
1219 } |
|
1220 |
|
1221 // --------------------------------------------------------------------------- |
|
1222 // |
|
1223 // --------------------------------------------------------------------------- |
|
1224 // |
|
1225 TInt CHWRMHapticsVibePacketizer::EncSetPlatformLicenseKeyReq( |
|
1226 TInt aDeviceHandle, RBuf8& aBuffer ) |
|
1227 { |
|
1228 TInt ret = EncSetDevicePropertyStringReq( aDeviceHandle, KNullDesC8, |
|
1229 CHWRMHaptics::EHWRMHapticsLicensekey, |
|
1230 aBuffer ); |
|
1231 |
|
1232 // change the command id from general device property to setting |
|
1233 // license key |
|
1234 if ( ret == KErrNone ) |
|
1235 { |
|
1236 TVibePacketSetDevicePropertyRequest* tmpReq = |
|
1237 reinterpret_cast<TVibePacketSetDevicePropertyRequest*> |
|
1238 ( const_cast<TUint8*>( aBuffer.Ptr() ) ); |
|
1239 |
|
1240 if ( tmpReq ) |
|
1241 { |
|
1242 tmpReq->iCmdCode = KVibeCmdSetLicense; |
|
1243 } |
|
1244 } |
|
1245 |
|
1246 return ret; |
|
1247 } |
|
1248 |
|
1249 // --------------------------------------------------------------------------- |
|
1250 // |
|
1251 // --------------------------------------------------------------------------- |
|
1252 // |
|
1253 TInt CHWRMHapticsVibePacketizer::EncGetDevicePropertyBoolReq( |
|
1254 TInt aDeviceHandle, TInt aDevPropType, RBuf8& aBuffer ) |
|
1255 { |
|
1256 return EncGetDevicePropertyReqInternal( |
|
1257 KVibeValuetypeBool, aDeviceHandle, aDevPropType, aBuffer ); |
|
1258 } |
|
1259 |
|
1260 // --------------------------------------------------------------------------- |
|
1261 // |
|
1262 // --------------------------------------------------------------------------- |
|
1263 // |
|
1264 TInt CHWRMHapticsVibePacketizer::EncGetDevicePropertyIntReq( |
|
1265 TInt aDeviceHandle, TInt aDevPropType, RBuf8& aBuffer ) |
|
1266 { |
|
1267 return EncGetDevicePropertyReqInternal( |
|
1268 KVibeValuetypeInt32, aDeviceHandle, aDevPropType, aBuffer ); |
|
1269 } |
|
1270 |
|
1271 // --------------------------------------------------------------------------- |
|
1272 // |
|
1273 // --------------------------------------------------------------------------- |
|
1274 // |
|
1275 TInt CHWRMHapticsVibePacketizer::EncGetDevicePropertyStringReq( |
|
1276 TInt aDeviceHandle, TInt aDevPropType, RBuf8& aBuffer ) |
|
1277 { |
|
1278 return EncGetDevicePropertyReqInternal( |
|
1279 KVibeValuetypeString, aDeviceHandle, aDevPropType, aBuffer ); |
|
1280 } |
|
1281 |
|
1282 // --------------------------------------------------------------------------- |
|
1283 // |
|
1284 // --------------------------------------------------------------------------- |
|
1285 // |
|
1286 TInt CHWRMHapticsVibePacketizer::EncGetDeviceCapabilityIntReq( |
|
1287 TInt aDeviceHandle, TInt aDevCapType, RBuf8& aBuffer ) |
|
1288 { |
|
1289 return EncGetDeviceCapabilityReqInternal( KVibeValuetypeInt32, |
|
1290 aDeviceHandle, |
|
1291 aDevCapType, |
|
1292 aBuffer ); |
|
1293 } |
|
1294 |
|
1295 // --------------------------------------------------------------------------- |
|
1296 // |
|
1297 // --------------------------------------------------------------------------- |
|
1298 // |
|
1299 TInt CHWRMHapticsVibePacketizer::EncGetDeviceCapabilityStringReq( |
|
1300 TInt aDeviceHandle, TInt aDevCapType, RBuf8& aBuffer ) |
|
1301 { |
|
1302 return EncGetDeviceCapabilityReqInternal( KVibeValuetypeString, |
|
1303 aDeviceHandle, |
|
1304 aDevCapType, |
|
1305 aBuffer ); |
|
1306 } |
|
1307 |
|
1308 // --------------------------------------------------------------------------- |
|
1309 // |
|
1310 // --------------------------------------------------------------------------- |
|
1311 // |
|
1312 CDesC8ArraySeg* CHWRMHapticsVibePacketizer::DecodeMessageL( |
|
1313 const TDesC8& aData, TInt& aStatus ) |
|
1314 { |
|
1315 // Clear Array before use |
|
1316 iReturnArray->Reset(); |
|
1317 |
|
1318 TVibePacket* pRsp = |
|
1319 reinterpret_cast<TVibePacket*>( const_cast<TUint8*>( aData.Ptr() ) ); |
|
1320 |
|
1321 switch( pRsp->iSimpleRsp.iCmdCode ) |
|
1322 { |
|
1323 case KVibeCmdOpenDevice: |
|
1324 { |
|
1325 aStatus = pRsp->iOpenDeviceRsp.iVibeStatus; |
|
1326 iDeviceHandle = |
|
1327 pRsp->iOpenDeviceRsp.iDeviceHandle_7_0 | |
|
1328 pRsp->iOpenDeviceRsp.iDeviceHandle_15_8 << KShiftByte | |
|
1329 pRsp->iOpenDeviceRsp.iDeviceHandle_23_16 << KShift2Bytes | |
|
1330 pRsp->iOpenDeviceRsp.iDeviceHandle_31_24 << KShift3Bytes; |
|
1331 |
|
1332 TPckg<TInt> deviceHandlePckg( iDeviceHandle ); |
|
1333 |
|
1334 iReturnArray->AppendL( deviceHandlePckg ); |
|
1335 break; |
|
1336 } |
|
1337 |
|
1338 case KVibeCmdCloseDevice: |
|
1339 { |
|
1340 aStatus = pRsp->iCloseDeviceRsp.iVibeStatus; |
|
1341 iDeviceHandle = KErrNotFound; |
|
1342 break; |
|
1343 } |
|
1344 |
|
1345 case KVibeCmdSetDeviceProperty: // flow through |
|
1346 case KVibeCmdSetLicense: |
|
1347 { |
|
1348 aStatus = pRsp->iSetDevicePropertyRsp.iVibeStatus; |
|
1349 break; |
|
1350 } |
|
1351 |
|
1352 case KVibeCmdGetDeviceProperty: |
|
1353 { |
|
1354 TInt propertyValueType = |
|
1355 pRsp->iGetDevicePropertyRsp.iPropertyValueType; |
|
1356 |
|
1357 switch( propertyValueType ) |
|
1358 { |
|
1359 case KVibeValuetypeBool: |
|
1360 { |
|
1361 aStatus = pRsp->iGetDevicePropertyRsp.iVibeStatus; |
|
1362 |
|
1363 TUint8* intArr = |
|
1364 pRsp->iGetDevicePropertyRsp.iPropertyValue; |
|
1365 |
|
1366 TUint value = ( TUint( intArr[0] ) ); |
|
1367 TPckg<TBool> devicePropertyValuePckg( value ); |
|
1368 |
|
1369 iReturnArray->AppendL( devicePropertyValuePckg ); |
|
1370 break; |
|
1371 } |
|
1372 case KVibeValuetypeInt32: |
|
1373 { |
|
1374 aStatus = pRsp->iGetDevicePropertyRsp.iVibeStatus; |
|
1375 |
|
1376 TUint8* intArr = |
|
1377 pRsp->iGetDevicePropertyRsp.iPropertyValue; |
|
1378 |
|
1379 TUint value = ( TUint( intArr[0] ) ) |
|
1380 | ( TUint( intArr[1] ) << KShiftByte ) |
|
1381 | ( TUint( intArr[2] ) << KShift2Bytes ) |
|
1382 | ( TUint( intArr[3] ) << KShift3Bytes ); |
|
1383 TPckg<TInt> devicePropertyValuePckg( value ); |
|
1384 |
|
1385 iReturnArray->AppendL( devicePropertyValuePckg ); |
|
1386 break; |
|
1387 } |
|
1388 |
|
1389 case KVibeValuetypeString: |
|
1390 { |
|
1391 aStatus = pRsp->iGetDevicePropertyRsp.iVibeStatus; |
|
1392 TInt stringSize = pRsp->iGetDevicePropertyRsp.iSize; |
|
1393 |
|
1394 if( stringSize > MaxPropertyStringLength() ) |
|
1395 { |
|
1396 // truncate string if too long |
|
1397 stringSize = MaxPropertyStringLength(); |
|
1398 } |
|
1399 |
|
1400 TUint8* text = reinterpret_cast<TUint8*>( |
|
1401 pRsp->iGetDevicePropertyRsp.iPropertyValue ); |
|
1402 TPtrC8 ptr( text, stringSize ); |
|
1403 |
|
1404 iReturnArray->AppendL( ptr ); |
|
1405 break; |
|
1406 } |
|
1407 default: |
|
1408 break; |
|
1409 }// switch |
|
1410 break; |
|
1411 } |
|
1412 |
|
1413 case KVibeCmdPlayMagSweepEffect: // flow through |
|
1414 case KVibeCmdPlayPeriodicEffect: |
|
1415 { |
|
1416 aStatus = pRsp->iPlayBasisEffectRsp.iVibeStatus; |
|
1417 TInt effectHandle = |
|
1418 pRsp->iPlayBasisEffectRsp.iEffectHandle_7_0 | |
|
1419 pRsp->iPlayBasisEffectRsp.iEffectHandle_15_8 << KShiftByte | |
|
1420 pRsp->iPlayBasisEffectRsp.iEffectHandle_23_16 << KShift2Bytes | |
|
1421 pRsp->iPlayBasisEffectRsp.iEffectHandle_31_24 << KShift3Bytes; |
|
1422 |
|
1423 TPckg<TInt> effectHandlePckg( effectHandle ); |
|
1424 iReturnArray->AppendL( effectHandlePckg ); |
|
1425 break; |
|
1426 } |
|
1427 |
|
1428 case KVibeCmdPlayIVTEffectIncludeData: // flow through |
|
1429 case KVibeCmdPlayIVTEffectNoData: |
|
1430 { |
|
1431 aStatus = pRsp->iPlayIVTEffectRsp.iVibeStatus; |
|
1432 TInt effectHandle = |
|
1433 pRsp->iPlayIVTEffectRsp.iEffectHandle_7_0 | |
|
1434 pRsp->iPlayIVTEffectRsp.iEffectHandle_15_8 << KShiftByte | |
|
1435 pRsp->iPlayIVTEffectRsp.iEffectHandle_23_16 << KShift2Bytes | |
|
1436 pRsp->iPlayIVTEffectRsp.iEffectHandle_31_24 << KShift3Bytes; |
|
1437 |
|
1438 TPckg<TInt> effectHandlePckg( effectHandle ); |
|
1439 iReturnArray->AppendL( effectHandlePckg ); |
|
1440 break; |
|
1441 } |
|
1442 |
|
1443 case KVibeCmdModifyPlayingMagSweepEffect: // flow through |
|
1444 case KVibeCmdModifyPlayingPeriodicEffect: |
|
1445 { |
|
1446 aStatus = pRsp->iModifyBasisEffectRsp.iVibeStatus; |
|
1447 break; |
|
1448 } |
|
1449 |
|
1450 case KVibeCmdStopEffect: |
|
1451 { |
|
1452 aStatus = pRsp->iStopEffectRsp.iVibeStatus; |
|
1453 break; |
|
1454 } |
|
1455 |
|
1456 case KVibeCmdStopAllEffects: |
|
1457 { |
|
1458 aStatus = pRsp->iStopAllEffectsRsp.iVibeStatus; |
|
1459 break; |
|
1460 } |
|
1461 |
|
1462 case KVibeCmdGetDeviceCapabilities: |
|
1463 { |
|
1464 TInt capabilityValueType = |
|
1465 pRsp->iGetDeviceCapsRsp.iCapabilityValueType; |
|
1466 |
|
1467 switch( capabilityValueType ) |
|
1468 { |
|
1469 case KVibeValuetypeInt32: |
|
1470 { |
|
1471 aStatus = pRsp->iGetDeviceCapsRsp.iVibeStatus; |
|
1472 TUint8* intArr = |
|
1473 pRsp->iGetDeviceCapsRsp.iCapabilityValue; |
|
1474 |
|
1475 TUint value = ( TUint( intArr[0] ) ) |
|
1476 | ( TUint( intArr[1] ) << KShiftByte ) |
|
1477 | ( TUint( intArr[2] ) << KShift2Bytes ) |
|
1478 | ( TUint( intArr[3] ) << KShift3Bytes ); |
|
1479 |
|
1480 TPckg<TInt> deviceCapabilityValuePckg( value ); |
|
1481 iReturnArray->AppendL( deviceCapabilityValuePckg ); |
|
1482 break; |
|
1483 } |
|
1484 |
|
1485 case KVibeValuetypeString: |
|
1486 { |
|
1487 aStatus = pRsp->iGetDeviceCapsRsp.iVibeStatus; |
|
1488 TUint8* text = |
|
1489 reinterpret_cast<TUint8*>( |
|
1490 pRsp->iGetDeviceCapsRsp.iCapabilityValue ); |
|
1491 TInt stringSize ( pRsp->iGetDeviceCapsRsp.iSize ); |
|
1492 |
|
1493 if( stringSize > MaxCapabilityStringLength() ) |
|
1494 { |
|
1495 // truncate string if too long |
|
1496 stringSize = MaxCapabilityStringLength(); |
|
1497 } |
|
1498 TPtrC8 ptr( text, stringSize ); |
|
1499 |
|
1500 iReturnArray->AppendL( ptr ); |
|
1501 break; |
|
1502 } |
|
1503 default: |
|
1504 break; |
|
1505 }// switch |
|
1506 break; |
|
1507 } |
|
1508 |
|
1509 case KVibeCmdPlayStreamingSample: |
|
1510 { |
|
1511 aStatus = pRsp->iPlayStreamingSampleRsp.iVibeStatus; |
|
1512 break; |
|
1513 } |
|
1514 |
|
1515 case KVibeCmdCreateStreamingEffect: |
|
1516 { |
|
1517 aStatus = pRsp->iCreateStreamingEffectRsp.iVibeStatus; |
|
1518 |
|
1519 TInt effectHandle = |
|
1520 pRsp->iCreateStreamingEffectRsp.iEffectHandle_7_0 | |
|
1521 pRsp->iCreateStreamingEffectRsp.iEffectHandle_15_8 |
|
1522 << KShiftByte | |
|
1523 pRsp->iCreateStreamingEffectRsp.iEffectHandle_23_16 |
|
1524 << KShift2Bytes | |
|
1525 pRsp->iCreateStreamingEffectRsp.iEffectHandle_31_24 |
|
1526 << KShift3Bytes; |
|
1527 |
|
1528 TPckg<TInt> effectHandlePckg( effectHandle ); |
|
1529 iReturnArray->AppendL( effectHandlePckg ); |
|
1530 break; |
|
1531 } |
|
1532 |
|
1533 case KVibeCmdDestroyStreamingEffect: |
|
1534 { |
|
1535 aStatus = pRsp->iDestroyStreamingEffectRsp.iVibeStatus; |
|
1536 break; |
|
1537 } |
|
1538 |
|
1539 case KVibeCmdPausePlayingEffect: |
|
1540 { |
|
1541 aStatus = pRsp->iPausePlayingEffectRsp.iVibeStatus; |
|
1542 break; |
|
1543 } |
|
1544 |
|
1545 case KVibeCmdResumePausedEffect: |
|
1546 { |
|
1547 aStatus = pRsp->iResumePausedEffectRsp.iVibeStatus; |
|
1548 break; |
|
1549 } |
|
1550 |
|
1551 case KVibeCmdGetEffectState: |
|
1552 { |
|
1553 aStatus = pRsp->iGetEffectStateRsp.iVibeStatus; |
|
1554 TInt effectState = pRsp->iGetEffectStateRsp.iEffectState; |
|
1555 |
|
1556 TPckg<TInt> effectStatePckg( effectState ); |
|
1557 iReturnArray->AppendL( effectStatePckg ); |
|
1558 break; |
|
1559 } |
|
1560 |
|
1561 default: |
|
1562 User::Leave( KErrGeneral ); |
|
1563 } |
|
1564 |
|
1565 // convert vibe error code to Symbian error code |
|
1566 aStatus = MapError( aStatus ); |
|
1567 |
|
1568 return iReturnArray; |
|
1569 } |
|
1570 |
|
1571 // --------------------------------------------------------------------------- |
|
1572 // |
|
1573 // --------------------------------------------------------------------------- |
|
1574 // |
|
1575 TInt CHWRMHapticsVibePacketizer::DeviceHandle() |
|
1576 { |
|
1577 return iDeviceHandle; |
|
1578 } |
|
1579 |
|
1580 // --------------------------------------------------------------------------- |
|
1581 // |
|
1582 // --------------------------------------------------------------------------- |
|
1583 // |
|
1584 TInt CHWRMHapticsVibePacketizer::InfiniteRepeat() |
|
1585 { |
|
1586 return static_cast<TInt>( KVibeRepeatCountInfinite ); |
|
1587 } |
|
1588 |
|
1589 // --------------------------------------------------------------------------- |
|
1590 // |
|
1591 // --------------------------------------------------------------------------- |
|
1592 // |
|
1593 TInt CHWRMHapticsVibePacketizer::InfiniteDuration() |
|
1594 { |
|
1595 return KVibeTimeInfinite; |
|
1596 } |
|
1597 |
|
1598 // --------------------------------------------------------------------------- |
|
1599 // |
|
1600 // --------------------------------------------------------------------------- |
|
1601 // |
|
1602 TInt CHWRMHapticsVibePacketizer::MaxEffectNameLength() |
|
1603 { |
|
1604 return KVibeMaxEffectNameLength; |
|
1605 } |
|
1606 |
|
1607 // --------------------------------------------------------------------------- |
|
1608 // |
|
1609 // --------------------------------------------------------------------------- |
|
1610 // |
|
1611 TInt CHWRMHapticsVibePacketizer::MaxDeviceNameLength() |
|
1612 { |
|
1613 return KVibeMaxDeviceNameLength; |
|
1614 } |
|
1615 |
|
1616 // --------------------------------------------------------------------------- |
|
1617 // |
|
1618 // --------------------------------------------------------------------------- |
|
1619 // |
|
1620 TInt CHWRMHapticsVibePacketizer::MaxCapabilityStringLength() |
|
1621 { |
|
1622 return KVibeMaxCapabilityStringLength; |
|
1623 } |
|
1624 |
|
1625 // --------------------------------------------------------------------------- |
|
1626 // |
|
1627 // --------------------------------------------------------------------------- |
|
1628 // |
|
1629 TInt CHWRMHapticsVibePacketizer::MaxPropertyStringLength() |
|
1630 { |
|
1631 return KVibeMaxPropertyStringLength; |
|
1632 } |
|
1633 |
|
1634 // --------------------------------------------------------------------------- |
|
1635 // |
|
1636 // --------------------------------------------------------------------------- |
|
1637 // |
|
1638 TInt CHWRMHapticsVibePacketizer::MaxStreamingSampleSize() |
|
1639 { |
|
1640 return KVibeMaxStreamingSampleSize; |
|
1641 } |
|
1642 |
|
1643 // --------------------------------------------------------------------------- |
|
1644 // |
|
1645 // --------------------------------------------------------------------------- |
|
1646 // |
|
1647 TInt CHWRMHapticsVibePacketizer::DefaultDevicePriority() |
|
1648 { |
|
1649 return KVibeDevicePriorityDefault; |
|
1650 } |
|
1651 |
|
1652 // --------------------------------------------------------------------------- |
|
1653 // Internal helper method. Fills Get Device Capability request data. |
|
1654 // --------------------------------------------------------------------------- |
|
1655 // |
|
1656 TInt CHWRMHapticsVibePacketizer::EncGetDeviceCapabilityReqInternal( |
|
1657 TInt aValueType, TInt aDeviceHandle, TInt aDevCapType, RBuf8& aBuffer ) |
|
1658 { |
|
1659 TVibePacketGetDeviceCapabilitiesRequest* pReq = |
|
1660 reinterpret_cast<TVibePacketGetDeviceCapabilitiesRequest*> |
|
1661 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
1662 |
|
1663 if ( pReq ) |
|
1664 { |
|
1665 pReq->iCmdCode = KVibeCmdGetDeviceCapabilities; |
|
1666 pReq->iCapabilityValueType = |
|
1667 static_cast<TUint8>( aValueType ); |
|
1668 pReq->iDeviceIndex_7_0 = |
|
1669 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
1670 pReq->iDeviceIndex_15_8 = |
|
1671 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
1672 pReq->iDeviceIndex_23_16 = |
|
1673 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
1674 pReq->iDeviceIndex_31_24 = |
|
1675 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
1676 pReq->iCapabilityType_7_0 = |
|
1677 static_cast<TUint8>( aDevCapType & 0xFF ); |
|
1678 pReq->iCapabilityType_15_8 = |
|
1679 static_cast<TUint8>( ( aDevCapType >> KShiftByte ) & 0xFF ); |
|
1680 pReq->iCapabilityType_23_16 = |
|
1681 static_cast<TUint8>( ( aDevCapType >> KShift2Bytes ) & 0xFF ); |
|
1682 pReq->iCapabilityType_31_24 = |
|
1683 static_cast<TUint8>( ( aDevCapType >> KShift3Bytes ) & 0xFF ); |
|
1684 iReqBuf.SetLength( |
|
1685 sizeof ( TVibePacketGetDeviceCapabilitiesRequest ) ); |
|
1686 } |
|
1687 else |
|
1688 { |
|
1689 iReqBuf.SetLength( 0 ); |
|
1690 } |
|
1691 |
|
1692 return aBuffer.Create( iReqBuf ); |
|
1693 } |
|
1694 |
|
1695 // --------------------------------------------------------------------------- |
|
1696 // Internal helper method. Fills Get Device Property request data. |
|
1697 // --------------------------------------------------------------------------- |
|
1698 // |
|
1699 TInt CHWRMHapticsVibePacketizer::EncGetDevicePropertyReqInternal( |
|
1700 TInt aValueType, TInt aDeviceHandle, TInt aDevPropType, RBuf8& aBuffer ) |
|
1701 { |
|
1702 TVibePacketGetDevicePropertyRequest* pReq = |
|
1703 reinterpret_cast<TVibePacketGetDevicePropertyRequest*> |
|
1704 ( const_cast<TUint8*>( iReqBuf.Ptr() ) ); |
|
1705 |
|
1706 if ( pReq ) |
|
1707 { |
|
1708 pReq->iCmdCode = KVibeCmdGetDeviceProperty; |
|
1709 pReq->iPropertyValueType = |
|
1710 static_cast<TUint8>( aValueType ); |
|
1711 pReq->iDeviceHandle_7_0 = |
|
1712 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
1713 pReq->iDeviceHandle_15_8 = |
|
1714 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
1715 pReq->iDeviceHandle_23_16 = |
|
1716 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
1717 pReq->iDeviceHandle_31_24 = |
|
1718 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
1719 pReq->iPropertyType_7_0 = |
|
1720 static_cast<TUint8>( aDevPropType & 0xFF ); |
|
1721 pReq->iPropertyType_15_8 = |
|
1722 static_cast<TUint8>( ( aDevPropType >> KShiftByte ) & 0xFF ); |
|
1723 pReq->iPropertyType_23_16 = |
|
1724 static_cast<TUint8>( ( aDevPropType >> KShift2Bytes ) & 0xFF ); |
|
1725 pReq->iPropertyType_31_24 = |
|
1726 static_cast<TUint8>( ( aDevPropType >> KShift3Bytes ) & 0xFF ); |
|
1727 iReqBuf.SetLength( sizeof ( TVibePacketGetDevicePropertyRequest ) ); |
|
1728 } |
|
1729 else |
|
1730 { |
|
1731 iReqBuf.SetLength( 0 ); |
|
1732 } |
|
1733 |
|
1734 return aBuffer.Create( iReqBuf ); |
|
1735 } |
|
1736 |
|
1737 // --------------------------------------------------------------------------- |
|
1738 // Internal helper method. Fills Play Streaming Sample request data. |
|
1739 // --------------------------------------------------------------------------- |
|
1740 // |
|
1741 TInt CHWRMHapticsVibePacketizer::EncPlayStreamingSampleInternal( |
|
1742 TInt aDeviceHandle, TInt aEffectHandle, const TDesC8& aStreamingSample, |
|
1743 TInt aOffsetTime, RBuf8& aBuffer ) |
|
1744 { |
|
1745 iDataBuf.Close(); |
|
1746 TInt err = iDataBuf.Create( aStreamingSample.Size() + KMsgDefaultSize ); |
|
1747 |
|
1748 TVibePacketPlayStreamingSampleRequest* pReq = |
|
1749 reinterpret_cast<TVibePacketPlayStreamingSampleRequest*> |
|
1750 ( const_cast<TUint8*>( iDataBuf.Ptr() ) ); |
|
1751 |
|
1752 if ( !err && pReq && |
|
1753 ( ( aStreamingSample.Size() + KMsgDefaultSize ) <= |
|
1754 KVibePacketMaxSize ) ) |
|
1755 { |
|
1756 pReq->iCmdCode = KVibeCmdPlayStreamingSample; |
|
1757 pReq->iDeviceHandle_7_0 = |
|
1758 static_cast<TUint8>( aDeviceHandle & 0xFF ); |
|
1759 pReq->iDeviceHandle_15_8 = |
|
1760 static_cast<TUint8>( ( aDeviceHandle >> KShiftByte ) & 0xFF ); |
|
1761 pReq->iDeviceHandle_23_16 = |
|
1762 static_cast<TUint8>( ( aDeviceHandle >> KShift2Bytes ) & 0xFF ); |
|
1763 pReq->iDeviceHandle_31_24 = |
|
1764 static_cast<TUint8>( ( aDeviceHandle >> KShift3Bytes ) & 0xFF ); |
|
1765 pReq->iEffectHandle_7_0 = |
|
1766 static_cast<TUint8>( aEffectHandle & 0xFF ); |
|
1767 pReq->iEffectHandle_15_8 = |
|
1768 static_cast<TUint8>( ( aEffectHandle >> KShiftByte ) & 0xFF ); |
|
1769 pReq->iEffectHandle_23_16 = |
|
1770 static_cast<TUint8>( ( aEffectHandle >> KShift2Bytes ) & 0xFF ); |
|
1771 pReq->iEffectHandle_31_24 = |
|
1772 static_cast<TUint8>( ( aEffectHandle >> KShift3Bytes ) & 0xFF ); |
|
1773 pReq->iSize = static_cast<TUint8>( aStreamingSample.Size() ); |
|
1774 pReq->iEffectOffsetTime_7_0 = |
|
1775 static_cast<TUint8>( aOffsetTime & 0xFF ); |
|
1776 pReq->iEffectOffsetTime_15_8 = |
|
1777 static_cast<TUint8>( ( aOffsetTime >> KShiftByte ) & 0xFF ); |
|
1778 |
|
1779 memcpy( pReq->iStreamingData, |
|
1780 reinterpret_cast<TUint8*>( |
|
1781 const_cast<TUint8*>( aStreamingSample.Ptr() ) ), |
|
1782 aStreamingSample.Size() ); |
|
1783 |
|
1784 iDataBuf.SetLength( |
|
1785 sizeof ( TVibePacketPlayStreamingSampleRequest ) |
|
1786 + aStreamingSample.Size() -1 ); |
|
1787 } |
|
1788 else |
|
1789 { |
|
1790 iDataBuf.SetLength( 0 ); |
|
1791 } |
|
1792 |
|
1793 return aBuffer.Create( iDataBuf ); |
|
1794 } |
|
1795 |
|
1796 // --------------------------------------------------------------------------- |
|
1797 // Maps Vibe error code to Symbian error code. |
|
1798 // --------------------------------------------------------------------------- |
|
1799 // |
|
1800 TInt CHWRMHapticsVibePacketizer::MapError( TInt aVibeError ) |
|
1801 { |
|
1802 TInt error = KErrNone; |
|
1803 |
|
1804 switch ( aVibeError ) |
|
1805 { |
|
1806 case KVibeErrAlreadyInitialized: |
|
1807 { |
|
1808 error = KErrAlreadyExists; |
|
1809 break; |
|
1810 } |
|
1811 |
|
1812 case KVibeErrNotInitialized: |
|
1813 { |
|
1814 error = KErrNotReady; |
|
1815 break; |
|
1816 } |
|
1817 |
|
1818 case KVibeWarningNotPlaying: // flow through |
|
1819 case KVibeErrInvalidArgument: |
|
1820 { |
|
1821 error = KErrArgument; |
|
1822 break; |
|
1823 } |
|
1824 |
|
1825 case KVibeErrFail: |
|
1826 { |
|
1827 error = KErrGeneral; |
|
1828 break; |
|
1829 } |
|
1830 |
|
1831 case KVibeErrIncompatibleEffectType: // flow through |
|
1832 case KVibeErrIncompatibleCapabilityType: // flow through |
|
1833 case KVibeErrIncompatiblePropertyType: |
|
1834 { |
|
1835 error = KErrNotSupported; |
|
1836 break; |
|
1837 } |
|
1838 |
|
1839 case KVibeErrDeviceNeedsLicense: |
|
1840 { |
|
1841 error = KErrAccessDenied; |
|
1842 break; |
|
1843 } |
|
1844 |
|
1845 case KVibeErrNotEnoughMemory: |
|
1846 { |
|
1847 error = KErrNoMemory; |
|
1848 break; |
|
1849 } |
|
1850 |
|
1851 case KVibeErrServiceNotRunning: |
|
1852 { |
|
1853 error = KErrNotReady; |
|
1854 break; |
|
1855 } |
|
1856 |
|
1857 case KVibeErrInsufficientPriority: |
|
1858 { |
|
1859 error = KErrAccessDenied; |
|
1860 break; |
|
1861 } |
|
1862 |
|
1863 case KVibeErrServiceBusy: |
|
1864 { |
|
1865 error = KErrInUse; |
|
1866 break; |
|
1867 } |
|
1868 |
|
1869 case KVibeStatusSuccess: |
|
1870 { |
|
1871 error = KErrNone; |
|
1872 break; |
|
1873 } |
|
1874 |
|
1875 default: |
|
1876 { |
|
1877 // All the warning codes, except KVibeWarningNotPlaying |
|
1878 // are handled here. Thus they are converted to KErrNone. |
|
1879 break; |
|
1880 } |
|
1881 } |
|
1882 |
|
1883 return error; |
|
1884 } |
|
1885 |
|
1886 // --------------------------------------------------------------------------- |
|
1887 // ImplementationTable[] |
|
1888 // --------------------------------------------------------------------------- |
|
1889 // |
|
1890 const TImplementationProxy ImplementationTable[] = |
|
1891 { |
|
1892 IMPLEMENTATION_PROXY_ENTRY( 0x20021207, CHWRMHapticsVibePacketizer::NewL ) |
|
1893 }; |
|
1894 |
|
1895 // --------------------------------------------------------------------------- |
|
1896 // TImplementationProxy* ImplementationGroupProxy() |
|
1897 // --------------------------------------------------------------------------- |
|
1898 // |
|
1899 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount ) |
|
1900 { |
|
1901 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
1902 return ImplementationTable; |
|
1903 } |
|
1904 |
|
1905 // End of file |
|