comparison include/SDL_events.h @ 911:04a403e4ccf5

Date: Mon, 3 May 2004 03:15:01 +0100 From: David Symmonds Subject: SDL Typedef Structs Hi, Thanks for the SDL libraries, I have been using them for about a year now and they are really brilliant. One thing that I have just found whilst using them through C++ (and needing forward declarations) is that when you typedef structs you sometimes use typedef struct Name { ... }Name; e.g. SDL_Surface and other times use typedef struct { ... }Name; e.g. SDL_Rect The first type works fine, when I define a header file I can just put 'struct Name;' at the top and use the Name throughout. However, the second type is harder to use in a header, and I haven't found a way yet, other than to include 'SDL.h' in the header file (undesirable). Would there be any harm in changing the definition of SDL_Rect and such like to the second form?
author Sam Lantinga <slouken@libsdl.org>
date Sun, 18 Jul 2004 22:57:40 +0000
parents cd0c77df70a4
children 02759105b989
comparison
equal deleted inserted replaced
910:4ab6d1fd028f 911:04a403e4ccf5
104 SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT) 104 SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT)
105 }; 105 };
106 #define SDL_ALLEVENTS 0xFFFFFFFF 106 #define SDL_ALLEVENTS 0xFFFFFFFF
107 107
108 /* Application visibility event structure */ 108 /* Application visibility event structure */
109 typedef struct { 109 typedef struct SDL_ActiveEvent {
110 Uint8 type; /* SDL_ACTIVEEVENT */ 110 Uint8 type; /* SDL_ACTIVEEVENT */
111 Uint8 gain; /* Whether given states were gained or lost (1/0) */ 111 Uint8 gain; /* Whether given states were gained or lost (1/0) */
112 Uint8 state; /* A mask of the focus states */ 112 Uint8 state; /* A mask of the focus states */
113 } SDL_ActiveEvent; 113 } SDL_ActiveEvent;
114 114
115 /* Keyboard event structure */ 115 /* Keyboard event structure */
116 typedef struct { 116 typedef struct SDL_KeyboardEvent {
117 Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */ 117 Uint8 type; /* SDL_KEYDOWN or SDL_KEYUP */
118 Uint8 which; /* The keyboard device index */ 118 Uint8 which; /* The keyboard device index */
119 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ 119 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
120 SDL_keysym keysym; 120 SDL_keysym keysym;
121 } SDL_KeyboardEvent; 121 } SDL_KeyboardEvent;
122 122
123 /* Mouse motion event structure */ 123 /* Mouse motion event structure */
124 typedef struct { 124 typedef struct SDL_MouseMotionEvent {
125 Uint8 type; /* SDL_MOUSEMOTION */ 125 Uint8 type; /* SDL_MOUSEMOTION */
126 Uint8 which; /* The mouse device index */ 126 Uint8 which; /* The mouse device index */
127 Uint8 state; /* The current button state */ 127 Uint8 state; /* The current button state */
128 Uint16 x, y; /* The X/Y coordinates of the mouse */ 128 Uint16 x, y; /* The X/Y coordinates of the mouse */
129 Sint16 xrel; /* The relative motion in the X direction */ 129 Sint16 xrel; /* The relative motion in the X direction */
130 Sint16 yrel; /* The relative motion in the Y direction */ 130 Sint16 yrel; /* The relative motion in the Y direction */
131 } SDL_MouseMotionEvent; 131 } SDL_MouseMotionEvent;
132 132
133 /* Mouse button event structure */ 133 /* Mouse button event structure */
134 typedef struct { 134 typedef struct SDL_MouseButtonEvent {
135 Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */ 135 Uint8 type; /* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
136 Uint8 which; /* The mouse device index */ 136 Uint8 which; /* The mouse device index */
137 Uint8 button; /* The mouse button index */ 137 Uint8 button; /* The mouse button index */
138 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ 138 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
139 Uint16 x, y; /* The X/Y coordinates of the mouse at press time */ 139 Uint16 x, y; /* The X/Y coordinates of the mouse at press time */
140 } SDL_MouseButtonEvent; 140 } SDL_MouseButtonEvent;
141 141
142 /* Joystick axis motion event structure */ 142 /* Joystick axis motion event structure */
143 typedef struct { 143 typedef struct SDL_JoyAxisEvent {
144 Uint8 type; /* SDL_JOYAXISMOTION */ 144 Uint8 type; /* SDL_JOYAXISMOTION */
145 Uint8 which; /* The joystick device index */ 145 Uint8 which; /* The joystick device index */
146 Uint8 axis; /* The joystick axis index */ 146 Uint8 axis; /* The joystick axis index */
147 Sint16 value; /* The axis value (range: -32768 to 32767) */ 147 Sint16 value; /* The axis value (range: -32768 to 32767) */
148 } SDL_JoyAxisEvent; 148 } SDL_JoyAxisEvent;
149 149
150 /* Joystick trackball motion event structure */ 150 /* Joystick trackball motion event structure */
151 typedef struct { 151 typedef struct SDL_JoyBallEvent {
152 Uint8 type; /* SDL_JOYBALLMOTION */ 152 Uint8 type; /* SDL_JOYBALLMOTION */
153 Uint8 which; /* The joystick device index */ 153 Uint8 which; /* The joystick device index */
154 Uint8 ball; /* The joystick trackball index */ 154 Uint8 ball; /* The joystick trackball index */
155 Sint16 xrel; /* The relative motion in the X direction */ 155 Sint16 xrel; /* The relative motion in the X direction */
156 Sint16 yrel; /* The relative motion in the Y direction */ 156 Sint16 yrel; /* The relative motion in the Y direction */
157 } SDL_JoyBallEvent; 157 } SDL_JoyBallEvent;
158 158
159 /* Joystick hat position change event structure */ 159 /* Joystick hat position change event structure */
160 typedef struct { 160 typedef struct SDL_JoyHatEvent {
161 Uint8 type; /* SDL_JOYHATMOTION */ 161 Uint8 type; /* SDL_JOYHATMOTION */
162 Uint8 which; /* The joystick device index */ 162 Uint8 which; /* The joystick device index */
163 Uint8 hat; /* The joystick hat index */ 163 Uint8 hat; /* The joystick hat index */
164 Uint8 value; /* The hat position value: 164 Uint8 value; /* The hat position value:
165 SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP 165 SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP
168 Note that zero means the POV is centered. 168 Note that zero means the POV is centered.
169 */ 169 */
170 } SDL_JoyHatEvent; 170 } SDL_JoyHatEvent;
171 171
172 /* Joystick button event structure */ 172 /* Joystick button event structure */
173 typedef struct { 173 typedef struct SDL_JoyButtonEvent {
174 Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */ 174 Uint8 type; /* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
175 Uint8 which; /* The joystick device index */ 175 Uint8 which; /* The joystick device index */
176 Uint8 button; /* The joystick button index */ 176 Uint8 button; /* The joystick button index */
177 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */ 177 Uint8 state; /* SDL_PRESSED or SDL_RELEASED */
178 } SDL_JoyButtonEvent; 178 } SDL_JoyButtonEvent;
179 179
180 /* The "window resized" event 180 /* The "window resized" event
181 When you get this event, you are responsible for setting a new video 181 When you get this event, you are responsible for setting a new video
182 mode with the new width and height. 182 mode with the new width and height.
183 */ 183 */
184 typedef struct { 184 typedef struct SDL_ResizeEvent {
185 Uint8 type; /* SDL_VIDEORESIZE */ 185 Uint8 type; /* SDL_VIDEORESIZE */
186 int w; /* New width */ 186 int w; /* New width */
187 int h; /* New height */ 187 int h; /* New height */
188 } SDL_ResizeEvent; 188 } SDL_ResizeEvent;
189 189
190 /* The "screen redraw" event */ 190 /* The "screen redraw" event */
191 typedef struct { 191 typedef struct SDL_ExposeEvent {
192 Uint8 type; /* SDL_VIDEOEXPOSE */ 192 Uint8 type; /* SDL_VIDEOEXPOSE */
193 } SDL_ExposeEvent; 193 } SDL_ExposeEvent;
194 194
195 /* The "quit requested" event */ 195 /* The "quit requested" event */
196 typedef struct { 196 typedef struct SDL_QuitEvent {
197 Uint8 type; /* SDL_QUIT */ 197 Uint8 type; /* SDL_QUIT */
198 } SDL_QuitEvent; 198 } SDL_QuitEvent;
199 199
200 /* A user-defined event type */ 200 /* A user-defined event type */
201 typedef struct { 201 typedef struct SDL_UserEvent {
202 Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */ 202 Uint8 type; /* SDL_USEREVENT through SDL_NUMEVENTS-1 */
203 int code; /* User defined event code */ 203 int code; /* User defined event code */
204 void *data1; /* User defined data pointer */ 204 void *data1; /* User defined data pointer */
205 void *data2; /* User defined data pointer */ 205 void *data2; /* User defined data pointer */
206 } SDL_UserEvent; 206 } SDL_UserEvent;
207 207
208 /* If you want to use this event, you should include SDL_syswm.h */ 208 /* If you want to use this event, you should include SDL_syswm.h */
209 struct SDL_SysWMmsg; 209 struct SDL_SysWMmsg;
210 typedef struct SDL_SysWMmsg SDL_SysWMmsg; 210 typedef struct SDL_SysWMmsg SDL_SysWMmsg;
211 typedef struct { 211 typedef struct SDL_SysWMEvent {
212 Uint8 type; 212 Uint8 type;
213 SDL_SysWMmsg *msg; 213 SDL_SysWMmsg *msg;
214 } SDL_SysWMEvent; 214 } SDL_SysWMEvent;
215 215
216 /* General event structure */ 216 /* General event structure */