Symbian 自动获取键盘锁状态事件(非RAknKeyLock方式)
2010-03-27 15:50:00 来源:WEB开发网Symbian自动获取键盘锁状态事件(非RAknKeyLock方式)
在知道这个方法之前,我做Mykeylock时就饱受键盘锁问题困扰,因为SDK提供的键盘锁API类RAknKeyLock中,只有主动获取当前键盘锁状态的函数,但是并没有自动关联键盘锁状态变化事件的功能,因此你要想知道当前键盘锁状态的话,你就不得不每次都查询一次,在很多时候都不太方便.
要感谢chenziteng大侠分享了如此精妙的方法,也是目前我能找到的最好办法了.以下是nokia论坛找到的原文,Yuelongr简要的翻译一下,献丑了:
Successful:
Let’s assume that the keylock state is saved in a Central Repository.
The S60 3rd Edition SDK FP2 emulator doesn't have keylock key, so I have to write code to lock/unlock keys (Everybody knows the RAknKeyLock).
Step 1. Start the emulator and then start the HelloKeyLock application, and then select the first command to enable keylock, and then search in the epoc32 folder for .cre files.
iKeyLock.EnableWithoutNote();
101f8765.cre is the only result, make a copy of it.
Step 2. Delete the 101f8765.cre and then restart the emulator, and then start the application, select the second command to enable and then disable keylock, search again.
iKeyLock.EnableWithoutNote();
iKeyLock.DisableWithoutNote();
Still only 101f8765.cre, make a copy
Step 3. Compare the two copies of the .cre files
Result: only one byte is different, when keylock is on the value is 1 and off is 0.
Step 4. Check the epoc32eleasewinscwudebzprivate10202be9101f8765.txt
Result: there are six keys with default value zero, so it hard to say which one is the keylock state.
Step 5. Select the third command to enable/disable keylock and then log the CenRep values
CRepository* cenrep = CRepository::NewLC(KCenRepUid);
iKeyLock.EnableWithoutNote();
for(TInt i=1; i<=6; i++)
{
TInt value=0;
TInt err = cenrep->Get(i, value);