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 "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: // t_halattprovider.ldd Provides fake HAL attribute values on H4 platform for sl@0: // advanced pointer event testing. sl@0: // Fake values are listed in halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2). sl@0: // Only some values from the group EHalGroupDigitiser are changed. sl@0: // For not changed values from the group EHalGroupDigitiser the original HAL handler is called sl@0: // (the one loaded before this kernel extension). sl@0: // Original handler of EHalGroupDigitiser group must be registered in order sl@0: // to run this kernel extension. sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent - Internal Symbian test code sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: static SHalEntry gOriginalHandler; sl@0: static TUint8 gNumberOfPointers; sl@0: sl@0: void InitialiseDigitiserHalData() sl@0: { sl@0: gNumberOfPointers = 6; sl@0: } sl@0: sl@0: LOCAL_C TInt halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2) sl@0: { sl@0: TInt r=KErrNone; sl@0: THalFunc function = gOriginalHandler.iFunction; sl@0: switch(aFunction) sl@0: { sl@0: case EDigitiserHal3DInfo: sl@0: { sl@0: // execute the original handler sl@0: r = (*function)(aPtr, EDigitiserHal3DInfo, a1, a2); sl@0: TBool receivedFullData = (r == KErrNone); sl@0: if (r != KErrNone) sl@0: { sl@0: // try to get at least TDigitiserInfoV01 sl@0: r = (*function)(aPtr, EDigitiserHalXYInfo, a1, a2); sl@0: if (r != KErrNone) sl@0: { sl@0: Kern::Printf("t_halattprovider error: original handler of EDigitiserHalXYInfo returned %d", r); sl@0: return r; sl@0: } sl@0: } sl@0: sl@0: // read data created by the original handler sl@0: TPckgBuf vPckg; sl@0: TDigitiserInfoV02& data = vPckg(); sl@0: sl@0: Kern::KUDesGet(vPckg, *(TDes8*)a1); sl@0: sl@0: // modify the data with the new values sl@0: vPckg.SetLength(sizeof(TDigitiserInfoV02)); sl@0: data.iPressureSupported=1; sl@0: data.iZRange=-100; // max proximity sl@0: data.iProximityStep=5; sl@0: data.iMaxPointers=8; sl@0: data.iNumberOfPointers=gNumberOfPointers; sl@0: data.iMaxPressure=5000; sl@0: data.iPressureStep=500; sl@0: sl@0: if (!receivedFullData) sl@0: { sl@0: // original handler has provided only TDigitiserInfoV01, so we have to sl@0: // fill all fields of TDigitiserInfoV02 sl@0: data.iThetaSupported=0; sl@0: data.iPhiSupported=0; sl@0: data.iAlphaSupported=0; sl@0: } sl@0: sl@0: // return the data sl@0: Kern::InfoCopy(*(TDes8*)a1, vPckg); sl@0: sl@0: break; sl@0: } sl@0: case EDigitiserHal3DPointer: sl@0: { sl@0: // Return value 1 for EPointer3D sl@0: TBool ret = ETrue; sl@0: kumemput32(a1,&ret,sizeof(ret)); sl@0: break; sl@0: } sl@0: case EDigitiserHalSetNumberOfPointers: sl@0: // Set request for EPointerNumberOfPointers sl@0: sl@0: // this line should be a correct implementation of this function but was not tested sl@0: //kumemget32(&gNumberOfPointers,a1,sizeof(gNumberOfPointers)); sl@0: Kern::Printf("t_halattprovider error: attempt to use not implemented HAL function EDigitiserHalSetNumberOfPointers"); sl@0: r = KErrNotSupported; sl@0: break; sl@0: default: sl@0: r = (*function)(aPtr, aFunction, a1, a2); sl@0: break; sl@0: } sl@0: return r; sl@0: } sl@0: sl@0: DECLARE_STANDARD_EXTENSION() sl@0: { sl@0: TInt r = KErrNone; sl@0: sl@0: // Initialise Digitiser HAL Data first. sl@0: InitialiseDigitiserHalData(); sl@0: sl@0: NKern::ThreadEnterCS(); sl@0: sl@0: // Find original handler whose behaviour will be overriden sl@0: SHalEntry* originalHandlerPtr = Kern::FindHalEntry(EHalGroupDigitiser,0); sl@0: if (originalHandlerPtr == NULL) sl@0: { sl@0: NKern::ThreadLeaveCS(); sl@0: Kern::Printf("t_halattprovider error: original handler of EHalGroupDigitiser group not found"); sl@0: return KErrNotFound; sl@0: } sl@0: gOriginalHandler = *originalHandlerPtr; // copy contents of the SHalEntry sl@0: sl@0: // Remove original handler sl@0: r = Kern::RemoveHalEntry(EHalGroupDigitiser, 0); sl@0: if (r != KErrNone) sl@0: { sl@0: NKern::ThreadLeaveCS(); sl@0: Kern::Printf("t_halattprovider error: unable to unregister original handler for EHalGroupDigitiser group, code:%d",r); sl@0: return r; sl@0: } sl@0: sl@0: // Add new handler sl@0: r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,gOriginalHandler.iPtr,0); sl@0: if (r != KErrNone) sl@0: { sl@0: NKern::ThreadLeaveCS(); sl@0: Kern::Printf("t_halattprovider error: unable register handler for EHalGroupDigitiser group, code:%d",r); sl@0: return r; sl@0: } sl@0: sl@0: NKern::ThreadLeaveCS(); sl@0: sl@0: Kern::Printf("t_halattprovider: registered successfully"); sl@0: return r; sl@0: }