sl@0: // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // e32test\digitiser\d_ldddigitisertest.cpp sl@0: // LDD for testing the Digitiser Hal Calls. sl@0: // sl@0: // sl@0: sl@0: #include sl@0: sl@0: #include "d_ldddigitisertest.h" sl@0: sl@0: const TUint KMaxDeviceNumber=10; sl@0: sl@0: TUint gDeviceNumber=1; // Device Number sl@0: TUint gRegisteredDeviceNumber; // Represents the registered Hal Entry sl@0: TBool gHalEntryRegistered; // States HAL Entry Successfully registered or not sl@0: static TDigitiserInfoV02 gDigitserHalData; // Buffer to hold the HAL data; sl@0: static TUint gPointer3DSupported; // States whether the pointing device supports 3rd dimension. sl@0: sl@0: class DDigitiserLDDTestFactory : public DLogicalDevice sl@0: // sl@0: // Test LDD factory sl@0: // sl@0: { sl@0: public: sl@0: DDigitiserLDDTestFactory(); sl@0: virtual TInt Install(); //overriding pure virtual sl@0: virtual void GetCaps(TDes8& aDes) const; //overriding pure virtual sl@0: virtual TInt Create(DLogicalChannelBase*& aChannel); //overriding pure virtual sl@0: }; sl@0: sl@0: class DDigitiserLDDTestChannel : public DLogicalChannelBase sl@0: // sl@0: // Test logical channel sl@0: // sl@0: { sl@0: public: sl@0: virtual ~DDigitiserLDDTestChannel(); sl@0: protected: sl@0: virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer); sl@0: virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2); sl@0: }; sl@0: sl@0: // Initialise Digitiser HAL Data sl@0: void initialiseDigitiserHalData() sl@0: { sl@0: // TDigitiserInfoV02 Class Data layout sl@0: sl@0: //class TDigitiserInfoV02 : public TDigitiserInfoV01 sl@0: // { sl@0: //public : sl@0: // TInt iZRange; /**< The maximum distance to screen a pointing device will be detected (settable).*/ sl@0: // TUint8 iThetaSupported; /**< A Boolean value that indicates if Theta polar angle detection (tilt) is supported.*/ sl@0: // TUint8 iPhiSupported; /**< A Boolean value that indicates if Phi polar angle detection (tilt) is supported.*/ sl@0: // TUint8 iAlphaSupported; /**< A Boolean value that indicates if rotation of the pointing device along its main axis is supported.*/ sl@0: // TUint8 iPressureSupported; /**< A Boolean value that indicates if pressure applied on screen is supported.*/ sl@0: // TInt iProximityStep; /** vPckg(gDigitserHalData); sl@0: switch(aFunction) sl@0: { sl@0: case EDigitiserHal3DInfo: sl@0: // Get Request for all but EPointer3D. Copy the TDigitiserInfoV02 object to a1 sl@0: Kern::InfoCopy(*(TDes8*)a1,vPckg); sl@0: break; sl@0: case EDigitiserHal3DPointer: sl@0: // Get request EPointer3D sl@0: kumemput32(a1,&gPointer3DSupported,sizeof(gPointer3DSupported)); sl@0: break; sl@0: case EDigitiserHalSetZRange: sl@0: // Set requeest for EPointer3DMaxProximity (iZRange) sl@0: gDigitserHalData.iZRange=(TInt)a1; sl@0: break; sl@0: case EDigitiserHalSetNumberOfPointers: sl@0: // Set request for EPointerNumberOfPointers sl@0: gDigitserHalData.iNumberOfPointers=static_cast((TInt)a1); sl@0: break; sl@0: default: sl@0: r=KErrNotSupported; sl@0: break; sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: #ifdef GRAPHICS_VERSION sl@0: DECLARE_EXTENSION_LDD() sl@0: { sl@0: return new DDigitiserLDDTestFactory; sl@0: } sl@0: DECLARE_STANDARD_EXTENSION() sl@0: { sl@0: TInt r; sl@0: // Initialise Digitiser HAL Data first. sl@0: initialiseDigitiserHalData(); sl@0: // Find device number sl@0: do sl@0: { sl@0: r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,NULL,gDeviceNumber); sl@0: } sl@0: while((r==KErrInUse) && (++gDeviceNumber < KMaxDeviceNumber)); sl@0: sl@0: if((gDeviceNumber < KMaxDeviceNumber) && (r==KErrNone)) sl@0: { sl@0: gHalEntryRegistered = ETrue; sl@0: gRegisteredDeviceNumber = gDeviceNumber; sl@0: } sl@0: else sl@0: { sl@0: gHalEntryRegistered = EFalse; sl@0: r=KErrInUse; sl@0: } sl@0: return r; sl@0: } sl@0: #else sl@0: DECLARE_STANDARD_LDD() sl@0: { sl@0: return new DDigitiserLDDTestFactory; sl@0: } sl@0: #endif sl@0: sl@0: // sl@0: // Constructor sl@0: // sl@0: DDigitiserLDDTestFactory::DDigitiserLDDTestFactory() sl@0: { sl@0: } sl@0: sl@0: TInt DDigitiserLDDTestFactory::Create(DLogicalChannelBase*& aChannel) sl@0: { sl@0: // sl@0: // Create new channel sl@0: // sl@0: aChannel=new DDigitiserLDDTestChannel; sl@0: return aChannel?KErrNone:KErrNoMemory; sl@0: } sl@0: sl@0: TInt DDigitiserLDDTestFactory::Install() sl@0: // sl@0: // Install the LDD - overriding pure virtual sl@0: { sl@0: return SetName(&KLddName); sl@0: } sl@0: sl@0: void DDigitiserLDDTestFactory::GetCaps(TDes8& /*aDes*/) const sl@0: // sl@0: // Get capabilities - overriding pure virtual sl@0: // sl@0: { sl@0: } sl@0: sl@0: TInt DDigitiserLDDTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/) sl@0: // sl@0: // Create channel sl@0: // sl@0: { sl@0: return KErrNone; sl@0: } sl@0: sl@0: DDigitiserLDDTestChannel::~DDigitiserLDDTestChannel() sl@0: // sl@0: // Destructor sl@0: // sl@0: { sl@0: } sl@0: sl@0: TInt DDigitiserLDDTestChannel::Request(TInt aReqNo, TAny* a1, TAny* /*a2*/) sl@0: { sl@0: TInt r=KErrNone; sl@0: switch(aReqNo) sl@0: { sl@0: case (RLddDigitiserTest::EADDHALENTRY): sl@0: #ifndef GRAPHICS_VERSION sl@0: NKern::ThreadEnterCS(); sl@0: do sl@0: { sl@0: r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,this,gDeviceNumber); sl@0: } sl@0: while((r==KErrInUse) && (++gDeviceNumber < KMaxDeviceNumber)); sl@0: NKern::ThreadLeaveCS(); sl@0: sl@0: if((gDeviceNumber < KMaxDeviceNumber) && (r==KErrNone)) sl@0: { sl@0: gHalEntryRegistered=ETrue; sl@0: gRegisteredDeviceNumber=gDeviceNumber; sl@0: } sl@0: else sl@0: { sl@0: gHalEntryRegistered=EFalse; sl@0: r=KErrInUse; sl@0: } sl@0: #else sl@0: r=KErrNotSupported; sl@0: #endif sl@0: break; sl@0: case (RLddDigitiserTest::EREMOVEHALENTRY): sl@0: if(gHalEntryRegistered) sl@0: { sl@0: r=Kern::RemoveHalEntry(EHalGroupDigitiser,gRegisteredDeviceNumber); sl@0: } sl@0: break; sl@0: case (RLddDigitiserTest::EGETREGISTEREDDEVICENUMBER): sl@0: if(gHalEntryRegistered) sl@0: { sl@0: r=gRegisteredDeviceNumber; sl@0: } sl@0: else sl@0: { sl@0: r=KErrNotFound; sl@0: } sl@0: break; sl@0: case (RLddDigitiserTest::EINITIALISEHALDATA): sl@0: #ifndef GRAPHICS_VERSION sl@0: initialiseDigitiserHalData(); sl@0: #else sl@0: r=KErrNone; sl@0: #endif sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3D): sl@0: r=gPointer3DSupported; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3D): sl@0: gPointer3DSupported=(TUint32)a1; sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTERMAXPROXIMITY): sl@0: r=gDigitserHalData.iZRange; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTERMAXPROXIMITY): sl@0: gDigitserHalData.iZRange=(TInt)a1; sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DTHETASUPPORTED): sl@0: r=gDigitserHalData.iThetaSupported; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DTHETASUPPORTED): sl@0: gDigitserHalData.iThetaSupported=static_cast((TInt)a1); sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DPHISUPPORTED): sl@0: r=gDigitserHalData.iPhiSupported; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DPHISUPPORTED): sl@0: gDigitserHalData.iPhiSupported=static_cast((TInt)a1); sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DROTATIONSUPPORTED): sl@0: r=gDigitserHalData.iAlphaSupported; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DROTATIONSUPPORTED): sl@0: gDigitserHalData.iAlphaSupported=static_cast((TInt)a1); sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DPRESSURESUPPORTED): sl@0: r=gDigitserHalData.iPressureSupported; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DPRESSURESUPPORTED): sl@0: gDigitserHalData.iPressureSupported=static_cast((TInt)a1); sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DPROXIMITYSTEP): sl@0: r=gDigitserHalData.iProximityStep; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DPROXIMITYSTEP): sl@0: gDigitserHalData.iProximityStep=(TInt)a1; sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DMAXPOINTERS): sl@0: r=gDigitserHalData.iMaxPointers; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DMAXPOINTERS): sl@0: gDigitserHalData.iMaxPointers=static_cast((TInt)a1); sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DNUMBEROFPOINTERS): sl@0: r=gDigitserHalData.iNumberOfPointers; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DNUMBEROFPOINTERS): sl@0: gDigitserHalData.iNumberOfPointers=static_cast((TInt)a1); sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DMAXPRESSURE): sl@0: r=gDigitserHalData.iMaxPressure; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DMAXPRESSURE): sl@0: gDigitserHalData.iMaxPressure=(TInt)a1; sl@0: break; sl@0: case (RLddDigitiserTest::EGET_EPOINTER3DPRESSURESTEP): sl@0: r=gDigitserHalData.iPressureStep; sl@0: break; sl@0: case (RLddDigitiserTest::ESET_EPOINTER3DPRESSURESTEP): sl@0: gDigitserHalData.iPressureStep=(TInt)a1; sl@0: break; sl@0: default: sl@0: r=KErrNotSupported; sl@0: break; sl@0: } sl@0: return r; sl@0: }