First public contribution.
1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\digitiser\d_ldddigitisertest.cpp
15 // LDD for testing the Digitiser Hal Calls.
19 #include <kernel/kernel.h>
21 #include "d_ldddigitisertest.h"
23 const TUint KMaxDeviceNumber=10;
25 TUint gDeviceNumber=1; // Device Number
26 TUint gRegisteredDeviceNumber; // Represents the registered Hal Entry
27 TBool gHalEntryRegistered; // States HAL Entry Successfully registered or not
28 static TDigitiserInfoV02 gDigitserHalData; // Buffer to hold the HAL data;
29 static TUint gPointer3DSupported; // States whether the pointing device supports 3rd dimension.
31 class DDigitiserLDDTestFactory : public DLogicalDevice
37 DDigitiserLDDTestFactory();
38 virtual TInt Install(); //overriding pure virtual
39 virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual
40 virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual
43 class DDigitiserLDDTestChannel : public DLogicalChannelBase
45 // Test logical channel
49 virtual ~DDigitiserLDDTestChannel();
51 virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
52 virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
55 // Initialise Digitiser HAL Data
56 void initialiseDigitiserHalData()
58 // TDigitiserInfoV02 Class Data layout
60 //class TDigitiserInfoV02 : public TDigitiserInfoV01
63 // TInt iZRange; /**< The maximum distance to screen a pointing device will be detected (settable).*/
64 // TUint8 iThetaSupported; /**< A Boolean value that indicates if Theta polar angle detection (tilt) is supported.*/
65 // TUint8 iPhiSupported; /**< A Boolean value that indicates if Phi polar angle detection (tilt) is supported.*/
66 // TUint8 iAlphaSupported; /**< A Boolean value that indicates if rotation of the pointing device along its main axis is supported.*/
67 // TUint8 iPressureSupported; /**< A Boolean value that indicates if pressure applied on screen is supported.*/
68 // TInt iProximityStep; /**<proximity resolution, e.g. proximity readings change in steps of 1, 5, 10, ... */
69 // TInt iMaxPressure; /**< maximum pressure reading*/
70 // TInt iPressureStep; /**< pressure resolution, */
71 // TUint8 iMaxPointers; /**< max number of multi-touch pointers supported by hardware/driver.*/
72 // TUint8 iNumberOfPointers; /**< Number of pointers it supports (settable).*/
75 gPointer3DSupported=1;
76 gDigitserHalData.iZRange=100;
77 gDigitserHalData.iThetaSupported=1;
78 gDigitserHalData.iPhiSupported=1;
79 gDigitserHalData.iPressureSupported=1;
80 gDigitserHalData.iAlphaSupported=1;
81 gDigitserHalData.iProximityStep=5;
82 gDigitserHalData.iMaxPointers=2;
83 gDigitserHalData.iNumberOfPointers=2;
84 gDigitserHalData.iMaxPressure=5000;
85 gDigitserHalData.iPressureStep=500;
88 LOCAL_C TInt halFunction(TAny* /*aPtr*/, TInt aFunction, TAny* a1, TAny* /*a2*/)
91 TPckgBuf<TDigitiserInfoV02> vPckg(gDigitserHalData);
94 case EDigitiserHal3DInfo:
95 // Get Request for all but EPointer3D. Copy the TDigitiserInfoV02 object to a1
96 Kern::InfoCopy(*(TDes8*)a1,vPckg);
98 case EDigitiserHal3DPointer:
99 // Get request EPointer3D
100 kumemput32(a1,&gPointer3DSupported,sizeof(gPointer3DSupported));
102 case EDigitiserHalSetZRange:
103 // Set requeest for EPointer3DMaxProximity (iZRange)
104 gDigitserHalData.iZRange=(TInt)a1;
106 case EDigitiserHalSetNumberOfPointers:
107 // Set request for EPointerNumberOfPointers
108 gDigitserHalData.iNumberOfPointers=static_cast<TUint8>((TInt)a1);
117 #ifdef GRAPHICS_VERSION
118 DECLARE_EXTENSION_LDD()
120 return new DDigitiserLDDTestFactory;
122 DECLARE_STANDARD_EXTENSION()
125 // Initialise Digitiser HAL Data first.
126 initialiseDigitiserHalData();
127 // Find device number
130 r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,NULL,gDeviceNumber);
132 while((r==KErrInUse) && (++gDeviceNumber < KMaxDeviceNumber));
134 if((gDeviceNumber < KMaxDeviceNumber) && (r==KErrNone))
136 gHalEntryRegistered = ETrue;
137 gRegisteredDeviceNumber = gDeviceNumber;
141 gHalEntryRegistered = EFalse;
147 DECLARE_STANDARD_LDD()
149 return new DDigitiserLDDTestFactory;
156 DDigitiserLDDTestFactory::DDigitiserLDDTestFactory()
160 TInt DDigitiserLDDTestFactory::Create(DLogicalChannelBase*& aChannel)
163 // Create new channel
165 aChannel=new DDigitiserLDDTestChannel;
166 return aChannel?KErrNone:KErrNoMemory;
169 TInt DDigitiserLDDTestFactory::Install()
171 // Install the LDD - overriding pure virtual
173 return SetName(&KLddName);
176 void DDigitiserLDDTestFactory::GetCaps(TDes8& /*aDes*/) const
178 // Get capabilities - overriding pure virtual
183 TInt DDigitiserLDDTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
191 DDigitiserLDDTestChannel::~DDigitiserLDDTestChannel()
198 TInt DDigitiserLDDTestChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/)
203 case (RLddDigitiserTest::EADDHALENTRY):
204 #ifndef GRAPHICS_VERSION
205 NKern::ThreadEnterCS();
208 r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,this,gDeviceNumber);
210 while((r==KErrInUse) && (++gDeviceNumber < KMaxDeviceNumber));
211 NKern::ThreadLeaveCS();
213 if((gDeviceNumber < KMaxDeviceNumber) && (r==KErrNone))
215 gHalEntryRegistered=ETrue;
216 gRegisteredDeviceNumber=gDeviceNumber;
220 gHalEntryRegistered=EFalse;
227 case (RLddDigitiserTest::EREMOVEHALENTRY):
228 if(gHalEntryRegistered)
230 r=Kern::RemoveHalEntry(EHalGroupDigitiser,gRegisteredDeviceNumber);
233 case (RLddDigitiserTest::EGETREGISTEREDDEVICENUMBER):
234 if(gHalEntryRegistered)
236 r=gRegisteredDeviceNumber;
243 case (RLddDigitiserTest::EINITIALISEHALDATA):
244 #ifndef GRAPHICS_VERSION
245 initialiseDigitiserHalData();
250 case (RLddDigitiserTest::EGET_EPOINTER3D):
251 r=gPointer3DSupported;
253 case (RLddDigitiserTest::ESET_EPOINTER3D):
254 gPointer3DSupported=(TUint32)a1;
256 case (RLddDigitiserTest::EGET_EPOINTERMAXPROXIMITY):
257 r=gDigitserHalData.iZRange;
259 case (RLddDigitiserTest::ESET_EPOINTERMAXPROXIMITY):
260 gDigitserHalData.iZRange=(TInt)a1;
262 case (RLddDigitiserTest::EGET_EPOINTER3DTHETASUPPORTED):
263 r=gDigitserHalData.iThetaSupported;
265 case (RLddDigitiserTest::ESET_EPOINTER3DTHETASUPPORTED):
266 gDigitserHalData.iThetaSupported=static_cast<TUint8>((TInt)a1);
268 case (RLddDigitiserTest::EGET_EPOINTER3DPHISUPPORTED):
269 r=gDigitserHalData.iPhiSupported;
271 case (RLddDigitiserTest::ESET_EPOINTER3DPHISUPPORTED):
272 gDigitserHalData.iPhiSupported=static_cast<TUint8>((TInt)a1);
274 case (RLddDigitiserTest::EGET_EPOINTER3DROTATIONSUPPORTED):
275 r=gDigitserHalData.iAlphaSupported;
277 case (RLddDigitiserTest::ESET_EPOINTER3DROTATIONSUPPORTED):
278 gDigitserHalData.iAlphaSupported=static_cast<TUint8>((TInt)a1);
280 case (RLddDigitiserTest::EGET_EPOINTER3DPRESSURESUPPORTED):
281 r=gDigitserHalData.iPressureSupported;
283 case (RLddDigitiserTest::ESET_EPOINTER3DPRESSURESUPPORTED):
284 gDigitserHalData.iPressureSupported=static_cast<TUint8>((TInt)a1);
286 case (RLddDigitiserTest::EGET_EPOINTER3DPROXIMITYSTEP):
287 r=gDigitserHalData.iProximityStep;
289 case (RLddDigitiserTest::ESET_EPOINTER3DPROXIMITYSTEP):
290 gDigitserHalData.iProximityStep=(TInt)a1;
292 case (RLddDigitiserTest::EGET_EPOINTER3DMAXPOINTERS):
293 r=gDigitserHalData.iMaxPointers;
295 case (RLddDigitiserTest::ESET_EPOINTER3DMAXPOINTERS):
296 gDigitserHalData.iMaxPointers=static_cast<TUint8>((TInt)a1);
298 case (RLddDigitiserTest::EGET_EPOINTER3DNUMBEROFPOINTERS):
299 r=gDigitserHalData.iNumberOfPointers;
301 case (RLddDigitiserTest::ESET_EPOINTER3DNUMBEROFPOINTERS):
302 gDigitserHalData.iNumberOfPointers=static_cast<TUint8>((TInt)a1);
304 case (RLddDigitiserTest::EGET_EPOINTER3DMAXPRESSURE):
305 r=gDigitserHalData.iMaxPressure;
307 case (RLddDigitiserTest::ESET_EPOINTER3DMAXPRESSURE):
308 gDigitserHalData.iMaxPressure=(TInt)a1;
310 case (RLddDigitiserTest::EGET_EPOINTER3DPRESSURESTEP):
311 r=gDigitserHalData.iPressureStep;
313 case (RLddDigitiserTest::ESET_EPOINTER3DPRESSURESTEP):
314 gDigitserHalData.iPressureStep=(TInt)a1;