Read-only archive of the All About Symbian forum (2001–2013) · About this archive

keyboard input in console program

2 replies · 3,590 views · Started 15 March 2005

Hello there,
I'm programming Symbian for the first time. And my company wants me to add keyboard input capability in their console framework.

I understand that we can build either GUI or console applications on Symbian. I've seen loads of code to handle keyboard input on GUI applications using windows, focus and events.
But how can I read the keyboard in console applications, I can't find any exemple. Do I have to code in assembler ? If yes can you point me to some ressources please ?

Thanks a lot for any help.

I've found some code to read the keyboard, here are the first 2 lines :

RWsSession ws;
User::LeaveIfError(ws.Connect());

The second line always fails in command line mode (we call it textshell)
It quits on a Panic USER 175 which is not documented (USER panics go up to 135)
Looks like you can't connect a Window Session in textshell mode ?

Do I make sense ?
Does someone have any idea of how to read keyboard in textshell mode ?

Thanks for any hints.

This wirked for me. Hope it helps, a bit late maybe.

Cheers

TKeyCode code; //Ascii, TKeyCode is TInt32, long

HBufC16* name = HBufC16::NewLC(100);


CleanupStack::Pop();
CleanupStack::PushL(name);

console->Printf(KHello);
console->Printf(KHelloName);

while(true)
{
console->Printf(KHelloQuit);
code = console->Getch();

name->Des().AppendNum(code);

console->Printf(name->Des());

//TKeyCode 113 == Enter
//63587 red key
if (code==63587)
{
break;
}


}
CleanupStack::PopAndDestroy(name);