include/SDL_events.h
changeset 6949 4de584a3a027
parent 6917 47dc155b774d
child 6950 1ddb72193079
equal deleted inserted replaced
6948:84a71440360d 6949:4de584a3a027
   129      */
   129      */
   130     SDL_LASTEVENT    = 0xFFFF
   130     SDL_LASTEVENT    = 0xFFFF
   131 } SDL_EventType;
   131 } SDL_EventType;
   132 
   132 
   133 /**
   133 /**
       
   134  *  \brief Fields shared by every event
       
   135  */
       
   136 typedef struct SDL_GenericEvent
       
   137 {
       
   138     Uint32 type;
       
   139     Uint32 timestamp;
       
   140 } SDL_GenericEvent;
       
   141     
       
   142 /**
   134  *  \brief Window state change event data (event.window.*)
   143  *  \brief Window state change event data (event.window.*)
   135  */
   144  */
   136 typedef struct SDL_WindowEvent
   145 typedef struct SDL_WindowEvent
   137 {
   146 {
   138     Uint32 type;        /**< ::SDL_WINDOWEVENT */
   147     Uint32 type;        /**< ::SDL_WINDOWEVENT */
   239  */
   248  */
   240 typedef struct SDL_JoyAxisEvent
   249 typedef struct SDL_JoyAxisEvent
   241 {
   250 {
   242     Uint32 type;        /**< ::SDL_JOYAXISMOTION */
   251     Uint32 type;        /**< ::SDL_JOYAXISMOTION */
   243     Uint32 timestamp;
   252     Uint32 timestamp;
   244     Uint8 which;        /**< The joystick instance id */
   253     Uint32 which;       /**< The joystick instance id */
   245     Uint8 axis;         /**< The joystick axis index */
   254     Uint8 axis;         /**< The joystick axis index */
   246     Uint8 padding1;
   255     Uint8 padding1;
   247     Uint8 padding2;
   256     Uint8 padding2;
   248     int value;          /**< The axis value (range: -32768 to 32767) */
   257     Uint8 padding3;
       
   258     Sint16 value;       /**< The axis value (range: -32768 to 32767) */
       
   259     Uint16 padding4;
   249 } SDL_JoyAxisEvent;
   260 } SDL_JoyAxisEvent;
   250 
   261 
   251 /**
   262 /**
   252  *  \brief Joystick trackball motion event structure (event.jball.*)
   263  *  \brief Joystick trackball motion event structure (event.jball.*)
   253  */
   264  */
   254 typedef struct SDL_JoyBallEvent
   265 typedef struct SDL_JoyBallEvent
   255 {
   266 {
   256     Uint32 type;        /**< ::SDL_JOYBALLMOTION */
   267     Uint32 type;        /**< ::SDL_JOYBALLMOTION */
   257     Uint32 timestamp;
   268     Uint32 timestamp;
   258     Uint8 which;        /**< The joystick instance id */
   269     Uint32 which;       /**< The joystick instance id */
   259     Uint8 ball;         /**< The joystick trackball index */
   270     Uint8 ball;         /**< The joystick trackball index */
   260     Uint8 padding1;
   271     Uint8 padding1;
   261     Uint8 padding2;
   272     Uint8 padding2;
   262     int xrel;           /**< The relative motion in the X direction */
   273     Uint8 padding3;
   263     int yrel;           /**< The relative motion in the Y direction */
   274     Sint16 xrel;        /**< The relative motion in the X direction */
       
   275     Sint16 yrel;        /**< The relative motion in the Y direction */
   264 } SDL_JoyBallEvent;
   276 } SDL_JoyBallEvent;
   265 
   277 
   266 /**
   278 /**
   267  *  \brief Joystick hat position change event structure (event.jhat.*)
   279  *  \brief Joystick hat position change event structure (event.jhat.*)
   268  */
   280  */
   269 typedef struct SDL_JoyHatEvent
   281 typedef struct SDL_JoyHatEvent
   270 {
   282 {
   271     Uint32 type;        /**< ::SDL_JOYHATMOTION */
   283     Uint32 type;        /**< ::SDL_JOYHATMOTION */
   272     Uint32 timestamp;
   284     Uint32 timestamp;
   273     Uint8 which;        /**< The joystick instance id */
   285     Uint32 which;       /**< The joystick instance id */
   274     Uint8 hat;          /**< The joystick hat index */
   286     Uint8 hat;          /**< The joystick hat index */
   275     Uint8 value;        /**< The hat position value.
   287     Uint8 value;        /**< The hat position value.
   276                          *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
   288                          *   \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
   277                          *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
   289                          *   \sa ::SDL_HAT_LEFT ::SDL_HAT_CENTERED ::SDL_HAT_RIGHT
   278                          *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
   290                          *   \sa ::SDL_HAT_LEFTDOWN ::SDL_HAT_DOWN ::SDL_HAT_RIGHTDOWN
   279                          *   
   291                          *   
   280                          *   Note that zero means the POV is centered.
   292                          *   Note that zero means the POV is centered.
   281                          */
   293                          */
   282     Uint8 padding1;
   294     Uint8 padding1;
       
   295     Uint8 padding2;
   283 } SDL_JoyHatEvent;
   296 } SDL_JoyHatEvent;
   284 
   297 
   285 /**
   298 /**
   286  *  \brief Joystick button event structure (event.jbutton.*)
   299  *  \brief Joystick button event structure (event.jbutton.*)
   287  */
   300  */
   288 typedef struct SDL_JoyButtonEvent
   301 typedef struct SDL_JoyButtonEvent
   289 {
   302 {
   290     Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
   303     Uint32 type;        /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
   291     Uint32 timestamp;
   304     Uint32 timestamp;
   292     Uint8 which;        /**< The joystick instance id */
   305     Uint32 which;       /**< The joystick instance id */
   293     Uint8 button;       /**< The joystick button index */
   306     Uint8 button;       /**< The joystick button index */
   294     Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
   307     Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
   295     Uint8 padding1;
   308     Uint8 padding1;
       
   309     Uint8 padding2;
   296 } SDL_JoyButtonEvent;
   310 } SDL_JoyButtonEvent;
   297 
   311 
   298 /**
   312 /**
   299  *  \brief Joystick device event structure (event.jdevice.*)
   313  *  \brief Joystick device event structure (event.jdevice.*)
   300  */
   314  */
   301 typedef struct SDL_JoyDeviceEvent
   315 typedef struct SDL_JoyDeviceEvent
   302 {
   316 {
   303 	Uint32 type;        /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
   317 	Uint32 type;        /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
   304 	Uint32 timestamp;
   318 	Uint32 timestamp;
   305 	Uint32 which;        /**< The joystick device index for ADD, instance_id for REMOVE*/
   319 	Uint32 which;       /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
   306 } SDL_JoyDeviceEvent;
   320 } SDL_JoyDeviceEvent;
   307 
   321 
   308 
   322 
   309 /**
   323 /**
   310  *  \brief Game controller axis motion event structure (event.caxis.*)
   324  *  \brief Game controller axis motion event structure (event.caxis.*)
   311  */
   325  */
   312 typedef struct SDL_ControllerAxisEvent
   326 typedef struct SDL_ControllerAxisEvent
   313 {
   327 {
   314     Uint32 type;        /**< ::SDL_CONTROLLERAXISMOTION */
   328     Uint32 type;        /**< ::SDL_CONTROLLERAXISMOTION */
   315     Uint32 timestamp;
   329     Uint32 timestamp;
   316     Uint8 which;        /**< The joystick instance id */
   330     Uint32 which;       /**< The joystick instance id */
   317     SDL_GameControllerAxis axis;         /**< The joystick axis index */
   331     Uint8 axis;         /**< The controller axis (SDL_GameControllerAxis) */
   318     int value;          /**< The axis value (range: -32768 to 32767) */
   332     Uint8 padding1;
       
   333     Uint8 padding2;
       
   334     Uint8 padding3;
       
   335     Sint16 value;       /**< The axis value (range: -32768 to 32767) */
       
   336     Uint16 padding4;
   319 } SDL_ControllerAxisEvent;
   337 } SDL_ControllerAxisEvent;
   320 
   338 
   321 
   339 
   322 /**
   340 /**
   323  *  \brief Game controller button event structure (event.cbutton.*)
   341  *  \brief Game controller button event structure (event.cbutton.*)
   324  */
   342  */
   325 typedef struct SDL_ControllerButtonEvent
   343 typedef struct SDL_ControllerButtonEvent
   326 {
   344 {
   327     Uint32 type;        /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
   345     Uint32 type;        /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
   328     Uint32 timestamp;
   346     Uint32 timestamp;
   329     Uint8 which;        /**< The joystick instance id */
   347     Uint32 which;       /**< The joystick instance id */
   330     SDL_GameControllerButton button;       /**< The joystick button index */
   348     Uint8 button;       /**< The controller button (SDL_GameControllerButton) */
   331     Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
   349     Uint8 state;        /**< ::SDL_PRESSED or ::SDL_RELEASED */
       
   350     Uint8 padding1;
       
   351     Uint8 padding2;
   332 } SDL_ControllerButtonEvent;
   352 } SDL_ControllerButtonEvent;
   333 
   353 
   334 
   354 
   335 /**
   355 /**
   336  *  \brief Controller device event structure (event.cdevice.*)
   356  *  \brief Controller device event structure (event.cdevice.*)
   337  */
   357  */
   338 typedef struct SDL_ControllerDeviceEvent
   358 typedef struct SDL_ControllerDeviceEvent
   339 {
   359 {
   340 	Uint32 type;        /**< ::SDL_CONTROLLERDEVICEADDED or ::SDL_CONTROLLERDEVICEREMOVED */
   360 	Uint32 type;        /**< ::SDL_CONTROLLERDEVICEADDED or ::SDL_CONTROLLERDEVICEREMOVED */
   341 	Uint32 timestamp;
   361 	Uint32 timestamp;
   342 	Uint32 which;        /**< The joystick device index for ADD, instance_id for REMOVE*/
   362 	Uint32 which;       /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
   343 } SDL_ControllerDeviceEvent;
   363 } SDL_ControllerDeviceEvent;
   344 
   364 
   345 
   365 
   346 /**
   366 /**
   347  *  \brief Touch finger motion/finger event structure (event.tfinger.*)
   367  *  \brief Touch finger motion/finger event structure (event.tfinger.*)
   348  */
   368  */
   349 typedef struct SDL_TouchFingerEvent
   369 typedef struct SDL_TouchFingerEvent
   350 {
   370 {
   351     Uint32 type;        /**< ::SDL_FINGERMOTION OR 
   371     Uint32 type;        /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
   352 			   SDL_FINGERDOWN OR SDL_FINGERUP*/
       
   353     Uint32 timestamp;
   372     Uint32 timestamp;
   354     Uint32 windowID;    /**< The window with mouse focus, if any */
   373     Uint32 windowID;    /**< The window with mouse focus, if any */
   355     SDL_TouchID touchId;        /**< The touch device id */
   374     SDL_TouchID touchId; /**< The touch device id */
   356     SDL_FingerID fingerId;
   375     SDL_FingerID fingerId;
   357     Uint8 state;        /**< The current button state */
   376     Uint8 state;        /**< The current button state */
   358     Uint8 padding1;
   377     Uint8 padding1;
   359     Uint8 padding2;
   378     Uint8 padding2;
   360     Uint8 padding3;
   379     Uint8 padding3;
   474  *  \brief General event structure
   493  *  \brief General event structure
   475  */
   494  */
   476 typedef union SDL_Event
   495 typedef union SDL_Event
   477 {
   496 {
   478     Uint32 type;                    /**< Event type, shared with all events */
   497     Uint32 type;                    /**< Event type, shared with all events */
       
   498     SDL_GenericEvent generic;       /**< Generic event data */
   479     SDL_WindowEvent window;         /**< Window event data */
   499     SDL_WindowEvent window;         /**< Window event data */
   480     SDL_KeyboardEvent key;          /**< Keyboard event data */
   500     SDL_KeyboardEvent key;          /**< Keyboard event data */
   481     SDL_TextEditingEvent edit;      /**< Text editing event data */
   501     SDL_TextEditingEvent edit;      /**< Text editing event data */
   482     SDL_TextInputEvent text;        /**< Text input event data */
   502     SDL_TextInputEvent text;        /**< Text input event data */
   483     SDL_MouseMotionEvent motion;    /**< Mouse motion event data */
   503     SDL_MouseMotionEvent motion;    /**< Mouse motion event data */