Source/EventHandler.h

/*
    File:       EventHandler.h
 
    Contains:   xxx put contents here xxx
 
    Version:    xxx put version here xxx
 
    Copyright:  © 1998 by Apple Computer, Inc., all rights reserved.
 
    File Ownership:
 
        DRI:                xxx put dri here xxx
 
        Other Contact:      xxx put other contact here xxx
 
        Technology:         xxx put technology here xxx
 
    Writers:
 
        (cjd)   Chris DeSalvo
        (sjb)   Steve Bollinger
 
    Change History (most recent first):
 
        <10>      7/1/98    cjd     Added CPU load axis to InputSprocket data set
         <9>     6/18/98    sjb     InputSprocket.h comes from <> place
         <8>     6/12/98    sjb     First checked in.
*/
 
//¥ ------------------------------------------------------------------------------------------  ¥
//¥
//¥ Copyright © 1996 Apple Computer, Inc., All Rights Reserved
//¥
//¥
//¥     You may incorporate this sample code into your applications without
//¥     restriction, though the sample code has been provided "AS IS" and the
//¥     responsibility for its operation is 100% yours.  However, what you are
//¥     not permitted to do is to redistribute the source as "DSC Sample Code"
//¥     after having made changes. If you're going to re-distribute the source,
//¥     we require that you make it clear in the source that the code was
//¥     descended from Apple Sample Code, but that you've made changes.
//¥
//¥     Authors:
//¥         Chris De Salvo
//¥         Michael Evans
//¥
//¥ ------------------------------------------------------------------------------------------  ¥
 
#ifndef __EVENT_HANDLER__
#define __EVENT_HANDLER__
 
//¥ ------------------------------  Includes
 
#include <Events.h>
#include <InputSprocket.h>
 
//¥ ------------------------------  Public Definitions
//¥ ------------------------------  Public Types
 
enum
{
    greenMovement,
    greenFire,
    redMovement,
    redFire,
    abort,
    soundToggle,
    soundSprocketThrottle,
    numInputs
};
 
typedef Boolean (*EventHandlerProc)(EventRecord *theEvent);
 
typedef struct EventHandlerSet
{
    EventHandlerProc keyHandler;
    EventHandlerProc autoKeyHandler;
    EventHandlerProc clickHandler;
    EventHandlerProc updateHandler;
    EventHandlerProc diskHandler;
    EventHandlerProc idleHandler;
} EventHandlerSet;
 
typedef struct GameKeys
{
    Boolean greenLeft;
    Boolean greenRight;
    Boolean greenFire;
    Boolean redLeft;
    Boolean redRight;
    Boolean redFire;
    float   greenMove;
    float   redMove;
} GameKeys, *GameKeysPtr;
 
//¥ ------------------------------  Public Variables
 
extern Boolean gDone;
extern SInt32 gDeltaTime;
extern EventHandlerSet gEventHandlers;
extern ISpElementReference gInputElements[];
extern GameKeys gGameKeys;
 
//¥ ------------------------------  Public Functions
 
#ifdef __cplusplus
extern "C" {
#endif
 
extern short EventInit(void);
extern void EventLoop(void);
extern void RegisterEventHandlers(EventHandlerProc keyDown, EventHandlerProc autoKey, EventHandlerProc mouseDown,
                            EventHandlerProc update, EventHandlerProc idle);
extern void ModifyEventHandlers(EventHandlerProc keyDown, EventHandlerProc autoKey, EventHandlerProc mouseDown,
                            EventHandlerProc update, EventHandlerProc idle);
 
#ifdef __cplusplus
}
#endif
 
#endif