[comp.sys.mac.programmer] How can I get Instantaneous Response from an Init that uses GNEfilter to look for keyboard events?

domenikos@emass1.enet.dec.com (George Domenikos) (09/01/90)

Hi there,

I am having an INIT that installs its self successfully and is using the 
GNEfilter method to look for events such as keyboard and perform certain
action when a certain key sequence is pressed.


Question how can I get my INIT  to process events immediatelly?


It seems that when I am compiling or linking something using MPW the events
are queued and the GNEfilter  processes the events after the compiling or 
linking is done.
How can I have instantaneous action all the time and not some times?
For example I have seen ScreenDumper applications doing that. They can jump
into the screendumper routine any time you press for instance shift-command-3
or whatever and they do not wait for a long compile or link to finish first.

HOW CAN I GET INSTANTANEOUS RESPONSE FROM THE GNE FILTER?
Do I have to install a VBL task for that that checks for Events all the time
and if a certain key is pressed can jump into my routine and performed
the desired action?
Do I have perhaps to raise the interrupt priority of the GNEfilter and how
can I do it?
Any help in the subject will be appreciated!


Thanks in advance

george domenikos

jackiw@cs.swarthmore.edu (Nick Jackiw) (09/02/90)

domenikos@emass1.enet.dec.com (George Domenikos) writes:
> HOW CAN I GET INSTANTANEOUS RESPONSE FROM THE GNE FILTER?

You can't. GetNextEvent is called when the application wants another
event.  If the app's hard at work, it's not going to call it, being
busy already.  Thus your GNEFilter won't get called either. Your
response rate is determined by the application; not by you.

Instead of using the GNE filter, try applying a headpatch to PostEvent or
PPostEvent.  These calls are made by the operating system at the moment
the event occurs; not at the moment the application choses to hear
about it.



-- 
---
jackiw@cs.swarthmore.edu  |  Smoggo: Can you prevent the detonation of
jackiw@swarthmr.bitnet    |          the thermonuclear device?
Applelink: D3717          |   Jimbo: No ... I cannot.

murat@farcomp.UUCP (Murat Konar) (09/02/90)

In article <1896@mountn.dec.com> domenikos@emass1.enet.dec.com (George Domenikos) writes:
>
>HOW CAN I GET INSTANTANEOUS RESPONSE FROM THE GNE FILTER?


The key here is that your GNE filter will only get called when GetNextEvent
is called.  For instantaneous response, you will most likely have to go to
a VBL scheme as you suggested.  You are probably aware though that VBL tasks
may not make any toolbox calls that may result in heap compaction.

-- 
____________________________________________________________________
Have a day. :^|             
Murat N. Konar	
murat@farcomp.UUCP             -or-          farcomp!murat@apple.com

stevec@Apple.COM (Steve Christensen) (09/05/90)

In article <1896@mountn.dec.com> George Domenikos writes:
>I am having an INIT that installs its self successfully and is using the 
>GNEfilter method to look for events such as keyboard and perform certain
>action when a certain key sequence is pressed.
>[...]
>HOW CAN I GET INSTANTANEOUS RESPONSE FROM THE GNE FILTER?

You can't.  The GNE filter only gets called when GetNextEvent gets called,
so if an application is busy doing something else, it would have to wait.

>Do I have to install a VBL task for that that checks for Events all the time
>and if a certain key is pressed can jump into my routine and performed
>the desired action?

Well, you can certainly use a VBL task to see if a particular key combination
is being pressed.  However if you run from a VBL task, you can't use QuickDraw
or call the Memory Manager, or use any services that call either.  Instead,
your VBL task could setup a deferred task that would be called as soon as
the interrupt level returns to zero.

>Do I have perhaps to raise the interrupt priority of the GNEfilter and how
>can I do it?

Since it's only called thru GNE, changing interrupt priorities don't even
make sense here.

steve
-- 
____________________________________________________________________

  Steve Christensen             Internet:   stevec@goofy.apple.com
  Apple Computer, Inc.          AppleLink:  STEVEC
  20525 Mariani Ave, MS 81-CS   CompuServe: 76174,1712
  Cupertino, CA  95014

  "You just contradicted me."  "No I didn't."
____________________________________________________________________