sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\digitiser\d_ldddigitisertest.cpp
|
sl@0
|
15 |
// LDD for testing the Digitiser Hal Calls.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <kernel/kernel.h>
|
sl@0
|
20 |
|
sl@0
|
21 |
#include "d_ldddigitisertest.h"
|
sl@0
|
22 |
|
sl@0
|
23 |
const TUint KMaxDeviceNumber=10;
|
sl@0
|
24 |
|
sl@0
|
25 |
TUint gDeviceNumber=1; // Device Number
|
sl@0
|
26 |
TUint gRegisteredDeviceNumber; // Represents the registered Hal Entry
|
sl@0
|
27 |
TBool gHalEntryRegistered; // States HAL Entry Successfully registered or not
|
sl@0
|
28 |
static TDigitiserInfoV02 gDigitserHalData; // Buffer to hold the HAL data;
|
sl@0
|
29 |
static TUint gPointer3DSupported; // States whether the pointing device supports 3rd dimension.
|
sl@0
|
30 |
|
sl@0
|
31 |
class DDigitiserLDDTestFactory : public DLogicalDevice
|
sl@0
|
32 |
//
|
sl@0
|
33 |
// Test LDD factory
|
sl@0
|
34 |
//
|
sl@0
|
35 |
{
|
sl@0
|
36 |
public:
|
sl@0
|
37 |
DDigitiserLDDTestFactory();
|
sl@0
|
38 |
virtual TInt Install(); //overriding pure virtual
|
sl@0
|
39 |
virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
|
sl@0
|
40 |
virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
|
sl@0
|
41 |
};
|
sl@0
|
42 |
|
sl@0
|
43 |
class DDigitiserLDDTestChannel : public DLogicalChannelBase
|
sl@0
|
44 |
//
|
sl@0
|
45 |
// Test logical channel
|
sl@0
|
46 |
//
|
sl@0
|
47 |
{
|
sl@0
|
48 |
public:
|
sl@0
|
49 |
virtual ~DDigitiserLDDTestChannel();
|
sl@0
|
50 |
protected:
|
sl@0
|
51 |
virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
|
sl@0
|
52 |
virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
|
sl@0
|
53 |
};
|
sl@0
|
54 |
|
sl@0
|
55 |
// Initialise Digitiser HAL Data
|
sl@0
|
56 |
void initialiseDigitiserHalData()
|
sl@0
|
57 |
{
|
sl@0
|
58 |
// TDigitiserInfoV02 Class Data layout
|
sl@0
|
59 |
|
sl@0
|
60 |
//class TDigitiserInfoV02 : public TDigitiserInfoV01
|
sl@0
|
61 |
// {
|
sl@0
|
62 |
//public :
|
sl@0
|
63 |
// TInt iZRange; /**< The maximum distance to screen a pointing device will be detected (settable).*/
|
sl@0
|
64 |
// TUint8 iThetaSupported; /**< A Boolean value that indicates if Theta polar angle detection (tilt) is supported.*/
|
sl@0
|
65 |
// TUint8 iPhiSupported; /**< A Boolean value that indicates if Phi polar angle detection (tilt) is supported.*/
|
sl@0
|
66 |
// TUint8 iAlphaSupported; /**< A Boolean value that indicates if rotation of the pointing device along its main axis is supported.*/
|
sl@0
|
67 |
// TUint8 iPressureSupported; /**< A Boolean value that indicates if pressure applied on screen is supported.*/
|
sl@0
|
68 |
// TInt iProximityStep; /**<proximity resolution, e.g. proximity readings change in steps of 1, 5, 10, ... */
|
sl@0
|
69 |
// TInt iMaxPressure; /**< maximum pressure reading*/
|
sl@0
|
70 |
// TInt iPressureStep; /**< pressure resolution, */
|
sl@0
|
71 |
// TUint8 iMaxPointers; /**< max number of multi-touch pointers supported by hardware/driver.*/
|
sl@0
|
72 |
// TUint8 iNumberOfPointers; /**< Number of pointers it supports (settable).*/
|
sl@0
|
73 |
// };
|
sl@0
|
74 |
|
sl@0
|
75 |
gPointer3DSupported=1;
|
sl@0
|
76 |
gDigitserHalData.iZRange=100;
|
sl@0
|
77 |
gDigitserHalData.iThetaSupported=1;
|
sl@0
|
78 |
gDigitserHalData.iPhiSupported=1;
|
sl@0
|
79 |
gDigitserHalData.iPressureSupported=1;
|
sl@0
|
80 |
gDigitserHalData.iAlphaSupported=1;
|
sl@0
|
81 |
gDigitserHalData.iProximityStep=5;
|
sl@0
|
82 |
gDigitserHalData.iMaxPointers=2;
|
sl@0
|
83 |
gDigitserHalData.iNumberOfPointers=2;
|
sl@0
|
84 |
gDigitserHalData.iMaxPressure=5000;
|
sl@0
|
85 |
gDigitserHalData.iPressureStep=500;
|
sl@0
|
86 |
}
|
sl@0
|
87 |
|
sl@0
|
88 |
LOCAL_C TInt halFunction(TAny* /*aPtr*/, TInt aFunction, TAny* a1, TAny* /*a2*/)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
TInt r=KErrNone;
|
sl@0
|
91 |
TPckgBuf<TDigitiserInfoV02> vPckg(gDigitserHalData);
|
sl@0
|
92 |
switch(aFunction)
|
sl@0
|
93 |
{
|
sl@0
|
94 |
case EDigitiserHal3DInfo:
|
sl@0
|
95 |
// Get Request for all but EPointer3D. Copy the TDigitiserInfoV02 object to a1
|
sl@0
|
96 |
Kern::InfoCopy(*(TDes8*)a1,vPckg);
|
sl@0
|
97 |
break;
|
sl@0
|
98 |
case EDigitiserHal3DPointer:
|
sl@0
|
99 |
// Get request EPointer3D
|
sl@0
|
100 |
kumemput32(a1,&gPointer3DSupported,sizeof(gPointer3DSupported));
|
sl@0
|
101 |
break;
|
sl@0
|
102 |
case EDigitiserHalSetZRange:
|
sl@0
|
103 |
// Set requeest for EPointer3DMaxProximity (iZRange)
|
sl@0
|
104 |
gDigitserHalData.iZRange=(TInt)a1;
|
sl@0
|
105 |
break;
|
sl@0
|
106 |
case EDigitiserHalSetNumberOfPointers:
|
sl@0
|
107 |
// Set request for EPointerNumberOfPointers
|
sl@0
|
108 |
gDigitserHalData.iNumberOfPointers=static_cast<TUint8>((TInt)a1);
|
sl@0
|
109 |
break;
|
sl@0
|
110 |
default:
|
sl@0
|
111 |
r=KErrNotSupported;
|
sl@0
|
112 |
break;
|
sl@0
|
113 |
}
|
sl@0
|
114 |
return r;
|
sl@0
|
115 |
}
|
sl@0
|
116 |
|
sl@0
|
117 |
#ifdef GRAPHICS_VERSION
|
sl@0
|
118 |
DECLARE_EXTENSION_LDD()
|
sl@0
|
119 |
{
|
sl@0
|
120 |
return new DDigitiserLDDTestFactory;
|
sl@0
|
121 |
}
|
sl@0
|
122 |
DECLARE_STANDARD_EXTENSION()
|
sl@0
|
123 |
{
|
sl@0
|
124 |
TInt r;
|
sl@0
|
125 |
// Initialise Digitiser HAL Data first.
|
sl@0
|
126 |
initialiseDigitiserHalData();
|
sl@0
|
127 |
// Find device number
|
sl@0
|
128 |
do
|
sl@0
|
129 |
{
|
sl@0
|
130 |
r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,NULL,gDeviceNumber);
|
sl@0
|
131 |
}
|
sl@0
|
132 |
while((r==KErrInUse) && (++gDeviceNumber < KMaxDeviceNumber));
|
sl@0
|
133 |
|
sl@0
|
134 |
if((gDeviceNumber < KMaxDeviceNumber) && (r==KErrNone))
|
sl@0
|
135 |
{
|
sl@0
|
136 |
gHalEntryRegistered = ETrue;
|
sl@0
|
137 |
gRegisteredDeviceNumber = gDeviceNumber;
|
sl@0
|
138 |
}
|
sl@0
|
139 |
else
|
sl@0
|
140 |
{
|
sl@0
|
141 |
gHalEntryRegistered = EFalse;
|
sl@0
|
142 |
r=KErrInUse;
|
sl@0
|
143 |
}
|
sl@0
|
144 |
return r;
|
sl@0
|
145 |
}
|
sl@0
|
146 |
#else
|
sl@0
|
147 |
DECLARE_STANDARD_LDD()
|
sl@0
|
148 |
{
|
sl@0
|
149 |
return new DDigitiserLDDTestFactory;
|
sl@0
|
150 |
}
|
sl@0
|
151 |
#endif
|
sl@0
|
152 |
|
sl@0
|
153 |
//
|
sl@0
|
154 |
// Constructor
|
sl@0
|
155 |
//
|
sl@0
|
156 |
DDigitiserLDDTestFactory::DDigitiserLDDTestFactory()
|
sl@0
|
157 |
{
|
sl@0
|
158 |
}
|
sl@0
|
159 |
|
sl@0
|
160 |
TInt DDigitiserLDDTestFactory::Create(DLogicalChannelBase*& aChannel)
|
sl@0
|
161 |
{
|
sl@0
|
162 |
//
|
sl@0
|
163 |
// Create new channel
|
sl@0
|
164 |
//
|
sl@0
|
165 |
aChannel=new DDigitiserLDDTestChannel;
|
sl@0
|
166 |
return aChannel?KErrNone:KErrNoMemory;
|
sl@0
|
167 |
}
|
sl@0
|
168 |
|
sl@0
|
169 |
TInt DDigitiserLDDTestFactory::Install()
|
sl@0
|
170 |
//
|
sl@0
|
171 |
// Install the LDD - overriding pure virtual
|
sl@0
|
172 |
{
|
sl@0
|
173 |
return SetName(&KLddName);
|
sl@0
|
174 |
}
|
sl@0
|
175 |
|
sl@0
|
176 |
void DDigitiserLDDTestFactory::GetCaps(TDes8& /*aDes*/) const
|
sl@0
|
177 |
//
|
sl@0
|
178 |
// Get capabilities - overriding pure virtual
|
sl@0
|
179 |
//
|
sl@0
|
180 |
{
|
sl@0
|
181 |
}
|
sl@0
|
182 |
|
sl@0
|
183 |
TInt DDigitiserLDDTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
|
sl@0
|
184 |
//
|
sl@0
|
185 |
// Create channel
|
sl@0
|
186 |
//
|
sl@0
|
187 |
{
|
sl@0
|
188 |
return KErrNone;
|
sl@0
|
189 |
}
|
sl@0
|
190 |
|
sl@0
|
191 |
DDigitiserLDDTestChannel::~DDigitiserLDDTestChannel()
|
sl@0
|
192 |
//
|
sl@0
|
193 |
// Destructor
|
sl@0
|
194 |
//
|
sl@0
|
195 |
{
|
sl@0
|
196 |
}
|
sl@0
|
197 |
|
sl@0
|
198 |
TInt DDigitiserLDDTestChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
TInt r=KErrNone;
|
sl@0
|
201 |
switch(aReqNo)
|
sl@0
|
202 |
{
|
sl@0
|
203 |
case (RLddDigitiserTest::EADDHALENTRY):
|
sl@0
|
204 |
#ifndef GRAPHICS_VERSION
|
sl@0
|
205 |
NKern::ThreadEnterCS();
|
sl@0
|
206 |
do
|
sl@0
|
207 |
{
|
sl@0
|
208 |
r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,this,gDeviceNumber);
|
sl@0
|
209 |
}
|
sl@0
|
210 |
while((r==KErrInUse) && (++gDeviceNumber < KMaxDeviceNumber));
|
sl@0
|
211 |
NKern::ThreadLeaveCS();
|
sl@0
|
212 |
|
sl@0
|
213 |
if((gDeviceNumber < KMaxDeviceNumber) && (r==KErrNone))
|
sl@0
|
214 |
{
|
sl@0
|
215 |
gHalEntryRegistered=ETrue;
|
sl@0
|
216 |
gRegisteredDeviceNumber=gDeviceNumber;
|
sl@0
|
217 |
}
|
sl@0
|
218 |
else
|
sl@0
|
219 |
{
|
sl@0
|
220 |
gHalEntryRegistered=EFalse;
|
sl@0
|
221 |
r=KErrInUse;
|
sl@0
|
222 |
}
|
sl@0
|
223 |
#else
|
sl@0
|
224 |
r=KErrNotSupported;
|
sl@0
|
225 |
#endif
|
sl@0
|
226 |
break;
|
sl@0
|
227 |
case (RLddDigitiserTest::EREMOVEHALENTRY):
|
sl@0
|
228 |
if(gHalEntryRegistered)
|
sl@0
|
229 |
{
|
sl@0
|
230 |
r=Kern::RemoveHalEntry(EHalGroupDigitiser,gRegisteredDeviceNumber);
|
sl@0
|
231 |
}
|
sl@0
|
232 |
break;
|
sl@0
|
233 |
case (RLddDigitiserTest::EGETREGISTEREDDEVICENUMBER):
|
sl@0
|
234 |
if(gHalEntryRegistered)
|
sl@0
|
235 |
{
|
sl@0
|
236 |
r=gRegisteredDeviceNumber;
|
sl@0
|
237 |
}
|
sl@0
|
238 |
else
|
sl@0
|
239 |
{
|
sl@0
|
240 |
r=KErrNotFound;
|
sl@0
|
241 |
}
|
sl@0
|
242 |
break;
|
sl@0
|
243 |
case (RLddDigitiserTest::EINITIALISEHALDATA):
|
sl@0
|
244 |
#ifndef GRAPHICS_VERSION
|
sl@0
|
245 |
initialiseDigitiserHalData();
|
sl@0
|
246 |
#else
|
sl@0
|
247 |
r=KErrNone;
|
sl@0
|
248 |
#endif
|
sl@0
|
249 |
break;
|
sl@0
|
250 |
case (RLddDigitiserTest::EGET_EPOINTER3D):
|
sl@0
|
251 |
r=gPointer3DSupported;
|
sl@0
|
252 |
break;
|
sl@0
|
253 |
case (RLddDigitiserTest::ESET_EPOINTER3D):
|
sl@0
|
254 |
gPointer3DSupported=(TUint32)a1;
|
sl@0
|
255 |
break;
|
sl@0
|
256 |
case (RLddDigitiserTest::EGET_EPOINTERMAXPROXIMITY):
|
sl@0
|
257 |
r=gDigitserHalData.iZRange;
|
sl@0
|
258 |
break;
|
sl@0
|
259 |
case (RLddDigitiserTest::ESET_EPOINTERMAXPROXIMITY):
|
sl@0
|
260 |
gDigitserHalData.iZRange=(TInt)a1;
|
sl@0
|
261 |
break;
|
sl@0
|
262 |
case (RLddDigitiserTest::EGET_EPOINTER3DTHETASUPPORTED):
|
sl@0
|
263 |
r=gDigitserHalData.iThetaSupported;
|
sl@0
|
264 |
break;
|
sl@0
|
265 |
case (RLddDigitiserTest::ESET_EPOINTER3DTHETASUPPORTED):
|
sl@0
|
266 |
gDigitserHalData.iThetaSupported=static_cast<TUint8>((TInt)a1);
|
sl@0
|
267 |
break;
|
sl@0
|
268 |
case (RLddDigitiserTest::EGET_EPOINTER3DPHISUPPORTED):
|
sl@0
|
269 |
r=gDigitserHalData.iPhiSupported;
|
sl@0
|
270 |
break;
|
sl@0
|
271 |
case (RLddDigitiserTest::ESET_EPOINTER3DPHISUPPORTED):
|
sl@0
|
272 |
gDigitserHalData.iPhiSupported=static_cast<TUint8>((TInt)a1);
|
sl@0
|
273 |
break;
|
sl@0
|
274 |
case (RLddDigitiserTest::EGET_EPOINTER3DROTATIONSUPPORTED):
|
sl@0
|
275 |
r=gDigitserHalData.iAlphaSupported;
|
sl@0
|
276 |
break;
|
sl@0
|
277 |
case (RLddDigitiserTest::ESET_EPOINTER3DROTATIONSUPPORTED):
|
sl@0
|
278 |
gDigitserHalData.iAlphaSupported=static_cast<TUint8>((TInt)a1);
|
sl@0
|
279 |
break;
|
sl@0
|
280 |
case (RLddDigitiserTest::EGET_EPOINTER3DPRESSURESUPPORTED):
|
sl@0
|
281 |
r=gDigitserHalData.iPressureSupported;
|
sl@0
|
282 |
break;
|
sl@0
|
283 |
case (RLddDigitiserTest::ESET_EPOINTER3DPRESSURESUPPORTED):
|
sl@0
|
284 |
gDigitserHalData.iPressureSupported=static_cast<TUint8>((TInt)a1);
|
sl@0
|
285 |
break;
|
sl@0
|
286 |
case (RLddDigitiserTest::EGET_EPOINTER3DPROXIMITYSTEP):
|
sl@0
|
287 |
r=gDigitserHalData.iProximityStep;
|
sl@0
|
288 |
break;
|
sl@0
|
289 |
case (RLddDigitiserTest::ESET_EPOINTER3DPROXIMITYSTEP):
|
sl@0
|
290 |
gDigitserHalData.iProximityStep=(TInt)a1;
|
sl@0
|
291 |
break;
|
sl@0
|
292 |
case (RLddDigitiserTest::EGET_EPOINTER3DMAXPOINTERS):
|
sl@0
|
293 |
r=gDigitserHalData.iMaxPointers;
|
sl@0
|
294 |
break;
|
sl@0
|
295 |
case (RLddDigitiserTest::ESET_EPOINTER3DMAXPOINTERS):
|
sl@0
|
296 |
gDigitserHalData.iMaxPointers=static_cast<TUint8>((TInt)a1);
|
sl@0
|
297 |
break;
|
sl@0
|
298 |
case (RLddDigitiserTest::EGET_EPOINTER3DNUMBEROFPOINTERS):
|
sl@0
|
299 |
r=gDigitserHalData.iNumberOfPointers;
|
sl@0
|
300 |
break;
|
sl@0
|
301 |
case (RLddDigitiserTest::ESET_EPOINTER3DNUMBEROFPOINTERS):
|
sl@0
|
302 |
gDigitserHalData.iNumberOfPointers=static_cast<TUint8>((TInt)a1);
|
sl@0
|
303 |
break;
|
sl@0
|
304 |
case (RLddDigitiserTest::EGET_EPOINTER3DMAXPRESSURE):
|
sl@0
|
305 |
r=gDigitserHalData.iMaxPressure;
|
sl@0
|
306 |
break;
|
sl@0
|
307 |
case (RLddDigitiserTest::ESET_EPOINTER3DMAXPRESSURE):
|
sl@0
|
308 |
gDigitserHalData.iMaxPressure=(TInt)a1;
|
sl@0
|
309 |
break;
|
sl@0
|
310 |
case (RLddDigitiserTest::EGET_EPOINTER3DPRESSURESTEP):
|
sl@0
|
311 |
r=gDigitserHalData.iPressureStep;
|
sl@0
|
312 |
break;
|
sl@0
|
313 |
case (RLddDigitiserTest::ESET_EPOINTER3DPRESSURESTEP):
|
sl@0
|
314 |
gDigitserHalData.iPressureStep=(TInt)a1;
|
sl@0
|
315 |
break;
|
sl@0
|
316 |
default:
|
sl@0
|
317 |
r=KErrNotSupported;
|
sl@0
|
318 |
break;
|
sl@0
|
319 |
}
|
sl@0
|
320 |
return r;
|
sl@0
|
321 |
}
|