comparison include/SDL_events.h @ 3191:91b335df6fc8

Fixed bug #750 Since many different event structures include windowID it should be placed near the beginning of the structure (preferably right after type) so it's position is the same between different events. This is to avoid code like this: if (event.type == SDL_WINDOWEVENT) win = event.window.windowID; else if ((SDL_EVENTMASK(event.type) & SDL_KEYEVENTMASK) != 0) win = event.key.windowID; else if (event.type == SDL_TEXTINPUT) win = event.text.windowID; else if (event.type == SDL_MOUSEMOTION) win = event.motion.windowID; else if ((SDL_EVENTMASK(event.type) & (SDL_MOUBUTTONDOWNMASK | SDL_MOUBUTTONUPMASK)) != 0) win = event.button.windowID; else if (event.type == SDL_MOUSEWHEEL) win = event.wheel.windowID; ... in favor of: win = event.window.windowID;
author Sam Lantinga <slouken@libsdl.org>
date Wed, 10 Jun 2009 14:00:21 +0000
parents 0c85abc61e47
children 00cace2d9080
comparison
equal deleted inserted replaced
3190:c68d2ca5970f 3191:91b335df6fc8
126 * \brief Window state change event data (event.window.*) 126 * \brief Window state change event data (event.window.*)
127 */ 127 */
128 typedef struct SDL_WindowEvent 128 typedef struct SDL_WindowEvent
129 { 129 {
130 Uint8 type; /**< SDL_WINDOWEVENT */ 130 Uint8 type; /**< SDL_WINDOWEVENT */
131 SDL_WindowID windowID; /**< The associated window */
131 Uint8 event; /**< SDL_WindowEventID */ 132 Uint8 event; /**< SDL_WindowEventID */
132 int data1; /**< event dependent data */ 133 int data1; /**< event dependent data */
133 int data2; /**< event dependent data */ 134 int data2; /**< event dependent data */
134 SDL_WindowID windowID; /**< The associated window */
135 } SDL_WindowEvent; 135 } SDL_WindowEvent;
136 136
137 /** 137 /**
138 * \struct SDL_KeyboardEvent 138 * \struct SDL_KeyboardEvent
139 * 139 *
140 * \brief Keyboard button event structure (event.key.*) 140 * \brief Keyboard button event structure (event.key.*)
141 */ 141 */
142 typedef struct SDL_KeyboardEvent 142 typedef struct SDL_KeyboardEvent
143 { 143 {
144 Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */ 144 Uint8 type; /**< SDL_KEYDOWN or SDL_KEYUP */
145 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
145 Uint8 which; /**< The keyboard device index */ 146 Uint8 which; /**< The keyboard device index */
146 Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ 147 Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
147 SDL_keysym keysym; /**< The key that was pressed or released */ 148 SDL_keysym keysym; /**< The key that was pressed or released */
148 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
149 } SDL_KeyboardEvent; 149 } SDL_KeyboardEvent;
150 150
151 /** 151 /**
152 * \struct SDL_TextInputEvent 152 * \struct SDL_TextInputEvent
153 * 153 *
155 */ 155 */
156 #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32) 156 #define SDL_TEXTINPUTEVENT_TEXT_SIZE (32)
157 typedef struct SDL_TextInputEvent 157 typedef struct SDL_TextInputEvent
158 { 158 {
159 Uint8 type; /**< SDL_TEXTINPUT */ 159 Uint8 type; /**< SDL_TEXTINPUT */
160 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
160 Uint8 which; /**< The keyboard device index */ 161 Uint8 which; /**< The keyboard device index */
161 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */ 162 char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; /**< The input text */
162 SDL_WindowID windowID; /**< The window with keyboard focus, if any */
163 } SDL_TextInputEvent; 163 } SDL_TextInputEvent;
164 164
165 /** 165 /**
166 * \struct SDL_MouseMotionEvent 166 * \struct SDL_MouseMotionEvent
167 * 167 *
168 * \brief Mouse motion event structure (event.motion.*) 168 * \brief Mouse motion event structure (event.motion.*)
169 */ 169 */
170 typedef struct SDL_MouseMotionEvent 170 typedef struct SDL_MouseMotionEvent
171 { 171 {
172 Uint8 type; /**< SDL_MOUSEMOTION */ 172 Uint8 type; /**< SDL_MOUSEMOTION */
173 SDL_WindowID windowID; /**< The window with mouse focus, if any */
173 Uint8 which; /**< The mouse device index */ 174 Uint8 which; /**< The mouse device index */
174 Uint8 state; /**< The current button state */ 175 Uint8 state; /**< The current button state */
175 int x; /**< X coordinate, relative to window */ 176 int x; /**< X coordinate, relative to window */
176 int y; /**< Y coordinate, relative to window */ 177 int y; /**< Y coordinate, relative to window */
177 int z; /**< Z coordinate, for future use */ 178 int z; /**< Z coordinate, for future use */
181 int rotation; /**< For future use */ 182 int rotation; /**< For future use */
182 int tilt; /**< For future use */ 183 int tilt; /**< For future use */
183 int cursor; /**< The cursor being used in the event */ 184 int cursor; /**< The cursor being used in the event */
184 int xrel; /**< The relative motion in the X direction */ 185 int xrel; /**< The relative motion in the X direction */
185 int yrel; /**< The relative motion in the Y direction */ 186 int yrel; /**< The relative motion in the Y direction */
187 } SDL_MouseMotionEvent;
188
189 /**
190 * \struct SDL_MouseButtonEvent
191 *
192 * \brief Mouse button event structure (event.button.*)
193 */
194 typedef struct SDL_MouseButtonEvent
195 {
196 Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
186 SDL_WindowID windowID; /**< The window with mouse focus, if any */ 197 SDL_WindowID windowID; /**< The window with mouse focus, if any */
187 } SDL_MouseMotionEvent;
188
189 /**
190 * \struct SDL_MouseButtonEvent
191 *
192 * \brief Mouse button event structure (event.button.*)
193 */
194 typedef struct SDL_MouseButtonEvent
195 {
196 Uint8 type; /**< SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
197 Uint8 which; /**< The mouse device index */ 198 Uint8 which; /**< The mouse device index */
198 Uint8 button; /**< The mouse button index */ 199 Uint8 button; /**< The mouse button index */
199 Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */ 200 Uint8 state; /**< SDL_PRESSED or SDL_RELEASED */
200 int x; /**< X coordinate, relative to window */ 201 int x; /**< X coordinate, relative to window */
201 int y; /**< Y coordinate, relative to window */ 202 int y; /**< Y coordinate, relative to window */
203 } SDL_MouseButtonEvent;
204
205 /**
206 * \struct SDL_MouseWheelEvent
207 *
208 * \brief Mouse wheel event structure (event.wheel.*)
209 */
210 typedef struct SDL_MouseWheelEvent
211 {
212 Uint8 type; /**< SDL_MOUSEWHEEL */
202 SDL_WindowID windowID; /**< The window with mouse focus, if any */ 213 SDL_WindowID windowID; /**< The window with mouse focus, if any */
203 } SDL_MouseButtonEvent;
204
205 /**
206 * \struct SDL_MouseWheelEvent
207 *
208 * \brief Mouse wheel event structure (event.wheel.*)
209 */
210 typedef struct SDL_MouseWheelEvent
211 {
212 Uint8 type; /**< SDL_MOUSEWHEEL */
213 Uint8 which; /**< The mouse device index */ 214 Uint8 which; /**< The mouse device index */
214 int x; /**< The amount scrolled horizontally */ 215 int x; /**< The amount scrolled horizontally */
215 int y; /**< The amount scrolled vertically */ 216 int y; /**< The amount scrolled vertically */
216 SDL_WindowID windowID; /**< The window with mouse focus, if any */
217 } SDL_MouseWheelEvent; 217 } SDL_MouseWheelEvent;
218 218
219 /** 219 /**
220 * \struct SDL_JoyAxisEvent 220 * \struct SDL_JoyAxisEvent
221 * 221 *
290 * \brief A user-defined event type (event.user.*) 290 * \brief A user-defined event type (event.user.*)
291 */ 291 */
292 typedef struct SDL_UserEvent 292 typedef struct SDL_UserEvent
293 { 293 {
294 Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */ 294 Uint8 type; /**< SDL_USEREVENT through SDL_NUMEVENTS-1 */
295 SDL_WindowID windowID; /**< The associated window if any*/
295 int code; /**< User defined event code */ 296 int code; /**< User defined event code */
296 void *data1; /**< User defined data pointer */ 297 void *data1; /**< User defined data pointer */
297 void *data2; /**< User defined data pointer */ 298 void *data2; /**< User defined data pointer */
298 SDL_WindowID windowID; /**< The associated window if any*/
299 } SDL_UserEvent; 299 } SDL_UserEvent;
300 300
301 /** 301 /**
302 * \struct SDL_SysWMEvent 302 * \struct SDL_SysWMEvent
303 * 303 *
314 } SDL_SysWMEvent; 314 } SDL_SysWMEvent;
315 315
316 typedef struct SDL_ProximityEvent 316 typedef struct SDL_ProximityEvent
317 { 317 {
318 Uint8 type; 318 Uint8 type;
319 SDL_WindowID windowID; /**< The associated window */
319 Uint8 which; 320 Uint8 which;
320 int cursor; 321 int cursor;
321 int x; 322 int x;
322 int y; 323 int y;
323 } SDL_ProximityEvent; 324 } SDL_ProximityEvent;