00001 /* 00002 Copyright Remco Bras 2007 00003 This file is part of RPGE. 00004 00005 RPGE is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 RPGE is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program. If not, see <http://www.gnu.org/licenses/> 00017 */ 00018 00019 #ifndef EVENT_H 00020 #define EVENT_H 00021 #include <SDL/SDL.h> 00022 #include <stdlib.h> 00023 #include <string.h> 00024 #include <libguile.h> 00025 #include "sequence.h" 00026 00027 00028 typedef struct 00029 { 00030 SCM type; 00031 SCM data; 00032 }event; 00033 00034 typedef struct 00035 { 00036 unsigned int index; 00037 char block; 00038 } user; 00039 00040 typedef struct 00041 { 00042 sequence events; 00043 sequence indices; 00044 /*We give all eventstacks their own mutex locks, to prevent having object-specific stacks lock each other out for no reason.*/ 00045 SDL_mutex* lock; 00046 /*Basically, threads block on this if they want to wait for events to pop up*/ 00047 SDL_cond* block; 00048 } eventstack; 00049 00050 extern eventstack global_usereventstack; 00051 00052 eventstack eventstack_init(); 00053 void eventstack_clear(eventstack* stackptr); 00054 void eventstack_addevent(eventstack* stackptr, event event); 00055 event eventstack_getfirstevent(eventstack* stackptr); 00056 event make_event(SCM type, SCM data); 00057 unsigned long int eventstack_open(eventstack* es,char block); 00058 void eventstack_close(eventstack* es,unsigned long int luser); 00059 event evenstack_get_next_event(eventstack es, unsigned long int luser); 00060 int eventstack_get_index_of_user(eventstack es, unsigned long int luser); 00061 event eventstack_get_first_of_user(eventstack* es, unsigned long int luser); 00062 #endif