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