mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-24 17:40:52 +00:00
Re-added balls to the SDL joystick API
It turns out these were being used on Linux and at least one virtual driver was making use of them (thanks @mrfixit2001!)
This commit is contained in:
@@ -152,11 +152,12 @@ typedef enum
|
||||
|
||||
/* Joystick events */
|
||||
SDL_EVENT_JOYSTICK_AXIS_MOTION = 0x600, /**< Joystick axis motion */
|
||||
SDL_EVENT_JOYSTICK_HAT_MOTION = 0x602, /**< Joystick hat position change */
|
||||
SDL_EVENT_JOYSTICK_BALL_MOTION, /**< Joystick trackball motion */
|
||||
SDL_EVENT_JOYSTICK_HAT_MOTION, /**< Joystick hat position change */
|
||||
SDL_EVENT_JOYSTICK_BUTTON_DOWN, /**< Joystick button pressed */
|
||||
SDL_EVENT_JOYSTICK_BUTTON_UP, /**< Joystick button released */
|
||||
SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */
|
||||
SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */
|
||||
SDL_EVENT_JOYSTICK_ADDED, /**< A new joystick has been inserted into the system */
|
||||
SDL_EVENT_JOYSTICK_REMOVED, /**< An opened joystick has been removed */
|
||||
SDL_EVENT_JOYSTICK_BATTERY_UPDATED, /**< Joystick battery level change */
|
||||
SDL_EVENT_JOYSTICK_UPDATE_COMPLETE, /**< Joystick update is complete */
|
||||
|
||||
@@ -336,6 +337,22 @@ typedef struct SDL_MouseMotionEvent
|
||||
float yrel; /**< The relative motion in the Y direction */
|
||||
} SDL_MouseMotionEvent;
|
||||
|
||||
/**
|
||||
* \brief Joystick trackball motion event structure (event.jball.*)
|
||||
*/
|
||||
typedef struct SDL_JoyBallEvent
|
||||
{
|
||||
Uint32 type; /**< ::SDL_JOYBALLMOTION */
|
||||
Uint64 timestamp; /**< In nanoseconds, populated using SDL_GetTicksNS() */
|
||||
SDL_JoystickID which; /**< The joystick instance id */
|
||||
Uint8 ball; /**< The joystick trackball index */
|
||||
Uint8 padding1;
|
||||
Uint8 padding2;
|
||||
Uint8 padding3;
|
||||
Sint16 xrel; /**< The relative motion in the X direction */
|
||||
Sint16 yrel; /**< The relative motion in the Y direction */
|
||||
} SDL_JoyBallEvent;
|
||||
|
||||
/**
|
||||
* Mouse button event structure (event.button.*)
|
||||
*/
|
||||
@@ -706,6 +723,7 @@ typedef union SDL_Event
|
||||
SDL_MouseButtonEvent button; /**< Mouse button event data */
|
||||
SDL_MouseWheelEvent wheel; /**< Mouse wheel event data */
|
||||
SDL_JoyAxisEvent jaxis; /**< Joystick axis event data */
|
||||
SDL_JoyBallEvent jball; /**< Joystick ball event data */
|
||||
SDL_JoyHatEvent jhat; /**< Joystick hat event data */
|
||||
SDL_JoyButtonEvent jbutton; /**< Joystick button event data */
|
||||
SDL_JoyDeviceEvent jdevice; /**< Joystick device change event data */
|
||||
|
||||
@@ -732,6 +732,24 @@ extern DECLSPEC SDL_JoystickID SDLCALL SDL_GetJoystickInstanceID(SDL_Joystick *j
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumJoystickAxes(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the number of trackballs on a joystick.
|
||||
*
|
||||
* Joystick trackballs have only relative motion events associated with them
|
||||
* and their state cannot be polled.
|
||||
*
|
||||
* Most joysticks do not have trackballs.
|
||||
*
|
||||
* \param joystick an SDL_Joystick structure containing joystick information
|
||||
* \returns the number of trackballs on success or a negative error code on
|
||||
* failure; call SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetJoystickBall
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetNumJoystickBalls(SDL_Joystick *joystick);
|
||||
|
||||
/**
|
||||
* Get the number of POV hats on a joystick.
|
||||
*
|
||||
@@ -823,8 +841,7 @@ extern DECLSPEC void SDLCALL SDL_UpdateJoysticks(void);
|
||||
*
|
||||
* \sa SDL_GetNumJoystickAxes
|
||||
*/
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick,
|
||||
int axis);
|
||||
extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick, int axis);
|
||||
|
||||
/**
|
||||
* Get the initial state of an axis control on a joystick.
|
||||
@@ -840,8 +857,28 @@ extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick,
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*/
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick,
|
||||
int axis, Sint16 *state);
|
||||
extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *joystick, int axis, Sint16 *state);
|
||||
|
||||
/**
|
||||
* Get the ball axis change since the last poll.
|
||||
*
|
||||
* Trackballs can only return relative motion since the last call to
|
||||
* SDL_GetJoystickBall(), these motion deltas are placed into `dx` and `dy`.
|
||||
*
|
||||
* Most joysticks do not have trackballs.
|
||||
*
|
||||
* \param joystick the SDL_Joystick to query
|
||||
* \param ball the ball index to query; ball indices start at index 0
|
||||
* \param dx stores the difference in the x axis position since the last poll
|
||||
* \param dy stores the difference in the y axis position since the last poll
|
||||
* \returns 0 on success or a negative error code on failure; call
|
||||
* SDL_GetError() for more information.
|
||||
*
|
||||
* \since This function is available since SDL 3.0.0.
|
||||
*
|
||||
* \sa SDL_GetNumJoystickBalls
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_GetJoystickBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
|
||||
|
||||
/**
|
||||
* \name Hat positions
|
||||
@@ -881,8 +918,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetJoystickAxisInitialState(SDL_Joystick *j
|
||||
*
|
||||
* \sa SDL_GetNumJoystickHats
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick,
|
||||
int hat);
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick, int hat);
|
||||
|
||||
/**
|
||||
* Get the current state of a button on a joystick.
|
||||
@@ -896,8 +932,7 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickHat(SDL_Joystick *joystick,
|
||||
*
|
||||
* \sa SDL_GetNumJoystickButtons
|
||||
*/
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick,
|
||||
int button);
|
||||
extern DECLSPEC Uint8 SDLCALL SDL_GetJoystickButton(SDL_Joystick *joystick, int button);
|
||||
|
||||
/**
|
||||
* Start a rumble effect.
|
||||
|
||||
@@ -115,6 +115,7 @@
|
||||
#define SDL_JOYBUTTONUP SDL_EVENT_JOYSTICK_BUTTON_UP
|
||||
#define SDL_JOYDEVICEADDED SDL_EVENT_JOYSTICK_ADDED
|
||||
#define SDL_JOYDEVICEREMOVED SDL_EVENT_JOYSTICK_REMOVED
|
||||
#define SDL_JOYBALLMOTION SDL_EVENT_JOYSTICK_BALL_MOTION
|
||||
#define SDL_JOYHATMOTION SDL_EVENT_JOYSTICK_HAT_MOTION
|
||||
#define SDL_KEYDOWN SDL_EVENT_KEY_DOWN
|
||||
#define SDL_KEYMAPCHANGED SDL_EVENT_KEYMAP_CHANGED
|
||||
@@ -302,6 +303,7 @@
|
||||
#define SDL_JoystickGetAttached SDL_JoystickConnected
|
||||
#define SDL_JoystickGetAxis SDL_GetJoystickAxis
|
||||
#define SDL_JoystickGetAxisInitialState SDL_GetJoystickAxisInitialState
|
||||
#define SDL_JoystickGetBall SDL_GetJoystickBall
|
||||
#define SDL_JoystickGetButton SDL_GetJoystickButton
|
||||
#define SDL_JoystickGetFirmwareVersion SDL_GetJoystickFirmwareVersion
|
||||
#define SDL_JoystickGetGUID SDL_GetJoystickGUID
|
||||
@@ -318,6 +320,7 @@
|
||||
#define SDL_JoystickIsVirtual SDL_IsJoystickVirtual
|
||||
#define SDL_JoystickName SDL_GetJoystickName
|
||||
#define SDL_JoystickNumAxes SDL_GetNumJoystickAxes
|
||||
#define SDL_JoystickNumBalls SDL_GetNumJoystickBalls
|
||||
#define SDL_JoystickNumButtons SDL_GetNumJoystickButtons
|
||||
#define SDL_JoystickNumHats SDL_GetNumJoystickHats
|
||||
#define SDL_JoystickOpen SDL_OpenJoystick
|
||||
@@ -597,6 +600,7 @@
|
||||
#define SDL_JOYBUTTONUP SDL_JOYBUTTONUP_renamed_SDL_EVENT_JOYSTICK_BUTTON_UP
|
||||
#define SDL_JOYDEVICEADDED SDL_JOYDEVICEADDED_renamed_SDL_EVENT_JOYSTICK_ADDED
|
||||
#define SDL_JOYDEVICEREMOVED SDL_JOYDEVICEREMOVED_renamed_SDL_EVENT_JOYSTICK_REMOVED
|
||||
#define SDL_JOYBALLMOTION SDL_JOYBALLMOTION_renamed_SDL_EVENT_JOYSTICK_BALL_MOTION
|
||||
#define SDL_JOYHATMOTION SDL_JOYHATMOTION_renamed_SDL_EVENT_JOYSTICK_HAT_MOTION
|
||||
#define SDL_KEYDOWN SDL_KEYDOWN_renamed_SDL_EVENT_KEY_DOWN
|
||||
#define SDL_KEYMAPCHANGED SDL_KEYMAPCHANGED_renamed_SDL_EVENT_KEYMAP_CHANGED
|
||||
@@ -785,6 +789,7 @@
|
||||
#define SDL_JoystickGetAttached SDL_JoystickGetAttached_renamed_SDL_JoystickConnected
|
||||
#define SDL_JoystickGetAxis SDL_JoystickGetAxis_renamed_SDL_GetJoystickAxis
|
||||
#define SDL_JoystickGetAxisInitialState SDL_JoystickGetAxisInitialState_renamed_SDL_GetJoystickAxisInitialState
|
||||
#define SDL_JoystickGetBall SDL_JoystickGetBall_renamed_SDL_GetJoystickBall
|
||||
#define SDL_JoystickGetButton SDL_JoystickGetButton_renamed_SDL_GetJoystickButton
|
||||
#define SDL_JoystickGetFirmwareVersion SDL_JoystickGetFirmwareVersion_renamed_SDL_GetJoystickFirmwareVersion
|
||||
#define SDL_JoystickGetGUID SDL_JoystickGetGUID_renamed_SDL_GetJoystickGUID
|
||||
@@ -801,6 +806,7 @@
|
||||
#define SDL_JoystickIsVirtual SDL_JoystickIsVirtual_renamed_SDL_IsJoystickVirtual
|
||||
#define SDL_JoystickName SDL_JoystickName_renamed_SDL_GetJoystickName
|
||||
#define SDL_JoystickNumAxes SDL_JoystickNumAxes_renamed_SDL_GetNumJoystickAxes
|
||||
#define SDL_JoystickNumBalls SDL_JoystickNumBalls_renamed_SDL_GetNumJoystickBalls
|
||||
#define SDL_JoystickNumButtons SDL_JoystickNumButtons_renamed_SDL_GetNumJoystickButtons
|
||||
#define SDL_JoystickNumHats SDL_JoystickNumHats_renamed_SDL_GetNumJoystickHats
|
||||
#define SDL_JoystickOpen SDL_JoystickOpen_renamed_SDL_OpenJoystick
|
||||
|
||||
Reference in New Issue
Block a user