event.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _GEL_EVENT_H
00023 #define _GEL_EVENT_H
00024
00046 struct event;
00047 struct event_callout;
00048 struct event_def;
00049 typedef struct event_def *event_type;
00050 typedef struct event event;
00051 typedef struct event_callout event_callout;
00052
00053 extern unsigned long event_idle_counter;
00054
00062 struct event
00063 {
00065 event_type type;
00066
00068 unsigned short time;
00069
00071 unsigned short data;
00072 };
00073
00074 typedef void (* event_handler_t) (event_callout *, event *);
00075
00076 struct event_callout
00077 {
00078 struct event_callout *next;
00079 struct event_def *type;
00080 event_handler_t callback;
00081 void *data;
00082 };
00083
00084 struct event_def
00085 {
00086 struct event_callout *callouts;
00087 };
00088
00099 void
00100 event_initialize (event *queue, unsigned short size);
00101
00120 void
00121 event_post (event_type type, unsigned short data);
00122
00132 void
00133 event_add_callout (event_type type, event_callout *callout);
00134
00137 void
00138 event_remove_callout (event_callout *callout);
00139
00149 extern void event_register (event_type type, event_callout *callout,
00150 event_handler_t handler, void *client_data);
00151
00152 extern inline void
00153 event_register (event_type type, event_callout *callout,
00154 event_handler_t handler, void *client_data)
00155 {
00156 callout->callback = handler;
00157 callout->data = client_data;
00158 event_add_callout (type, callout);
00159 }
00160
00161 extern void event_unregister (event_callout *);
00162
00163 extern inline void
00164 event_unregister (event_callout *callout)
00165 {
00166 event_remove_callout (callout);
00167 }
00168
00169 extern unsigned char event_false;
00170
00171 extern void
00172 event_loop (unsigned long tick, unsigned char *bool);
00173
00174 extern void
00175 event_wait (unsigned long nticks, event_type type);
00176
00179 #endif
|