General improvements for user custom event registration
authorSam Lantinga <slouken@libsdl.org>
Thu, 25 Mar 2010 01:08:26 -0700
changeset 4429faa9fc8e7f67
parent 4428 68dfd6df47da
child 4432 77ebcd41b577
General improvements for user custom event registration

* Switched event type to enum (int32)
* Switched polling by mask to polling by type range
* Added SDL_RegisterEvents() to allow dynamic user event registration
* Spread events out to allow inserting new related events without breaking binary compatibility
* Added padding to event structures so they're the same size regardless of 32-bit compiler structure packing settings
* Split SDL_HasEvent() to SDL_HasEvent() for a single event and SDL_HasEvents() for a range of events
* Added SDL_GetEventState() as a shortcut for SDL_EventState(X, SDL_QUERY)
* Added SDL_FlushEvent() and SDL_FlushEvents() to clear events from the event queue
include/SDL_compat.h
include/SDL_events.h
src/SDL_compat.c
src/events/SDL_events.c
src/events/SDL_events_c.h
src/events/SDL_keyboard.c
src/events/SDL_mouse.c
src/events/SDL_quit.c
src/events/SDL_windowevents.c
src/joystick/SDL_joystick.c
src/video/win32/SDL_win32events.c
src/video/x11/SDL_x11events.c
test/threadwin.c
     1.1 --- a/include/SDL_compat.h	Wed Mar 10 15:07:20 2010 +0000
     1.2 +++ b/include/SDL_compat.h	Thu Mar 25 01:08:26 2010 -0700
     1.3 @@ -91,12 +91,34 @@
     1.4  #define SDL_LOGPAL 0x01
     1.5  #define SDL_PHYSPAL 0x02
     1.6  
     1.7 -#define SDL_ACTIVEEVENT	SDL_EVENT_RESERVED1
     1.8 -#define SDL_VIDEORESIZE	SDL_EVENT_RESERVED2
     1.9 -#define SDL_VIDEOEXPOSE	SDL_EVENT_RESERVED3
    1.10 -#define SDL_ACTIVEEVENTMASK	SDL_EVENTMASK(SDL_ACTIVEEVENT)
    1.11 -#define SDL_VIDEORESIZEMASK SDL_EVENTMASK(SDL_VIDEORESIZE)
    1.12 -#define SDL_VIDEOEXPOSEMASK SDL_EVENTMASK(SDL_VIDEOEXPOSE)
    1.13 +#define SDL_ACTIVEEVENT	SDL_EVENT_COMPAT1
    1.14 +#define SDL_VIDEORESIZE	SDL_EVENT_COMPAT2
    1.15 +#define SDL_VIDEOEXPOSE	SDL_EVENT_COMPAT3
    1.16 +#define SDL_ACTIVEEVENTMASK	SDL_ACTIVEEVENT, SDL_ACTIVEEVENT
    1.17 +#define SDL_VIDEORESIZEMASK SDL_VIDEORESIZE, SDL_VIDEORESIZE
    1.18 +#define SDL_VIDEOEXPOSEMASK SDL_VIDEOEXPOSE, SDL_VIDEOEXPOSE
    1.19 +#define SDL_WINDOWEVENTMASK SDL_WINDOWEVENT, SDL_WINDOWEVENT
    1.20 +#define SDL_KEYDOWNMASK SDL_KEYDOWN, SDL_KEYDOWN
    1.21 +#define SDL_KEYUPMASK SDL_KEYUP, SDL_KEYUP
    1.22 +#define SDL_KEYEVENTMASK SDL_KEYDOWN, SDL_KEYUP
    1.23 +#define SDL_TEXTEDITINGMASK SDL_TEXTEDITING, SDL_TEXTEDITING
    1.24 +#define SDL_TEXTINPUTMASK SDL_TEXTINPUT, SDL_TEXTINPUT
    1.25 +#define SDL_MOUSEMOTIONMASK SDL_MOUSEMOTION, SDL_MOUSEMOTION
    1.26 +#define SDL_MOUSEBUTTONDOWNMASK SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONDOWN
    1.27 +#define SDL_MOUSEBUTTONUPMASK SDL_MOUSEBUTTONUP, SDL_MOUSEBUTTONUP
    1.28 +#define SDL_MOUSEWHEELMASK SDL_MOUSEWHEEL, SDL_MOUSEWHEEL
    1.29 +#define SDL_MOUSEEVENTMASK SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP
    1.30 +#define SDL_JOYAXISMOTIONMASK SDL_JOYAXISMOTION, SDL_JOYAXISMOTION
    1.31 +#define SDL_JOYBALLMOTIONMASK SDL_JOYBALLMOTION, SDL_JOYBALLMOTION
    1.32 +#define SDL_JOYHATMOTIONMASK SDL_JOYHATMOTION, SDL_JOYHATMOTION
    1.33 +#define SDL_JOYBUTTONDOWNMASK SDL_JOYBUTTONDOWN, SDL_JOYBUTTONDOWN
    1.34 +#define SDL_JOYBUTTONUPMASK SDL_JOYBUTTONUP, SDL_JOYBUTTONUP
    1.35 +#define SDL_JOYEVENTMASK SDL_JOYAXISMOTION, SDL_JOYBUTTONUP
    1.36 +#define SDL_QUITMASK SDL_QUIT, SDL_QUIT
    1.37 +#define SDL_SYSWMEVENTMASK SDL_SYSWMEVENT, SDL_SYSWMEVENT
    1.38 +#define SDL_PROXIMITYINMASK SDL_PROXIMITYIN, SDL_PROXIMITYIN
    1.39 +#define SDL_PROXIMITYOUTMASK SDL_PROXIMITYOUT, SDL_PROXIMITYOUT
    1.40 +#define SDL_ALLEVENTS SDL_FIRSTEVENT, SDL_LASTEVENT
    1.41  
    1.42  #define SDL_BUTTON_WHEELUP	4
    1.43  #define SDL_BUTTON_WHEELDOWN	5
     2.1 --- a/include/SDL_events.h	Wed Mar 10 15:07:20 2010 +0000
     2.2 +++ b/include/SDL_events.h	Thu Mar 25 01:08:26 2010 -0700
     2.3 @@ -54,83 +54,67 @@
     2.4   */
     2.5  typedef enum
     2.6  {
     2.7 -    SDL_NOEVENT = 0,            /**< Unused (do not remove) */
     2.8 -    SDL_WINDOWEVENT,            /**< Window state change */
     2.9 -    SDL_KEYDOWN,                /**< Keys pressed */
    2.10 +    SDL_FIRSTEVENT     = 0,     /**< Unused (do not remove) */
    2.11 +
    2.12 +    /* Application events */
    2.13 +    SDL_QUIT           = 0x100, /**< User-requested quit */
    2.14 +
    2.15 +    /* Window events */
    2.16 +    SDL_WINDOWEVENT    = 0x200, /**< Window state change */
    2.17 +    SDL_SYSWMEVENT,             /**< System specific event */
    2.18 +
    2.19 +    /* Keyboard events */
    2.20 +    SDL_KEYDOWN        = 0x300, /**< Keys pressed */
    2.21      SDL_KEYUP,                  /**< Keys released */
    2.22      SDL_TEXTEDITING,            /**< Keyboard text editing (composition) */
    2.23      SDL_TEXTINPUT,              /**< Keyboard text input */
    2.24 -    SDL_MOUSEMOTION,            /**< Mouse moved */
    2.25 +
    2.26 +    /* Mouse events */
    2.27 +    SDL_MOUSEMOTION    = 0x400, /**< Mouse moved */
    2.28      SDL_MOUSEBUTTONDOWN,        /**< Mouse button pressed */
    2.29      SDL_MOUSEBUTTONUP,          /**< Mouse button released */
    2.30      SDL_MOUSEWHEEL,             /**< Mouse wheel motion */
    2.31 -    SDL_JOYAXISMOTION,          /**< Joystick axis motion */
    2.32 +
    2.33 +    /* Tablet events */
    2.34 +    SDL_PROXIMITYIN    = 0x500, /**< Proximity In event */
    2.35 +    SDL_PROXIMITYOUT,           /**< Proximity Out event */
    2.36 +
    2.37 +    /* Joystick events */
    2.38 +    SDL_JOYAXISMOTION  = 0x600, /**< Joystick axis motion */
    2.39      SDL_JOYBALLMOTION,          /**< Joystick trackball motion */
    2.40      SDL_JOYHATMOTION,           /**< Joystick hat position change */
    2.41      SDL_JOYBUTTONDOWN,          /**< Joystick button pressed */
    2.42      SDL_JOYBUTTONUP,            /**< Joystick button released */
    2.43 -    SDL_QUIT,                   /**< User-requested quit */
    2.44 -    SDL_SYSWMEVENT,             /**< System specific event */
    2.45 -    SDL_PROXIMITYIN,            /**< Proximity In event */
    2.46 -    SDL_PROXIMITYOUT,           /**< Proximity Out event */
    2.47 -    SDL_EVENT_RESERVED1,        /**< Reserved for future use... */
    2.48 -    SDL_EVENT_RESERVED2,        /**< Reserved for future use... */
    2.49 -    SDL_EVENT_RESERVED3,        /**< Reserved for future use... */
    2.50 -    /** Events ::SDL_USEREVENT through ::SDL_MAXEVENTS-1 are for your use */
    2.51 -    SDL_USEREVENT = 24,
    2.52 +
    2.53 +    /* Obsolete events */
    2.54 +    SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */
    2.55 +    SDL_EVENT_COMPAT2,
    2.56 +    SDL_EVENT_COMPAT3,
    2.57 +
    2.58 +    /** Events ::SDL_USEREVENT through ::SDL_LASTEVENT are for your use,
    2.59 +     *  and should be allocated with SDL_RegisterEvents()
    2.60 +     */
    2.61 +    SDL_USEREVENT    = 0x8000,
    2.62 +
    2.63      /**
    2.64       *  This last event is only for bounding internal arrays
    2.65 -     *  It is the number of bits in the event mask datatype -- Uint32
    2.66       */
    2.67 -    SDL_NUMEVENTS = 32
    2.68 +    SDL_LASTEVENT    = 0xFFFF
    2.69  } SDL_EventType;
    2.70  
    2.71 -/*@{*/
    2.72 -#define SDL_EVENTMASK(X)	(1<<(X))
    2.73 -/**
    2.74 - * \brief Predefined event masks
    2.75 - */
    2.76 -typedef enum
    2.77 -{
    2.78 -    SDL_WINDOWEVENTMASK = SDL_EVENTMASK(SDL_WINDOWEVENT),
    2.79 -    SDL_KEYDOWNMASK = SDL_EVENTMASK(SDL_KEYDOWN),
    2.80 -    SDL_KEYUPMASK = SDL_EVENTMASK(SDL_KEYUP),
    2.81 -    SDL_KEYEVENTMASK = SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP),
    2.82 -    SDL_TEXTEDITINGMASK = SDL_EVENTMASK(SDL_TEXTEDITING),
    2.83 -    SDL_TEXTINPUTMASK = SDL_EVENTMASK(SDL_TEXTINPUT),
    2.84 -    SDL_MOUSEMOTIONMASK = SDL_EVENTMASK(SDL_MOUSEMOTION),
    2.85 -    SDL_MOUSEBUTTONDOWNMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
    2.86 -    SDL_MOUSEBUTTONUPMASK = SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
    2.87 -    SDL_MOUSEWHEELMASK = SDL_EVENTMASK(SDL_MOUSEWHEEL),
    2.88 -    SDL_MOUSEEVENTMASK = SDL_EVENTMASK(SDL_MOUSEMOTION) |
    2.89 -        SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN) | SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
    2.90 -    SDL_JOYAXISMOTIONMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION),
    2.91 -    SDL_JOYBALLMOTIONMASK = SDL_EVENTMASK(SDL_JOYBALLMOTION),
    2.92 -    SDL_JOYHATMOTIONMASK = SDL_EVENTMASK(SDL_JOYHATMOTION),
    2.93 -    SDL_JOYBUTTONDOWNMASK = SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
    2.94 -    SDL_JOYBUTTONUPMASK = SDL_EVENTMASK(SDL_JOYBUTTONUP),
    2.95 -    SDL_JOYEVENTMASK = SDL_EVENTMASK(SDL_JOYAXISMOTION) |
    2.96 -        SDL_EVENTMASK(SDL_JOYBALLMOTION) |
    2.97 -        SDL_EVENTMASK(SDL_JOYHATMOTION) |
    2.98 -        SDL_EVENTMASK(SDL_JOYBUTTONDOWN) | SDL_EVENTMASK(SDL_JOYBUTTONUP),
    2.99 -    SDL_QUITMASK = SDL_EVENTMASK(SDL_QUIT),
   2.100 -    SDL_SYSWMEVENTMASK = SDL_EVENTMASK(SDL_SYSWMEVENT),
   2.101 -    SDL_PROXIMITYINMASK = SDL_EVENTMASK(SDL_PROXIMITYIN),
   2.102 -    SDL_PROXIMITYOUTMASK = SDL_EVENTMASK(SDL_PROXIMITYOUT)
   2.103 -} SDL_EventMask;
   2.104 -#define SDL_ALLEVENTS		0xFFFFFFFF
   2.105 -/*@}*/
   2.106 -
   2.107  /**
   2.108   *  \brief Window state change event data (event.window.*)
   2.109   */
   2.110  typedef struct SDL_WindowEvent
   2.111  {
   2.112 -    Uint8 type;             /**< ::SDL_WINDOWEVENT */
   2.113 -    Uint32 windowID;        /**< The associated window */
   2.114 -    Uint8 event;            /**< ::SDL_WindowEventID */
   2.115 -    int data1;              /**< event dependent data */
   2.116 -    int data2;              /**< event dependent data */
   2.117 +    Uint32 type;        /**< ::SDL_WINDOWEVENT */
   2.118 +    Uint32 windowID;    /**< The associated window */
   2.119 +    Uint8 event;        /**< ::SDL_WindowEventID */
   2.120 +    Uint8 padding1;
   2.121 +    Uint8 padding2;
   2.122 +    Uint8 padding3;
   2.123 +    int data1;          /**< event dependent data */
   2.124 +    int data2;          /**< event dependent data */
   2.125  } SDL_WindowEvent;
   2.126  
   2.127  /**
   2.128 @@ -138,11 +122,13 @@
   2.129   */
   2.130  typedef struct SDL_KeyboardEvent
   2.131  {
   2.132 -    Uint8 type;             /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
   2.133 -    Uint32 windowID;        /**< The window with keyboard focus, if any */
   2.134 -    Uint8 which;            /**< The keyboard device index */
   2.135 -    Uint8 state;            /**< ::SDL_PRESSED or ::SDL_RELEASED */
   2.136 -    SDL_keysym keysym;      /**< The key that was pressed or released */
   2.137 +    Uint32 type;        /**< ::SDL_KEYDOWN or ::SDL_KEYUP */
   2.138 +    Uint32 windowID;    /**< The window with keyboard focus, if any */
   2.139 +    Uint8 which;        /**< The keyboard device index */
   2.140 +    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
   2.141 +    Uint8 padding1;
   2.142 +    Uint8 padding2;
   2.143 +    SDL_keysym keysym;  /**< The key that was pressed or released */
   2.144  } SDL_KeyboardEvent;
   2.145  
   2.146  #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
   2.147 @@ -151,7 +137,7 @@
   2.148   */
   2.149  typedef struct SDL_TextEditingEvent
   2.150  {
   2.151 -    Uint8 type;                                 /**< ::SDL_TEXTEDITING */
   2.152 +    Uint32 type;                                /**< ::SDL_TEXTEDITING */
   2.153      char text[SDL_TEXTEDITINGEVENT_TEXT_SIZE];  /**< The editing text */
   2.154      int start;                                  /**< The start cursor of selected editing text */
   2.155      int length;                                 /**< The length of selected editing text */
   2.156 @@ -164,9 +150,12 @@
   2.157   */
   2.158  typedef struct SDL_TextInputEvent
   2.159  {
   2.160 -    Uint8 type;                               /**< ::SDL_TEXTINPUT */
   2.161 +    Uint32 type;                              /**< ::SDL_TEXTINPUT */
   2.162      Uint32 windowID;                          /**< The window with keyboard focus, if any */
   2.163      Uint8 which;                              /**< The keyboard device index */
   2.164 +    Uint8 padding1;
   2.165 +    Uint8 padding2;
   2.166 +    Uint8 padding3;
   2.167      char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];  /**< The input text */
   2.168  } SDL_TextInputEvent;
   2.169  
   2.170 @@ -175,22 +164,24 @@
   2.171   */
   2.172  typedef struct SDL_MouseMotionEvent
   2.173  {
   2.174 -    Uint8 type;             /**< ::SDL_MOUSEMOTION */
   2.175 -    Uint32 windowID;        /**< The window with mouse focus, if any */
   2.176 -    Uint8 which;            /**< The mouse device index */
   2.177 -    Uint8 state;            /**< The current button state */
   2.178 -    int x;                  /**< X coordinate, relative to window */
   2.179 -    int y;                  /**< Y coordinate, relative to window */
   2.180 -    int z;                  /**< Z coordinate, for future use */
   2.181 -    int pressure;           /**< Pressure reported by tablets */
   2.182 -    int pressure_max;       /**< Maximum value of the pressure reported by the device */
   2.183 -    int pressure_min;       /**< Minimum value of the pressure reported by the device */
   2.184 -    int rotation;           /**< For future use */
   2.185 -    int tilt_x;             /**< For future use */
   2.186 -    int tilt_y;             /**< For future use */
   2.187 -    int cursor;             /**< The cursor being used in the event */
   2.188 -    int xrel;               /**< The relative motion in the X direction */
   2.189 -    int yrel;               /**< The relative motion in the Y direction */
   2.190 +    Uint32 type;        /**< ::SDL_MOUSEMOTION */
   2.191 +    Uint32 windowID;    /**< The window with mouse focus, if any */
   2.192 +    Uint8 which;        /**< The mouse device index */
   2.193 +    Uint8 state;        /**< The current button state */
   2.194 +    Uint8 padding1;
   2.195 +    Uint8 padding2;
   2.196 +    int x;              /**< X coordinate, relative to window */
   2.197 +    int y;              /**< Y coordinate, relative to window */
   2.198 +    int z;              /**< Z coordinate, for future use */
   2.199 +    int pressure;       /**< Pressure reported by tablets */
   2.200 +    int pressure_max;   /**< Maximum value of the pressure reported by the device */
   2.201 +    int pressure_min;   /**< Minimum value of the pressure reported by the device */
   2.202 +    int rotation;       /**< For future use */
   2.203 +    int tilt_x;         /**< For future use */
   2.204 +    int tilt_y;         /**< For future use */
   2.205 +    int cursor;         /**< The cursor being used in the event */
   2.206 +    int xrel;           /**< The relative motion in the X direction */
   2.207 +    int yrel;           /**< The relative motion in the Y direction */
   2.208  } SDL_MouseMotionEvent;
   2.209  
   2.210  /**
   2.211 @@ -198,13 +189,14 @@
   2.212   */
   2.213  typedef struct SDL_MouseButtonEvent
   2.214  {
   2.215 -    Uint8 type;             /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
   2.216 -    Uint32 windowID;        /**< The window with mouse focus, if any */
   2.217 -    Uint8 which;            /**< The mouse device index */
   2.218 -    Uint8 button;           /**< The mouse button index */
   2.219 -    Uint8 state;            /**< ::SDL_PRESSED or ::SDL_RELEASED */
   2.220 -    int x;                  /**< X coordinate, relative to window */
   2.221 -    int y;                  /**< Y coordinate, relative to window */
   2.222 +    Uint32 type;        /**< ::SDL_MOUSEBUTTONDOWN or ::SDL_MOUSEBUTTONUP */
   2.223 +    Uint32 windowID;    /**< The window with mouse focus, if any */
   2.224 +    Uint8 which;        /**< The mouse device index */
   2.225 +    Uint8 button;       /**< The mouse button index */
   2.226 +    Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
   2.227 +    Uint8 padding1;
   2.228 +    int x;              /**< X coordinate, relative to window */
   2.229 +    int y;              /**< Y coordinate, relative to window */
   2.230  } SDL_MouseButtonEvent;
   2.231  
   2.232  /**
   2.233 @@ -212,21 +204,42 @@
   2.234   */
   2.235  typedef struct SDL_MouseWheelEvent
   2.236  {
   2.237 -    Uint8 type;             /**< ::SDL_MOUSEWHEEL */
   2.238 -    Uint32 windowID;        /**< The window with mouse focus, if any */
   2.239 -    Uint8 which;            /**< The mouse device index */
   2.240 -    int x;                  /**< The amount scrolled horizontally */
   2.241 -    int y;                  /**< The amount scrolled vertically */
   2.242 +    Uint32 type;        /**< ::SDL_MOUSEWHEEL */
   2.243 +    Uint32 windowID;    /**< The window with mouse focus, if any */
   2.244 +    Uint8 which;        /**< The mouse device index */
   2.245 +    Uint8 padding1;
   2.246 +    Uint8 padding2;
   2.247 +    Uint8 padding3;
   2.248 +    int x;              /**< The amount scrolled horizontally */
   2.249 +    int y;              /**< The amount scrolled vertically */
   2.250  } SDL_MouseWheelEvent;
   2.251  
   2.252  /**
   2.253 + * \brief Tablet pen proximity event
   2.254 + */
   2.255 +typedef struct SDL_ProximityEvent
   2.256 +{
   2.257 +    Uint32 type;        /**< ::SDL_PROXIMITYIN or ::SDL_PROXIMITYOUT */
   2.258 +    Uint32 windowID;    /**< The associated window */
   2.259 +    Uint8 which;
   2.260 +    Uint8 padding1;
   2.261 +    Uint8 padding2;
   2.262 +    Uint8 padding3;
   2.263 +    int cursor;
   2.264 +    int x;
   2.265 +    int y;
   2.266 +} SDL_ProximityEvent;
   2.267 +
   2.268 +/**
   2.269   *  \brief Joystick axis motion event structure (event.jaxis.*)
   2.270   */
   2.271  typedef struct SDL_JoyAxisEvent
   2.272  {
   2.273 -    Uint8 type;         /**< ::SDL_JOYAXISMOTION */
   2.274 +    Uint32 type;        /**< ::SDL_JOYAXISMOTION */
   2.275      Uint8 which;        /**< The joystick device index */
   2.276      Uint8 axis;         /**< The joystick axis index */
   2.277 +    Uint8 padding1;
   2.278 +    Uint8 padding2;
   2.279      int value;          /**< The axis value (range: -32768 to 32767) */
   2.280  } SDL_JoyAxisEvent;
   2.281  
   2.282 @@ -235,9 +248,11 @@
   2.283   */
   2.284  typedef struct SDL_JoyBallEvent
   2.285  {
   2.286 -    Uint8 type;         /**< ::SDL_JOYBALLMOTION */
   2.287 +    Uint32 type;        /**< ::SDL_JOYBALLMOTION */
   2.288      Uint8 which;        /**< The joystick device index */
   2.289      Uint8 ball;         /**< The joystick trackball index */
   2.290 +    Uint8 padding1;
   2.291 +    Uint8 padding2;
   2.292      int xrel;           /**< The relative motion in the X direction */
   2.293      int yrel;           /**< The relative motion in the Y direction */
   2.294  } SDL_JoyBallEvent;
   2.295 @@ -247,7 +262,7 @@
   2.296   */
   2.297  typedef struct SDL_JoyHatEvent
   2.298  {
   2.299 -    Uint8 type;         /**< ::SDL_JOYHATMOTION */
   2.300 +    Uint32 type;        /**< ::SDL_JOYHATMOTION */
   2.301      Uint8 which;        /**< The joystick device index */
   2.302      Uint8 hat;          /**< The joystick hat index */
   2.303      Uint8 value;        /**< The hat position value.
   2.304 @@ -257,6 +272,7 @@
   2.305                           *   
   2.306                           *   Note that zero means the POV is centered.
   2.307                           */
   2.308 +    Uint8 padding1;
   2.309  } SDL_JoyHatEvent;
   2.310  
   2.311  /**
   2.312 @@ -264,10 +280,11 @@
   2.313   */
   2.314  typedef struct SDL_JoyButtonEvent
   2.315  {
   2.316 -    Uint8 type;         /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
   2.317 +    Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
   2.318      Uint8 which;        /**< The joystick device index */
   2.319      Uint8 button;       /**< The joystick button index */
   2.320      Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
   2.321 +    Uint8 padding1;
   2.322  } SDL_JoyButtonEvent;
   2.323  
   2.324  /**
   2.325 @@ -275,7 +292,7 @@
   2.326   */
   2.327  typedef struct SDL_QuitEvent
   2.328  {
   2.329 -    Uint8 type;         /**< ::SDL_QUIT */
   2.330 +    Uint32 type;        /**< ::SDL_QUIT */
   2.331  } SDL_QuitEvent;
   2.332  
   2.333  /**
   2.334 @@ -283,11 +300,11 @@
   2.335   */
   2.336  typedef struct SDL_UserEvent
   2.337  {
   2.338 -    Uint8 type;             /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
   2.339 -    Uint32 windowID;        /**< The associated window if any*/
   2.340 -    int code;               /**< User defined event code */
   2.341 -    void *data1;            /**< User defined data pointer */
   2.342 -    void *data2;            /**< User defined data pointer */
   2.343 +    Uint32 type;        /**< ::SDL_USEREVENT through ::SDL_NUMEVENTS-1 */
   2.344 +    Uint32 windowID;    /**< The associated window if any */
   2.345 +    int code;           /**< User defined event code */
   2.346 +    void *data1;        /**< User defined data pointer */
   2.347 +    void *data2;        /**< User defined data pointer */
   2.348  } SDL_UserEvent;
   2.349  
   2.350  struct SDL_SysWMmsg;
   2.351 @@ -300,20 +317,10 @@
   2.352   */
   2.353  typedef struct SDL_SysWMEvent
   2.354  {
   2.355 -    Uint8 type;         /**< ::SDL_SYSWMEVENT */
   2.356 +    Uint32 type;        /**< ::SDL_SYSWMEVENT */
   2.357      SDL_SysWMmsg *msg;  /**< driver dependent data, defined in SDL_syswm.h */
   2.358  } SDL_SysWMEvent;
   2.359  
   2.360 -typedef struct SDL_ProximityEvent
   2.361 -{
   2.362 -    Uint8 type;
   2.363 -    Uint32 windowID;    /**< The associated window */
   2.364 -    Uint8 which;
   2.365 -    int cursor;
   2.366 -    int x;
   2.367 -    int y;
   2.368 -} SDL_ProximityEvent;
   2.369 -
   2.370  #ifndef SDL_NO_COMPAT
   2.371  /**
   2.372   *  \addtogroup Compatibility 
   2.373 @@ -326,14 +333,14 @@
   2.374  /*@{*/
   2.375  typedef struct SDL_ActiveEvent
   2.376  {
   2.377 -    Uint8 type;
   2.378 +    Uint32 type;
   2.379      Uint8 gain;
   2.380      Uint8 state;
   2.381  } SDL_ActiveEvent;
   2.382  
   2.383  typedef struct SDL_ResizeEvent
   2.384  {
   2.385 -    Uint8 type;
   2.386 +    Uint32 type;
   2.387      int w;
   2.388      int h;
   2.389  } SDL_ResizeEvent;
   2.390 @@ -347,7 +354,7 @@
   2.391   */
   2.392  typedef union SDL_Event
   2.393  {
   2.394 -    Uint8 type;                     /**< Event type, shared with all events */
   2.395 +    Uint32 type;                    /**< Event type, shared with all events */
   2.396      SDL_WindowEvent window;         /**< Window event data */
   2.397      SDL_KeyboardEvent key;          /**< Keyboard event data */
   2.398      SDL_TextEditingEvent edit;      /**< Text editing event data */
   2.399 @@ -413,13 +420,20 @@
   2.400   */
   2.401  extern DECLSPEC int SDLCALL SDL_PeepEvents(SDL_Event * events, int numevents,
   2.402                                             SDL_eventaction action,
   2.403 -                                           Uint32 mask);
   2.404 +                                           Uint32 minType, Uint32 maxType);
   2.405  /*@}*/
   2.406  
   2.407  /**
   2.408   *  Checks to see if certain event types are in the event queue.
   2.409   */
   2.410 -extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 mask);
   2.411 +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvent(Uint32 type);
   2.412 +extern DECLSPEC SDL_bool SDLCALL SDL_HasEvents(Uint32 minType, Uint32 maxType);
   2.413 +
   2.414 +/**
   2.415 + *  This function clears events from the event queue
   2.416 + */
   2.417 +extern DECLSPEC void SDLCALL SDL_FlushEvent(Uint32 type);
   2.418 +extern DECLSPEC void SDLCALL SDL_FlushEvents(Uint32 minType, Uint32 maxType);
   2.419  
   2.420  /**
   2.421   *  \brief Polls for currently pending events.
   2.422 @@ -520,8 +534,18 @@
   2.423   *   - If \c state is set to ::SDL_QUERY, SDL_EventState() will return the 
   2.424   *     current processing state of the specified event.
   2.425   */
   2.426 -extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint8 type, int state);
   2.427 +extern DECLSPEC Uint8 SDLCALL SDL_EventState(Uint32 type, int state);
   2.428  /*@}*/
   2.429 +#define SDL_GetEventState(type) SDL_EventState(type, SDL_QUERY)
   2.430 +
   2.431 +/**
   2.432 + *  This function allocates a set of user-defined events, and returns
   2.433 + *  the beginning event number for that set of events.
   2.434 + *
   2.435 + *  If there aren't enough user-defined events left, this function
   2.436 + *  returns (Uint32)-1
   2.437 + */
   2.438 +extern DECLSPEC Uint32 SDLCALL SDL_RegisterEvents(int numevents);
   2.439  
   2.440  /* Ends C function definitions when using C++ */
   2.441  #ifdef __cplusplus
     3.1 --- a/src/SDL_compat.c	Wed Mar 10 15:07:20 2010 +0000
     3.2 +++ b/src/SDL_compat.c	Thu Mar 25 01:08:26 2010 -0700
     3.3 @@ -196,13 +196,13 @@
     3.4      case SDL_WINDOWEVENT:
     3.5          switch (event->window.event) {
     3.6          case SDL_WINDOWEVENT_EXPOSED:
     3.7 -            if (!SDL_HasEvent(SDL_VIDEOEXPOSEMASK)) {
     3.8 +            if (!SDL_HasEvent(SDL_VIDEOEXPOSE)) {
     3.9                  fake.type = SDL_VIDEOEXPOSE;
    3.10                  SDL_PushEvent(&fake);
    3.11              }
    3.12              break;
    3.13          case SDL_WINDOWEVENT_RESIZED:
    3.14 -            SDL_PeepEvents(&fake, 1, SDL_GETEVENT, SDL_VIDEORESIZEMASK);
    3.15 +            SDL_FlushEvent(SDL_VIDEORESIZE);
    3.16              fake.type = SDL_VIDEORESIZE;
    3.17              fake.resize.w = event->window.data1;
    3.18              fake.resize.h = event->window.data2;
     4.1 --- a/src/events/SDL_events.c	Wed Mar 10 15:07:20 2010 +0000
     4.2 +++ b/src/events/SDL_events.c	Thu Mar 25 01:08:26 2010 -0700
     4.3 @@ -37,8 +37,13 @@
     4.4  /* Public data -- the event filter */
     4.5  SDL_EventFilter SDL_EventOK = NULL;
     4.6  void *SDL_EventOKParam;
     4.7 -Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
     4.8 -static Uint32 SDL_eventstate = 0;
     4.9 +
    4.10 +typedef struct {
    4.11 +    Uint32 bits[8];
    4.12 +} SDL_DisabledEventBlock;
    4.13 +
    4.14 +static SDL_DisabledEventBlock *SDL_disabled_events[256];
    4.15 +static Uint32 SDL_userevents = SDL_USEREVENT;
    4.16  
    4.17  /* Private data -- event queue */
    4.18  #define MAXEVENTS	128
    4.19 @@ -84,6 +89,17 @@
    4.20      }
    4.21  }
    4.22  
    4.23 +static __inline__ SDL_bool
    4.24 +SDL_ShouldPollJoystick()
    4.25 +{
    4.26 +    if (SDL_numjoysticks &&
    4.27 +        (!SDL_disabled_events[SDL_JOYAXISMOTION >> 8] ||
    4.28 +         SDL_JoystickEventState(SDL_QUERY))) {
    4.29 +        return SDL_TRUE;
    4.30 +    }
    4.31 +    return SDL_FALSE;
    4.32 +}
    4.33 +
    4.34  static int SDLCALL
    4.35  SDL_GobbleEvents(void *unused)
    4.36  {
    4.37 @@ -98,7 +114,7 @@
    4.38          }
    4.39  #if !SDL_JOYSTICK_DISABLED
    4.40          /* Check for joystick state change */
    4.41 -        if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) {
    4.42 +        if (SDL_ShouldPollJoystick()) {
    4.43              SDL_JoystickUpdate();
    4.44          }
    4.45  #endif
    4.46 @@ -195,6 +211,8 @@
    4.47  void
    4.48  SDL_StopEventLoop(void)
    4.49  {
    4.50 +    int i;
    4.51 +
    4.52      /* Halt the event thread, if running */
    4.53      SDL_StopEventThread();
    4.54  
    4.55 @@ -207,6 +225,14 @@
    4.56      SDL_EventQ.head = 0;
    4.57      SDL_EventQ.tail = 0;
    4.58      SDL_EventQ.wmmsg_next = 0;
    4.59 +
    4.60 +    /* Clear disabled event state */
    4.61 +    for (i = 0; i < SDL_arraysize(SDL_disabled_events); ++i) {
    4.62 +        if (SDL_disabled_events[i]) {
    4.63 +            SDL_free(SDL_disabled_events[i]);
    4.64 +            SDL_disabled_events[i] = NULL;
    4.65 +        }
    4.66 +    }
    4.67  }
    4.68  
    4.69  /* This function (and associated calls) may be called more than once */
    4.70 @@ -222,11 +248,7 @@
    4.71  
    4.72      /* No filter to start with, process most event types */
    4.73      SDL_EventOK = NULL;
    4.74 -    SDL_memset(SDL_ProcessEvents, SDL_ENABLE, sizeof(SDL_ProcessEvents));
    4.75 -    SDL_eventstate = ~0;
    4.76 -    /* It's not save to call SDL_EventState() yet */
    4.77 -    SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT);
    4.78 -    SDL_ProcessEvents[SDL_SYSWMEVENT] = SDL_IGNORE;
    4.79 +    SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
    4.80  
    4.81      /* Initialize event handlers */
    4.82      retcode = 0;
    4.83 @@ -305,7 +327,7 @@
    4.84  /* Lock the event queue, take a peep at it, and unlock it */
    4.85  int
    4.86  SDL_PeepEvents(SDL_Event * events, int numevents, SDL_eventaction action,
    4.87 -               Uint32 mask)
    4.88 +               Uint32 minType, Uint32 maxType)
    4.89  {
    4.90      int i, used;
    4.91  
    4.92 @@ -332,7 +354,8 @@
    4.93              }
    4.94              spot = SDL_EventQ.head;
    4.95              while ((used < numevents) && (spot != SDL_EventQ.tail)) {
    4.96 -                if (mask & SDL_EVENTMASK(SDL_EventQ.event[spot].type)) {
    4.97 +                Uint32 type = SDL_EventQ.event[spot].type;
    4.98 +                if (minType <= type && type <= maxType) {
    4.99                      events[used++] = SDL_EventQ.event[spot];
   4.100                      if (action == SDL_GETEVENT) {
   4.101                          spot = SDL_CutEvent(spot);
   4.102 @@ -353,9 +376,44 @@
   4.103  }
   4.104  
   4.105  SDL_bool
   4.106 -SDL_HasEvent(Uint32 mask)
   4.107 +SDL_HasEvent(Uint32 type)
   4.108  {
   4.109 -    return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, mask) > 0);
   4.110 +    return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, type, type) > 0);
   4.111 +}
   4.112 +
   4.113 +SDL_bool
   4.114 +SDL_HasEvents(Uint32 minType, Uint32 maxType)
   4.115 +{
   4.116 +    return (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, minType, maxType) > 0);
   4.117 +}
   4.118 +
   4.119 +void
   4.120 +SDL_FlushEvent(Uint32 type)
   4.121 +{
   4.122 +    SDL_FlushEvents(type, type);
   4.123 +}
   4.124 +
   4.125 +void
   4.126 +SDL_FlushEvents(Uint32 minType, Uint32 maxType)
   4.127 +{
   4.128 +    /* Don't look after we've quit */
   4.129 +    if (!SDL_EventQ.active) {
   4.130 +        return;
   4.131 +    }
   4.132 +
   4.133 +    /* Lock the event queue */
   4.134 +    if (SDL_mutexP(SDL_EventQ.lock) == 0) {
   4.135 +        int spot = SDL_EventQ.head;
   4.136 +        while (spot != SDL_EventQ.tail) {
   4.137 +            Uint32 type = SDL_EventQ.event[spot].type;
   4.138 +            if (minType <= type && type <= maxType) {
   4.139 +                spot = SDL_CutEvent(spot);
   4.140 +            } else {
   4.141 +                spot = (spot + 1) % MAXEVENTS;
   4.142 +            }
   4.143 +        }
   4.144 +        SDL_mutexV(SDL_EventQ.lock);
   4.145 +    }
   4.146  }
   4.147  
   4.148  /* Run the system dependent event loops */
   4.149 @@ -371,7 +429,7 @@
   4.150          }
   4.151  #if !SDL_JOYSTICK_DISABLED
   4.152          /* Check for joystick state change */
   4.153 -        if (SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK)) {
   4.154 +        if (SDL_ShouldPollJoystick()) {
   4.155              SDL_JoystickUpdate();
   4.156          }
   4.157  #endif
   4.158 @@ -402,7 +460,7 @@
   4.159  
   4.160      for (;;) {
   4.161          SDL_PumpEvents();
   4.162 -        switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) {
   4.163 +        switch (SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
   4.164          case -1:
   4.165              return 0;
   4.166          case 1:
   4.167 @@ -428,7 +486,7 @@
   4.168      if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
   4.169          return 0;
   4.170      }
   4.171 -    if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0) <= 0) {
   4.172 +    if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) {
   4.173          return -1;
   4.174      }
   4.175      return 1;
   4.176 @@ -476,48 +534,58 @@
   4.177  }
   4.178  
   4.179  Uint8
   4.180 -SDL_EventState(Uint8 type, int state)
   4.181 +SDL_EventState(Uint32 type, int state)
   4.182  {
   4.183 -    SDL_Event bitbucket;
   4.184      Uint8 current_state;
   4.185 +    Uint8 hi = ((type >> 8) & 0xff);
   4.186 +    Uint8 lo = (type & 0xff);
   4.187  
   4.188 -    /* If SDL_ALLEVENTS was specified... */
   4.189 -    if (type == 0xFF) {
   4.190 -        current_state = SDL_IGNORE;
   4.191 -        for (type = 0; type < SDL_NUMEVENTS; ++type) {
   4.192 -            if (SDL_ProcessEvents[type] != SDL_IGNORE) {
   4.193 -                current_state = SDL_ENABLE;
   4.194 -            }
   4.195 -            SDL_ProcessEvents[type] = state;
   4.196 -            if (state == SDL_ENABLE) {
   4.197 -                SDL_eventstate |= (0x00000001 << (type));
   4.198 -            } else {
   4.199 -                SDL_eventstate &= ~(0x00000001 << (type));
   4.200 -            }
   4.201 -        }
   4.202 -        while (SDL_PollEvent(&bitbucket) > 0);
   4.203 -        return (current_state);
   4.204 +    if (SDL_disabled_events[hi] &&
   4.205 +        (SDL_disabled_events[hi]->bits[lo/32] & (1 << (lo&31)))) {
   4.206 +        current_state = SDL_DISABLE;
   4.207 +    } else {
   4.208 +        current_state = SDL_ENABLE;
   4.209      }
   4.210  
   4.211 -    /* Just set the state for one event type */
   4.212 -    current_state = SDL_ProcessEvents[type];
   4.213 -    switch (state) {
   4.214 -    case SDL_IGNORE:
   4.215 -    case SDL_ENABLE:
   4.216 -        /* Set state and discard pending events */
   4.217 -        SDL_ProcessEvents[type] = state;
   4.218 -        if (state == SDL_ENABLE) {
   4.219 -            SDL_eventstate |= (0x00000001 << (type));
   4.220 -        } else {
   4.221 -            SDL_eventstate &= ~(0x00000001 << (type));
   4.222 +    if (state != current_state)
   4.223 +    {
   4.224 +        switch (state) {
   4.225 +        case SDL_DISABLE:
   4.226 +            /* Disable this event type and discard pending events */
   4.227 +            if (!SDL_disabled_events[hi]) {
   4.228 +                SDL_disabled_events[hi] = (SDL_DisabledEventBlock*) SDL_calloc(1, sizeof(SDL_DisabledEventBlock));
   4.229 +                if (!SDL_disabled_events[hi]) {
   4.230 +                    /* Out of memory, nothing we can do... */
   4.231 +                    break;
   4.232 +                }
   4.233 +            }
   4.234 +            SDL_disabled_events[hi]->bits[lo/32] |= (1 << (lo&31));
   4.235 +            SDL_FlushEvent(type);
   4.236 +            break;
   4.237 +        case SDL_ENABLE:
   4.238 +            SDL_disabled_events[hi]->bits[lo/32] &= ~(1 << (lo&31));
   4.239 +            break;
   4.240 +        default:
   4.241 +            /* Querying state... */
   4.242 +            break;
   4.243          }
   4.244 -        while (SDL_PollEvent(&bitbucket) > 0);
   4.245 -        break;
   4.246 -    default:
   4.247 -        /* Querying state? */
   4.248 -        break;
   4.249      }
   4.250 -    return (current_state);
   4.251 +
   4.252 +    return current_state;
   4.253 +}
   4.254 +
   4.255 +Uint32
   4.256 +SDL_RegisterEvents(int numevents)
   4.257 +{
   4.258 +    Uint32 event_base;
   4.259 +
   4.260 +    if (SDL_userevents+numevents <= SDL_LASTEVENT) {
   4.261 +        event_base = SDL_userevents;
   4.262 +        SDL_userevents += numevents;
   4.263 +    } else {
   4.264 +        event_base = (Uint32)-1;
   4.265 +    }
   4.266 +    return event_base;
   4.267  }
   4.268  
   4.269  /* This is a generic event handler.
   4.270 @@ -528,7 +596,7 @@
   4.271      int posted;
   4.272  
   4.273      posted = 0;
   4.274 -    if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
   4.275 +    if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
   4.276          SDL_Event event;
   4.277          SDL_memset(&event, 0, sizeof(event));
   4.278          event.type = SDL_SYSWMEVENT;
     5.1 --- a/src/events/SDL_events_c.h	Wed Mar 10 15:07:20 2010 +0000
     5.2 +++ b/src/events/SDL_events_c.h	Thu Mar 25 01:08:26 2010 -0700
     5.3 @@ -47,7 +47,4 @@
     5.4  extern SDL_EventFilter SDL_EventOK;
     5.5  extern void *SDL_EventOKParam;
     5.6  
     5.7 -/* The array of event processing states */
     5.8 -extern Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
     5.9 -
    5.10  /* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/events/SDL_keyboard.c	Wed Mar 10 15:07:20 2010 +0000
     6.2 +++ b/src/events/SDL_keyboard.c	Thu Mar 25 01:08:26 2010 -0700
     6.3 @@ -688,7 +688,7 @@
     6.4      SDL_Keyboard *keyboard = SDL_GetKeyboard(index);
     6.5      int posted;
     6.6      Uint16 modstate;
     6.7 -    Uint8 type;
     6.8 +    Uint32 type;
     6.9  
    6.10      if (!keyboard || !scancode) {
    6.11          return 0;
    6.12 @@ -800,7 +800,7 @@
    6.13  
    6.14      /* Post the event, if desired */
    6.15      posted = 0;
    6.16 -    if (SDL_ProcessEvents[type] == SDL_ENABLE) {
    6.17 +    if (SDL_GetEventState(type) == SDL_ENABLE) {
    6.18          SDL_Event event;
    6.19          event.key.type = type;
    6.20          event.key.which = (Uint8) index;
    6.21 @@ -827,7 +827,7 @@
    6.22  
    6.23      /* Post the event, if desired */
    6.24      posted = 0;
    6.25 -    if (SDL_ProcessEvents[SDL_TEXTINPUT] == SDL_ENABLE) {
    6.26 +    if (SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) {
    6.27          SDL_Event event;
    6.28          event.text.type = SDL_TEXTINPUT;
    6.29          event.text.which = (Uint8) index;
    6.30 @@ -845,7 +845,7 @@
    6.31  
    6.32      /* Post the event, if desired */
    6.33      posted = 0;
    6.34 -    if (SDL_ProcessEvents[SDL_TEXTEDITING] == SDL_ENABLE) {
    6.35 +    if (SDL_GetEventState(SDL_TEXTEDITING) == SDL_ENABLE) {
    6.36          SDL_Event event;
    6.37          event.edit.type = SDL_TEXTEDITING;
    6.38          event.edit.start = start;
     7.1 --- a/src/events/SDL_mouse.c	Wed Mar 10 15:07:20 2010 +0000
     7.2 +++ b/src/events/SDL_mouse.c	Thu Mar 25 01:08:26 2010 -0700
     7.3 @@ -365,7 +365,7 @@
     7.4  
     7.5      mouse->last_x = x;
     7.6      mouse->last_y = y;
     7.7 -    if (SDL_ProcessEvents[type] == SDL_ENABLE) {
     7.8 +    if (SDL_GetEventState(type) == SDL_ENABLE) {
     7.9          SDL_Event event;
    7.10          event.proximity.which = (Uint8) index;
    7.11          event.proximity.x = x;
    7.12 @@ -461,7 +461,7 @@
    7.13  
    7.14      /* Post the event, if desired */
    7.15      posted = 0;
    7.16 -    if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE &&
    7.17 +    if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE &&
    7.18          mouse->proximity == SDL_TRUE) {
    7.19          SDL_Event event;
    7.20          event.motion.type = SDL_MOUSEMOTION;
    7.21 @@ -493,7 +493,7 @@
    7.22      int index = SDL_GetMouseIndexId(id);
    7.23      SDL_Mouse *mouse = SDL_GetMouse(index);
    7.24      int posted;
    7.25 -    Uint8 type;
    7.26 +    Uint32 type;
    7.27  
    7.28      if (!mouse) {
    7.29          return 0;
    7.30 @@ -524,7 +524,7 @@
    7.31  
    7.32      /* Post the event, if desired */
    7.33      posted = 0;
    7.34 -    if (SDL_ProcessEvents[type] == SDL_ENABLE) {
    7.35 +    if (SDL_GetEventState(type) == SDL_ENABLE) {
    7.36          SDL_Event event;
    7.37          event.type = type;
    7.38          event.button.which = (Uint8) index;
    7.39 @@ -550,7 +550,7 @@
    7.40  
    7.41      /* Post the event, if desired */
    7.42      posted = 0;
    7.43 -    if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) {
    7.44 +    if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
    7.45          SDL_Event event;
    7.46          event.type = SDL_MOUSEWHEEL;
    7.47          event.wheel.which = (Uint8) index;
     8.1 --- a/src/events/SDL_quit.c	Wed Mar 10 15:07:20 2010 +0000
     8.2 +++ b/src/events/SDL_quit.c	Thu Mar 25 01:08:26 2010 -0700
     8.3 @@ -85,7 +85,7 @@
     8.4      int posted;
     8.5  
     8.6      posted = 0;
     8.7 -    if (SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE) {
     8.8 +    if (SDL_GetEventState(SDL_QUIT) == SDL_ENABLE) {
     8.9          SDL_Event event;
    8.10          event.type = SDL_QUIT;
    8.11          posted = (SDL_PushEvent(&event) > 0);
     9.1 --- a/src/events/SDL_windowevents.c	Wed Mar 10 15:07:20 2010 +0000
     9.2 +++ b/src/events/SDL_windowevents.c	Thu Mar 25 01:08:26 2010 -0700
     9.3 @@ -144,7 +144,7 @@
     9.4  
     9.5      /* Post the event, if desired */
     9.6      posted = 0;
     9.7 -    if (SDL_ProcessEvents[SDL_WINDOWEVENT] == SDL_ENABLE) {
     9.8 +    if (SDL_GetEventState(SDL_WINDOWEVENT) == SDL_ENABLE) {
     9.9          SDL_Event event;
    9.10          event.type = SDL_WINDOWEVENT;
    9.11          event.window.event = windowevent;
    10.1 --- a/src/joystick/SDL_joystick.c	Wed Mar 10 15:07:20 2010 +0000
    10.2 +++ b/src/joystick/SDL_joystick.c	Thu Mar 25 01:08:26 2010 -0700
    10.3 @@ -445,7 +445,7 @@
    10.4      /* Post the event, if desired */
    10.5      posted = 0;
    10.6  #if !SDL_EVENTS_DISABLED
    10.7 -    if (SDL_ProcessEvents[SDL_JOYAXISMOTION] == SDL_ENABLE) {
    10.8 +    if (SDL_GetEventState(SDL_JOYAXISMOTION) == SDL_ENABLE) {
    10.9          SDL_Event event;
   10.10          event.type = SDL_JOYAXISMOTION;
   10.11          event.jaxis.which = joystick->index;
   10.12 @@ -472,7 +472,7 @@
   10.13      /* Post the event, if desired */
   10.14      posted = 0;
   10.15  #if !SDL_EVENTS_DISABLED
   10.16 -    if (SDL_ProcessEvents[SDL_JOYHATMOTION] == SDL_ENABLE) {
   10.17 +    if (SDL_GetEventState(SDL_JOYHATMOTION) == SDL_ENABLE) {
   10.18          SDL_Event event;
   10.19          event.jhat.type = SDL_JOYHATMOTION;
   10.20          event.jhat.which = joystick->index;
   10.21 @@ -501,7 +501,7 @@
   10.22      /* Post the event, if desired */
   10.23      posted = 0;
   10.24  #if !SDL_EVENTS_DISABLED
   10.25 -    if (SDL_ProcessEvents[SDL_JOYBALLMOTION] == SDL_ENABLE) {
   10.26 +    if (SDL_GetEventState(SDL_JOYBALLMOTION) == SDL_ENABLE) {
   10.27          SDL_Event event;
   10.28          event.jball.type = SDL_JOYBALLMOTION;
   10.29          event.jball.which = joystick->index;
   10.30 @@ -544,7 +544,7 @@
   10.31      /* Post the event, if desired */
   10.32      posted = 0;
   10.33  #if !SDL_EVENTS_DISABLED
   10.34 -    if (SDL_ProcessEvents[event.type] == SDL_ENABLE) {
   10.35 +    if (SDL_GetEventState(event.type) == SDL_ENABLE) {
   10.36          event.jbutton.which = joystick->index;
   10.37          event.jbutton.button = button;
   10.38          event.jbutton.state = state;
   10.39 @@ -574,7 +574,7 @@
   10.40  #if SDL_EVENTS_DISABLED
   10.41      return SDL_IGNORE;
   10.42  #else
   10.43 -    const Uint8 event_list[] = {
   10.44 +    const Uint32 event_list[] = {
   10.45          SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
   10.46          SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP,
   10.47      };
    11.1 --- a/src/video/win32/SDL_win32events.c	Wed Mar 10 15:07:20 2010 +0000
    11.2 +++ b/src/video/win32/SDL_win32events.c	Thu Mar 25 01:08:26 2010 -0700
    11.3 @@ -109,7 +109,7 @@
    11.4      LRESULT returnCode = -1;
    11.5  
    11.6      /* Send a SDL_SYSWMEVENT if the application wants them */
    11.7 -    if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
    11.8 +    if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
    11.9          SDL_SysWMmsg wmmsg;
   11.10  
   11.11          SDL_VERSION(&wmmsg.version);
    12.1 --- a/src/video/x11/SDL_x11events.c	Wed Mar 10 15:07:20 2010 +0000
    12.2 +++ b/src/video/x11/SDL_x11events.c	Thu Mar 25 01:08:26 2010 -0700
    12.3 @@ -53,7 +53,7 @@
    12.4      }
    12.5  
    12.6      /* Send a SDL_SYSWMEVENT if the application wants them */
    12.7 -    if (SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE) {
    12.8 +    if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) {
    12.9          SDL_SysWMmsg wmmsg;
   12.10  
   12.11          SDL_VERSION(&wmmsg.version);
    13.1 --- a/test/threadwin.c	Wed Mar 10 15:07:20 2010 +0000
    13.2 +++ b/test/threadwin.c	Thu Mar 25 01:08:26 2010 -0700
    13.3 @@ -133,14 +133,10 @@
    13.4  {
    13.5      SDL_Event events[10];
    13.6      int i, found;
    13.7 -    Uint32 mask;
    13.8  
    13.9      /* Handle mouse events here */
   13.10 -    mask =
   13.11 -        (SDL_MOUSEMOTIONMASK | SDL_MOUSEBUTTONDOWNMASK |
   13.12 -         SDL_MOUSEBUTTONUPMASK);
   13.13      while (!done) {
   13.14 -        found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask);
   13.15 +        found = SDL_PeepEvents(events, 10, SDL_GETEVENT, SDL_MOUSEMOTION, SDL_MOUSEBUTTONUP);
   13.16          for (i = 0; i < found; ++i) {
   13.17              switch (events[i].type) {
   13.18                  /* We want to toggle visibility on buttonpress */
   13.19 @@ -173,12 +169,10 @@
   13.20  {
   13.21      SDL_Event events[10];
   13.22      int i, found;
   13.23 -    Uint32 mask;
   13.24  
   13.25      /* Handle mouse events here */
   13.26 -    mask = (SDL_KEYDOWNMASK | SDL_KEYUPMASK);
   13.27      while (!done) {
   13.28 -        found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask);
   13.29 +        found = SDL_PeepEvents(events, 10, SDL_GETEVENT, SDL_KEYDOWN, SDL_KEYUP);
   13.30          for (i = 0; i < found; ++i) {
   13.31              switch (events[i].type) {
   13.32                  /* We want to toggle visibility on buttonpress */
   13.33 @@ -329,7 +323,7 @@
   13.34          if (!(init_flags & SDL_INIT_EVENTTHREAD)) {
   13.35              SDL_PumpEvents();   /* Needed when event thread is off */
   13.36          }
   13.37 -        if (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_QUITMASK)) {
   13.38 +        if (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_QUIT, SDL_QUIT)) {
   13.39              done = 1;
   13.40          }
   13.41          /* Give up some CPU so the events can accumulate */