|
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 the License "Symbian Foundation License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Haptics test (adaptation) plugin header file. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __HWRMHAPTICSTESTPLUGIN_H_ |
|
20 #define __HWRMHAPTICSTESTPLUGIN_H_ |
|
21 |
|
22 #include <f32file.h> |
|
23 #include <HWRMHapticsPluginService.h> |
|
24 #include <HWRMHapticsCommands.h> |
|
25 #include "PluginTimer.h" |
|
26 #include "hwrmhapticsvibepackets.h" |
|
27 |
|
28 #ifdef PUBLISH_STATE_INFO |
|
29 #include <e32property.h> |
|
30 const TUid KPSUidHWResourceNotification = { 0x101F7A04 }; // HWRM private PS Uid |
|
31 const TUint32 KHWRMTestHapticsCommand = 0x11110001; |
|
32 const TUint32 KHWRMTestHapticsDataPckg = 0x11110002; |
|
33 const TUint32 KHWRMTestVibCmdData = 0x11110003; |
|
34 #endif // PUBLISH_STATE_INFO |
|
35 |
|
36 #ifdef __WINS__ |
|
37 _LIT( KStubResponseFile, "C:\\system\\apps\\haptics\\stubresponse.txt" ); |
|
38 #else |
|
39 _LIT( KStubResponseFile, "Z:\\system\\apps\\haptics\\stubresponse.txt" ); |
|
40 #endif |
|
41 |
|
42 _LIT8( KVibraCmdInitialize, "VIBEPKT_CMD_INITIALIZE" ); |
|
43 _LIT8( KVibraCmdOpenDevice, "VIBEPKT_CMD_OPENDEVICE" ); |
|
44 _LIT8( KVibraCmdSetDeviceProperty, "VIBEPKT_CMD_SETDEVICEPROPERTY" ); |
|
45 _LIT8( KVibraCmdPlayMagSweepEffect, "VIBEPKT_CMD_PLAYMAGSWEEPEFFECT" ); |
|
46 _LIT8( KVibraCmdCloseDevice, "VIBEPKT_CMD_CLOSEDEVICE" ); |
|
47 _LIT8( KVibraCmdDeviceCount, "VIBEPKT_CMD_DEVICE_COUNT" ); |
|
48 _LIT8( KVibraCmdGetDeviceProperty, "VIBEPKT_CMD_GETDEVICEPROPERTY" ); |
|
49 _LIT8( KVibraCmdGetDevicePropertyInteger, "VIBEPKT_CMD_GETDEVICEPROPERTY_INTEGER" ); |
|
50 _LIT8( KVibraCmdGetDevicePropertyString, "VIBEPKT_CMD_GETDEVICEPROPERTY_STRING" ); |
|
51 _LIT8( KVibraCmdGetDevicePropertyBool, "VIBEPKT_CMD_GETDEVICEPROPERTY_BOOL" ); |
|
52 _LIT8( KVibraCmdGetDeviceState, "VIBEPKT_CMD_GETDEVICESTATE" ); |
|
53 _LIT8( KVibraCmdGetDeviceCapabilities, "VIBEPKT_CMD_GETDEVICECAPABILITIES" ); |
|
54 _LIT8( KVibraCmdGetDeviceCapabilitiesInteger, "VIBEPKT_CMD_GETDEVICECAPABILITIES_INTEGER" ); |
|
55 _LIT8( KVibraCmdGetDeviceCapabilitiesString, "VIBEPKT_CMD_GETDEVICECAPABILITIES_STRING" ); |
|
56 _LIT8( KVibraCmdPlayPeriodicEffect, "VIBEPKT_CMD_PLAYPERIODICEFFECT" ); |
|
57 _LIT8( KVibraCmdPlayIVTEffectIncludeIVTData, "VIBEPKT_CMD_PLAYIVTEFFECT_INCLUDEIVTDATA" ); |
|
58 _LIT8( KVibraCmdPlayIVTEffectNoIVTData, "VIBEPKT_CMD_PLAYIVTEFFECT_NOIVTDATA" ); |
|
59 _LIT8( KVibraCmdStopEffect, "VIBEPKT_CMD_STOPEFFECT" ); |
|
60 _LIT8( KVibraCmdStopAllEffects, "VIBEPKT_CMD_STOPALLEFFECTS" ); |
|
61 _LIT8( KVibraCmdPlayStreamingSample, "VIBEPKT_CMD_PLAYSTREAMINGSAMPLE" ); |
|
62 _LIT8( KVibraCmdCreateStreamingEffect, "VIBEPKT_CMD_CREATESTREAMINGEFFECT" ); |
|
63 _LIT8( KVibraCmdDestroyStreamingEffect, "VIBEPKT_CMD_DESTROYSTREAMINGEFFECT" ); |
|
64 _LIT8( KVibraCmdModifyPlayingMagSweepEffect, "VIBEPKT_CMD_MODIFYPLAYINGMAGSWEEPEFFECT" ); |
|
65 _LIT8( KVibraCmdModifyPlayingPeriodicEffect, "VIBEPKT_CMD_MODIFYPLAYINGPERIODICEFFECT" ); |
|
66 _LIT8( KVibraCmdPausePlayingEffect, "VIBEPKT_CMD_PAUSEPLAYINGEFFECT" ); |
|
67 _LIT8( KVibraCmdResumePausedEffect, "VIBEPKT_CMD_RESUMEPAUSEDEFFECT" ); |
|
68 _LIT8( KVibraCmdGetEffectStateNotPlaying, "VIBEPKT_CMD_GETEFFECTSTATE_NOTPLAYING" ); |
|
69 _LIT8( KVibraCmdGetEffectStatePlaying, "VIBEPKT_CMD_GETEFFECTSTATE_PLAYING" ); |
|
70 _LIT8( KVibraCmdGetEffectStatePaused, "VIBEPKT_CMD_GETEFFECTSTATE_PAUSED" ); |
|
71 _LIT8( KVibraCmdSetKernelParameter, "VIBEPKT_CMD_SETKERNELPARAMETER" ); |
|
72 _LIT8( KVibraCmdGetKernelParameter, "VIBEPKT_CMD_GETKERNELPARAMETER" ); |
|
73 _LIT8( KVibraCmdSetLicense, "VIBEPKT_CMD_SETLICENSE" ); |
|
74 |
|
75 // for vibe status to S60 status cases.. |
|
76 _LIT8(KVibraCmdStatusCaseSuccess, "VIBEPKT_CMD_STATUSCASESUCCESS"); |
|
77 _LIT8(KVibraCmdStatusCaseAlreadyInit, "VIBEPKT_CMD_STATUSCASEALREADYINIT"); |
|
78 _LIT8(KVibraCmdStatusCaseNotInit, "VIBEPKT_CMD_STATUSCASENOTINIT"); |
|
79 _LIT8(KVibraCmdStatusCaseInvalidArg, "VIBEPKT_CMD_STATUSCASEINVALIDARG"); |
|
80 _LIT8(KVibraCmdStatusCaseFail, "VIBEPKT_CMD_STATUSCASEFAIL"); |
|
81 _LIT8(KVibraCmdStatusCaseIncompEffType, "VIBEPKT_CMD_STATUSCASEINCOMPEFFTYPE"); |
|
82 _LIT8(KVibraCmdStatusCaseIncompCapaType, "VIBEPKT_CMD_STATUSCASEINCOMPCAPATYPE"); |
|
83 _LIT8(KVibraCmdStatusCaseIncompPropType, "VIBEPKT_CMD_STATUSCASEINCOMPPROPTYPE"); |
|
84 _LIT8(KVibraCmdStatusCaseDevNeedsLicense, "VIBEPKT_CMD_STATUSCASEDEVNEEDSLICENSE"); |
|
85 _LIT8(KVibraCmdStatusCaseNotEnoughMem, "VIBEPKT_CMD_STATUSCASENOTENOUGHMEM"); |
|
86 _LIT8(KVibraCmdStatusCaseSrvNotRunning, "VIBEPKT_CMD_STATUSCASESRVNOTRUNNING"); |
|
87 _LIT8(KVibraCmdStatusCaseErrInsuffPriority, "VIBEPKT_CMD_STATUSCASEERRINSUFFPRIORITY"); |
|
88 _LIT8(KVibraCmdStatusCaseSrvBusy, "VIBEPKT_CMD_STATUSCASESRVBUSY"); |
|
89 _LIT8(KVibraCmdStatusCaseWrnNotPlaying, "VIBEPKT_CMD_STATUSCASEWRNNOTPLAYING"); |
|
90 _LIT8(KVibraCmdStatusCaseWrnInsuffPriority, "VIBEPKT_CMD_STATUSCASEWRNINSUFFPRIORITY"); |
|
91 |
|
92 const TInt KRespFileData = 3000; |
|
93 const TInt KHexRespCode = 100; |
|
94 const TInt KBinRespCode = 100; |
|
95 const TInt KTimeOut = 500; |
|
96 |
|
97 class CPluginTimer; |
|
98 |
|
99 /** |
|
100 * Haptics test plugin. |
|
101 * Test implementation that handles reception and responding to |
|
102 * haptics commands in adaptation layer in semi-hardcoded manner. |
|
103 * (Where semi-hardcoded means that responses are chosen, based on |
|
104 * the current state of the test stub, from a file containing hardcoded |
|
105 * response alternatives. |
|
106 * |
|
107 * @since S60 5.1 |
|
108 */ |
|
109 class CHWRMHapticsTestPlugin : public CHWRMHapticsPluginService, |
|
110 public MPluginTimerCallback |
|
111 { |
|
112 public: |
|
113 /** |
|
114 * Static method for instantiating test plugin objects. |
|
115 * Uses two-phase construction. |
|
116 * |
|
117 * @param aCallback Callback to haptics subsystem. |
|
118 */ |
|
119 static CHWRMHapticsTestPlugin* NewL( MHWRMHapticsPluginCallback* aCallback ); |
|
120 |
|
121 /** |
|
122 * Destructor |
|
123 */ |
|
124 virtual ~CHWRMHapticsTestPlugin(); |
|
125 |
|
126 /** |
|
127 * Method to invoke a particular command in the plugin. |
|
128 * Implements the CHWRMHapticsPluginService::ProcessCommandL |
|
129 * abstract interface method. |
|
130 * |
|
131 * @param aCommandId Command ID |
|
132 * @param aTransId Transaction ID |
|
133 * @param aData Data associated with command |
|
134 */ |
|
135 virtual void ProcessCommandL( TInt aCommandId, |
|
136 TUint8 aTransId, |
|
137 TDesC8& aData ); |
|
138 |
|
139 /** |
|
140 * Method to cancel a particular command. |
|
141 * Implements the CHWRMHapticsPluginService::CancelCommandL |
|
142 * abstract interface method. |
|
143 * |
|
144 * @param aTransId Transaction ID |
|
145 * @param aCommandId Command ID to optionally double check with the |
|
146 * transaction ID |
|
147 */ |
|
148 virtual void CancelCommandL( TUint8 aTransId, |
|
149 TInt aCommandId ); |
|
150 |
|
151 /** |
|
152 * The callback method that is called from CPluginTimer when timer |
|
153 * has expired. |
|
154 * This method basically does all the processing needed to return a |
|
155 * (emulated) response to a Haptics command. |
|
156 * |
|
157 * @param aService Pointer to the implementation of |
|
158 * MHWRMHapticsPluginCallback callback |
|
159 * interface whose ProcessResponseL is called |
|
160 * with (Haptics command's emulated) response |
|
161 * data. |
|
162 * @param aCommandId Id of the (emulated) Haptics command. |
|
163 * @param aTransId Id of the transaction to which the (emulated) |
|
164 * haptics command belongs to. |
|
165 * @param aRetVal Return value to be inserted to the response |
|
166 * of the (emulated) Haptics command. |
|
167 */ |
|
168 void GenericTimerFired(MHWRMHapticsPluginCallback* aService, |
|
169 TInt aCommandId, |
|
170 TUint8 aTransId, |
|
171 TInt aRetVal); |
|
172 /** |
|
173 * Static method to convert hex string to binary format |
|
174 * |
|
175 * @param aSrcBuffer Reference to a descriptor containing the hex buffer. |
|
176 * @param aDstBuffer Reference to a descriptor containing the buffer |
|
177 * to which binary data is written. |
|
178 */ |
|
179 static void Hex2Bin(const TDesC8& aSrcBuffer, TDes8& aDstBuffer); |
|
180 |
|
181 /** |
|
182 * Method that gets the hex data string from file buffer and converts it to binary format. |
|
183 * |
|
184 * @param aCmdPosition Command position in the file data. The command position |
|
185 * is calculated in GenericTimerFired method based on |
|
186 * emulated Haptics command's command Id |
|
187 * @param aRetvalPackage Reference to a descriptor containing the buffer |
|
188 * to which binary data is written. |
|
189 */ |
|
190 void CHWRMHapticsTestPlugin::GetBinRespCode(TInt aCmdPosition, TDes8& aRetvalPackage); |
|
191 |
|
192 private: |
|
193 |
|
194 /** |
|
195 * Constructor. |
|
196 * |
|
197 * @param aCallback Callback to haptics subsystem. |
|
198 */ |
|
199 CHWRMHapticsTestPlugin( MHWRMHapticsPluginCallback* aCallback ); |
|
200 |
|
201 /** |
|
202 * Two-phase construction ConstructL |
|
203 */ |
|
204 void ConstructL(); |
|
205 |
|
206 |
|
207 private: // data |
|
208 |
|
209 /** |
|
210 * Array of pointers to running CPluginTimer timer objects |
|
211 */ |
|
212 RPointerArray<CPluginTimer> iTimers; |
|
213 |
|
214 /** |
|
215 * File data buffer |
|
216 */ |
|
217 TBuf8<KRespFileData> iFileData; |
|
218 |
|
219 /** |
|
220 * Emulated haptics command's response data |
|
221 */ |
|
222 HWRMHapticsCommand::RHWRMHapticsRespData iStorage; |
|
223 |
|
224 /** |
|
225 * Emulated haptics command (stored as a VibeTonz packet pointer) |
|
226 */ |
|
227 TVibePacket* iVibeCmdPacket; |
|
228 |
|
229 /** |
|
230 * Effect state. Used to distinguish (in an emulated way) different |
|
231 * states of effect ("Playing","Paused","Not playing"). |
|
232 */ |
|
233 enum TEffectState |
|
234 { |
|
235 ENotPlaying = 0, |
|
236 EPlaying, |
|
237 EPaused |
|
238 }; |
|
239 TEffectState iEffectState; |
|
240 |
|
241 #ifdef PUBLISH_STATE_INFO |
|
242 |
|
243 /** |
|
244 * P&S property for publishing (emulated) Haptics command's command Id |
|
245 */ |
|
246 RProperty iCmdProperty; |
|
247 |
|
248 /** |
|
249 * P&S property for publishing (emulated) Haptics command's data |
|
250 */ |
|
251 RProperty iDataProperty; |
|
252 |
|
253 /** |
|
254 * P&S property for publishing (emulated) Haptics command's Vibe command code |
|
255 */ |
|
256 RProperty iVibeCmdProperty; |
|
257 #endif // PUBLISH_STATE_INFO |
|
258 }; |
|
259 |
|
260 #endif // __HWRMHAPTICSDPLUGIN_H_ |