sl@0
|
1 |
// Copyright (c) 1996-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 |
// e32\drivers\edisp\epoc\generic\wd_vt100.cpp
|
sl@0
|
15 |
// Display/Keyboard driver using VT100 terminal
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "ws_std.h"
|
sl@0
|
20 |
#include <d32comm.h>
|
sl@0
|
21 |
#include <e32svr.h>
|
sl@0
|
22 |
|
sl@0
|
23 |
/**
|
sl@0
|
24 |
* Define a comms driver and port to use.
|
sl@0
|
25 |
*/
|
sl@0
|
26 |
|
sl@0
|
27 |
//#define __USE_RDEBUG_OUTPUT
|
sl@0
|
28 |
#define __USE_SERIAL_INPUT
|
sl@0
|
29 |
const TInt KPortNumber=1;
|
sl@0
|
30 |
|
sl@0
|
31 |
#if defined(__USE_SERIAL_INPUT) || !defined(__USE_RDEBUG_OUTPUT)
|
sl@0
|
32 |
#define __COMMS_DRIVER_NEEDED
|
sl@0
|
33 |
_LIT(KPddName,"EUART");
|
sl@0
|
34 |
_LIT(KLddName,"ECOMM");
|
sl@0
|
35 |
#endif
|
sl@0
|
36 |
|
sl@0
|
37 |
class CSerialKeyboard : public CActive
|
sl@0
|
38 |
{
|
sl@0
|
39 |
public:
|
sl@0
|
40 |
static CSerialKeyboard* NewL();
|
sl@0
|
41 |
~CSerialKeyboard();
|
sl@0
|
42 |
void GetKey();
|
sl@0
|
43 |
public:
|
sl@0
|
44 |
CSerialKeyboard();
|
sl@0
|
45 |
void ConstructL();
|
sl@0
|
46 |
void RunL();
|
sl@0
|
47 |
void DoCancel();
|
sl@0
|
48 |
TInt KeyCode();
|
sl@0
|
49 |
public:
|
sl@0
|
50 |
#ifdef __COMMS_DRIVER_NEEDED
|
sl@0
|
51 |
RBusDevComm iDevComm;
|
sl@0
|
52 |
TBuf8<1> iBuf;
|
sl@0
|
53 |
#endif
|
sl@0
|
54 |
};
|
sl@0
|
55 |
|
sl@0
|
56 |
#define SHIFTED(x) (0x8000|(x))
|
sl@0
|
57 |
#define ISSHIFTED(x) (0x8000&(x))
|
sl@0
|
58 |
#define FUNCED(x) (0x4000|(x))
|
sl@0
|
59 |
#define ISFUNCED(x) (0x4000&(x))
|
sl@0
|
60 |
#define CTRLED(x) (0x2000|(x))
|
sl@0
|
61 |
#define ISCTRLED(x) (0x2000&(x))
|
sl@0
|
62 |
#define STDKEY(x) (0x1FFF&(x))
|
sl@0
|
63 |
|
sl@0
|
64 |
const TUint16 convertCode[] =
|
sl@0
|
65 |
{
|
sl@0
|
66 |
/*00 NUL*/ EStdKeyNull,
|
sl@0
|
67 |
/*01 SOH*/ CTRLED('A'), // ^A
|
sl@0
|
68 |
/*02 STX*/ CTRLED('B'), // ^B
|
sl@0
|
69 |
/*03 ETX*/ CTRLED('C'), // ^C
|
sl@0
|
70 |
/*04 EOT*/ CTRLED('D'), // ^D
|
sl@0
|
71 |
/*05 ENQ*/ CTRLED('E'), // ^E
|
sl@0
|
72 |
/*06 ACK*/ CTRLED('F'), // ^F
|
sl@0
|
73 |
/*07 BEL*/ CTRLED('G'), // ^G
|
sl@0
|
74 |
/*08 BS */ EStdKeyBackspace,
|
sl@0
|
75 |
/*09 TAB*/ CTRLED(FUNCED('5')),
|
sl@0
|
76 |
/*0a LF */ CTRLED('J'), // ^J
|
sl@0
|
77 |
/*0b VT */ CTRLED('K'), // ^K
|
sl@0
|
78 |
/*0c FF */ CTRLED('L'), // ^L
|
sl@0
|
79 |
/*0d CR */ EStdKeyEnter,
|
sl@0
|
80 |
/*0e SO */ CTRLED('N'), // ^N
|
sl@0
|
81 |
/*0f SI */ CTRLED('O'), // ^O
|
sl@0
|
82 |
/*10 DLE*/ CTRLED('P'), // ^P
|
sl@0
|
83 |
/*11 DC1*/ CTRLED('Q'), // ^Q
|
sl@0
|
84 |
/*12 DC2*/ CTRLED('R'), // ^R
|
sl@0
|
85 |
/*13 DC3*/ CTRLED('S'), // ^S
|
sl@0
|
86 |
/*14 DC4*/ CTRLED('T'), // ^T
|
sl@0
|
87 |
/*15 NAK*/ CTRLED('U'), // ^U
|
sl@0
|
88 |
/*16 SYN*/ CTRLED('V'), // ^V
|
sl@0
|
89 |
/*17 ETB*/ CTRLED('W'), // ^W
|
sl@0
|
90 |
/*18 CAN*/ CTRLED('X'), // ^X
|
sl@0
|
91 |
/*19 EM */ CTRLED('Y'), // ^Y
|
sl@0
|
92 |
/*1a SUB*/ CTRLED('Z'), // ^Z
|
sl@0
|
93 |
/*1b ESC*/ EStdKeyEscape,
|
sl@0
|
94 |
/*1c FS */ EStdKeyNull, // ^backslash -> ignored
|
sl@0
|
95 |
/*1d GS */ EStdKeyNull, // ^] -> ignored
|
sl@0
|
96 |
/*1e RS */ EStdKeyNull, // ^^ -> ignored
|
sl@0
|
97 |
/*1f US */ EStdKeyNull, // ^_ -> ignored
|
sl@0
|
98 |
/*20*/ EStdKeySpace,
|
sl@0
|
99 |
/*21*/ SHIFTED('1'), // !
|
sl@0
|
100 |
/*22*/ SHIFTED('2'), // "
|
sl@0
|
101 |
/*23*/ EStdKeyHash, // #
|
sl@0
|
102 |
/*24*/ SHIFTED('4'), // $
|
sl@0
|
103 |
/*25*/ SHIFTED('5'), // %
|
sl@0
|
104 |
/*26*/ SHIFTED('7'), // &
|
sl@0
|
105 |
/*27*/ EStdKeySingleQuote,
|
sl@0
|
106 |
/*28*/ SHIFTED('9'), // (
|
sl@0
|
107 |
/*29*/ SHIFTED('0'), // )
|
sl@0
|
108 |
/*2a*/ SHIFTED('8'), // *
|
sl@0
|
109 |
/*2b*/ SHIFTED(EStdKeyEquals), // +
|
sl@0
|
110 |
/*2c*/ EStdKeyComma, // ,
|
sl@0
|
111 |
/*2d*/ EStdKeyMinus, // -
|
sl@0
|
112 |
/*2e*/ EStdKeyFullStop, // .
|
sl@0
|
113 |
/*2f*/ EStdKeyForwardSlash,// forward slash
|
sl@0
|
114 |
/*30*/ '0',
|
sl@0
|
115 |
/*31*/ '1',
|
sl@0
|
116 |
/*32*/ '2',
|
sl@0
|
117 |
/*33*/ '3',
|
sl@0
|
118 |
/*34*/ '4',
|
sl@0
|
119 |
/*35*/ '5',
|
sl@0
|
120 |
/*36*/ '6',
|
sl@0
|
121 |
/*37*/ '7',
|
sl@0
|
122 |
/*38*/ '8',
|
sl@0
|
123 |
/*39*/ '9',
|
sl@0
|
124 |
/*3a*/ SHIFTED(EStdKeySemiColon), // :
|
sl@0
|
125 |
/*3b*/ EStdKeySemiColon, // ;
|
sl@0
|
126 |
/*3c*/ SHIFTED(EStdKeyComma), // <
|
sl@0
|
127 |
/*3d*/ EStdKeyEquals, // =
|
sl@0
|
128 |
/*3e*/ SHIFTED(EStdKeyFullStop), // >
|
sl@0
|
129 |
/*3f*/ SHIFTED(EStdKeyForwardSlash), // ?
|
sl@0
|
130 |
/*40*/ SHIFTED(EStdKeySingleQuote), // @
|
sl@0
|
131 |
/*41*/ SHIFTED('A'),
|
sl@0
|
132 |
/*42*/ SHIFTED('B'),
|
sl@0
|
133 |
/*43*/ SHIFTED('C'),
|
sl@0
|
134 |
/*44*/ SHIFTED('D'),
|
sl@0
|
135 |
/*45*/ SHIFTED('E'),
|
sl@0
|
136 |
/*46*/ SHIFTED('F'),
|
sl@0
|
137 |
/*47*/ SHIFTED('G'),
|
sl@0
|
138 |
/*48*/ SHIFTED('H'),
|
sl@0
|
139 |
/*49*/ SHIFTED('I'),
|
sl@0
|
140 |
/*4a*/ SHIFTED('J'),
|
sl@0
|
141 |
/*4b*/ SHIFTED('K'),
|
sl@0
|
142 |
/*4c*/ SHIFTED('L'),
|
sl@0
|
143 |
/*4d*/ SHIFTED('M'),
|
sl@0
|
144 |
/*4e*/ SHIFTED('N'),
|
sl@0
|
145 |
/*4f*/ SHIFTED('O'),
|
sl@0
|
146 |
/*50*/ SHIFTED('P'),
|
sl@0
|
147 |
/*51*/ SHIFTED('Q'),
|
sl@0
|
148 |
/*52*/ SHIFTED('R'),
|
sl@0
|
149 |
/*53*/ SHIFTED('S'),
|
sl@0
|
150 |
/*54*/ SHIFTED('T'),
|
sl@0
|
151 |
/*55*/ SHIFTED('U'),
|
sl@0
|
152 |
/*56*/ SHIFTED('V'),
|
sl@0
|
153 |
/*57*/ SHIFTED('W'),
|
sl@0
|
154 |
/*58*/ SHIFTED('X'),
|
sl@0
|
155 |
/*59*/ SHIFTED('Y'),
|
sl@0
|
156 |
/*5a*/ SHIFTED('Z'),
|
sl@0
|
157 |
/*5b*/ EStdKeySquareBracketLeft, // [
|
sl@0
|
158 |
/*5c*/ EStdKeyBackSlash, // backslash
|
sl@0
|
159 |
/*5d*/ EStdKeySquareBracketRight, // ]
|
sl@0
|
160 |
/*5e*/ SHIFTED('6'), // ^
|
sl@0
|
161 |
/*5f*/ SHIFTED(EStdKeyMinus), // _
|
sl@0
|
162 |
/*60*/ EStdKeyXXX, // Actually `
|
sl@0
|
163 |
/*61*/ 'A',
|
sl@0
|
164 |
/*62*/ 'B',
|
sl@0
|
165 |
/*63*/ 'C',
|
sl@0
|
166 |
/*64*/ 'D',
|
sl@0
|
167 |
/*65*/ 'E',
|
sl@0
|
168 |
/*66*/ 'F',
|
sl@0
|
169 |
/*67*/ 'G',
|
sl@0
|
170 |
/*68*/ 'H',
|
sl@0
|
171 |
/*69*/ 'I',
|
sl@0
|
172 |
/*6a*/ 'J',
|
sl@0
|
173 |
/*6b*/ 'K',
|
sl@0
|
174 |
/*6c*/ 'L',
|
sl@0
|
175 |
/*6d*/ 'M',
|
sl@0
|
176 |
/*6e*/ 'N',
|
sl@0
|
177 |
/*6f*/ 'O',
|
sl@0
|
178 |
/*70*/ 'P',
|
sl@0
|
179 |
/*71*/ 'Q',
|
sl@0
|
180 |
/*72*/ 'R',
|
sl@0
|
181 |
/*73*/ 'S',
|
sl@0
|
182 |
/*74*/ 'T',
|
sl@0
|
183 |
/*75*/ 'U',
|
sl@0
|
184 |
/*76*/ 'V',
|
sl@0
|
185 |
/*77*/ 'W',
|
sl@0
|
186 |
/*78*/ 'X',
|
sl@0
|
187 |
/*79*/ 'Y',
|
sl@0
|
188 |
/*7a*/ 'Z',
|
sl@0
|
189 |
/*7b*/ SHIFTED(EStdKeySquareBracketLeft), // {
|
sl@0
|
190 |
/*7c*/ SHIFTED(EStdKeyBackSlash), // |
|
sl@0
|
191 |
/*7d*/ SHIFTED(EStdKeySquareBracketRight), // }
|
sl@0
|
192 |
/*7e*/ SHIFTED(EStdKeyHash), // ~
|
sl@0
|
193 |
/*7f*/ EKeyDelete
|
sl@0
|
194 |
};
|
sl@0
|
195 |
|
sl@0
|
196 |
CSerialKeyboard* CSerialKeyboard::NewL()
|
sl@0
|
197 |
{
|
sl@0
|
198 |
CSerialKeyboard* self = new(ELeave) CSerialKeyboard;
|
sl@0
|
199 |
self->ConstructL();
|
sl@0
|
200 |
return self;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
|
sl@0
|
203 |
CSerialKeyboard::CSerialKeyboard()
|
sl@0
|
204 |
: CActive(0)
|
sl@0
|
205 |
{
|
sl@0
|
206 |
}
|
sl@0
|
207 |
|
sl@0
|
208 |
void CSerialKeyboard::ConstructL()
|
sl@0
|
209 |
{
|
sl@0
|
210 |
#ifdef __COMMS_DRIVER_NEEDED
|
sl@0
|
211 |
// load and connect to serial port
|
sl@0
|
212 |
TInt r=User::LoadPhysicalDevice(KPddName);
|
sl@0
|
213 |
if (r!=KErrNone && r!=KErrAlreadyExists)
|
sl@0
|
214 |
User::Leave(r);
|
sl@0
|
215 |
r=User::LoadLogicalDevice (KLddName);
|
sl@0
|
216 |
if (r!=KErrNone && r!=KErrAlreadyExists)
|
sl@0
|
217 |
User::Leave(r);
|
sl@0
|
218 |
|
sl@0
|
219 |
r=iDevComm.Open(KPortNumber);
|
sl@0
|
220 |
User::LeaveIfError(r);
|
sl@0
|
221 |
|
sl@0
|
222 |
TCommConfig cfgBuf;
|
sl@0
|
223 |
TCommConfigV01& cfg=cfgBuf();
|
sl@0
|
224 |
iDevComm.Config(cfgBuf);
|
sl@0
|
225 |
cfg.iRate=EBps115200;
|
sl@0
|
226 |
cfg.iDataBits=EData8;
|
sl@0
|
227 |
cfg.iStopBits=EStop1;
|
sl@0
|
228 |
cfg.iParity=EParityNone;
|
sl@0
|
229 |
cfg.iHandshake=0;//KConfigObeyXoff|KConfigSendXoff;
|
sl@0
|
230 |
cfg.iFifo=EFifoEnable;
|
sl@0
|
231 |
cfg.iTerminatorCount=0;
|
sl@0
|
232 |
cfg.iSIREnable=ESIRDisable;
|
sl@0
|
233 |
User::LeaveIfError(iDevComm.SetConfig(cfgBuf));
|
sl@0
|
234 |
#endif
|
sl@0
|
235 |
|
sl@0
|
236 |
CActiveScheduler::Add(this);
|
sl@0
|
237 |
}
|
sl@0
|
238 |
|
sl@0
|
239 |
CSerialKeyboard::~CSerialKeyboard()
|
sl@0
|
240 |
{
|
sl@0
|
241 |
Cancel();
|
sl@0
|
242 |
}
|
sl@0
|
243 |
|
sl@0
|
244 |
void CSerialKeyboard::GetKey()
|
sl@0
|
245 |
{
|
sl@0
|
246 |
__ASSERT_ALWAYS(!IsActive(), User::Panic(_L("CSerialKeyboard"),1));
|
sl@0
|
247 |
|
sl@0
|
248 |
// wait for a key
|
sl@0
|
249 |
#ifdef __USE_SERIAL_INPUT
|
sl@0
|
250 |
iDevComm.Read(iStatus,iBuf,1);
|
sl@0
|
251 |
#endif
|
sl@0
|
252 |
SetActive();
|
sl@0
|
253 |
}
|
sl@0
|
254 |
|
sl@0
|
255 |
TInt CSerialKeyboard::KeyCode()
|
sl@0
|
256 |
{
|
sl@0
|
257 |
TInt c=-1;
|
sl@0
|
258 |
#ifdef __USE_SERIAL_INPUT
|
sl@0
|
259 |
if (iBuf.Length()>0)
|
sl@0
|
260 |
c=iBuf[0];
|
sl@0
|
261 |
#endif
|
sl@0
|
262 |
return c;
|
sl@0
|
263 |
}
|
sl@0
|
264 |
|
sl@0
|
265 |
void CSerialKeyboard::RunL()
|
sl@0
|
266 |
{
|
sl@0
|
267 |
TInt c=KeyCode();
|
sl@0
|
268 |
if (c>=0)
|
sl@0
|
269 |
{
|
sl@0
|
270 |
// convert character to keycode and shift, func, ctrl status
|
sl@0
|
271 |
TUint16 code = convertCode[c];
|
sl@0
|
272 |
TBool isShifted = ISSHIFTED(code);
|
sl@0
|
273 |
TBool isFunced = ISFUNCED(code);
|
sl@0
|
274 |
TBool isCtrled = ISCTRLED(code);
|
sl@0
|
275 |
TUint8 stdKey = STDKEY(code);
|
sl@0
|
276 |
TRawEvent e;
|
sl@0
|
277 |
|
sl@0
|
278 |
// post it as a sequence of events
|
sl@0
|
279 |
if (isShifted)
|
sl@0
|
280 |
{
|
sl@0
|
281 |
e.Set(TRawEvent::EKeyDown,EStdKeyRightShift,0);
|
sl@0
|
282 |
UserSvr::AddEvent(e);
|
sl@0
|
283 |
}
|
sl@0
|
284 |
if (isCtrled)
|
sl@0
|
285 |
{
|
sl@0
|
286 |
e.Set(TRawEvent::EKeyDown,EStdKeyLeftCtrl,0);
|
sl@0
|
287 |
UserSvr::AddEvent(e);
|
sl@0
|
288 |
}
|
sl@0
|
289 |
if (isFunced)
|
sl@0
|
290 |
{
|
sl@0
|
291 |
e.Set(TRawEvent::EKeyDown,EStdKeyLeftFunc,0);
|
sl@0
|
292 |
UserSvr::AddEvent(e);
|
sl@0
|
293 |
}
|
sl@0
|
294 |
|
sl@0
|
295 |
e.Set(TRawEvent::EKeyDown,stdKey,0);
|
sl@0
|
296 |
UserSvr::AddEvent(e);
|
sl@0
|
297 |
|
sl@0
|
298 |
e.Set(TRawEvent::EKeyUp,stdKey,0);
|
sl@0
|
299 |
UserSvr::AddEvent(e);
|
sl@0
|
300 |
|
sl@0
|
301 |
if (isFunced)
|
sl@0
|
302 |
{
|
sl@0
|
303 |
e.Set(TRawEvent::EKeyUp,EStdKeyLeftFunc,0);
|
sl@0
|
304 |
UserSvr::AddEvent(e);
|
sl@0
|
305 |
}
|
sl@0
|
306 |
if (isCtrled)
|
sl@0
|
307 |
{
|
sl@0
|
308 |
e.Set(TRawEvent::EKeyUp,EStdKeyLeftCtrl,0);
|
sl@0
|
309 |
UserSvr::AddEvent(e);
|
sl@0
|
310 |
}
|
sl@0
|
311 |
if (isShifted)
|
sl@0
|
312 |
{
|
sl@0
|
313 |
e.Set(TRawEvent::EKeyUp,EStdKeyRightShift,0);
|
sl@0
|
314 |
UserSvr::AddEvent(e);
|
sl@0
|
315 |
}
|
sl@0
|
316 |
}
|
sl@0
|
317 |
|
sl@0
|
318 |
// get another key
|
sl@0
|
319 |
GetKey();
|
sl@0
|
320 |
}
|
sl@0
|
321 |
|
sl@0
|
322 |
void CSerialKeyboard::DoCancel()
|
sl@0
|
323 |
{
|
sl@0
|
324 |
#ifdef __USE_SERIAL_INPUT
|
sl@0
|
325 |
iDevComm.ReadCancel();
|
sl@0
|
326 |
#endif
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
|
sl@0
|
330 |
class CScreenDriverVT100 : public CScreenDriver
|
sl@0
|
331 |
{
|
sl@0
|
332 |
public:
|
sl@0
|
333 |
CScreenDriverVT100();
|
sl@0
|
334 |
virtual void Init(TSize &aScreenSize,TSize &aFontSize);
|
sl@0
|
335 |
virtual void Blit(const TText *aBuffer,TInt aLength,const TPoint &aPosition);
|
sl@0
|
336 |
virtual TBool ScrollUp(const TRect& aRect);
|
sl@0
|
337 |
virtual void Clear(const TRect& aRect);
|
sl@0
|
338 |
|
sl@0
|
339 |
virtual void SetPixel(const TPoint& aPoint,TUint8 aColour);
|
sl@0
|
340 |
virtual TInt GetPixel(const TPoint& aPoint);
|
sl@0
|
341 |
virtual void SetWord(const TPoint& aPoint,TInt aWord);
|
sl@0
|
342 |
virtual TInt GetWord(const TPoint& aPoint);
|
sl@0
|
343 |
virtual void SetLine(const TPoint& aPoint,const TPixelLine& aPixelLine);
|
sl@0
|
344 |
virtual void GetLine(const TPoint& aPoint,TPixelLine& aPixelLine);
|
sl@0
|
345 |
|
sl@0
|
346 |
virtual TInt SetMode(TVideoMode aMode);
|
sl@0
|
347 |
|
sl@0
|
348 |
virtual void SetPaletteEntry(TColorIndex anIndex,TUint8 aRed,TUint8 aGreen,TUint8 aBlue) {}
|
sl@0
|
349 |
virtual void GetPaletteEntry(TColorIndex anIndex,TUint8 &aRed,TUint8 &aGreen,TUint8 &aBlue) {}
|
sl@0
|
350 |
virtual void SetForegroundColor(TColorIndex anIndex) {}
|
sl@0
|
351 |
virtual void SetBackgroundColor(TColorIndex anIndex) {}
|
sl@0
|
352 |
virtual void GetAttributeColors(TColorIndex* anArray) {}
|
sl@0
|
353 |
|
sl@0
|
354 |
//
|
sl@0
|
355 |
void Update(const TRect &aRect);
|
sl@0
|
356 |
void Print(const TDesC8& aDes);
|
sl@0
|
357 |
TUint8 *iScreenBuffer;
|
sl@0
|
358 |
private:
|
sl@0
|
359 |
CSerialKeyboard *iSerialKeyboard;
|
sl@0
|
360 |
};
|
sl@0
|
361 |
|
sl@0
|
362 |
const TInt KScreenWidth = 80;
|
sl@0
|
363 |
const TInt KScreenHeight = 24;
|
sl@0
|
364 |
|
sl@0
|
365 |
CScreenDriverVT100::CScreenDriverVT100()
|
sl@0
|
366 |
//
|
sl@0
|
367 |
// Constructor
|
sl@0
|
368 |
//
|
sl@0
|
369 |
{
|
sl@0
|
370 |
}
|
sl@0
|
371 |
|
sl@0
|
372 |
EXPORT_C CScreenDriver *CScreenDriver::New()
|
sl@0
|
373 |
//
|
sl@0
|
374 |
// Return the actual screen driver.
|
sl@0
|
375 |
//
|
sl@0
|
376 |
{
|
sl@0
|
377 |
|
sl@0
|
378 |
CScreenDriverVT100 *pS=new CScreenDriverVT100;
|
sl@0
|
379 |
pS->iScreenBuffer=new TUint8 [KScreenWidth*KScreenHeight];
|
sl@0
|
380 |
return pS;
|
sl@0
|
381 |
}
|
sl@0
|
382 |
|
sl@0
|
383 |
void CScreenDriverVT100::Init(TSize& aScreenSize, TSize& aFontSize)
|
sl@0
|
384 |
{
|
sl@0
|
385 |
// Report screen information
|
sl@0
|
386 |
aFontSize=TSize(8,10);
|
sl@0
|
387 |
aScreenSize=TSize(KScreenWidth,KScreenHeight);
|
sl@0
|
388 |
|
sl@0
|
389 |
// start keyboard
|
sl@0
|
390 |
TRAPD(r,iSerialKeyboard = CSerialKeyboard::NewL());
|
sl@0
|
391 |
// must panic if there are not enough resources to continue
|
sl@0
|
392 |
__ASSERT_ALWAYS(r==KErrNone, User::Panic(_L("CSerialKeyboard"),2));
|
sl@0
|
393 |
|
sl@0
|
394 |
iSerialKeyboard->GetKey();
|
sl@0
|
395 |
}
|
sl@0
|
396 |
|
sl@0
|
397 |
TInt CScreenDriverVT100::SetMode(TVideoMode aMode)
|
sl@0
|
398 |
//
|
sl@0
|
399 |
// Set the screen mode
|
sl@0
|
400 |
//
|
sl@0
|
401 |
{
|
sl@0
|
402 |
return(KErrNotSupported);
|
sl@0
|
403 |
}
|
sl@0
|
404 |
|
sl@0
|
405 |
void CScreenDriverVT100::Update(const TRect &aRect)
|
sl@0
|
406 |
{
|
sl@0
|
407 |
TBuf8<0x100> buf;
|
sl@0
|
408 |
TInt i;
|
sl@0
|
409 |
|
sl@0
|
410 |
for (i=aRect.iTl.iY; i<=aRect.iBr.iY; i++)
|
sl@0
|
411 |
{
|
sl@0
|
412 |
buf.Format(_L8("\x1b[%02d;%02dH"), i+1, aRect.iTl.iX+1);
|
sl@0
|
413 |
TPtrC8 ptr(iScreenBuffer+(aRect.iTl.iX+i*KScreenWidth),aRect.iBr.iX-aRect.iTl.iX);
|
sl@0
|
414 |
buf.Append(ptr);
|
sl@0
|
415 |
Print(buf);
|
sl@0
|
416 |
}
|
sl@0
|
417 |
Print(_L8("\x1b[01;01H"));
|
sl@0
|
418 |
}
|
sl@0
|
419 |
|
sl@0
|
420 |
void CScreenDriverVT100::Blit(const TText *aBuffer, TInt aLength, const TPoint &aPosition)
|
sl@0
|
421 |
//
|
sl@0
|
422 |
// Write contiguous block of characters to some segment of a line on the display
|
sl@0
|
423 |
//
|
sl@0
|
424 |
{
|
sl@0
|
425 |
TUint8 *ptr=iScreenBuffer+(aPosition.iX+aPosition.iY*KScreenWidth);
|
sl@0
|
426 |
const TText* endBuf = aBuffer + aLength;
|
sl@0
|
427 |
while (aBuffer < endBuf)
|
sl@0
|
428 |
*ptr++ = (TUint8)*aBuffer++;
|
sl@0
|
429 |
Update(TRect(aPosition.iX, aPosition.iY, aPosition.iX+aLength, aPosition.iY));
|
sl@0
|
430 |
}
|
sl@0
|
431 |
|
sl@0
|
432 |
TBool CScreenDriverVT100::ScrollUp(const TRect& aRect)
|
sl@0
|
433 |
//
|
sl@0
|
434 |
// Scroll a rectangle of the screen up one line, don't update bottom line
|
sl@0
|
435 |
//
|
sl@0
|
436 |
{
|
sl@0
|
437 |
TInt j;
|
sl@0
|
438 |
for (j=aRect.iTl.iY; j<aRect.iBr.iY; j++)
|
sl@0
|
439 |
{
|
sl@0
|
440 |
TUint8 *ptr=iScreenBuffer+(aRect.iTl.iX+j*KScreenWidth);
|
sl@0
|
441 |
Mem::Copy(ptr, ptr+KScreenWidth, aRect.iBr.iX-aRect.iTl.iX);
|
sl@0
|
442 |
}
|
sl@0
|
443 |
if ((aRect.iTl.iX<=1) && (aRect.iBr.iX>=KScreenWidth-2))
|
sl@0
|
444 |
{
|
sl@0
|
445 |
// Optimisation: range of whole lines
|
sl@0
|
446 |
TBuf8<0x100> buf;
|
sl@0
|
447 |
// cursor pos
|
sl@0
|
448 |
buf.Format(_L8("\x1b[%02d;%02dH\xd\xa\xba\x1b[%02dC\xba"), aRect.iBr.iY, 1, aRect.iBr.iX);
|
sl@0
|
449 |
Print(buf);
|
sl@0
|
450 |
// set scroll region
|
sl@0
|
451 |
buf.Format(_L8("\x1b[%02d;%02dr\xd\xa"), aRect.iTl.iY+1, aRect.iBr.iY);
|
sl@0
|
452 |
Print(buf);
|
sl@0
|
453 |
Print(_L8("\x1b[01;01H"));
|
sl@0
|
454 |
}
|
sl@0
|
455 |
else
|
sl@0
|
456 |
Update(aRect);
|
sl@0
|
457 |
|
sl@0
|
458 |
return(ETrue);
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
void CScreenDriverVT100::Clear(const TRect& aRect)
|
sl@0
|
462 |
//
|
sl@0
|
463 |
// Clear a rectangle of the screen
|
sl@0
|
464 |
//
|
sl@0
|
465 |
{
|
sl@0
|
466 |
TInt j;
|
sl@0
|
467 |
TBuf8<0x100> buf;
|
sl@0
|
468 |
for (j=aRect.iTl.iY; j<=aRect.iBr.iY; j++)
|
sl@0
|
469 |
{
|
sl@0
|
470 |
TUint8 *ptr=iScreenBuffer+(aRect.iTl.iX+j*KScreenWidth);
|
sl@0
|
471 |
Mem::FillZ(ptr, aRect.iBr.iX-aRect.iTl.iX);
|
sl@0
|
472 |
}
|
sl@0
|
473 |
if ((aRect.iTl.iY == aRect.iBr.iY) && (aRect.iTl.iX==0) && (aRect.iBr.iX==KScreenWidth-1))
|
sl@0
|
474 |
{
|
sl@0
|
475 |
// Optimisation: one whole line
|
sl@0
|
476 |
buf.Format(_L8("\x1b[%02d;%02dH"), aRect.iTl.iY, 1);
|
sl@0
|
477 |
Print(buf);
|
sl@0
|
478 |
// Erase line
|
sl@0
|
479 |
buf.Format(_L8("\x1b[2K"));
|
sl@0
|
480 |
Print(buf);
|
sl@0
|
481 |
Print(_L8("\x1b[01;01H"));
|
sl@0
|
482 |
}
|
sl@0
|
483 |
else if ((aRect.iTl.iY == 0) && (aRect.iBr.iY == KScreenHeight-1) &&
|
sl@0
|
484 |
(aRect.iTl.iX == 0) && (aRect.iBr.iX == KScreenWidth-1))
|
sl@0
|
485 |
{
|
sl@0
|
486 |
// Optimisation: whole screen
|
sl@0
|
487 |
buf.Format(_L8("\x1b[2J"));
|
sl@0
|
488 |
Print(buf);
|
sl@0
|
489 |
Print(_L8("\x1b[01;01H"));
|
sl@0
|
490 |
}
|
sl@0
|
491 |
else
|
sl@0
|
492 |
Update(aRect);
|
sl@0
|
493 |
}
|
sl@0
|
494 |
|
sl@0
|
495 |
void CScreenDriverVT100::SetPixel(const TPoint& /*aPoint*/,TUint8 /*aColour*/)
|
sl@0
|
496 |
{
|
sl@0
|
497 |
}
|
sl@0
|
498 |
|
sl@0
|
499 |
TInt CScreenDriverVT100::GetPixel(const TPoint& /*aPoint*/)
|
sl@0
|
500 |
{
|
sl@0
|
501 |
return 0;
|
sl@0
|
502 |
}
|
sl@0
|
503 |
|
sl@0
|
504 |
void CScreenDriverVT100::SetWord(const TPoint& /*aPoint*/,TInt /*aWord*/)
|
sl@0
|
505 |
{
|
sl@0
|
506 |
}
|
sl@0
|
507 |
|
sl@0
|
508 |
TInt CScreenDriverVT100::GetWord(const TPoint& /*aPoint*/)
|
sl@0
|
509 |
{
|
sl@0
|
510 |
return 0;
|
sl@0
|
511 |
}
|
sl@0
|
512 |
|
sl@0
|
513 |
void CScreenDriverVT100::SetLine(const TPoint& /*aPoint*/,const TPixelLine& /*aPixelLine*/)
|
sl@0
|
514 |
{
|
sl@0
|
515 |
}
|
sl@0
|
516 |
|
sl@0
|
517 |
void CScreenDriverVT100::GetLine(const TPoint& /*aPoint*/,TPixelLine& /*aPixelLine*/)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
}
|
sl@0
|
520 |
|
sl@0
|
521 |
void CScreenDriverVT100::Print(const TDesC8& aDes)
|
sl@0
|
522 |
{
|
sl@0
|
523 |
#ifdef __USE_RDEBUG_OUTPUT
|
sl@0
|
524 |
TBuf<256> unicodeBuf;
|
sl@0
|
525 |
unicodeBuf.Copy(aDes);
|
sl@0
|
526 |
RDebug::RawPrint(unicodeBuf);
|
sl@0
|
527 |
#else
|
sl@0
|
528 |
RBusDevComm c=iSerialKeyboard->iDevComm;
|
sl@0
|
529 |
TRequestStatus s;
|
sl@0
|
530 |
c.Write(s,aDes);
|
sl@0
|
531 |
User::WaitForRequest(s);
|
sl@0
|
532 |
#endif
|
sl@0
|
533 |
}
|
sl@0
|
534 |
|