Skip to content
Archive of entries posted on February 2010

Implementing AntSnes with Qt part 4: using special keys

Support for green, red, menu, and camera keys:
Current S60 v. 5.0 phones really don’t have that much keys, so I decided to add support for all keys that I can find from the phone. This will require the SwEvent capability. The downside is that SwEvent requires signing by user. The signing can be made at Symbian signed website.

Here’s a trick how to catch these special button events from the phone.

CAknAppUi* appUi = dynamic_cast (CEikonEnv::Static()->AppUi());
TRAPD(error,
    if (appUi) {
     // disable other green key functionality to be able to use it
     appUi->SetKeyEventFlags(CAknAppUi::EDisableSendKeyShort|CAknAppUi::EDisableSendKeyLong);
    }

//capturing menukeys, redkey (no), and camera keys
iMenuKeyHandle = CEikonEnv::Static()->RootWin().CaptureKeyUpAndDowns(EStdKeyApplication0, 0,0);
iNoKeyHandle = CEikonEnv::Static()->RootWin().CaptureKeyUpAndDowns(EStdKeyNo, 0, 0);
iNoKeyHandle2 = CEikonEnv::Static()->RootWin().CaptureKey( EKeyNo, 0, 0 );
iCameraKeyHandle = CEikonEnv::Static()->RootWin().CaptureKey( EKeyDevice7, 0, 0 );

There are limitations in these keys also. The green and red button are sending the  KeyUp events, even if I would hold the button down. So these keys shouldn’t be mapped into keys that require long key presses.

Adding support for multimedia buttons:
There’s are very good forum.nokia article about how to utilize multimedia keys: http://wiki.forum.nokia.com/index.php/TSS000432_-_Utilising_media_keys. I utilized the multimedia keys in similar ways, and after that I’ll make a KeyEvent with Qt’s Event:
Continue reading ‘Implementing AntSnes with Qt part 4: using special keys’ »