I have an application which responds to the
sysNotifyVirtualCharHandlingEvent notification to poll the 4 main hard
keys.
------
SysNotifyVirtualCharHandlingType
*virtChar=SysNotifyVirtualCharHandlingType*)notData->notifyDetailsP;
// If not any hard, break immediately
if ((virtChar->keyDown.chr < vchrHard1) || (virtChar->keyDown.chr >
vchrHard4)) {
break;
}
// Exclude non-commandKeyMask modifier
if (virtChar->keyDown.modifiers != commandKeyMask) break;
notData->handled=HandleHardPressed(virtChar->keyDown.chr);
------
In HandleHardPressed(), KeySetMask() is called to avoid further event
generation by the hard keys and the number of times the button is pressed
is determined by polling the keys using KeyCurrentState().
------
switch(key) {
case (vchrHard1):
usedKey=keyBitHard1;
break;
case (vchrHard2):
usedKey=keyBitHard2;
break;
case (vchrHard3):
usedKey=keyBitHard3;
break;
case (vchrHard4):
usedKey=keyBitHard4;
break;
default:
return 0;
break;
}
// Set the key polled to not generate events.
savedKeyMask=KeySetMask(~usedKey);
while (1) {
UpdateFeedbackScreen(key-vchrHard1, count-1 , feedbackList);
// Wait for key to be released
while (KeyCurrentState() & usedKey) {
SysTaskDelay(SysTicksPerSecond()/50);
}
// Pause between presses
ticks=TimGetTicks()+ticksDelay;
while ((TimGetTicks()<ticks) && (!(KeyCurrentState() & usedKey))) {
SysTaskDelay(SysTicksPerSecond()/50);
}
// When key not pressed, break out of loop
if (!(KeyCurrentState() & usedKey)) {
break;
}
// Pressed again, increase count and remove key from event queue
count +=1;
// Break out when more than maxpresses
if (count > kMaxPresses) break;
}
KeySetMask(savedKeyMask);
------
This all seems to work on all devices and simulators, however it does not
seem to work on a real Tungsten-C as reported by one of my users. On this
device still multiple events seem to be generated.
Is anyone aware of a problem with KeySetMask() on a real Tungsten-C?
Thanks for the help,
Gerben Roosenboom
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/