sl@0
|
1 |
// Copyright (c) 1995-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 the License "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 |
// e32test\window\t_wsimp.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32std.h>
|
sl@0
|
19 |
#include <e32std_private.h>
|
sl@0
|
20 |
#include <e32test.h>
|
sl@0
|
21 |
#include <e32ver.h>
|
sl@0
|
22 |
#include <e32hal.h>
|
sl@0
|
23 |
#include <e32twin.h>
|
sl@0
|
24 |
#include <e32svr.h>
|
sl@0
|
25 |
#include <hal.h>
|
sl@0
|
26 |
|
sl@0
|
27 |
LOCAL_D RConsole theConsole;
|
sl@0
|
28 |
|
sl@0
|
29 |
LOCAL_C void readKeys()
|
sl@0
|
30 |
//
|
sl@0
|
31 |
// Read keys until ESC pressed
|
sl@0
|
32 |
//
|
sl@0
|
33 |
{
|
sl@0
|
34 |
|
sl@0
|
35 |
TRequestStatus s;
|
sl@0
|
36 |
TConsoleKey k;
|
sl@0
|
37 |
do
|
sl@0
|
38 |
{
|
sl@0
|
39 |
theConsole.Read(k,s);
|
sl@0
|
40 |
User::WaitForRequest(s);
|
sl@0
|
41 |
} while((TInt)k.Code()!=EKeyEscape);
|
sl@0
|
42 |
}
|
sl@0
|
43 |
|
sl@0
|
44 |
LOCAL_C void printf(TRefByValue<const TDesC> aFmt,...)
|
sl@0
|
45 |
//
|
sl@0
|
46 |
// Print to the console
|
sl@0
|
47 |
//
|
sl@0
|
48 |
{
|
sl@0
|
49 |
|
sl@0
|
50 |
if (theConsole.Handle()==KNullHandle)
|
sl@0
|
51 |
{
|
sl@0
|
52 |
TInt r=theConsole.Init(_L("T_SWIMP"),TSize(KConsFullScreen,KConsFullScreen));
|
sl@0
|
53 |
__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Open-Console"),0));
|
sl@0
|
54 |
r=theConsole.Control(_L("+Maximize +NewLine -Lock -Wrap"));
|
sl@0
|
55 |
__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Config-Console"),0));
|
sl@0
|
56 |
}
|
sl@0
|
57 |
VA_LIST list;
|
sl@0
|
58 |
VA_START(list,aFmt);
|
sl@0
|
59 |
TBuf<0x100> aBuf;
|
sl@0
|
60 |
aBuf.AppendFormatList(aFmt,list);
|
sl@0
|
61 |
TInt r=theConsole.Write(aBuf);
|
sl@0
|
62 |
__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Write-Console"),0));
|
sl@0
|
63 |
}
|
sl@0
|
64 |
|
sl@0
|
65 |
|
sl@0
|
66 |
GLDEF_C TInt E32Main()
|
sl@0
|
67 |
//
|
sl@0
|
68 |
// Test the various kernel types.
|
sl@0
|
69 |
//
|
sl@0
|
70 |
{
|
sl@0
|
71 |
|
sl@0
|
72 |
TVersion v(KE32MajorVersionNumber,KE32MinorVersionNumber,KE32BuildVersionNumber);
|
sl@0
|
73 |
TName vName = v.Name();
|
sl@0
|
74 |
printf(_L("T_SWIMP %S\n"),&vName);
|
sl@0
|
75 |
TName uvName = User::Version().Name();
|
sl@0
|
76 |
printf(_L("Epoc/32 %S\n"),&uvName);
|
sl@0
|
77 |
//
|
sl@0
|
78 |
TRequestStatus s;
|
sl@0
|
79 |
TConsoleKey k;
|
sl@0
|
80 |
theConsole.Read(k,s);
|
sl@0
|
81 |
theConsole.ReadCancel();
|
sl@0
|
82 |
User::WaitForRequest(s);
|
sl@0
|
83 |
__ASSERT_ALWAYS(s.Int()==KErrCancel || s.Int()==KErrNone, User::Panic(_L("Test Fail"),1));
|
sl@0
|
84 |
//
|
sl@0
|
85 |
TInt r=theConsole.Control(_L("+Raw"));
|
sl@0
|
86 |
__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Set Raw Mode"),0));
|
sl@0
|
87 |
//
|
sl@0
|
88 |
printf(_L("Raw mode - hit ESC to continue\r\n"));
|
sl@0
|
89 |
//
|
sl@0
|
90 |
FOREVER
|
sl@0
|
91 |
{
|
sl@0
|
92 |
theConsole.Read(k,s);
|
sl@0
|
93 |
User::WaitForRequest(s);
|
sl@0
|
94 |
if (k.Type()==TRawEvent::EKeyDown)
|
sl@0
|
95 |
{
|
sl@0
|
96 |
if (k.Code()==4)
|
sl@0
|
97 |
break;
|
sl@0
|
98 |
printf(_L("Down %d\r\n"),k.Code());
|
sl@0
|
99 |
}
|
sl@0
|
100 |
else if (k.Type()==TRawEvent::EKeyUp)
|
sl@0
|
101 |
printf(_L("Up %d\r\n"),k.Code());
|
sl@0
|
102 |
}
|
sl@0
|
103 |
//
|
sl@0
|
104 |
r=theConsole.Control(_L("-Raw"));
|
sl@0
|
105 |
__ASSERT_ALWAYS(r==KErrNone,User::Panic(_L("Reset Raw Mode"),0));
|
sl@0
|
106 |
//
|
sl@0
|
107 |
printf(_L("Normal mode - hit ESC to continue\r\n"));
|
sl@0
|
108 |
//
|
sl@0
|
109 |
FOREVER
|
sl@0
|
110 |
{
|
sl@0
|
111 |
theConsole.Read(k,s);
|
sl@0
|
112 |
User::WaitForRequest(s);
|
sl@0
|
113 |
if (k.Code()==EKeyEscape)
|
sl@0
|
114 |
break;
|
sl@0
|
115 |
printf(_L("Key %d\r\n"),k.Code());
|
sl@0
|
116 |
}
|
sl@0
|
117 |
//
|
sl@0
|
118 |
printf(_L("Completed OK\n"));
|
sl@0
|
119 |
//
|
sl@0
|
120 |
printf(_L("Key click set to LOUD - press keys, ESC to continue...\n"));
|
sl@0
|
121 |
|
sl@0
|
122 |
TInt max;
|
sl@0
|
123 |
HAL::Get(HAL::EKeyboardClickVolumeMax, max);
|
sl@0
|
124 |
HAL::Set(HAL::EKeyboardClickVolume, max);
|
sl@0
|
125 |
HAL::Set(HAL::EKeyboardClickState, ETrue);
|
sl@0
|
126 |
|
sl@0
|
127 |
readKeys();
|
sl@0
|
128 |
|
sl@0
|
129 |
printf(_L("Key click set to SOFT...\n"));
|
sl@0
|
130 |
|
sl@0
|
131 |
HAL::Set(HAL::EKeyboardClickVolume, 0);
|
sl@0
|
132 |
HAL::Set(HAL::EKeyboardClickState, ETrue);
|
sl@0
|
133 |
|
sl@0
|
134 |
readKeys();
|
sl@0
|
135 |
|
sl@0
|
136 |
printf(_L("Key click set to LOUD...\n"));
|
sl@0
|
137 |
|
sl@0
|
138 |
HAL::Set(HAL::EKeyboardClickVolume, max);
|
sl@0
|
139 |
HAL::Set(HAL::EKeyboardClickState, ETrue);
|
sl@0
|
140 |
|
sl@0
|
141 |
readKeys();
|
sl@0
|
142 |
|
sl@0
|
143 |
printf(_L("Key click set to LOUD and OFF...\n"));
|
sl@0
|
144 |
|
sl@0
|
145 |
HAL::Set(HAL::EKeyboardClickVolume, max);
|
sl@0
|
146 |
HAL::Set(HAL::EKeyboardClickState, EFalse);
|
sl@0
|
147 |
|
sl@0
|
148 |
readKeys();
|
sl@0
|
149 |
|
sl@0
|
150 |
return(KErrNone);
|
sl@0
|
151 |
}
|
sl@0
|
152 |
|