Chris Faherty wrote:
>
> On 18-May-99 Alex Robinson wrote:
>
> > Chris,
> >
> > Remember that on OS version 2 and 1 the automatic power off is normally
> > done under interrupt and not with autoOffChr.
> >
> > You might keep the time/date display up to date by asking for events
> > every 30 seconds or so. OS V 3 allows you to put that timeout in the
> > call to EvtGetEvent(). Older OS's, I've observed, require -1 for the
> > timeout and your own logic to filter nilEvent's.
>
> I do update every 30 seconds or so, but I'm in the habit of turning on and
> looking at the screen immediately. I'm not sure of the difference you
> mention in EvtGetEvent(). I've been putting a 30*sysTicksPerSecond as the
> argument and only looking for the nilEvent. That appears to work fine on OS2
> & OS3. I don't have an OS1 device however.
>
> I still get an autoOffChr though on OS2 because that's what I use in xcopilot
> to test with. This is a breakpoint right after:
>
> EvtGetEvent(&e, eventTimeout);
> if (! SysHandleEvent(&e))
> if (! MenuHandleEvent(NULL, &e, &err))
> if (! ApplicationHandleEvent(&e))
> FrmDispatchEvent(&e);
>
> I let xcopilot go to sleep by itself, and then I pressed the on button.
> Inspecting 'e' following the above code shows that the autoOffChr was the
> last event received.
>
> gdb) p e.eType
> $7 = keyDownEvent
> (gdb) p e.data.keyDown
> $8 = {chr = 276, keyCode = 0, modifiers = 8}
>
> From Chars.h:
> #define autoOffChr 0x0114
>
> Likewise if I inspect 'e' after a hardPowerChr turned the unit off, I will
> see the hardPowerChr as the last 'e' before the SysHandlEvent() took control.
>
> /* Chris Faherty <[EMAIL PROTECTED]>, finger for PGP */
OS 2 and OS 1 call SysSleep() directly from the a routine named
PrvSystemTimerProc() when the device times out. OS 3 enqueues autoOffChr
at the same logical point in the code. I found that both under the
emulator and on real devices, I needed to simulate the OS 3 logic under
OS2 and 1 in order to "trap" auto/timeout power-off.
Can't explain your contrary experience. But then, I also found crashes
when calling EvtGetEvent() with a timeout other than 0 or -1 under OS V
1 (and 2?).
My experience, also, is that the emulator differs from the devices with
respect to generating nilEvent's; the emulator generates them in more
cases than the device.
Alex Robinson
[EMAIL PROTECTED]
-eom-