how they do this ?

Login to reply to this topic.
Wed, 2006-03-15 16:37
Joined: 2005-11-28
Forum posts: 101
hey
im wondering how they do this:
i have an application that works in background (written by some1 else not me ) and this application has key shortcuts for example soft1 + 5... now im making an app that use button '5'. And i return EKeyWasConsumed in my handle key event... even tho i consume key 5 (my app is forgrond) the second app 'know' 5 was hit and do its shortcut stuff... How is it possible ??

and second thing with the same app..
It "says" (play a wav i guess but im not sure) for example "Select" after OK was hit... now i want to say something else (lets say HELLO)... im using MdaAudioPlayerUtility to play my wav and whats happening: i hit OK then this app says SELECT and after it my app says HELLO.. even i give my player highhest priority (SetPriority(...)Wink
How can they be always first ? how can i make that app not saying anything ! i want just my app say something...

Hope all is clear...
Thanks for reading and answering Smiley
BG

Sun, 2006-03-19 00:41
Joined: 2004-11-29
Forum posts: 1246
Re: how they do this ?
Well, it is very hard to say for sure how they implement it.
I am sure there could be several ways to achieve that.

But I know of one way to always be "first" to see all keyboard and pen events. (if the device supports a pen)

This is to write a CAnimDll window server plugin.

It is originally ment for animated content, but also has the very usefull feature of being able to listen to all user events, AND can modify them, before they reach any application.

I've used CAnims in a number of unconventional ways... they are very useful Smiley
Mon, 2006-03-20 23:58
Joined: 2005-11-28
Forum posts: 101
Re: how they do this ?
hey thanks for replay..
for now i have no idea how to use canimdll to catch key events.. but mabye i v not read enough Smiley

BG
Tue, 2006-03-21 20:15
Joined: 2004-11-29
Forum posts: 1246
Re: how they do this ?
search for them on this forum, I think I listed in some post what is needed to write and use a plugin dll.

Then read the manual, and note the interface available to your derived class, the MAnimGeneralFunctions. Via that, you can enable raw events to you anim, and then you just implement the OfferRawEvent() function.

The manual actually has quite a lot of information on how to write these. But if you get stuck, feel free to ask.
Mon, 2006-03-27 13:20
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
Re: how they do this ?
I'm also interested in the result of the investigations. My first answer would have been that it's always the application in foreground that has the focus and it's always its topmost control that has the chance to the process any new events. Consequently if one of your controls consume an event, then no-one else's own control should be able to do that - but it seems that it's different in practice. Please, let us know if you get to know something!

Thx,

tOtE

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

Wed, 2006-03-29 09:06
Joined: 2003-05-15
Forum posts: 53
Re: how they do this ?
the keycapture functions in SymbianOS may do it without any sweat.

The background app, gets they keys first, and then "recycle" them in the event stack (so that your app will receive them).
Thu, 2006-03-30 16:49
Joined: 2006-03-14
Forum posts: 2
Re: how they do this ?
Any suggestions for how to create such an application working in the background and creating a valid window for the "animation" pluggin?



Wed, 2006-04-05 10:54
Joined: 2004-11-29
Forum posts: 1246
Re: how they do this ?
I use code along these lines for the window:

Code:
RWindowGroup* DummyWindowGroup = new (ELeave) RWindowGroup(WsSession);
TUint32 h = (TUint32)DummyWindowGroup;
User::LeaveIfError(DummyWindowGroup->Construct(h,EFalse));
DummyWindowGroup->SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront );

RWindow* DummyWindow = new (ELeave) RWindow(WsSession);
User::LeaveIfError(DummyWindow->Construct(*DummyWindowGroup,(TUint32)DummyWindow));

RAnimDll* AnimDll = new (ELeave) RAnimDll(WsSession);
err = AnimDll->Load(KMyAnimDll);
RMyAnim* myAnim = new (ELeave) RMyAnim(*AnimDll,*DummyWindow);

The app/exe in the background could then be written in numerous ways depending on what other requirements you have.
Wed, 2006-04-05 16:34
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
Re: how they do this ?
Quote from: alh
Code:
RWindowGroup* DummyWindowGroup = new (ELeave) RWindowGroup(WsSession);
TUint32 h = (TUint32)DummyWindowGroup;
User::LeaveIfError(DummyWindowGroup->Construct(h,EFalse));
DummyWindowGroup->SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront );

RWindow* DummyWindow = new (ELeave) RWindow(WsSession);
User::LeaveIfError(DummyWindow->Construct(*DummyWindowGroup,(TUint32)DummyWindow));

RAnimDll* AnimDll = new (ELeave) RAnimDll(WsSession);
err = AnimDll->Load(KMyAnimDll);
RMyAnim* myAnim = new (ELeave) RMyAnim(*AnimDll,*DummyWindow);

Some optimisation:
- R objects usually don't require too much memory so you can simply put them on the stack. That is, don't use new (ELeave) with R objects, but a simple RAnimDll animDll will always do.
- If you still insist on having R objects allocated on the heap, then don't forget to use the cleanup stack properly. For example, above code is prone to error: if one function leaves then all other, previously created objects that are not on the cleanup stack will be lost resulting in a memory leak.

tOtE

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

Thu, 2006-04-06 08:28
Joined: 2004-11-29
Forum posts: 1246
Re: how they do this ?
Thanks for pointing it out. I wrote that code in a hurry Smiley

A thought though, how do you suggest to do the error handling in this case?

Just changeing to stack variables isn't enough to solve it all together is it?
Say that the creation of the DummyWindow fails and leaves.
Wouldn't that leave the DummyWindowGroup open (Close() is never called), resulting in a probable memory leak?

So I see it as..  Either allocate on heap and put on cleanupstack, and use leaveiferror,
or
Use stackvariables, and check all error codes, and call close on anything needing it for every function.
Thu, 2006-04-06 20:04
Forum Nokia Champion
Joined: 2003-10-01
Forum posts: 723
Re: how they do this ?
Quote from: alh
So I see it as..  Either allocate on heap and put on cleanupstack, and use leaveiferror,
or
Use stackvariables, and check all error codes, and call close on anything needing it for every function.

Correct.  Wink

Gabor Torok
Software architect, Agil Eight (http://www.agileight.com/)
Blog: http://mobile-thoughts.blogspot.com/

  • Login to reply to this topic.