Update contrib.
1 // Copyright (c) 1996-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\window\t_calib.cpp
31 LOCAL_C void printf(TRefByValue<const TDesC> aFmt,...)
33 // Print to the console
40 aBuf.AppendFormatList(aFmt,list);
42 __ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Write-Console"),0));
45 LOCAL_C void Fault(TFault aFault)
51 User::Panic(_L("T_CALIB fault"),aFault);
54 GLDEF_C void DrawBlob(TPoint aPos)
56 TPoint pos(aPos.iX/8-1,aPos.iY/10-1);
57 w.SetCursorPosAbs(TPoint(0,0));
59 aBuf.AppendFormat(_L("(%d,%d) "),aPos.iX,aPos.iY);
63 w.SetCursorPosAbs(pos);
68 GLDEF_C void TestBlob()
70 // Draw blob when digitizer pressed
78 if((TInt)k.Code()==27 && k.Type()==EKeyPress)
80 if(k.Type()==EMouseClick)
81 DrawBlob(k.MousePos());
86 GLDEF_C TInt E32Main()
88 // Calibrate digitizer
93 __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
94 r=w.Init(_L("T_CALIB window"),TSize(KConsFullScreen,KConsFullScreen));
95 __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
96 r=w.Control(_L("+Maximised"));
97 __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
98 r=w.Control(_L("+Inform"));
99 __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
100 r=w.Control(_L("+Pointer"));
101 __ASSERT_ALWAYS(r==KErrNone,Fault(EConsole));
106 printf(_L("Please touch the three points, in the order TL, BL, BR\r\n"));
108 TDigitizerCalibration cal;
109 UserHal::CalibrationPoints(cal);
111 printf(_L("Points are at: (%d,%d), (%d,%d), (%d,%d)\r\n")
112 ,cal.iTl.iX,cal.iTl.iY
113 ,cal.iBl.iX,cal.iBl.iY
114 ,cal.iBr.iX,cal.iBr.iY);
120 // Set digitiser to 'bypass' calibration
122 // UserHal::SetXYInputCalibration(cal);
126 w.SetCursorPosAbs(pos);
132 if(k.Type()==EMouseClick)
134 TPoint mouse=k.MousePos();
135 printf(_L("You touched point %d,%d\r\n"),mouse.iX,mouse.iY);
150 UserHal::SetXYInputCalibration(cal);
152 printf(_L("Digitizer calibrated! Click away!\r\n"));
154 // Test to validate when invalid calibration input values are supplied.
165 r = UserHal::SetXYInputCalibration(cal);
167 if (r != KErrArgument)
168 // Test failure panic.
169 User::Panic(_L("T_CALIB Test Failure"),84);