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 "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 |
// t_halattprovider.ldd Provides fake HAL attribute values on H4 platform for
|
sl@0
|
15 |
// advanced pointer event testing.
|
sl@0
|
16 |
// Fake values are listed in halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2).
|
sl@0
|
17 |
// Only some values from the group EHalGroupDigitiser are changed.
|
sl@0
|
18 |
// For not changed values from the group EHalGroupDigitiser the original HAL handler is called
|
sl@0
|
19 |
// (the one loaded before this kernel extension).
|
sl@0
|
20 |
// Original handler of EHalGroupDigitiser group must be registered in order
|
sl@0
|
21 |
// to run this kernel extension.
|
sl@0
|
22 |
//
|
sl@0
|
23 |
//
|
sl@0
|
24 |
|
sl@0
|
25 |
/**
|
sl@0
|
26 |
@file
|
sl@0
|
27 |
@test
|
sl@0
|
28 |
@internalComponent - Internal Symbian test code
|
sl@0
|
29 |
*/
|
sl@0
|
30 |
|
sl@0
|
31 |
#include <kernel/kernel.h>
|
sl@0
|
32 |
#include <e32cmn.h>
|
sl@0
|
33 |
|
sl@0
|
34 |
static SHalEntry gOriginalHandler;
|
sl@0
|
35 |
static TUint8 gNumberOfPointers;
|
sl@0
|
36 |
|
sl@0
|
37 |
void InitialiseDigitiserHalData()
|
sl@0
|
38 |
{
|
sl@0
|
39 |
gNumberOfPointers = 6;
|
sl@0
|
40 |
}
|
sl@0
|
41 |
|
sl@0
|
42 |
LOCAL_C TInt halFunction(TAny* aPtr, TInt aFunction, TAny* a1, TAny* a2)
|
sl@0
|
43 |
{
|
sl@0
|
44 |
TInt r=KErrNone;
|
sl@0
|
45 |
THalFunc function = gOriginalHandler.iFunction;
|
sl@0
|
46 |
switch(aFunction)
|
sl@0
|
47 |
{
|
sl@0
|
48 |
case EDigitiserHal3DInfo:
|
sl@0
|
49 |
{
|
sl@0
|
50 |
// execute the original handler
|
sl@0
|
51 |
r = (*function)(aPtr, EDigitiserHal3DInfo, a1, a2);
|
sl@0
|
52 |
TBool receivedFullData = (r == KErrNone);
|
sl@0
|
53 |
if (r != KErrNone)
|
sl@0
|
54 |
{
|
sl@0
|
55 |
// try to get at least TDigitiserInfoV01
|
sl@0
|
56 |
r = (*function)(aPtr, EDigitiserHalXYInfo, a1, a2);
|
sl@0
|
57 |
if (r != KErrNone)
|
sl@0
|
58 |
{
|
sl@0
|
59 |
Kern::Printf("t_halattprovider error: original handler of EDigitiserHalXYInfo returned %d", r);
|
sl@0
|
60 |
return r;
|
sl@0
|
61 |
}
|
sl@0
|
62 |
}
|
sl@0
|
63 |
|
sl@0
|
64 |
// read data created by the original handler
|
sl@0
|
65 |
TPckgBuf<TDigitiserInfoV02> vPckg;
|
sl@0
|
66 |
TDigitiserInfoV02& data = vPckg();
|
sl@0
|
67 |
|
sl@0
|
68 |
Kern::KUDesGet(vPckg, *(TDes8*)a1);
|
sl@0
|
69 |
|
sl@0
|
70 |
// modify the data with the new values
|
sl@0
|
71 |
vPckg.SetLength(sizeof(TDigitiserInfoV02));
|
sl@0
|
72 |
data.iPressureSupported=1;
|
sl@0
|
73 |
data.iZRange=-100; // max proximity
|
sl@0
|
74 |
data.iProximityStep=5;
|
sl@0
|
75 |
data.iMaxPointers=8;
|
sl@0
|
76 |
data.iNumberOfPointers=gNumberOfPointers;
|
sl@0
|
77 |
data.iMaxPressure=5000;
|
sl@0
|
78 |
data.iPressureStep=500;
|
sl@0
|
79 |
|
sl@0
|
80 |
if (!receivedFullData)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
// original handler has provided only TDigitiserInfoV01, so we have to
|
sl@0
|
83 |
// fill all fields of TDigitiserInfoV02
|
sl@0
|
84 |
data.iThetaSupported=0;
|
sl@0
|
85 |
data.iPhiSupported=0;
|
sl@0
|
86 |
data.iAlphaSupported=0;
|
sl@0
|
87 |
}
|
sl@0
|
88 |
|
sl@0
|
89 |
// return the data
|
sl@0
|
90 |
Kern::InfoCopy(*(TDes8*)a1, vPckg);
|
sl@0
|
91 |
|
sl@0
|
92 |
break;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
case EDigitiserHal3DPointer:
|
sl@0
|
95 |
{
|
sl@0
|
96 |
// Return value 1 for EPointer3D
|
sl@0
|
97 |
TBool ret = ETrue;
|
sl@0
|
98 |
kumemput32(a1,&ret,sizeof(ret));
|
sl@0
|
99 |
break;
|
sl@0
|
100 |
}
|
sl@0
|
101 |
case EDigitiserHalSetNumberOfPointers:
|
sl@0
|
102 |
// Set request for EPointerNumberOfPointers
|
sl@0
|
103 |
|
sl@0
|
104 |
// this line should be a correct implementation of this function but was not tested
|
sl@0
|
105 |
//kumemget32(&gNumberOfPointers,a1,sizeof(gNumberOfPointers));
|
sl@0
|
106 |
Kern::Printf("t_halattprovider error: attempt to use not implemented HAL function EDigitiserHalSetNumberOfPointers");
|
sl@0
|
107 |
r = KErrNotSupported;
|
sl@0
|
108 |
break;
|
sl@0
|
109 |
default:
|
sl@0
|
110 |
r = (*function)(aPtr, aFunction, a1, a2);
|
sl@0
|
111 |
break;
|
sl@0
|
112 |
}
|
sl@0
|
113 |
return r;
|
sl@0
|
114 |
}
|
sl@0
|
115 |
|
sl@0
|
116 |
DECLARE_STANDARD_EXTENSION()
|
sl@0
|
117 |
{
|
sl@0
|
118 |
TInt r = KErrNone;
|
sl@0
|
119 |
|
sl@0
|
120 |
// Initialise Digitiser HAL Data first.
|
sl@0
|
121 |
InitialiseDigitiserHalData();
|
sl@0
|
122 |
|
sl@0
|
123 |
NKern::ThreadEnterCS();
|
sl@0
|
124 |
|
sl@0
|
125 |
// Find original handler whose behaviour will be overriden
|
sl@0
|
126 |
SHalEntry* originalHandlerPtr = Kern::FindHalEntry(EHalGroupDigitiser,0);
|
sl@0
|
127 |
if (originalHandlerPtr == NULL)
|
sl@0
|
128 |
{
|
sl@0
|
129 |
NKern::ThreadLeaveCS();
|
sl@0
|
130 |
Kern::Printf("t_halattprovider error: original handler of EHalGroupDigitiser group not found");
|
sl@0
|
131 |
return KErrNotFound;
|
sl@0
|
132 |
}
|
sl@0
|
133 |
gOriginalHandler = *originalHandlerPtr; // copy contents of the SHalEntry
|
sl@0
|
134 |
|
sl@0
|
135 |
// Remove original handler
|
sl@0
|
136 |
r = Kern::RemoveHalEntry(EHalGroupDigitiser, 0);
|
sl@0
|
137 |
if (r != KErrNone)
|
sl@0
|
138 |
{
|
sl@0
|
139 |
NKern::ThreadLeaveCS();
|
sl@0
|
140 |
Kern::Printf("t_halattprovider error: unable to unregister original handler for EHalGroupDigitiser group, code:%d",r);
|
sl@0
|
141 |
return r;
|
sl@0
|
142 |
}
|
sl@0
|
143 |
|
sl@0
|
144 |
// Add new handler
|
sl@0
|
145 |
r=Kern::AddHalEntry(EHalGroupDigitiser,halFunction,gOriginalHandler.iPtr,0);
|
sl@0
|
146 |
if (r != KErrNone)
|
sl@0
|
147 |
{
|
sl@0
|
148 |
NKern::ThreadLeaveCS();
|
sl@0
|
149 |
Kern::Printf("t_halattprovider error: unable register handler for EHalGroupDigitiser group, code:%d",r);
|
sl@0
|
150 |
return r;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|
sl@0
|
153 |
NKern::ThreadLeaveCS();
|
sl@0
|
154 |
|
sl@0
|
155 |
Kern::Printf("t_halattprovider: registered successfully");
|
sl@0
|
156 |
return r;
|
sl@0
|
157 |
}
|