Fixed the joystick id usage in the joystick and game controller events.
This commit is contained in:
parent
c6dc8b64e7
commit
c02018f852
4 changed files with 46 additions and 27 deletions
|
@ -130,6 +130,15 @@ typedef enum
|
|||
SDL_LASTEVENT = 0xFFFF
|
||||
} SDL_EventType;
|
||||
|
||||
/**
|
||||
* \brief Fields shared by every event
|
||||
*/
|
||||
typedef struct SDL_GenericEvent
|
||||
{
|
||||
Uint32 type;
|
||||
Uint32 timestamp;
|
||||
} SDL_GenericEvent;
|
||||
|
||||
/**
|
||||
* \brief Window state change event data (event.window.*)
|
||||
*/
|
||||
|
@ -241,11 +250,13 @@ typedef struct SDL_JoyAxisEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_JOYAXISMOTION */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
Uint32 which; /**< The joystick instance id */
|
||||
Uint8 axis; /**< The joystick axis index */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
int value; /**< The axis value (range: -32768 to 32767) */
|
||||
Uint8 padding3;
|
||||
Sint16 value; /**< The axis value (range: -32768 to 32767) */
|
||||
Uint16 padding4;
|
||||
} SDL_JoyAxisEvent;
|
||||
|
||||
/**
|
||||
|
@ -255,12 +266,13 @@ typedef struct SDL_JoyBallEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_JOYBALLMOTION */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
Uint32 which; /**< The joystick instance id */
|
||||
Uint8 ball; /**< The joystick trackball index */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
int xrel; /**< The relative motion in the X direction */
|
||||
int yrel; /**< The relative motion in the Y direction */
|
||||
Uint8 padding3;
|
||||
Sint16 xrel; /**< The relative motion in the X direction */
|
||||
Sint16 yrel; /**< The relative motion in the Y direction */
|
||||
} SDL_JoyBallEvent;
|
||||
|
||||
/**
|
||||
|
@ -270,7 +282,7 @@ typedef struct SDL_JoyHatEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_JOYHATMOTION */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
Uint32 which; /**< The joystick instance id */
|
||||
Uint8 hat; /**< The joystick hat index */
|
||||
Uint8 value; /**< The hat position value.
|
||||
* \sa ::SDL_HAT_LEFTUP ::SDL_HAT_UP ::SDL_HAT_RIGHTUP
|
||||
|
@ -280,6 +292,7 @@ typedef struct SDL_JoyHatEvent
|
|||
* Note that zero means the POV is centered.
|
||||
*/
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
} SDL_JoyHatEvent;
|
||||
|
||||
/**
|
||||
|
@ -289,10 +302,11 @@ typedef struct SDL_JoyButtonEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_JOYBUTTONDOWN or ::SDL_JOYBUTTONUP */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
Uint32 which; /**< The joystick instance id */
|
||||
Uint8 button; /**< The joystick button index */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
} SDL_JoyButtonEvent;
|
||||
|
||||
/**
|
||||
|
@ -302,7 +316,7 @@ typedef struct SDL_JoyDeviceEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_JOYDEVICEADDED or ::SDL_JOYDEVICEREMOVED */
|
||||
Uint32 timestamp;
|
||||
Uint32 which; /**< The joystick device index for ADD, instance_id for REMOVE*/
|
||||
Uint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
|
||||
} SDL_JoyDeviceEvent;
|
||||
|
||||
|
||||
|
@ -313,9 +327,13 @@ typedef struct SDL_ControllerAxisEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_CONTROLLERAXISMOTION */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
SDL_GameControllerAxis axis; /**< The joystick axis index */
|
||||
int value; /**< The axis value (range: -32768 to 32767) */
|
||||
Uint32 which; /**< The joystick instance id */
|
||||
Uint8 axis; /**< The controller axis (SDL_GameControllerAxis) */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
Sint16 value; /**< The axis value (range: -32768 to 32767) */
|
||||
Uint16 padding4;
|
||||
} SDL_ControllerAxisEvent;
|
||||
|
||||
|
||||
|
@ -326,9 +344,11 @@ typedef struct SDL_ControllerButtonEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_CONTROLLERBUTTONDOWN or ::SDL_CONTROLLERBUTTONUP */
|
||||
Uint32 timestamp;
|
||||
Uint8 which; /**< The joystick instance id */
|
||||
SDL_GameControllerButton button; /**< The joystick button index */
|
||||
Uint32 which; /**< The joystick instance id */
|
||||
Uint8 button; /**< The controller button (SDL_GameControllerButton) */
|
||||
Uint8 state; /**< ::SDL_PRESSED or ::SDL_RELEASED */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
} SDL_ControllerButtonEvent;
|
||||
|
||||
|
||||
|
@ -339,7 +359,7 @@ typedef struct SDL_ControllerDeviceEvent
|
|||
{
|
||||
Uint32 type; /**< ::SDL_CONTROLLERDEVICEADDED or ::SDL_CONTROLLERDEVICEREMOVED */
|
||||
Uint32 timestamp;
|
||||
Uint32 which; /**< The joystick device index for ADD, instance_id for REMOVE*/
|
||||
Uint32 which; /**< The joystick device index for the ADDED event, instance id for the REMOVED event */
|
||||
} SDL_ControllerDeviceEvent;
|
||||
|
||||
|
||||
|
@ -348,11 +368,10 @@ typedef struct SDL_ControllerDeviceEvent
|
|||
*/
|
||||
typedef struct SDL_TouchFingerEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_FINGERMOTION OR
|
||||
SDL_FINGERDOWN OR SDL_FINGERUP*/
|
||||
Uint32 type; /**< ::SDL_FINGERMOTION or ::SDL_FINGERDOWN or ::SDL_FINGERUP */
|
||||
Uint32 timestamp;
|
||||
Uint32 windowID; /**< The window with mouse focus, if any */
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
SDL_TouchID touchId; /**< The touch device id */
|
||||
SDL_FingerID fingerId;
|
||||
Uint8 state; /**< The current button state */
|
||||
Uint8 padding1;
|
||||
|
@ -476,6 +495,7 @@ typedef struct SDL_SysWMEvent
|
|||
typedef union SDL_Event
|
||||
{
|
||||
Uint32 type; /**< Event type, shared with all events */
|
||||
SDL_GenericEvent generic; /**< Generic event data */
|
||||
SDL_WindowEvent window; /**< Window event data */
|
||||
SDL_KeyboardEvent key; /**< Keyboard event data */
|
||||
SDL_TextEditingEvent edit; /**< Text editing event data */
|
||||
|
|
|
@ -67,7 +67,7 @@ typedef struct {
|
|||
Uint8 data[16];
|
||||
} SDL_JoystickGUID;
|
||||
|
||||
typedef int SDL_JoystickID;
|
||||
typedef Uint32 SDL_JoystickID;
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
|
|
@ -365,7 +365,7 @@ int
|
|||
SDL_PushEvent(SDL_Event * event)
|
||||
{
|
||||
SDL_EventWatcher *curr;
|
||||
event->window.timestamp = SDL_GetTicks();
|
||||
event->generic.timestamp = SDL_GetTicks();
|
||||
if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
/* The SDL joystick structure */
|
||||
struct _SDL_Joystick
|
||||
{
|
||||
int instance_id; /* Device instance, monotonically increasing from 0 */
|
||||
char *name; /* Joystick name - system dependent */
|
||||
SDL_JoystickID instance_id; /* Device instance, monotonically increasing from 0 */
|
||||
char *name; /* Joystick name - system dependent */
|
||||
|
||||
int naxes; /* Number of axis controls on the joystick */
|
||||
Sint16 *axes; /* Current axis states */
|
||||
|
@ -38,8 +38,7 @@ struct _SDL_Joystick
|
|||
Uint8 *hats; /* Current hat states */
|
||||
|
||||
int nballs; /* Number of trackballs on the joystick */
|
||||
struct balldelta
|
||||
{
|
||||
struct balldelta {
|
||||
int dx;
|
||||
int dy;
|
||||
} *balls; /* Current ball motion deltas */
|
||||
|
@ -50,10 +49,10 @@ struct _SDL_Joystick
|
|||
struct joystick_hwdata *hwdata; /* Driver dependent information */
|
||||
|
||||
int ref_count; /* Reference count for multiple opens */
|
||||
|
||||
Uint8 closed; /* 1 if this device is no longer valid */
|
||||
Uint8 uncentered; /* 1 if this device needs to have its state reset to 0 */
|
||||
struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
|
||||
|
||||
Uint8 closed; /* 1 if this device is no longer valid */
|
||||
Uint8 uncentered; /* 1 if this device needs to have its state reset to 0 */
|
||||
struct _SDL_Joystick *next; /* pointer to next joystick we have allocated */
|
||||
};
|
||||
|
||||
/* Function to scan the system for joysticks.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue