In my app Secret! I have to erase the screen when the user switches the
device off, *before* SysHandleEvent() shuts the device off. Thus I also have
to handle backlight on/off myself. See code snippet below.
This app runs fine on all PalmOS versions <= 3.3
However, on POSE 3.0a3 with PalmOS35-Bld20-Color.rom, when I press the power
button for 1 second, the contrast slider pops up. The same happens when I
press the power button in the memopad application, so it might be a
bug/feature of the new ROM. (POSE with a 3.3 ROM works OK)
Regards,
Andreas
---------------
// code for gcc/PalmOS SDK 3.0
#include <System/KeyPrv.h> // for hardware backlight handling
#include <System/KeyMgr.h>
// cannot include hardware.h so declare trap here
Boolean HwrBacklight(Boolean set, Boolean newState)
SYS_TRAP(sysTrapHwrBacklight);
...
// main event handler
...
EvtGetEvent(&e, 100);
// special key handling
if (e.eType == keyDownEvent &&
(e.data.keyDown.modifiers & commandKeyMask)
&& insecretdata()) // inside the data form?
{
// user switched off or auto-off
// don't close when light-on
if(e.data.keyDown.chr==hardPowerChr)
{
// handle backlight
DWord hasBacklight=0;
FtrGet(sysFtrCreator, sysFtrNumBacklight, &hasBacklight);
if(hasBacklight)
{
DWord endTime = TimGetTicks() +
keyMinBacklightTicks;
do
{
if (!(KeyCurrentState() & keyBitPower))
break;
SysTaskDelay(1);
}
while (TimGetTicks() < endTime);
if (TimGetTicks() >= endTime)
{
// pressed power button long enough
Byte oldState;
oldState = HwrBacklight(false, false);
HwrBacklight(true, !oldState);
continue; // event loop
}
}
FrmEraseForm(FrmGetActiveForm()); // erase display now
FrmGotoForm(MainForm); // enqueue events, encrypt at
power-on
}
// auto-off
if(e.data.keyDown.chr==autoOffChr)
{
FrmEraseForm(FrmGetActiveForm());
FrmGotoForm(MainForm);
}
...
}
if(!SysHandleEvent(&e))
...
-------------------