1 /*
2  * file event.h - xblast event queue
3  *
4  * $Id: event.h,v 1.14 2006/02/09 21:21:23 fzago Exp $
5  *
6  * Program XBLAST
7  * (C) by Oliver Vogel (e-mail: m.vogel@ndh.net)
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published
11  * by the Free Software Foundation; either version 2; or (at your option)
12  * any later version
13  *
14  * This program is distributed in the hope that it will be entertaining,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
17  * Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.
21  * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22  */
23 #ifndef XBLAST_EVENT_H
24 #define XBLAST_EVENT_H
25 
26 /*
27  * atoms for faster and secure string handling
28  */
29 typedef int XBAtom;
30 /* value for invalid atom */
31 #define ATOM_INVALID 0
32 
33 /*
34  * types of events xblast knows
35  */
36 typedef enum
37 {
38 	XBE_NONE,					/* no event */
39 	XBE_TIMER,					/* timer event */
40 	XBE_POLL,					/* it was undefined... */
41 	XBE_SOCKET_READ,			/* socket has become readable */
42 	XBE_SOCKET_WRITE,			/* socket has become writable */
43 	XBE_MENU,					/* menu key was pressed */
44 	XBE_ASCII,					/* ASCII character has been entered */
45 	XBE_CTRL,					/* Control character has been entered */
46 	XBE_CHAT,					/* Chat key has been entered */
47 	XBE_KEYSYM,					/* Key with given name has been pressed */
48 	XBE_XBLAST,					/* Special game has been pressed (exit/pause) */
49 	XBE_KEYB_1,					/* XBlast game key from keyboard 1 has been pressed/released */
50 	XBE_KEYB_2,					/* XBlast game key from keyboard 2 has been pressed/released */
51 	XBE_JOYST_1,				/* XBlast game key from joystick 1 has been pressed/released */
52 	XBE_JOYST_2,				/* XBlast game key from joystick 2 has been pressed/released */
53 	XBE_JOYST_3,				/* XBlast game key from joystick 3 has been pressed/released */
54 	XBE_JOYST_4,				/* XBlast game key from joystick 4 has been pressed/released */
55 	XBE_MOUSE_1,				/* Mouse Button 1 has been pressed */
56 	XBE_MOUSE_2,				/* Mouse Button 2 has been pressed */
57 	XBE_MOUSE_3,				/* Mouse Button 3 has been pressed */
58 	XBE_RMOUSE_1,				/* Mouse Button 1 has been released */
59 	XBE_RMOUSE_2,				/* Mouse Button 2 has been released  */
60 	XBE_RMOUSE_3,				/* Mouse Button 3 has been released  */
61 	XBE_MOUSE_MOVE,				/* Mouse has been moved */
62 	XBE_SERVER,					/* server has send data for next frame */
63 	NUM_XBE
64 } XBEventCode;
65 
66 /*
67  * menu key events
68  */
69 typedef enum
70 {
71 	XBMK_NONE,					/* nothing */
72 	XBMK_PREV,					/* goto to previous field */
73 	XBMK_NEXT,					/* goto to next field */
74 	XBMK_LEFT,					/* goto left field */
75 	XBMK_RIGHT,					/* goto right field */
76 	XBMK_UP,					/* goto upper field */
77 	XBMK_DOWN,					/* goto lower field */
78 	XBMK_SELECT,				/* select current field */
79 	XBMK_DEFAULT,				/* select default button */
80 	XBMK_ABORT,					/* abort current menu */
81 	NUM_XBMENUKEY
82 } XBMenuKey;
83 
84 /*
85  * control key events
86  */
87 typedef enum
88 {
89 	XBCK_NONE,					/* nothing */
90 	XBCK_RETURN,				/* return key or similar */
91 	XBCK_ESCAPE,				/* escape key or similar */
92 	XBCK_BACKSPACE,				/* backspace key or similar */
93 	XBCK_INSERT,				/* INSERT key or similar */
94 	XBCK_END,					/* END key or similar */
95 	XBCK_DELETE,				/* DELETE key or similar */
96 	XBCK_HOME,					/* HOME key or similar */
97 } XBCtrlKey;
98 
99 typedef enum
100 {
101 	XBXK_NONE,
102 	XBXK_EXIT					/* leave game immediately */
103 } XBXBlastKey;
104 
105 /*
106  * game key events
107  */
108 typedef enum
109 {
110 	XBGK_NONE,					/* nothing */
111 	XBGK_GO_UP,					/* start moving upwards */
112 	XBGK_GO_LEFT,				/* start moving left */
113 	XBGK_GO_DOWN,				/* start moving downwards */
114 	XBGK_GO_RIGHT,				/* start moving right */
115 	XBGK_STOP_UP,				/* stop moving upwards (when not using stop key) */
116 	XBGK_STOP_LEFT,				/* stop moving left (when not using stop key) */
117 	XBGK_STOP_DOWN,				/* stop moving downwards (when not using stop key) */
118 	XBGK_STOP_RIGHT,			/* stop moving right (when not using stop key) */
119 	XBGK_STOP_ALL,				/* stop moving (only when using sttop key) */
120 	XBGK_BOMB,					/* drop a bomb */
121 	XBGK_SPECIAL,				/* activate special extra */
122 	XBGK_PAUSE,					/* activate game pause */
123 	XBGK_ABORT,					/* activate abort */
124 	XBGK_ABORT_CANCEL,			/* cancel abort */
125 	/* Skywalker */
126 	XBGK_LAOLA,					/*  activate laola */
127 	XBGK_LOOSER,				/* activate looser */
128 	XBGK_BOT,					/* activate looser */
129 	NUM_XBGK
130 		/* */
131 } XBGameKey;
132 
133 /*
134  * chat key events
135  */
136 typedef enum
137 {
138 	XBCE_NONE,					/* no chat event */
139 	XBCE_START,					/* start chatting */
140 	XBCE_SEND,					/* send line */
141 	XBCE_CANCEL,				/* cancel line */
142 	XBCE_CHANGE,				/* change target */
143 	XBCE_BACK,					/* backspace a character */
144 	XBCE_ESCAPE,				/* escape pressed in chat */
145 	XBCE_ENTER,					/* enter pressed in chat */
146 	NUM_XBCE
147 } XBChatEvent;
148 
149 /*
150  * server events
151  */
152 typedef enum
153 {
154 	XBSE_FINISH = -2,			/* finish level */
155 	XBSE_ERROR = -1,			/* error in communication */
156 	XBSE_NONE					/* nothing */
157 } XBServerEvent;
158 
159 /*
160  * additional data for events
161  */
162 typedef union
163 {
164 	int value;
165 	void *ptr;
166 	XBAtom atom;
167 	struct
168 	{
169 		short x;
170 		short y;
171 	} pos;
172 } XBEventData;
173 
174 /*
175  * global prototypes
176  */
177 extern XBEventCode NextEvent (XBEventData * data);
178 extern XBBool QueueEventVoid (XBEventCode code);
179 extern XBBool QueueEventValue (XBEventCode code, int value);
180 extern XBBool QueueEventPointer (XBEventCode code, void *ptr);
181 extern XBBool QueueEventPos (XBEventCode code, short x, short y);
182 extern XBBool QueueEventAtom (XBEventCode code, XBAtom atom);
183 
184 #endif
185 /*
186  * end of file event.h
187  */
188