home *** CD-ROM | disk | FTP | other *** search
- /*
- kbidle.c 10/02/87
-
- % kb_Idle
- Replaces normal kb_Read() function with new handler.
-
- OWL 1.1
- Copyright (c) 1987, 1988, 1989 by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 9/09/88 jmd Ported to oakland lib
- 9/19/88 jmd Added messages to idle func
- 10/04/88 jmd Added support for kb_Check
- 10/27/88 jmd Fixed bug in ReadHandler
- 12/01/88 jmd modified for new KeyReadEvent
- 2/07/89 Ted added timeout wait arg to hCheckEvent function.
- 7/07/89 gam changed NULL to FNULL where applicable
- */
-
- #include "oakhead.h"
- #include "disppriv.h"
- #include "kbidle.h"
-
- OSTATIC unsigned kb_ReadHandler(_arg1(moupos_struct *));
- OSTATIC unsigned kb_CheckHandler(_arg1(unsigned));
-
- /* static function pointers */
- static idle_fptr kIdle_fptr = FNULL;
- static dig_hReadEvent_func ((*hReadEventFptr)) = FNULL;
- static dig_hCheckEvent_func ((*hCheckEventFptr)) = FNULL;
- /* -------------------------------------------------------------------------- */
-
- void kb_Idle(idle)
- idle_fptr idle;
- /*
- Sets up idle key function.
-
- The idle function is called with an IDLE_START message.
-
- If idle == NULL turn off the idle function and call it with
- an IDLE_STOP message.
- */
- {
- if (hReadEventFptr != FNULL) {
- /* reset kb functions */
- (*kIdle_fptr)(IDLE_STOP);
- curr_dmgr->disp.dig.hReadEvent = hReadEventFptr;
- curr_dmgr->disp.dig.hCheckEvent = hCheckEventFptr;
- hReadEventFptr = FNULL;
- hCheckEventFptr = FNULL;
- kIdle_fptr = FNULL;
- }
-
- if (idle != FNULL) {
- /* save old keyboard handlers */
- hReadEventFptr = curr_dmgr->disp.dig.hReadEvent;
- hCheckEventFptr = curr_dmgr->disp.dig.hCheckEvent;
-
- /* set new keyboard handlers */
- curr_dmgr->disp.dig.hReadEvent = kb_ReadHandler;
- curr_dmgr->disp.dig.hCheckEvent = kb_CheckHandler;
- kIdle_fptr = idle;
- (*kIdle_fptr)(IDLE_START);
- }
- }
- /* -------------------------------------------------------------------------- */
-
- static unsigned kb_CheckHandler(wait)
- unsigned wait;
- /*
- Calls user idle function then calls original kb_Check routine
- idle function is called with an IDLE_RUN message.
- */
- {
- oak_notused(wait);
-
- (*kIdle_fptr)(IDLE_RUN);
- return((*hCheckEventFptr)(0));
- }
- /* -------------------------------------------------------------------------- */
-
- static unsigned int kb_ReadHandler(mposp)
- moupos_struct *mposp;
- /*
- Calls user idle function while real kb_Check routine returns FALSE.
- Calls original kb_Read when a keystroke is available
- idle function is called with an IDLE_RUN message.
- */
- {
- while (!(*hCheckEventFptr)(0)) {
- (*kIdle_fptr)(IDLE_RUN);
- }
- return((*hReadEventFptr)(mposp));
- }
- /* -------------------------------------------------------------------------- */
-
-