plugins/consoles/terminalkeyboardcons/terminalkeyboardcons.cpp
author Tom Sutcliffe <thomas.sutcliffe@accenture.com>
Thu, 26 Aug 2010 00:49:35 +0100
changeset 37 534b01198c2d
parent 35 f8e05215af4a
child 47 1c9b53dbf08b
permissions -rw-r--r--
Added ENotifyKeypresses and ECaptureCtrlC flags to CCommandBase. Commands can now get keypresses and handle ctrl-C via callbacks instead of having to implement custom active objects. As part of this extended the CCommandBase extension interface to MCommandExtensionsV2 for the new virtual functions KeyPressed(TUint aKeyCode, TUint aModifiers) and CtrlCPressed(). sudo now cleans up correctly by using ECaptureCtrlC.
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
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   103
	// Idiotic driver only accepts connections from processes with nokia vid - like that will stop us
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;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   109
	RProcess me; me.Open(RProcess().Id());
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   110
	memAccess.SetProcessProperties(me, props);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   111
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   112
	err = iDriver.Open();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   113
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   114
	props.iVid = originalVid;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   115
	memAccess.SetProcessProperties(me, props);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   116
	me.Close();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   117
	memAccess.Close();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   118
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   119
	if (err)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   120
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   121
		Message(EError, _L("Couldn't open RTcDriver: %d"), err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   122
		User::Leave(err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   123
		}
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
	err = iDriver.Subscribe(KTkbdMessageId);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   126
	if (err)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   127
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   128
		Message(EError, _L("Couldn't subscribe: %d"), err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   129
		User::Leave(err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   130
		}
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
	iWatcher = new(ELeave) CMessageWatcher(*this);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   133
	CleanupUnderlyingConsole();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   134
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   135
	ClearScreen();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   136
	}
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
TInt CTerminalKeyboardCons::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   140
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   141
	/*if (aExtensionId == ConsoleMode::KSetConsoleModeExtension)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   142
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   143
		ConsoleMode::TMode mode = (ConsoleMode::TMode)(TInt)a1;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   144
		iInputController->SetMode(mode);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   145
		iOutputController->SetMode(mode);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   146
		return KErrNone;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   147
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   148
	else*/
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   149
	/*else if (aExtensionId == ConsoleAttributes::KSetConsoleAttributesExtension)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   150
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   151
		ConsoleAttributes::TAttributes* attributes = (ConsoleAttributes::TAttributes*)a1;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   152
		return iOutputController->SetAttributes(attributes->iAttributes, attributes->iForegroundColor, attributes->iBackgroundColor);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   153
		}*/
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
	TInt ret = MIosrvConsoleHelper_Extension(aExtensionId, a0, a1);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   156
	if (ret == KErrExtensionNotSupported) ret = CConsoleBase::Extension_(aExtensionId, a0, a1);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   157
	return ret;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   158
	}
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
void CTerminalKeyboardCons::MessageReceived(TInt aError)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   161
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   162
	Message(EDebug, _L("MessageReceived err=%d"), aError);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   163
	TInt err = aError;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   164
	if (err == KErrNone)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   165
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   166
		TPtrC8 data;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   167
		err = iDriver.GetMessageData(data);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   168
		if (!err && data.Length() < 1) err = KErrCorrupt;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   169
		if (!err && !iGotKey)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   170
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   171
			TUint16 rawkey = data[0];
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   172
			Message(EDebug, _L("CTerminalKeyboardCons got key %d"), (TInt)rawkey);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   173
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   174
			// 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
   175
			if (iBacktickModifierDown)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   176
				{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   177
				// 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
   178
				if (rawkey == '2') rawkey = (TUint16)EKeyUpArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   179
				else if (rawkey == '4') rawkey = (TUint16)EKeyLeftArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   180
				else if (rawkey == '6') rawkey = (TUint16)EKeyRightArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   181
				else if (rawkey == '8') rawkey = (TUint16)EKeyDownArrow;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   182
				else if (rawkey >= 'a' && rawkey <= 'z')
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   183
					{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   184
					// backtick-c means CTRL-C
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   185
					rawkey = rawkey - 'a'+1;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   186
					}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   187
				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
   188
				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
   189
				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
   190
				iBacktickModifierDown = EFalse;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   191
				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
   192
				}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   193
			else if (rawkey == '`')
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   194
				{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   195
				iBacktickModifierDown = ETrue;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   196
				return;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   197
				}
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
			iKeyCode = (TKeyCode)rawkey; // Close enough for now!
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   200
			iGotKey = ETrue;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   201
			}
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
	if (iClientStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   204
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   205
		User::RequestComplete(iClientStatus, err);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   206
		if (err == KErrNone) iGotKey = EFalse;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   207
		}
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
void CTerminalKeyboardCons::Read(TRequestStatus& aStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   211
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   212
	/*if (iClientStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   213
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   214
		TRequestStatus* stat = &aStatus;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   215
		User::RequestComplete(stat, KErrInUse);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   216
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   217
	else*/
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   218
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   219
		aStatus = KRequestPending;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   220
		iClientStatus = &aStatus;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   221
		if (iGotKey)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   222
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   223
			iGotKey = EFalse;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   224
			User::RequestComplete(iClientStatus, KErrNone);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   225
			}
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
void CTerminalKeyboardCons::ReadCancel()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   230
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   231
	if (iClientStatus)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   232
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   233
		User::RequestComplete(iClientStatus, KErrCancel);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   234
		}
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
void CTerminalKeyboardCons::Write(const TDesC& aDes)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   238
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   239
	for (TInt i = 0; i < aDes.Length(); i++)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   240
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   241
		TInt textBufPos = CursorPos().iY * ScreenSize().iWidth + CursorPos().iX;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   242
		TChar ch(aDes[i]);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   243
		iTracker.WriteChar(ch);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   244
		if (ch.IsPrint()) iTextBuffer[textBufPos] = aDes[i];
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   245
		}
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
	Update();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   248
	}
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
TPoint CTerminalKeyboardCons::CursorPos() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   251
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   252
	return iTracker.CursorPos();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   253
	}
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
void CTerminalKeyboardCons::SetCursorPosAbs(const TPoint& aPoint)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   256
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   257
	iTracker.SetCursorPosAbs(aPoint);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   258
	}
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
void CTerminalKeyboardCons::SetCursorPosRel(const TPoint& aPoint)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   261
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   262
	iTracker.SetCursorPosRel(aPoint);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   263
	}
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
void CTerminalKeyboardCons::SetCursorHeight(TInt /*aPercentage*/)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   266
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   267
	//iOutputController->SetCursorHeight(aPercentage);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   268
	}
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
void CTerminalKeyboardCons::SetTitle(const TDesC& /*aDes*/)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   271
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   272
	//iOutputController->SetTitle(aDes);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   273
	}
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
void CTerminalKeyboardCons::ClearScreen()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   276
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   277
	SetCursorPosAbs(TPoint(0,0));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   278
	iTextBuffer.Fill(' ');
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   279
	Update();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   280
	}
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
void CTerminalKeyboardCons::ClearToEndOfLine()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   283
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   284
	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
   285
	Update();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   286
	}
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
TSize CTerminalKeyboardCons::ScreenSize() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   289
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   290
	return iTracker.ConsoleSize();
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   291
	}
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
TKeyCode CTerminalKeyboardCons::KeyCode() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   294
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   295
	return iKeyCode;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   296
	}
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
TUint CTerminalKeyboardCons::KeyModifiers() const
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   299
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   300
	return iKeyModifiers;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   301
	}
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
// 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
   304
