Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Camera key handling in Nokia Belle

From Wiki
Jump to: navigation, search

Nokia Belle's Camera application has changed its handling of the dedicated camera key. This article describes how 3rd party applications can adapt to this change and remain able to handle the camera key event.

Article Metadata
Tested with
Devices(s): Nokia 701
Compatibility
Platform(s): Symbian^3 and later
Nokia Belle
Device(s): All Nokia Belle
Platform Security
Signing Required: Nokia Publish or Symbian Signed issued developer certificate required.
Capabilities: SwEvent
Article
Keywords: RWindowGroup::CaptureKey(), RWindowGroup::CaptureKeyUpAndDowns(), RWindowGroup::CancelCaptureKey(), RWindowGroup::CancelCaptureKeyUpAndDowns()
Created: ltomuta (08 Feb 2012)
Last edited: hamishwillee (30 May 2013)

Summary

If you are developing a camera application, or any other utility app which intents to use the camera key event for custom user initiated actions, one of the essential tasks is to capture the camera key even and prevent its default handling, which would be starting the built-in Camera application and bringing it to foreground.

The task itself is easy to achieve, all that is required is a call to Symbian's RWindowGroup::CaptureKey() API in order to capture the key pressed event of the camera key, as in line #73 of the code snippet below.

  1.     RWsSession &wsSession = CCoeEnv::Static()->WsSession();
  2.     TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);
  3.     if (wGroupHandle) {
  4.         RWindowGroup wGroup(wsSession);
  5.         wGroup.Construct(wGroupHandle);
  6.         TBool captureOK = ETrue;
  7.         captureOK = captureOK && (wGroup.CaptureKey(EKeyCamera, 0, 0, 100) > 0);
  8.         if (!captureOK)
  9.             qWarning("Unable to register for camera capture key events, SwEvent capability may be missing");
  10.     }

In Nokia Belle, the Camera app is started on the camera key down event so capturing the key pressed event is not enough, your application would have to capture the up and down events as well. This is easily solved with an additional call to RWindowGroup::CaptureKeyUpAndDowns(), as illustrated at line #74 in the code below.

  1.     RWsSession &wsSession = CCoeEnv::Static()->WsSession();
  2.     TUint wGroupHandle = wsSession.GetWindowGroupHandle(wGroupId);
  3.     if (wGroupHandle) {
  4.         RWindowGroup wGroup(wsSession);
  5.         wGroup.Construct(wGroupHandle);
  6.         TBool captureOK = ETrue;
  7.         captureOK = captureOK && (wGroup.CaptureKey(EKeyCamera, 0, 0, 100) > 0);
  8.         captureOK = captureOK && (wGroup.CaptureKeyUpAndDowns(EStdKeyDevice7, 0, 0, 100) > 0);
  9.         if (!captureOK)
  10.             qWarning("Unable to register for camera capture key events, SwEvent capability may be missing");
  11.     }

Of course the application will have to release the key events to their normal handling as soon as the application no longer requires them. The corresponding calls to RWindowGroup::CancelCaptureKey() and RWindowGroup::CancelCaptureKeyUpAndDowns() will for example have to be made each time your camera application is sent by the user to the background, just as you would also release the camera resource at the same time, in order to allow other applications to make use of them.

Note: The above code snippets are slightly modified extracts from QtMobility's camera example application (camerakeyevent_symbian.cpp), available in the Qt SDK 1.2 under \QtSDK\Examples\QtMobility\camera. The code makes use of Symbian C++ APIs so similar code is to be used on Symbian C++ applications.

Please also note that the CaptureKey* APIs require that your application has the SwEvent capability, for which self-signing is not supported. Before using this API in your application make sure that you have applied for a valid developer certificate and enable its use for signing in your IDE's settings.

This page was last modified on 30 May 2013, at 06:38.
156 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×