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