Fixed the joystick id usage in the joystick and game controller events.
1.1 --- a/include/SDL_events.h Fri Mar 01 11:27:01 2013 -0800
1.2 +++ b/include/SDL_events.h Sat Mar 02 17:51:32 2013 -0800
1.3 @@ -131,6 +131,15 @@
1.4 } SDL_EventType;
1.5
1.6 /**
1.7 + * \brief Fields shared by every event
1.8 + */
1.9 +typedef struct SDL_GenericEvent
1.10 +{
1.11 + Uint32 type;
1.12 + Uint32 timestamp;
1.13 +} SDL_GenericEvent;
1.14 +
1.15 +/**
1.16 * \brief Window state change event data (event.window.*)
1.17 */
1.18 typedef struct SDL_WindowEvent
1.19 @@ -241,11 +250,13 @@
1.20 {
1.21 Uint32 type; /**< ::SDL_JOYAXISMOTION */
1.22 Uint32 timestamp;
1.23 - Uint8 which; /**< The joystick instance id */
1.24 + Uint32 which; /**< The joystick instance id */
1.25 Uint8 axis; /**< The joystick axis index */
1.26 Uint8 padding1;
1.27 Uint8 padding2;
1.28 - int value; /**< The axis value (range: -32768 to 32767) */
1.29 + Uint8 padding3;
1.30 + Sint16 value; /**< The axis value (range: -32768 to 32767) */
1.31 + Uint16 padding4;
1.32 } SDL_JoyAxisEvent;
1.33
1.34 /**
1.35 @@ -255,12 +266,13 @@
1.36 {
1.37 Uint32 type; /**< ::SDL_JOYBALLMOTION */
1.38 Uint32 timestamp;
1.39 - Uint8 which; /**< The joystick instance id */
1.40 + Uint32 which; /**< The joystick instance id */
1.41 Uint8 ball; /**< The joystick trackball index */
1.42 Uint8 padding1;
1.43 Uint8 padding2;
1.44 - int xrel; /**< The relative motion in the X direction */
1.45 - int yrel; /**< The relative motion in the Y direction */
1.46 + Uint8 padding3;
1.47 + Sint16 xrel; /**< The relative motion in the X direction */
1.48 + Sint16 yrel; /**< The relative motion in the Y direction */
1.49 } SDL_JoyBallEvent;
1.50
1.51 /**
1.52 @@ -270,7 +282,7 @@
1.53 {
1.54 Uint32 type; /**< ::SDL_JOYHATMOTION */
1.55 Uint32 timestamp;
1.56 - Uint8 which; /**< The joystick instance id */
1.57 + Uint32 which; /**< The joystick instance id */
1.58 Uint8 hat; /**< The joystick hat index */
1.59 Uint8 value; /**< The hat position value.
1.60 * \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
1.61 @@ -280,6 +292,7 @@
1.62 * Note that zero means the POV is centered.
1.63 */
1.64 Uint8 padding1;
1.65 + Uint8 padding2;
1.66 } SDL_JoyHatEvent;
1.67
1.68 /**
1.69 @@ -289,10 +302,11 @@
1.70 {
1.71 Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
1.72 Uint32 timestamp;
1.73 - Uint8 which; /**< The joystick instance id */
1.74 + Uint32 which; /**< The joystick instance id */
1.75 Uint8 button; /**< The joystick button index */
1.76 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
1.77 Uint8 padding1;
1.78 + Uint8 padding2;
1.79 } SDL_JoyButtonEvent;
1.80
1.81 /**
1.82 @@ -302,7 +316,7 @@
1.83 {
1.84 Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
1.85 Uint32 timestamp;
1.86 - Uint32 which; /**< The joystick device index for ADD, instance_id for REMOVE*/
1.87 + Uint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
1.88 } SDL_JoyDeviceEvent;
1.89
1.90
1.91 @@ -313,9 +327,13 @@
1.92 {
1.93 Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
1.94 Uint32 timestamp;
1.95 - Uint8 which; /**< The joystick instance id */
1.96 - SDL_GameControllerAxis axis; /**< The joystick axis index */
1.97 - int value; /**< The axis value (range: -32768 to 32767) */
1.98 + Uint32 which; /**< The joystick instance id */
1.99 + Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
1.100 + Uint8 padding1;
1.101 + Uint8 padding2;
1.102 + Uint8 padding3;
1.103 + Sint16 value; /**< The axis value (range: -32768 to 32767) */
1.104 + Uint16 padding4;
1.105 } SDL_ControllerAxisEvent;
1.106
1.107
1.108 @@ -326,9 +344,11 @@
1.109 {
1.110 Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
1.111 Uint32 timestamp;
1.112 - Uint8 which; /**< The joystick instance id */
1.113 - SDL_GameControllerButton button; /**< The joystick button index */
1.114 + Uint32 which; /**< The joystick instance id */
1.115 + Uint8 button; /**< The controller button (SDL_GameControllerButton) */
1.116 Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
1.117 + Uint8 padding1;
1.118 + Uint8 padding2;
1.119 } SDL_ControllerButtonEvent;
1.120
1.121
1.122 @@ -339,7 +359,7 @@
1.123 {
1.124 Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED or ::SDL_CONTROLLERDEVICEREMOVED */
1.125 Uint32 timestamp;
1.126 - Uint32 which; /**< The joystick device index for ADD, instance_id for REMOVE*/
1.127 + Uint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
1.128 } SDL_ControllerDeviceEvent;
1.129
1.130
1.131 @@ -348,11 +368,10 @@
1.132 */
1.133 typedef struct SDL_TouchFingerEvent
1.134 {
1.135 - Uint32 type; /**< ::SDL_FINGERMOTION OR
1.136 - SDL_FINGERDOWN OR SDL_FINGERUP*/
1.137 + Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
1.138 Uint32 timestamp;
1.139 Uint32 windowID; /**< The window with mouse focus, if any */
1.140 - SDL_TouchID touchId; /**< The touch device id */
1.141 + SDL_TouchID touchId; /**< The touch device id */
1.142 SDL_FingerID fingerId;
1.143 Uint8 state; /**< The current button state */
1.144 Uint8 padding1;
1.145 @@ -476,6 +495,7 @@
1.146 typedef union SDL_Event
1.147 {
1.148 Uint32 type; /**< Event type, shared with all events */
1.149 + SDL_GenericEvent generic; /**< Generic event data */
1.150 SDL_WindowEvent window; /**< Window event data */
1.151 SDL_KeyboardEvent key; /**< Keyboard event data */
1.152 SDL_TextEditingEvent edit; /**< Text editing event data */
2.1 --- a/include/SDL_joystick.h Fri Mar 01 11:27:01 2013 -0800
2.2 +++ b/include/SDL_joystick.h Sat Mar 02 17:51:32 2013 -0800
2.3 @@ -67,7 +67,7 @@
2.4 Uint8 data[16];
2.5 } SDL_JoystickGUID;
2.6
2.7 -typedef int SDL_JoystickID;
2.8 +typedef Uint32 SDL_JoystickID;
2.9
2.10
2.11 /* Function prototypes */
3.1 --- a/src/events/SDL_events.c Fri Mar 01 11:27:01 2013 -0800
3.2 +++ b/src/events/SDL_events.c Sat Mar 02 17:51:32 2013 -0800
3.3 @@ -365,7 +365,7 @@
3.4 SDL_PushEvent(SDL_Event * event)
3.5 {
3.6 SDL_EventWatcher *curr;
3.7 - event->window.timestamp = SDL_GetTicks();
3.8 + event->generic.timestamp = SDL_GetTicks();
3.9 if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
3.10 return 0;
3.11 }
4.1 --- a/src/joystick/SDL_sysjoystick.h Fri Mar 01 11:27:01 2013 -0800
4.2 +++ b/src/joystick/SDL_sysjoystick.h Sat Mar 02 17:51:32 2013 -0800
4.3 @@ -28,8 +28,8 @@
4.4 /* The SDL joystick structure */
4.5 struct _SDL_Joystick
4.6 {
4.7 - int instance_id; /* Device instance, monotonically increasing from 0 */
4.8 - char *name; /* Joystick name - system dependent */
4.9 + SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
4.10 + char *name; /* Joystick name - system dependent */
4.11
4.12 int naxes; /* Number of axis controls on the joystick */
4.13 Sint16 *axes; /* Current axis states */
4.14 @@ -38,8 +38,7 @@
4.15 Uint8 *hats; /* Current hat states */
4.16
4.17 int nballs; /* Number of trackballs on the joystick */
4.18 - struct balldelta
4.19 - {
4.20 + struct balldelta {
4.21 int dx;
4.22 int dy;
4.23 } *balls; /* Current ball motion deltas */
4.24 @@ -50,10 +49,10 @@
4.25 struct joystick_hwdata *hwdata; /* Driver dependent information */
4.26
4.27 int ref_count; /* Reference count for multiple opens */
4.28 -
4.29 - Uint8 closed; /* 1 if this device is no longer valid */
4.30 - Uint8 uncentered; /* 1 if this device needs to have its state reset to 0 */
4.31 - struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
4.32 +
4.33 + Uint8 closed; /* 1 if this device is no longer valid */
4.34 + Uint8 uncentered; /* 1 if this device needs to have its state reset to 0 */
4.35 + struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
4.36 };
4.37
4.38 /* Function to scan the system for joysticks.