plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.cpp
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Thu, 16 Sep 2010 15:05:53 +0100
changeset 60 f9caadcaea11
parent 47 1c9b53dbf08b
permissions -rw-r--r--
Update change history to make Release 001 official.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     1
// terminalkeyboardcons.cpp
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     2
// 
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     3
// Copyright (c) 2010 Accenture. All rights reserved.
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     4
// This component and the accompanying materials are made available
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     5
// under the terms of the "Eclipse Public License v1.0"
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     6
// which accompanies this distribution, and is available
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     7
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     8
// 
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
     9
// Initial Contributors:
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    10
// Accenture - Initial contribution
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    11
//
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    12
#include "terminalkeyboardcons.h"
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    13
#include <fshell/common.mmh>
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    14
#include <e32debug.h>
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    15
#include <fshell/memoryaccess.h>
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    16
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    17
const TInt KTkbdMessageId = 0xD6;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    18
// These are the defaults unless overridden by --console-size
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    19
const TInt KWidth = 80;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    20
const TInt KHeight = 24;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    21
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    22
class CMessageWatcher : public CActive
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    23
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    24
public:
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    25
	CMessageWatcher(CTerminalKeyboardCons& aConsole)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    26
		: CActive(CActive::EPriorityStandard), iConsole(aConsole)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    27
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    28
		CActiveScheduler::Add(this);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    29
		iConsole.iDriver.RequestMessage(iStatus);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    30
		SetActive();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    31
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    32
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    33
	void DoCancel()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    34
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    35
		iConsole.iDriver.CancelMessage();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    36
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    37
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    38
	void RunL()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    39
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    40
		iConsole.MessageReceived(iStatus.Int());
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    41
		if (iStatus.Int() == KErrNone)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    42
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    43
			iConsole.iDriver.RequestMessage(iStatus);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    44
			SetActive();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    45
			}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    46
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    47
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    48
	~CMessageWatcher()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    49
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    50
		Cancel();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    51
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    52
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    53
private:
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    54
	CTerminalKeyboardCons& iConsole;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    55
	};
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    56
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    57
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    58
CTerminalKeyboardCons::CTerminalKeyboardCons()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    59
	: iTracker(TSize(KWidth, KHeight), this)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    60
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    61
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    62
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    63
CTerminalKeyboardCons::~CTerminalKeyboardCons()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    64
	{
35
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
    65
	delete iIdleUpdateTimer;
33
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    66
	CleanupUnderlyingConsole();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    67
	delete iWatcher;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    68
	iDriver.Close();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    69
	iTextBuffer.Close();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    70
	iMungedTextBuffer.Close();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    71
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    72
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    73
TInt CTerminalKeyboardCons::Create(const TDesC& aTitle, TSize aSize)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    74
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    75
	TRAPD(err, ConstructL(aTitle, aSize));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    76
	HandleConsoleCreationError(_L("TerminalKeyboard"), err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    77
	return err;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    78
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    79
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    80
void CTerminalKeyboardCons::ConstructL(const TDesC& aTitle, const TSize& aSize)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    81
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    82
	if (aTitle == _L("debug")) SetDebug(ETrue);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    83
	if (aSize.iWidth > 10 && aSize.iHeight > 10)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    84
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    85
		// Override size now we know it, checking that it's sane-ish - be sure to do this before anything that uses the console size!
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    86
		new (&iTracker) TCursorTracker(aSize, this);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    87
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    88
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    89
	iTextBuffer.CreateMaxL(ScreenSize().iWidth * ScreenSize().iHeight);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    90
#ifdef SHOW_TEXTSHELL_BORDERS
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    91
	iMungedTextBuffer.CreateL((ScreenSize().iWidth + 2) * (ScreenSize().iHeight + 2));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    92
#endif
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    93
35
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
    94
	iIdleUpdateTimer = CPeriodic::NewL(CActive::EPriorityLow); // Lower priority than the message watcher
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
    95
33
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    96
	TInt err = User::LoadLogicalDevice(KTcLddDriverName);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    97
	if (err && err != KErrAlreadyExists)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    98
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
    99
		Message(EError, _L("Couldn't load LDD %S: %d"), &KTcLddDriverName, err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   100
		User::Leave(err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   101
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   102
47
1c9b53dbf08b Updated wording :)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 35
diff changeset
   103
	// Annoying driver only accepts connections from processes with nokia vid - like that will stop us
33
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   104
	TUint originalVid = RProcess().VendorId();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   105
	RMemoryAccess memAccess;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   106
	User::LeaveIfError(memAccess.Open());
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   107
	TProcessProperties props;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   108
	props.iVid = 0x101FB657;
47
1c9b53dbf08b Updated wording :)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 35
diff changeset
   109
	RProcess me;
1c9b53dbf08b Updated wording :)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 35
diff changeset
   110
	User::LeaveIfError(me.Open(RProcess().Id()));
33
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   111
	memAccess.SetProcessProperties(me, props);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   112
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   113
	err = iDriver.Open();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   114
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   115
	props.iVid = originalVid;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   116
	memAccess.SetProcessProperties(me, props);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   117
	me.Close();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   118
	memAccess.Close();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   119
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   120
	if (err)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   121
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   122
		Message(EError, _L("Couldn't open RTcDriver: %d"), err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   123
		User::Leave(err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   124
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   125
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   126
	err = iDriver.Subscribe(KTkbdMessageId);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   127
	if (err)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   128
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   129
		Message(EError, _L("Couldn't subscribe: %d"), err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   130
		User::Leave(err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   131
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   132
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   133
	iWatcher = new(ELeave) CMessageWatcher(*this);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   134
	CleanupUnderlyingConsole();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   135
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   136
	ClearScreen();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   137
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   138
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   139
	
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   140
TInt CTerminalKeyboardCons::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   141
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   142
	/*if (aExtensionId == ConsoleMode::KSetConsoleModeExtension)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   143
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   144
		ConsoleMode::TMode mode = (ConsoleMode::TMode)(TInt)a1;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   145
		iInputController->SetMode(mode);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   146
		iOutputController->SetMode(mode);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   147
		return KErrNone;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   148
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   149
	else*/
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   150
	/*else if (aExtensionId == ConsoleAttributes::KSetConsoleAttributesExtension)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   151
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   152
		ConsoleAttributes::TAttributes* attributes = (ConsoleAttributes::TAttributes*)a1;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   153
		return iOutputController->SetAttributes(attributes->iAttributes, attributes->iForegroundColor, attributes->iBackgroundColor);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   154
		}*/
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   155
	
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   156
	TInt ret = MIosrvConsoleHelper_Extension(aExtensionId, a0, a1);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   157
	if (ret == KErrExtensionNotSupported) ret = CConsoleBase::Extension_(aExtensionId, a0, a1);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   158
	return ret;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   159
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   160
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   161
void CTerminalKeyboardCons::MessageReceived(TInt aError)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   162
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   163
	Message(EDebug, _L("MessageReceived err=%d"), aError);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   164
	TInt err = aError;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   165
	if (err == KErrNone)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   166
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   167
		TPtrC8 data;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   168
		err = iDriver.GetMessageData(data);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   169
		if (!err && data.Length() < 1) err = KErrCorrupt;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   170
		if (!err && !iGotKey)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   171
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   172
			TUint16 rawkey = data[0];
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   173
			Message(EDebug, _L("CTerminalKeyboardCons got key %d"), (TInt)rawkey);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   174
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   175
			// Terminal keyboard doesn't support control keys or cursor keys so we use our own two-stage sticky modifier (like unix meta key I think?)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   176
			if (iBacktickModifierDown)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   177
				{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   178
				// Terminal keyboard sends 2,4,6,8 for cursors, so we translate backtick-2 (ie backtick-leftarrow) as meaning left arrow
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   179
				if (rawkey == '2') rawkey = (TUint16)EKeyUpArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   180
				else if (rawkey == '4') rawkey = (TUint16)EKeyLeftArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   181
				else if (rawkey == '6') rawkey = (TUint16)EKeyRightArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   182
				else if (rawkey == '8') rawkey = (TUint16)EKeyDownArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   183
				else if (rawkey >= 'a' && rawkey <= 'z')
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   184
					{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   185
					// backtick-c means CTRL-C
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   186
					rawkey = rawkey - 'a'+1;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   187
					}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   188
				else if (rawkey == ' ') rawkey = '`'; // backtick-space is how you do a backtick
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   189
				else if (rawkey == '`') rawkey = (TUint16)EKeyEscape; // backtick-backtick is 'escape'
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   190
				else if (rawkey == '1') rawkey = (TUint16)EKeyTab; // backtick-1 is 'tab'
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   191
				iBacktickModifierDown = EFalse;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   192
				Message(EDebug, _L("Backtick escape converted to %d"), (TInt)rawkey);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   193
				}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   194
			else if (rawkey == '`')
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   195
				{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   196
				iBacktickModifierDown = ETrue;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   197
				return;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   198
				}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   199
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   200
			iKeyCode = (TKeyCode)rawkey; // Close enough for now!
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   201
			iGotKey = ETrue;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   202
			}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   203
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   204
	if (iClientStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   205
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   206
		User::RequestComplete(iClientStatus, err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   207
		if (err == KErrNone) iGotKey = EFalse;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   208
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   209
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   210
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   211
void CTerminalKeyboardCons::Read(TRequestStatus& aStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   212
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   213
	/*if (iClientStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   214
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   215
		TRequestStatus* stat = &aStatus;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   216
		User::RequestComplete(stat, KErrInUse);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   217
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   218
	else*/
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   219
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   220
		aStatus = KRequestPending;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   221
		iClientStatus = &aStatus;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   222
		if (iGotKey)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   223
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   224
			iGotKey = EFalse;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   225
			User::RequestComplete(iClientStatus, KErrNone);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   226
			}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   227
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   228
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   229
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   230
void CTerminalKeyboardCons::ReadCancel()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   231
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   232
	if (iClientStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   233
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   234
		User::RequestComplete(iClientStatus, KErrCancel);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   235
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   236
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   237
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   238
void CTerminalKeyboardCons::Write(const TDesC& aDes)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   239
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   240
	for (TInt i = 0; i < aDes.Length(); i++)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   241
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   242
		TInt textBufPos = CursorPos().iY * ScreenSize().iWidth + CursorPos().iX;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   243
		TChar ch(aDes[i]);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   244
		iTracker.WriteChar(ch);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   245
		if (ch.IsPrint()) iTextBuffer[textBufPos] = aDes[i];
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   246
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   247
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   248
	Update();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   249
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   250
	
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   251
TPoint CTerminalKeyboardCons::CursorPos() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   252
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   253
	return iTracker.CursorPos();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   254
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   255
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   256
void CTerminalKeyboardCons::SetCursorPosAbs(const TPoint& aPoint)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   257
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   258
	iTracker.SetCursorPosAbs(aPoint);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   259
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   260
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   261
void CTerminalKeyboardCons::SetCursorPosRel(const TPoint& aPoint)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   262
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   263
	iTracker.SetCursorPosRel(aPoint);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   264
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   265
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   266
void CTerminalKeyboardCons::SetCursorHeight(TInt /*aPercentage*/)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   267
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   268
	//iOutputController->SetCursorHeight(aPercentage);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   269
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   270
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   271
void CTerminalKeyboardCons::SetTitle(const TDesC& /*aDes*/)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   272
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   273
	//iOutputController->SetTitle(aDes);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   274
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   275
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   276
void CTerminalKeyboardCons::ClearScreen()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   277
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   278
	SetCursorPosAbs(TPoint(0,0));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   279
	iTextBuffer.Fill(' ');
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   280
	Update();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   281
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   282
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   283
void CTerminalKeyboardCons::ClearToEndOfLine()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   284
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   285
	iTextBuffer.MidTPtr(CursorPos().iY * ScreenSize().iWidth + CursorPos().iX, ScreenSize().iWidth - CursorPos().iX).Fill(' ');
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   286
	Update();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   287
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   288
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   289
TSize CTerminalKeyboardCons::ScreenSize() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   290
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   291
	return iTracker.ConsoleSize();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   292
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   293
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   294
TKeyCode CTerminalKeyboardCons::KeyCode() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   295
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   296
	return iKeyCode;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   297
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   298
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   299
TUint CTerminalKeyboardCons::KeyModifiers() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   300
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   301
	return iKeyModifiers;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   302
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   303
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   304
// All these magic vals are as per the DOS 437 codepage http://en.wikipedia.org/wiki/CP437 and not Windows-1252 like the ws_win.cpp source incorrectly states
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   305
// See also http://en.wikipedia.org/wiki/Box_drawing_characters
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   306
enum
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   307
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   308
	EBoxHorizontalBar = 0xCD,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   309
	EBoxVerticalBar = 0xBA,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   310
	EBoxTopLeft = 0xC9,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   311
	EBoxTopRight = 0xBB,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   312
	EBoxBottomLeft = 0xC8,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   313
	EBoxBottomRight = 0xBC,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   314
	};
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   315
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   316
void CTerminalKeyboardCons::Update()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   317
	{
35
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   318
	// Delay updates to the screen, to improve performance
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   319
	static const TInt KDelay = 100000; // 0.1s
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   320
	if (!iIdleUpdateTimer->IsActive())
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   321
		{
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   322
		// Don't reset timer if we're already running - otherwise constant typing will never show up until you stop pressing keys
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   323
		iIdleUpdateTimer->Start(KDelay, KDelay, TCallBack(&UpdateCallback, this));
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   324
		}
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   325
	}
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   326
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   327
TInt CTerminalKeyboardCons::UpdateCallback(TAny* aSelf)
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   328
	{
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   329
	static_cast<CTerminalKeyboardCons*>(aSelf)->DoUpdate();
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   330
	return 0;
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   331
	}
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   332
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   333
void CTerminalKeyboardCons::DoUpdate()
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   334
	{
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   335
	iIdleUpdateTimer->Cancel(); // Stop any further updates
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   336
33
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   337
#ifdef SHOW_TEXTSHELL_BORDERS
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   338
	// Update munged buffer
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   339
	const TInt contentWidth = ScreenSize().iWidth;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   340
	const TInt width = contentWidth + 2;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   341
	iMungedTextBuffer.SetLength(width);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   342
	iMungedTextBuffer.Fill(TChar(EBoxHorizontalBar));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   343
	iMungedTextBuffer[0] = EBoxTopLeft;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   344
	iMungedTextBuffer[width-1] = EBoxTopRight;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   345
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   346
	for (TInt i = 0; i < ScreenSize().iHeight; i++)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   347
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   348
		TPtrC line(iTextBuffer.Mid(i*contentWidth, contentWidth));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   349
		iMungedTextBuffer.AppendFormat(_L("%c%S%c"), EBoxVerticalBar, &line, EBoxVerticalBar);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   350
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   351
	
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   352
	iMungedTextBuffer.Append(EBoxBottomLeft);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   353
	iMungedTextBuffer.SetLength(iMungedTextBuffer.Length() + contentWidth);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   354
	iMungedTextBuffer.RightTPtr(contentWidth).Fill(EBoxHorizontalBar);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   355
	iMungedTextBuffer.Append(EBoxBottomRight);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   356
	
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   357
	// And send the munged buffer
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   358
	Transmit(iMungedTextBuffer, width, ScreenSize().iHeight + 2);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   359
#else
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   360
	// Just send it straight
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   361
	Transmit(iTextBuffer, ScreenSize().iWidth, ScreenSize().iHeight);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   362
#endif
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   363
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   364
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   365
void CTerminalKeyboardCons::Transmit(const TDesC& aBuf, TInt aWidth, TInt aHeight)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   366
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   367
	// This is how terminal keyboard does it - pretty horrible really
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   368
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   369
	static const TInt KMaxLen = 200; // This is what terminal keyboard uses - technically you could go as far as a total of 256
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   370
	TInt numLinesPerPrint = KMaxLen / aWidth;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   371
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   372
	TBuf<256> line;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   373
	TInt startLine = 0;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   374
	while (startLine < aHeight)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   375
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   376
		if (startLine == 0)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   377
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   378
			// First line has extra info
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   379
			line.Format(_L("#$STIConsole#$%02d%02X%02X"), startLine, aWidth, aHeight);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   380
			}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   381
		else
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   382
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   383
			line.Format(_L("#$STIConsole#$%02d"), startLine);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   384
			}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   385
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   386
		for (TInt i = 0; i < numLinesPerPrint; i++)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   387
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   388
			TPtrC theContents(aBuf.Mid((startLine+i)*aWidth, aWidth));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   389
			//RDebug::Printf("line len=%d theContents len=%d", line.Length(), theContents.Length());
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   390
			line.Append(theContents);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   391
			}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   392
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   393
		RDebug::Print(line);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   394
		startLine += numLinesPerPrint;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   395
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   396
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   397
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   398
void CTerminalKeyboardCons::ConsoleScrolled(TInt aNumberOfLines)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   399
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   400
	TInt numChars = Abs(aNumberOfLines) * ScreenSize().iWidth;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   401
	if (aNumberOfLines > 0)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   402
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   403
		iTextBuffer.Delete(0, numChars);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   404
		iTextBuffer.AppendFill(' ', numChars);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   405
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   406
	else if (aNumberOfLines < 0)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   407
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   408
		iTextBuffer.SetLength(iTextBuffer.Length() - numChars);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   409
		while (numChars--) iTextBuffer.Insert(0, _L(" "));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   410
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   411
	}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   412
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   413
extern "C" EXPORT_C TAny* NewConsole()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   414
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   415
	return new CTerminalKeyboardCons;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   416
	}