
| July 2003 How to Program the Buttons on the Sony Ericsson P80x and P90x |
|
|
The Sony Ericsson P80x and P90x are touch-screen devices; so most apps will be navigated using pointer presses. But the Sony Ericsson P80x and P90x do have several buttons on the sides of the case, including the camera key, the Internet key, the jog dial and the power key.
The built-in camera app, Internet app and power app register themselves to respond to these keys. When you press these keys the key event gets sent to their (background) application, which decides what to do with it (e.g. bring the browser app to the foreground). Your applications can register to handle these keys using the RWindowGroup class. These perphirary buttons are identified by ID numbers. You need to know the ID number to be able to request notification in your application when it is pressed. These buttons are 'special buttons', with IDs within the range ESpecialKeyBase .. ESpecialKeyBase+EspecialKeyCount in the header file <e32keys.h> These are the key codes on the Sony Ericsson P80x and P90x; they are ideal to add as private constants to your AppUi class: enum PxxxKey {
EPowerKeyCode = 0x0F842,
EInternetKey = 0x0F852,
ECameraKeyCode
};
Here is a snippet of code to paste into your applications so you too can respond to these key presses. You need:
//** in your view activated listener
iCameraKeyId = CEikonEnv::Static()
->RootWin().CaptureKey(P800Key::ECameraKeyCode,0,0,2);//** You can test whether this request to capture the camera key was // successful or not by testing // the returned ID; if it is greater than zero, you now 'own' that key. //** When the camera key is pressed, events will now be rooted to // your AppUI's HandleWsEventL // in your view deactivated listener //** When you no longer require them or you close, it is important // that you cancel all captures // that you have. You should ensure you only cancel valid // captures, as otherwise your app will panic! if(0 < iCameraKeyId)
{
CEikonEnv::Static()->RootWin().CancelCaptureKey(iCameraKeyId);
iCameraKeyId = 0; // avoid double cancel!
}
//** and to be very sure we cancel any captures,
// lets cancel too in the destructor
if(0 < iCameraKeyId)
{
CEikonEnv::Static()->RootWin().CancelCaptureKey(iCameraKeyId);
}
| |
Copyright © 2001 - 2009 Sony Ericsson Mobile Communications AB. All Rights Reserved.