// 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
   305
enum
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   306
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   307
	EBoxHorizontalBar = 0xCD,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   308
	EBoxVerticalBar = 0xBA,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   309
	EBoxTopLeft = 0xC9,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   310
	EBoxTopRight = 0xBB,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   311
	EBoxBottomLeft = 0xC8,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   312
	EBoxBottomRight = 0xBC,
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   313
	};
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
void CTerminalKeyboardCons::Update()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   316
	{
35
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   317
	// Delay updates to the screen, to improve performance
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   318
	static const TInt KDelay = 100000; // 0.1s
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   319
	if (!iIdleUpdateTimer->IsActive())
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   320
		{
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   321
		// 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
   322
		iIdleUpdateTimer->Start(KDelay, KDelay, TCallBack(&UpdateCallback, this));
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   323
		}
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
TInt CTerminalKeyboardCons::UpdateCallback(TAny* aSelf)
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   327
	{
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   328
	static_cast<CTerminalKeyboardCons*>(aSelf)->DoUpdate();
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   329
	return 0;
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   330
	}
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
void CTerminalKeyboardCons::DoUpdate()
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   333
	{
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   334
	iIdleUpdateTimer->Cancel(); // Stop any further updates
f8e05215af4a Performance improvements to terminalkeyboardcons.
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents: 33
diff changeset
   335
33
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   336
#ifdef SHOW_TEXTSHELL_BORDERS
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   337
	// Update munged buffer
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   338
	const TInt contentWidth = ScreenSize().iWidth;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   339
	const TInt width = contentWidth + 2;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   340
	iMungedTextBuffer.SetLength(width);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   341
	iMungedTextBuffer.Fill(TChar(EBoxHorizontalBar));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   342
	iMungedTextBuffer[0] = EBoxTopLeft;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   343
	iMungedTextBuffer[width-1] = EBoxTopRight;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   344
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   345
	for (TInt i = 0; i < ScreenSize().iHeight; i++)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   346
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   347
		TPtrC line(iTextBuffer.Mid(i*contentWidth, contentWidth));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   348
		iMungedTextBuffer.AppendFormat(_L("%c%S%c"), EBoxVerticalBar, &line, EBoxVerticalBar);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   349
		}
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
	iMungedTextBuffer.Append(EBoxBottomLeft);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   352
	iMungedTextBuffer.SetLength(iMungedTextBuffer.Length() + contentWidth);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   353
	iMungedTextBuffer.RightTPtr(contentWidth).Fill(EBoxHorizontalBar);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   354
	iMungedTextBuffer.Append(EBoxBottomRight);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   355
	
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   356
	// And send the munged buffer
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   357
	Transmit(iMungedTextBuffer, width, ScreenSize().iHeight + 2);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   358
#else
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   359
	// Just send it straight
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   360
	Transmit(iTextBuffer, ScreenSize().iWidth, ScreenSize().iHeight);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   361
#endif
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   362
	}
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
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
   365
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   366
	// 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
   367
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   368
	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
   369
	TInt numLinesPerPrint = KMaxLen / aWidth;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   370
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   371
	TBuf<256> line;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   372
	TInt startLine = 0;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   373
	while (startLine < aHeight)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   374
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   375
		if (startLine == 0)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   376
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   377
			// First line has extra info
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   378
			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
   379
			}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   380
		else
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   381
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   382
			line.Format(_L("#$STIConsole#$%02d"), startLine);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   383
			}
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
		for (TInt i = 0; i < numLinesPerPrint; i++)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   386
			{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   387
			TPtrC theContents(aBuf.Mid((startLine+i)*aWidth, aWidth));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   388
			//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
   389
			line.Append(theContents);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   390
			}
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
		RDebug::Print(line);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   393
		startLine += numLinesPerPrint;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   394
		}
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
void CTerminalKeyboardCons::ConsoleScrolled(TInt aNumberOfLines)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   398
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   399
	TInt numChars = Abs(aNumberOfLines) * ScreenSize().iWidth;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   400
	if (aNumberOfLines > 0)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   401
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   402
		iTextBuffer.Delete(0, numChars);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   403
		iTextBuffer.AppendFill(' ', numChars);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   404
		}
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   405
	else if (aNumberOfLines < 0)
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   406
		{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   407
		iTextBuffer.SetLength(iTextBuffer.Length() - numChars);
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   408
		while (numChars--) iTextBuffer.Insert(0, _L(" "));
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   409
		}
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
extern "C" EXPORT_C TAny* NewConsole()
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   413
	{
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   414
	return new CTerminalKeyboardCons;
cfabd0207208 Added terminalkeyboard console (terminalkeyboardcons.dll)
Tom Sutcliffe <thomas.sutcliffe@accenture.com>
parents:
diff changeset
   415
	}