/* inputhandler.c */
/* by Alex Livshits   26-Sep-87 */

#include <exec/types.h>
#include <exec/ports.h>
#include <exec/memory.h>
#include <exec/tasks.h>
#include <devices/input.h>
#include <devices/inputevent.h>

#define FKEY 0x23
#define PKEY 0x19


/* ====  EXPORT  ==== */
extern struct InputEvent *InputHandler();
/*****/

/* ==== IMPORT ===== */
extern APTR MyTask;
extern ULONG EVENT;
extern ULONG STOPFLAG;
extern int Suspend;
/****/


struct InputEvent
*InputHandler(ev, data)
   struct InputEvent *ev;
   struct MemEntry *data[];
{

    if (Suspend) return(ev);

    if (ev->ie_Class == IECLASS_RAWKEY)
    {
        if ((ev->ie_Code == FKEY) &&
            (ev->ie_Qualifier & (IEQUALIFIER_LALT|IEQUALIFIER_RALT)))
        {
            STOPFLAG=TRUE;
            ev->ie_Class=IECLASS_NULL;
            Signal(MyTask,EVENT);
            Suspend = TRUE;
        }
        else if ((ev->ie_Code==PKEY) &&
                 (ev->ie_Qualifier & (IEQUALIFIER_LALT|IEQUALIFIER_RALT)))
        {
             ev->ie_Class=IECLASS_NULL;
             Signal(MyTask,EVENT);
             Suspend=TRUE;
        }

    }

    return(ev);

}

