S60 3rd edition
The button events of media keys cannot be detected by conventional means, which is different from other key events. Media keys, such as play/pause, stop, high/low volume, forward and backward keys, are new features of the s60 third-edition mobile phone and do not generate general button events, to be captured by the program framework, such as handlekeyeventl () and offerkeyeventl ().
Solution:
You can use the remote control API to process key events.
The following code snippet demonstrates how to handle the problem:
Cremconinterfaceselector </P> <p> cremconcoreapitarget </P> <p> mremconcoreapitargetobserver </P> <p> Remote Control API requires readuserdata capability. </P> <p> // ------------------------------------------------------------------------------ </P> <p> # include <remconcoreapitargetobserver. h> // link against remconcoreapi. lib </P> <p> # include <remconcoreapitarget. h> // and </P> <p> # include <remconinterfaceselector. h> // remconinterfacebase. lib </P> <p> class cmediakeystestui: Public caknappui, public mremconcoreapitargetobserver </P> <p >{</P> <p>... </P> <p> // from example </P> <p> void mrccatocommand (tremconcoreapioperationid aoperationid, </P> <p> tremconcoreapibuttonaction abuttonact ); </P> <p> // following functions from mremconcoreapitargetobserver are not needed </P> <p> // in this case-> use empty implementations for these: </P> <p> // mrccatoplay </P> <p> // mrccatotunefunction </P> <p> // mrccatoselectdiskfunction </P> <p> // mrccatoselectavinputfunction </P> <p> // mrccatoselectaudioinputfunction </P> <p> PRIVATE: </P> <p> cremconinterfaceselector * iinterfaceselector; </P> <p> cremconcoreapitarget * icoretarget; </P> <p> }; </P> <p> void cmediakeystestui: constructl () </P> <p >{</P> <p>... </P> <p> iinterfaceselector = cremconinterfaceselector: newl (); </P> <p> icoretarget = cremconcoreapitarget: newl (* iinterfaceselector, * This ); </P> <p> iinterfaceselector-> opentargetl (); </P> <p >}</P> <p> // ---------------------------------------------------------------------- </P> <p> // mrccatocommand () </P> <p> // attributes es events (Press/click/release) from the following buttons: </P> <p> // 'play/pause ', 'Volume up', 'Volume down', 'stop', 'rewind ', 'Forward '</P> <p> // forward </P> <p> void cmediakeystestui: mrccatocommand (effecaoperationid, </P> <p> tremconcoreapibuttonaction abuttonact) </P> <p >{</P> <p> trequeststatus; </P> <p> switch (aoperationid) </P> <p >{</P> <p> case eremconcoreapipauseplayfunction: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> case eremconcoreapibuttonpress: </P> <p> // play/pause button pressed </P> <p> break; </P> <p> case eremconcoreapibuttonrelease: </P> <p> // play/pause button released </P> <p> break; </P> <p> case eremconcoreapibuttonclick: </P> <p> // play/pause button clicked </P> <p> break; </P> <p> default: </P> <p> // play/pause unknown action </P> <p> break; </P> <p >}</P> <p> // send the response back to remcon server </P> <p> icoretarget-> pauseplayfunctionresponse (status, kerrnone); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> case eremconcoreapistop: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> // see above (Case eremconcoreapipauseplayfunction) </P> <p> // for possible actions </P> <p >}</P> <p> icoretarget-> stopresponse (status, kerrnone ); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> case eremconcoreapirewind: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> // see above for possible actions </P> <p >}</P> <p> icoretarget-> rewindresponse (status, kerrnone); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> case eremconcoreapiforward: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> // see above for possible actions </P> <p >}</P> <p> icoretarget-> forwardresponse (status, kerrnone); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> case eremconcoreapivolumeup: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> // see above for possible actions </P> <p >}</P> <p> icoretarget-> volumeupresponse (status, kerrnone); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> case eremconcoreapivolumedown: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> // see above for possible actions </P> <p >}</P> <p> icoretarget-> volumedownresponse (status, kerrnone); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> case eremconcoreapifastforward: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> // see above for possible actions </P> <p >}</P> <p> icoretarget-> fastforwardresponse (status, kerrnone); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> case eremconcoreapibackward: </P> <p >{</P> <p> switch (abuttonact) </P> <p >{</P> <p> // see above for possible actions </P> <p >}</P> <p> icoretarget-> backwardresponse (status, kerrnone); </P> <p> User: waitforrequest (Status); </P> <p> break; </P> <p >}</P> <p> default: </P> <p> break; </P> <p >}</P> <p>}
Note: When you press these keys, the media keys cannot automatically repeat these commands. If you need to repeat them, you need to complete a (cperiodic) timer by yourself.
Huwell: It's no wonder that a simulator like vnes cannot capture it. If we can use the media key with reference, what a good game machine N95 will be, huh, huh, from
Note:
If (iinterfaceselector)
Delete iinterfaceselector;
Iinterfaceselector = NULL;
Icoretarget = NULL;