[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference 7.286::atarist

Title:Atari ST, TT, & Falcon
Notice:Please read note 1.0 and its replies before posting!
Moderator:FUNYET::ANDERSON
Created:Mon Apr 04 1988
Last Modified:Tue May 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:1433
Total number of notes:10312

180.0. "Trap a key press?" by STAR::HEERMANCE (Mars needs RMS developers!) Tue Aug 02 1988 11:25

    I have a program which needs to be able to halt when the user hits
    the undo or ^Y key even if it's in the middle of an evaluation.  I
    am hoping that a transparent mechanism exists to do this.  The only
    method I can currently think of is the get_event call but that will
    slow down evaluation.
    
    The program is in Personal Pascal.
    
    Any ideas?
    
    Martin H.
T.RTitleUserPersonal
Name
DateLines
180.1Don't call EventMultiple too often.PANGLS::BAILEYTue Aug 02 1988 16:4513
    It depends upon how gritty you want to get.
    
    The only ``portable'' approach is with an EventMultiple call.  The
    best way to put an EventMultiple in a loop which is performance
    sensitive is to only call it every second or so.  The performance
    really does get bad if you call it frequently.
    
    Your other option is to put a wedge into one of the keyboard interupt
    handlers.  Look in the XBIOS docs for how to do that.  I'm not sure
    that its really all that difficult to do this.
    
    Steph
    
180.2BconstatPRNSYS::LOMICKAJJeff LomickaFri Aug 05 1988 12:233
Bconstat() is a pretty cheap service to detect if there is any typeahead
on the console.

180.3^Y detect or typeaheadMILRAT::WALLACEFri Aug 05 1988 13:087
    That implies that your program can't take advantage of typeahead
    and detect ^Y at the same time. Also using Bconstat() means you
    need a call to it (or appropriate handler routine) in every "loop"
    in your program. It would be much nicer (though maybe not possible)
    to have an AST type ^Y detection.
    
    	Ray
180.4Bconout() versus get_event()MILRAT::WALLACEFri Aug 05 1988 13:1310
    Just reRead the original note (should have done that before my reply
    to Jeffs suggestion)...  Since Martin mentions the use of get_event()
    and it being slow, I would concurr with Jeff that Bconstat() would
    be a good (faster) alternative to get_event().
    
    It would still be nice to be able to trap ^Y's asynchronously and
    without disturbing the rest of the typeahead buffer while whatching
    for the ^Y.
    
    	Ray
180.5A possibilityPRNSYS::LOMICKAJJeff LomickaMon Aug 08 1988 11:3414
>    It would still be nice to be able to trap ^Y's asynchronously and
>    without disturbing the rest of the typeahead buffer while whatching
>    for the ^Y.

Well, there are a few things you can try.  Note that I don't think you
will ever find a reasonable way of "signaling" the interrupt event in a
trappable way, but if you are willing to poll, there may be ways.  One
possibility would be to do an Iorec( 1), and poll the tail of the
buffer for the keyboard scan code of "^Y" to appear.  I don't believe
that this will actually work, because I think that there is another
level of buffering going on inside GEM that is below this level that
handles the ^C that is trapped by Cconout and Cconin.  It is, however,
worth a try.

180.6ISRs aren't necessarily all that hard.PANGLS::BAILEYMon Aug 08 1988 18:257
    Really, the only way to get asynchronous ^Y detection is to write
    a keyboard interrupt handler which check to see if the key is a
    ^Y, and if not, calls the old keyboard handler.
    
    Poling is a way of life in low-budget event-driven interfaces.
    
    Steph
180.7Other way around ?MOVIES::FORSTERMon Nov 07 1988 07:497
I know this is a bit late but...

I had a look at this and it seemed simpler to steal the KBD/MIDI ISR vector
and call the existing keyboard ISR first, then look at the IOREC when the
ISR returns. This requires a lot less coding.

Dave.