Merge branch 'libsdl-org:main' into br_video_capture

This commit is contained in:
Sylvain Becker 2023-02-12 10:24:09 +01:00 committed by GitHub
commit 98abef4de5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 314 additions and 130 deletions

View file

@ -2090,7 +2090,7 @@ expression e;
@@
@@
- SDL_WINDOWEVENT_SIZE_CHANGED
+ SDL_EVENT_WINDOW_SIZE_CHANGED
+ SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED
@@
@@
- SDL_WINDOWEVENT_MINIMIZED
@ -2321,11 +2321,6 @@ expression e;
+ SDL_EVENT_LAST
@@
@@
- SDL_GetDisplayDPI
+ SDL_GetDisplayPhysicalDPI
(...)
@@
@@
- SDL_WINDOW_INPUT_GRABBED
+ SDL_WINDOW_MOUSE_GRABBED
@@

View file

@ -130,19 +130,28 @@ typedef struct SDL_AssertData
#if (SDL_ASSERT_LEVEL > 0)
/* Never call this directly. Use the SDL_assert* macros. */
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *,
const char *,
const char *, int)
/**
* Never call this directly. Use the SDL_assert* macros.
*
* \param data assert data structure
* \param func function name
* \param file file name
* \param line line number
* \returns assert state
*/
extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *data,
const char *func,
const char *file, int line)
#if defined(__clang__)
#if __has_feature(attribute_analyzer_noreturn)
/* this tells Clang's static analysis that we're a custom assert function,
and that the analyzer should assume the condition was always true past this
SDL_assert test. */
__attribute__((analyzer_noreturn))
#endif
#endif
;
/* Previous 'analyzer_noreturn' attribute tells Clang's static analysis that we're a custom assert function,
and that the analyzer should assume the condition was always true past this
SDL_assert test. */
/* the do {} while(0) avoids dangling else problems:
if (x) SDL_assert(y); else blah();

View file

@ -768,6 +768,9 @@ extern DECLSPEC int SDLCALL SDL_GetAudioStreamData(SDL_AudioStream *stream, void
* resample correctly, so this number might be lower than what you expect, or
* even be zero. Add more data or flush the stream if you need the data now.
*
* \param stream The audio stream to query
* \returns the number of converted/resampled bytes available.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateAudioStream
@ -787,6 +790,10 @@ extern DECLSPEC int SDLCALL SDL_GetAudioStreamAvailable(SDL_AudioStream *stream)
* audio gaps in the output. Generally this is intended to signal the end of
* input, so the complete output becomes available.
*
* \param stream The audio stream to flush
* \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_CreateAudioStream
@ -819,6 +826,7 @@ extern DECLSPEC int SDLCALL SDL_ClearAudioStream(SDL_AudioStream *stream);
/**
* Free an audio stream
*
* \param stream The audio stream to free
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CreateAudioStream

View file

@ -148,7 +148,12 @@ typedef enum
SDL_UNSUPPORTED,
SDL_LASTERROR
} SDL_errorcode;
/* SDL_Error() unconditionally returns -1. */
/**
* SDL_Error()
*
* \param code Error code
* \returns unconditionally -1.
*/
extern DECLSPEC int SDLCALL SDL_Error(SDL_errorcode code);
/* @} *//* Internal error functions */

View file

@ -232,6 +232,7 @@ extern DECLSPEC int SDLCALL SDL_GetNumGamepadMappings(void);
/**
* Get the mapping at a particular index.
*
* \param mapping_index mapping index
* \returns the mapping string. Must be freed with SDL_free(). Returns NULL if
* the index is out of range.
*
@ -550,7 +551,7 @@ extern DECLSPEC int SDLCALL SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int
* If the vendor ID isn't available this function returns 0.
*
* \param gamepad the gamepad object to query.
* \return the USB vendor ID, or zero if unavailable.
* \returns the USB vendor ID, or zero if unavailable.
*
* \since This function is available since SDL 3.0.0.
*/
@ -562,7 +563,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadVendor(SDL_Gamepad *gamepad);
* If the product ID isn't available this function returns 0.
*
* \param gamepad the gamepad object to query.
* \return the USB product ID, or zero if unavailable.
* \returns the USB product ID, or zero if unavailable.
*
* \since This function is available since SDL 3.0.0.
*/
@ -574,7 +575,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProduct(SDL_Gamepad *gamepad);
* If the product version isn't available this function returns 0.
*
* \param gamepad the gamepad object to query.
* \return the USB product version, or zero if unavailable.
* \returns the USB product version, or zero if unavailable.
*
* \since This function is available since SDL 3.0.0.
*/
@ -586,7 +587,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad
* If the firmware version isn't available this function returns 0.
*
* \param gamepad the gamepad object to query.
* \return the gamepad firmware version, or zero if unavailable.
* \returns the gamepad firmware version, or zero if unavailable.
*
* \since This function is available since SDL 3.0.0.
*/
@ -598,7 +599,7 @@ extern DECLSPEC Uint16 SDLCALL SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepa
* Returns the serial number of the gamepad, or NULL if it is not available.
*
* \param gamepad the gamepad object to query.
* \return the serial number, or NULL if unavailable.
* \returns the serial number, or NULL if unavailable.
*
* \since This function is available since SDL 3.0.0.
*/
@ -843,6 +844,9 @@ extern DECLSPEC Uint8 SDLCALL SDL_GetGamepadButton(SDL_Gamepad *gamepad, SDL_Gam
/**
* Get the number of touchpads on a gamepad.
*
* \param gamepad a gamepad
* \returns number of touchpads
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
@ -851,6 +855,10 @@ extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpads(SDL_Gamepad *gamepad);
* Get the number of supported simultaneous fingers on a touchpad on a game
* gamepad.
*
* \param gamepad a gamepad
* \param touchpad a touchpad
* \returns number of supported simultaneous fingers
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepad, int touchpad);
@ -858,6 +866,16 @@ extern DECLSPEC int SDLCALL SDL_GetNumGamepadTouchpadFingers(SDL_Gamepad *gamepa
/**
* Get the current state of a finger on a touchpad on a gamepad.
*
* \param gamepad a gamepad
* \param touchpad a touchpad
* \param finger a finger
* \param state filled with state
* \param x filled with x position
* \param y filled with y position
* \param pressure filled with pressure value
* \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.
*/
extern DECLSPEC int SDLCALL SDL_GetGamepadTouchpadFinger(SDL_Gamepad *gamepad, int touchpad, int finger, Uint8 *state, float *x, float *y, float *pressure);
@ -901,7 +919,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GamepadSensorEnabled(SDL_Gamepad *gamepad,
*
* \param gamepad The gamepad to query
* \param type The type of sensor to query
* \return the data rate, or 0.0f if the data rate is not available.
* \returns the data rate, or 0.0f if the data rate is not available.
*
* \since This function is available since SDL 3.0.0.
*/
@ -917,7 +935,7 @@ extern DECLSPEC float SDLCALL SDL_GetGamepadSensorDataRate(SDL_Gamepad *gamepad,
* \param type The type of sensor to query
* \param data A pointer filled with the current sensor state
* \param num_values The number of values to write to data
* \return 0 or -1 if an error occurred.
* \returns 0 or -1 if an error occurred.
*
* \since This function is available since SDL 3.0.0.
*/

View file

@ -235,6 +235,7 @@ extern DECLSPEC SDL_hid_device * SDLCALL SDL_hid_open(unsigned short vendor_id,
* platform-specific path name can be used (eg: /dev/hidraw0 on Linux).
*
* \param path The path name of the device to open
* \param bExclusive exclusive opening (windows only?FIXME)
* \returns a pointer to a SDL_hid_device object on success or NULL on
* failure.
*

View file

@ -309,6 +309,10 @@ extern DECLSPEC SDL_Joystick *SDLCALL SDL_GetJoystickFromPlayerIndex(int player_
/**
* Attach a new virtual joystick.
*
* \param type Type of joystick
* \param naxes number of axes
* \param nbuttons number of buttons
* \param nhats number of hats
* \returns the joystick instance ID, or 0 if an error occurred; call
* SDL_GetError() for more information.
*
@ -361,6 +365,7 @@ typedef struct SDL_VirtualJoystickDesc
/**
* Attach a new virtual joystick with extended properties.
*
* \param desc Joystick description
* \returns the joystick instance ID, or 0 if an error occurred; call
* SDL_GetError() for more information.
*
@ -793,7 +798,7 @@ extern DECLSPEC Sint16 SDLCALL SDL_GetJoystickAxis(SDL_Joystick *joystick,
* \param joystick an SDL_Joystick structure containing joystick information
* \param axis the axis to query; the axis indices start at index 0
* \param state Upon return, the initial value is supplied here.
* \return SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
* \returns SDL_TRUE if this axis has any initial value, or SDL_FALSE if not.
*
* \since This function is available since SDL 3.0.0.
*/
@ -908,7 +913,7 @@ extern DECLSPEC int SDLCALL SDL_RumbleJoystickTriggers(SDL_Joystick *joystick, U
* DualShock 4 controller.
*
* \param joystick The joystick to query
* \return SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
* \returns SDL_TRUE if the joystick has a modifiable LED, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*/
@ -918,7 +923,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasLED(SDL_Joystick *joystick);
* Query whether a joystick has rumble support.
*
* \param joystick The joystick to query
* \return SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
* \returns SDL_TRUE if the joystick has rumble, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
@ -930,7 +935,7 @@ extern DECLSPEC SDL_bool SDLCALL SDL_JoystickHasRumble(SDL_Joystick *joystick);
* Query whether a joystick has rumble support on triggers.
*
* \param joystick The joystick to query
* \return SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
* \returns SDL_TRUE if the joystick has trigger rumble, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*

View file

@ -293,6 +293,8 @@ extern DECLSPEC void SDLCALL SDL_ClearComposition(void);
/**
* Returns if an IME Composite or Candidate window is currently shown.
*
* \returns SDL_TRUE if shown, else SDL_FALSE
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_bool SDLCALL SDL_TextInputShown(void);

View file

@ -83,7 +83,7 @@ typedef struct SDL_Locale
* if possible, and you can call this function again to get an updated copy of
* preferred locales.
*
* \return array of locales, terminated with a locale with a NULL language
* \returns array of locales, terminated with a locale with a NULL language
* field. Will return NULL on error.
*
* \since This function is available since SDL 3.0.0.

View file

@ -191,7 +191,7 @@ extern DECLSPEC void SDLCALL SDL_SetMainReady(void);
* argc, char* argv[])
* \param reserved should be NULL (reserved for future use, will probably be
* platform-specific then)
* \return the return value from mainFunction: 0 on success, -1 on failure;
* \returns the return value from mainFunction: 0 on success, -1 on failure;
* SDL_GetError() might have more information on the failure
*
* \since This function is available since SDL 3.0.0.

View file

@ -58,6 +58,9 @@ typedef void *SDL_MetalView;
* The returned handle can be casted directly to a NSView or UIView. To access
* the backing CAMetalLayer, call SDL_Metal_GetLayer().
*
* \param window the window
* \returns handle NSView or UIView
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Metal_DestroyView
@ -71,6 +74,8 @@ extern DECLSPEC SDL_MetalView SDLCALL SDL_Metal_CreateView(SDL_Window * window);
* This should be called before SDL_DestroyWindow, if SDL_Metal_CreateView was
* called after SDL_CreateWindow.
*
* \param view the view
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Metal_CreateView
@ -80,6 +85,9 @@ extern DECLSPEC void SDLCALL SDL_Metal_DestroyView(SDL_MetalView view);
/**
* Get a pointer to the backing CAMetalLayer for the given view.
*
* \param view the view
* \returns a pointer
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_Metal_CreateView

View file

@ -166,7 +166,7 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
* other threads in the system (this is known as a "recursive mutex").
*
* \param mutex the mutex to lock
* \return 0, or -1 on error.
* \returns 0, or -1 on error.
*
* \since This function is available since SDL 3.0.0.
*/

View file

@ -128,7 +128,7 @@
#define SDL_WINDOWEVENT_RESIZED SDL_EVENT_WINDOW_RESIZED
#define SDL_WINDOWEVENT_RESTORED SDL_EVENT_WINDOW_RESTORED
#define SDL_WINDOWEVENT_SHOWN SDL_EVENT_WINDOW_SHOWN
#define SDL_WINDOWEVENT_SIZE_CHANGED SDL_EVENT_WINDOW_SIZE_CHANGED
#define SDL_WINDOWEVENT_SIZE_CHANGED SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED
#define SDL_WINDOWEVENT_TAKE_FOCUS SDL_EVENT_WINDOW_TAKE_FOCUS
/* ##SDL_gamepad.h */
@ -507,7 +507,7 @@
#define SDL_TEXTEDITING_EXT SDL_TEXTEDITING_EXT_renamed_SDL_EVENT_TEXT_EDITING_EXT
#define SDL_TEXTINPUT SDL_TEXTINPUT_renamed_SDL_EVENT_TEXT_INPUT
#define SDL_USEREVENT SDL_USEREVENT_renamed_SDL_EVENT_USER
#define SDL_WINDOWEVENT_CLOSE SDL_WINDOWEVENT_CLOSE_renamed_SDL_EVENT_WINDOW_CLOSE
#define SDL_WINDOWEVENT_CLOSE SDL_WINDOWEVENT_CLOSE_renamed_SDL_EVENT_WINDOW_CLOSE_REQUESTED
#define SDL_WINDOWEVENT_DISPLAY_CHANGED SDL_WINDOWEVENT_DISPLAY_CHANGED_renamed_SDL_EVENT_WINDOW_DISPLAY_CHANGED
#define SDL_WINDOWEVENT_ENTER SDL_WINDOWEVENT_ENTER_renamed_SDL_EVENT_WINDOW_ENTER
#define SDL_WINDOWEVENT_EXPOSED SDL_WINDOWEVENT_EXPOSED_renamed_SDL_EVENT_WINDOW_EXPOSED
@ -523,7 +523,7 @@
#define SDL_WINDOWEVENT_RESIZED SDL_WINDOWEVENT_RESIZED_renamed_SDL_EVENT_WINDOW_RESIZED
#define SDL_WINDOWEVENT_RESTORED SDL_WINDOWEVENT_RESTORED_renamed_SDL_EVENT_WINDOW_RESTORED
#define SDL_WINDOWEVENT_SHOWN SDL_WINDOWEVENT_SHOWN_renamed_SDL_EVENT_WINDOW_SHOWN
#define SDL_WINDOWEVENT_SIZE_CHANGED SDL_WINDOWEVENT_SIZE_CHANGED_renamed_SDL_EVENT_WINDOW_SIZE_CHANGED
#define SDL_WINDOWEVENT_SIZE_CHANGED SDL_WINDOWEVENT_SIZE_CHANGED_renamed_SDL_EVENT_WINDOW_PIXEL_SIZE_CHANGED
#define SDL_WINDOWEVENT_TAKE_FOCUS SDL_WINDOWEVENT_TAKE_FOCUS_renamed_SDL_EVENT_WINDOW_TAKE_FOCUS
/* ##SDL_gamepad.h */

View file

@ -580,7 +580,7 @@ extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture *texture, SDL_Sc
*
* \param texture the texture to query.
* \param scaleMode a pointer filled in with the current scale mode.
* \return 0 on success, or -1 if the texture is not valid.
* \returns 0 on success, or -1 if the texture is not valid.
*
* \since This function is available since SDL 3.0.0.
*
@ -605,7 +605,7 @@ extern DECLSPEC int SDLCALL SDL_SetTextureUserData(SDL_Texture *texture, void *u
* Get the user-specified pointer associated with a texture
*
* \param texture the texture to query.
* \return the pointer associated with the texture, or NULL if the texture is
* \returns the pointer associated with the texture, or NULL if the texture is
* not valid.
*
* \since This function is available since SDL 3.0.0.
@ -694,7 +694,7 @@ extern DECLSPEC int SDLCALL SDL_UpdateYUVTexture(SDL_Texture *texture,
* \param UVplane the raw pixel data for the UV plane.
* \param UVpitch the number of bytes between rows of pixel data for the UV
* plane.
* \return 0 on success, or -1 if the texture is not valid.
* \returns 0 on success, or -1 if the texture is not valid.
*
* \since This function is available since SDL 3.0.0.
*/
@ -1161,7 +1161,7 @@ extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer *renderer);
* \param renderer The renderer which should draw a point.
* \param x The x coordinate of the point.
* \param y The y coordinate of the point.
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1173,7 +1173,7 @@ extern DECLSPEC int SDLCALL SDL_RenderPoint(SDL_Renderer *renderer, float x, flo
* \param renderer The renderer which should draw multiple points.
* \param points The points to draw
* \param count The number of points to draw
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1187,7 +1187,7 @@ extern DECLSPEC int SDLCALL SDL_RenderPoints(SDL_Renderer *renderer, const SDL_F
* \param y1 The y coordinate of the start point.
* \param x2 The x coordinate of the end point.
* \param y2 The y coordinate of the end point.
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1200,7 +1200,7 @@ extern DECLSPEC int SDLCALL SDL_RenderLine(SDL_Renderer *renderer, float x1, flo
* \param renderer The renderer which should draw multiple lines.
* \param points The points along the lines
* \param count The number of points, drawing count-1 lines
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1212,7 +1212,7 @@ extern DECLSPEC int SDLCALL SDL_RenderLines(SDL_Renderer *renderer, const SDL_FP
* \param renderer The renderer which should draw a rectangle.
* \param rect A pointer to the destination rectangle, or NULL to outline the
* entire rendering target.
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1225,7 +1225,7 @@ extern DECLSPEC int SDLCALL SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRe
* \param renderer The renderer which should draw multiple rectangles.
* \param rects A pointer to an array of destination rectangles.
* \param count The number of rectangles.
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1238,7 +1238,7 @@ extern DECLSPEC int SDLCALL SDL_RenderRects(SDL_Renderer *renderer, const SDL_FR
* \param renderer The renderer which should fill a rectangle.
* \param rect A pointer to the destination rectangle, or NULL for the entire
* rendering target.
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1251,7 +1251,7 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer *renderer, const SDL
* \param renderer The renderer which should fill multiple rectangles.
* \param rects A pointer to an array of destination rectangles.
* \param count The number of rectangles.
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1267,7 +1267,7 @@ extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer *renderer, const SD
* texture.
* \param dstrect A pointer to the destination rectangle, or NULL for the
* entire rendering target.
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1290,7 +1290,7 @@ extern DECLSPEC int SDLCALL SDL_RenderTexture(SDL_Renderer *renderer, SDL_Textur
* around dstrect.w/2, dstrect.h/2).
* \param flip An SDL_RendererFlip value stating which flipping actions should
* be performed on the texture
* \return 0 on success, or -1 on error
* \returns 0 on success, or -1 on error
*
* \since This function is available since SDL 3.0.0.
*/
@ -1312,7 +1312,7 @@ extern DECLSPEC int SDLCALL SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL
* array, if NULL all vertices will be rendered in sequential
* order.
* \param num_indices Number of indices.
* \return 0 on success, or -1 if the operation is not supported
* \returns 0 on success, or -1 if the operation is not supported
*
* \since This function is available since SDL 3.0.0.
*
@ -1342,7 +1342,7 @@ extern DECLSPEC int SDLCALL SDL_RenderGeometry(SDL_Renderer *renderer,
* if NULL all vertices will be rendered in sequential order.
* \param num_indices Number of indices.
* \param size_indices Index size: 1 (byte), 2 (short), 4 (int)
* \return 0 on success, or -1 if the operation is not supported
* \returns 0 on success, or -1 if the operation is not supported
*
* \since This function is available since SDL 3.0.0.
*

View file

@ -60,7 +60,7 @@ extern "C" {
* ::SDL_WINDOW_RESIZABLE, ::SDL_WINDOW_MAXIMIZED,
* ::SDL_WINDOW_MINIMIZED, ::SDL_WINDOW_BORDERLESS is always set,
* and ::SDL_WINDOW_FULLSCREEN is always unset.
* \return the window created, or NULL if window creation failed.
* \returns the window created, or NULL if window creation failed.
*
* \since This function is available since SDL 3.0.0.
*
@ -72,7 +72,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_CreateShapedWindow(const char *title,un
* Return whether the given window is a shaped window.
*
* \param window The window to query for being shaped.
* \return SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if
* \returns SDL_TRUE if the window is a window that can be shaped, SDL_FALSE if
* the window is unshaped or NULL.
*
* \since This function is available since SDL 3.0.0.
@ -116,7 +116,7 @@ typedef struct SDL_WindowShapeMode {
* \param window The shaped window whose parameters should be set.
* \param shape A surface encoding the desired shape for the window.
* \param shape_mode The parameters to set for the shaped window.
* \return 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape
* \returns 0 on success, SDL_INVALID_SHAPE_ARGUMENT on an invalid shape
* argument, or SDL_NONSHAPEABLE_WINDOW if the SDL_Window given does
* not reference a valid shaped window.
*
@ -133,7 +133,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowShape(SDL_Window *window,SDL_Surface *s
* \param window The shaped window whose parameters should be retrieved.
* \param shape_mode An empty shape-mode structure to fill, or NULL to check
* whether the window has a shape.
* \return 0 if the window has a shape and, provided shape_mode was not NULL,
* \returns 0 if the window has a shape and, provided shape_mode was not NULL,
* shape_mode has been filled with the mode data,
* SDL_NONSHAPEABLE_WINDOW if the SDL_Window given is not a shaped
* window, or SDL_WINDOW_LACKS_SHAPE if the SDL_Window given is a

View file

@ -394,6 +394,11 @@ typedef void (SDLCALL *SDL_free_func)(void *mem);
/**
* Get the original set of SDL memory functions
*
* \param malloc_func filled with malloc function
* \param calloc_func filled with calloc function
* \param realloc_func filled with realloc function
* \param free_func filled with free function
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *malloc_func,
@ -404,6 +409,11 @@ extern DECLSPEC void SDLCALL SDL_GetOriginalMemoryFunctions(SDL_malloc_func *mal
/**
* Get the current set of SDL memory functions
*
* \param malloc_func filled with malloc function
* \param calloc_func filled with calloc function
* \param realloc_func filled with realloc function
* \param free_func filled with free function
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func,
@ -414,6 +424,13 @@ extern DECLSPEC void SDLCALL SDL_GetMemoryFunctions(SDL_malloc_func *malloc_func
/**
* Replace SDL's memory allocation functions with a custom set
*
* \param malloc_func custom malloc function
* \param calloc_func custom calloc function
* \param realloc_func custom realloc function
* \param free_func custom free function
* \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.
*/
extern DECLSPEC int SDLCALL SDL_SetMemoryFunctions(SDL_malloc_func malloc_func,
@ -454,6 +471,8 @@ extern DECLSPEC void SDLCALL SDL_aligned_free(void *mem);
/**
* Get the number of outstanding (unfreed) allocations
*
* \returns the number of allocations
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_GetNumAllocations(void);

View file

@ -351,7 +351,7 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceColorKey(SDL_Surface *surface,
* It is safe to pass a NULL `surface` here; it will return SDL_FALSE.
*
* \param surface the SDL_Surface structure to query
* \return SDL_TRUE if the surface has a color key, SDL_FALSE otherwise.
* \returns SDL_TRUE if the surface has a color key, SDL_FALSE otherwise.
*
* \since This function is available since SDL 3.0.0.
*
@ -795,6 +795,15 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUnchecked
* Perform a fast, low quality, stretch blit between two surfaces of the same
* format.
*
* \param src the SDL_Surface structure to be copied from
* \param srcrect the SDL_Rect structure representing the rectangle to be
* copied
* \param dst the SDL_Surface structure that is the blit target
* \param dstrect the SDL_Rect structure representing the rectangle that is
* copied into
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* Please use SDL_BlitScaled() instead.
*
* \since This function is available since SDL 3.0.0.
@ -807,6 +816,15 @@ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src,
/**
* Perform bilinear scaling between two surfaces of the same format, 32BPP.
*
* \param src the SDL_Surface structure to be copied from
* \param srcrect the SDL_Rect structure representing the rectangle to be
* copied
* \param dst the SDL_Surface structure that is the blit target
* \param dstrect the SDL_Rect structure representing the rectangle that is
* copied into
* \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.
*/
extern DECLSPEC int SDLCALL SDL_SoftStretchLinear(SDL_Surface *src,
@ -861,6 +879,8 @@ extern DECLSPEC int SDLCALL SDL_BlitSurfaceUncheckedScaled
/**
* Set the YUV conversion mode
*
* \param mode YUV conversion mode
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
@ -868,6 +888,8 @@ extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mo
/**
* Get the YUV conversion mode
*
* \returns YUV conversion mode
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
@ -876,6 +898,10 @@ extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
* Get the YUV conversion mode, returning the correct mode for the resolution
* when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
*
* \param width width
* \param height height
* \returns YUV conversion mode
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);

View file

@ -456,6 +456,8 @@ extern DECLSPEC int SDLCALL SDL_AndroidShowToast(const char* message, int durati
*
* \param command user command that must be greater or equal to 0x8000
* \param param user parameter
* \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.
*/

View file

@ -39,7 +39,7 @@ extern "C" {
/**
* \brief Start tracking SDL memory allocations
*
*
* \note This should be called before any other SDL functions for complete tracking coverage
*/
int SDLTest_TrackAllocations(void);

View file

@ -116,11 +116,35 @@ typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code);
#define SDL_endthread _endthreadex
#endif
/*
* Create a SDL Thread
*
* \param fn Thread function
* \param name name
* \param data some data
* \param pfnSDL_CurrentBeginThread begin function
* \param pfnSDL_CurrentEndThread end function
*
* \returns SDL_Thread pointer
*/
extern DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data,
pfnSDL_CurrentBeginThread pfnBeginThread,
pfnSDL_CurrentEndThread pfnEndThread);
/*
* Create a SDL Thread, with explicit stack size
*
* \param fn Thread function
* \param name name
* \param stacksize stack size
* \param data some data
* \param pfnSDL_CurrentBeginThread begin function
* \param pfnSDL_CurrentEndThread end function
*
* \returns SDL_Thread pointer
*/
extern DECLSPEC SDL_Thread *SDLCALL
SDL_CreateThreadWithStackSize(SDL_ThreadFunction fn,
const char *name, const size_t stacksize, void *data,

View file

@ -99,6 +99,9 @@ extern DECLSPEC SDL_TouchID SDLCALL SDL_GetTouchDevice(int index);
* Get the touch device name as reported from the driver or NULL if the index
* is invalid.
*
* \param index the touch device index
* \returns touch device name
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC const char* SDLCALL SDL_GetTouchName(int index);
@ -106,6 +109,9 @@ extern DECLSPEC const char* SDLCALL SDL_GetTouchName(int index);
/**
* Get the type of the given touch device.
*
* \param touchID the ID of a touch device
* \returns touch device type
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_TouchID touchID);

View file

@ -476,7 +476,7 @@ extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetDesktopDisplayMode(SDL_Dis
extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayID displayID);
/**
* Get the display containing a point
* Get the display containing a point, in screen coordinates.
*
* \param point the point to query
* \returns the instance ID of the display containing the point or 0 on
@ -490,7 +490,7 @@ extern DECLSPEC const SDL_DisplayMode *SDLCALL SDL_GetCurrentDisplayMode(SDL_Dis
extern DECLSPEC SDL_DisplayID SDLCALL SDL_GetDisplayForPoint(const SDL_Point *point);
/**
* Get the display primarily containing a rect
* Get the display primarily containing a rect, in screen coordinates.
*
* \param rect the rect to query
* \returns the instance ID of the display entirely containing the rect or
@ -1458,7 +1458,7 @@ typedef enum
* \param win the SDL_Window where hit-testing was set on
* \param area an SDL_Point which should be hit-tested
* \param data what was passed as `callback_data` to SDL_SetWindowHitTest()
* \return an SDL_HitTestResult value.
* \returns an SDL_HitTestResult value.
*
* \sa SDL_SetWindowHitTest
*/
@ -1842,6 +1842,7 @@ extern DECLSPEC SDL_EGLConfig SDLCALL SDL_EGL_GetCurrentEGLConfig(void);
/**
* Get the EGL surface associated with the window.
*
* \param window the window to query
* \returns the EGLSurface pointer associated with the window, or NULL on
* failure.
*

View file

@ -38,6 +38,11 @@
/* The tag name used by PSP audio */
#define PSPAUDIO_DRIVER_NAME "psp"
static inline SDL_bool isBasicAudioConfig(const SDL_AudioSpec *spec)
{
return spec->freq == 44100;
}
static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
{
int format, mixlen, i;
@ -52,23 +57,37 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
/* device only natively supports S16LSB */
this->spec.format = AUDIO_S16LSB;
/* The sample count must be a multiple of 64. */
this->spec.samples = PSP_AUDIO_SAMPLE_ALIGN(this->spec.samples);
/* Setup the hardware channel. */
if (this->spec.channels == 1) {
format = PSP_AUDIO_FORMAT_MONO;
} else {
format = PSP_AUDIO_FORMAT_STEREO;
this->spec.channels = 2; /* we're forcing the hardware to stereo. */
}
/* PSP has some limitations with the Audio. It fully supports 44.1KHz (Mono & Stereo),
however with frequencies differents than 44.1KHz, it just supports Stereo,
so a resampler must be done for these scenarios */
if (this->spec.freq == 44100) {
if (isBasicAudioConfig(&this->spec)) {
/* The sample count must be a multiple of 64. */
this->spec.samples = PSP_AUDIO_SAMPLE_ALIGN(this->spec.samples);
/* The number of channels (1 or 2). */
this->spec.channels = this->spec.channels == 1 ? 1 : 2;
format = this->spec.channels == 1 ? PSP_AUDIO_FORMAT_MONO : PSP_AUDIO_FORMAT_STEREO;
this->hidden->channel = sceAudioChReserve(PSP_AUDIO_NEXT_CHANNEL, this->spec.samples, format);
} else {
/* 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11050, 8000 */
switch (this->spec.freq) {
case 8000:
case 11025:
case 12000:
case 16000:
case 22050:
case 24000:
case 32000:
case 44100:
case 48000:
this->spec.freq = this->spec.freq;
break;
default:
this->spec.freq = 48000;
break;
}
/* The number of samples to output in one output call (min 17, max 4111). */
this->spec.samples = this->spec.samples < 17 ? 17 : (this->spec.samples > 4111 ? 4111 : this->spec.samples);
this->spec.channels = 2; /* we're forcing the hardware to stereo. */
this->hidden->channel = sceAudioSRCChReserve(this->spec.samples, this->spec.freq, 2);
}
@ -101,12 +120,11 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
static void PSPAUDIO_PlayDevice(_THIS)
{
if (this->spec.freq != 44100) {
Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer];
Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer];
if (!isBasicAudioConfig(&this->spec)) {
SDL_assert(this->spec.channels == 2);
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, mixbuf);
} else {
Uint8 *mixbuf = this->hidden->mixbufs[this->hidden->next_buffer];
sceAudioOutputPannedBlocking(this->hidden->channel, PSP_AUDIO_VOLUME_MAX, PSP_AUDIO_VOLUME_MAX, mixbuf);
}
@ -127,7 +145,7 @@ static Uint8 *PSPAUDIO_GetDeviceBuf(_THIS)
static void PSPAUDIO_CloseDevice(_THIS)
{
if (this->hidden->channel >= 0) {
if (this->spec.freq != 44100) {
if (!isBasicAudioConfig(&this->spec)) {
sceAudioSRCChRelease();
} else {
sceAudioChRelease(this->hidden->channel);

View file

@ -443,6 +443,47 @@ static void GetScaledMouseDeltas(SDL_Mouse *mouse, float *x, float *y)
}
}
static void ConstrainMousePosition(SDL_Mouse *mouse, SDL_Window *window, float *x, float *y)
{
/* make sure that the pointers find themselves inside the windows,
unless we have the mouse captured. */
if (window && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
int x_min = 0, x_max = window->w - 1;
int y_min = 0, y_max = window->h - 1;
const SDL_Rect *confine = SDL_GetWindowMouseRect(window);
if (confine) {
SDL_Rect window_rect;
SDL_Rect mouse_rect;
window_rect.x = 0;
window_rect.y = 0;
window_rect.w = x_max + 1;
window_rect.h = y_max + 1;
if (SDL_GetRectIntersection(confine, &window_rect, &mouse_rect)) {
x_min = mouse_rect.x;
y_min = mouse_rect.y;
x_max = x_min + mouse_rect.w - 1;
y_max = y_min + mouse_rect.h - 1;
}
}
if (*x >= (float)(x_max + 1)) {
*x = SDL_max((float)x_max, mouse->last_x);
}
if (*x < (float)x_min) {
*x = (float)x_min;
}
if (*y >= (float)(y_max + 1)) {
*y = SDL_max((float)y_max, mouse->last_y);
}
if (*y < (float)y_min) {
*y = (float)y_min;
}
}
}
static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_MouseID mouseID, int relative, float x, float y)
{
SDL_Mouse *mouse = SDL_GetMouse();
@ -498,9 +539,14 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
yrel = y;
x = (mouse->last_x + xrel);
y = (mouse->last_y + yrel);
} else if (mouse->has_position) {
xrel = x - mouse->last_x;
yrel = y - mouse->last_y;
ConstrainMousePosition(mouse, window, &x, &y);
} else {
ConstrainMousePosition(mouse, window, &x, &y);
if (mouse->has_position) {
xrel = x - mouse->last_x;
yrel = y - mouse->last_y;
}
}
/* Ignore relative motion when first positioning the mouse */
@ -530,44 +576,6 @@ static int SDL_PrivateSendMouseMotion(Uint64 timestamp, SDL_Window *window, SDL_
mouse->y += yrel;
}
/* make sure that the pointers find themselves inside the windows,
unless we have the mouse captured. */
if (window && !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)) {
int x_min = 0, x_max = window->w - 1;
int y_min = 0, y_max = window->h - 1;
const SDL_Rect *confine = SDL_GetWindowMouseRect(window);
if (confine) {
SDL_Rect window_rect;
SDL_Rect mouse_rect;
window_rect.x = 0;
window_rect.y = 0;
window_rect.w = x_max + 1;
window_rect.h = y_max + 1;
if (SDL_GetRectIntersection(confine, &window_rect, &mouse_rect)) {
x_min = mouse_rect.x;
y_min = mouse_rect.y;
x_max = x_min + mouse_rect.w - 1;
y_max = y_min + mouse_rect.h - 1;
}
}
if (mouse->x >= (float)(x_max + 1)) {
mouse->x = (float)x_max;
}
if (mouse->x < (float)x_min) {
mouse->x = (float)x_min;
}
if (mouse->y >= (float)(y_max + 1)) {
mouse->y = (float)y_max;
}
if (mouse->y < (float)y_min) {
mouse->y = (float)y_min;
}
}
mouse->xdelta += xrel;
mouse->ydelta += yrel;

View file

@ -175,6 +175,7 @@ static const char *s_GamepadMappings[] = {
"030000000d0f00000900000000000000,Hori Pad 3 Turbo,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"030000000d0f00005400000000000000,Hori Pad 3,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"030000000d0f00004d00000000000000,Hori Pad A,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"030000000d0f00009200000000000000,Hori Pokken Tournament DX Pro Pad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
"030000000d0f0000c100000000000000,Horipad,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,leftstick:b10,lefttrigger:b6,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b11,righttrigger:b7,rightx:a2,righty:a3,start:b9,x:b0,y:b3,",
"030000008f0e00001330000000000000,HuiJia SNES Controller,a:b2,b:b1,back:b8,dpdown:+a1,dpleft:-a0,dpright:+a0,dpup:-a1,leftshoulder:b6,rightshoulder:b7,start:b9,x:b3,y:b0,",
"030000006f0e00002401000000000000,INJUSTICE FightStick PS3 Controller,a:b1,b:b2,back:b8,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b4,lefttrigger:b6,rightshoulder:b5,righttrigger:b7,start:b9,x:b0,y:b3,",
@ -540,12 +541,12 @@ static const char *s_GamepadMappings[] = {
"05000000203800000900000000010000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,leftshoulder:b6,leftstick:b13,lefttrigger:b8,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:b9,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000c82d00002038000000010000,8BitDo NES30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000c82d00002038000000010000,8BitDo NES30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"03000000c82d00000020000000000000,8BitDo Pro 2 Wired Controller for Xbox,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"06000000c82d00000020000006010000,8BitDo Pro 2 Wired Controller for Xbox,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"03000000c82d00000660000011010000,8BitDo Pro 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"03000000c82d00000660000011010000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000c82d00000660000000010000,8BitDo Pro 2,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000c82d00000660000000010000,8BitDo Pro 2,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b12,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"03000000c82d00000020000000000000,8BitDo Pro 2 Wired Controller for Xbox,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"06000000c82d00000020000006010000,8BitDo Pro 2 Wired Controller for Xbox,a:b0,b:b1,back:b6,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b8,leftshoulder:b4,leftstick:b9,lefttrigger:a2,leftx:a0,lefty:a1,rightshoulder:b5,rightstick:b10,righttrigger:a5,rightx:a3,righty:a4,start:b7,x:b2,y:b3,",
"05000000c82d00000061000000010000,8BitDo SF30 Pro,a:b0,b:b1,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000c82d00000061000000010000,8BitDo SF30 Pro,a:b1,b:b0,back:b10,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,dpup:h0.1,guide:b2,leftshoulder:b6,leftstick:b13,lefttrigger:a5,leftx:a0,lefty:a1,rightshoulder:b7,rightstick:b14,righttrigger:a4,rightx:a2,righty:a3,start:b11,x:b4,y:b3,hint:!SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",
"05000000102800000900000000010000,8BitDo SFC30 Gamepad,a:b0,b:b1,back:b10,leftshoulder:b6,leftx:a0,lefty:a1,rightshoulder:b7,start:b11,x:b3,y:b4,hint:SDL_GAMECONTROLLER_USE_BUTTON_LABELS:=1,",

View file

@ -694,7 +694,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
* Xbox Series X firmware version 5.1, report is 44 bytes, share button is in byte 18
* Xbox Series X firmware version 5.5, report is 48 bytes, share button is in byte 22
* Victrix Gambit Tournament Controller, report is 50 bytes, share button is in byte 32
* ThrustMaster eSwap PRO Controller Xbox, report is 64 bytes, share button is in byte 46
* ThrustMaster eSwap PRO Controller Xbox, report is 60 bytes, share button is in byte 46
*/
if (size < 48) {
if (ctx->last_state[18] != data[18]) {
@ -708,7 +708,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D
if (ctx->last_state[32] != data[32]) {
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[32] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
}
} else if (size == 64) {
} else if (size == 60) {
if (ctx->last_state[46] != data[46]) {
SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[46] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
}

View file

@ -1235,11 +1235,12 @@ SDL_DisplayID SDL_GetDisplayForWindowCoordinate(int coordinate)
return displayID;
}
SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
static SDL_DisplayID SDL_GetDisplayForWindowPosition(SDL_Window *window)
{
SDL_DisplayID displayID = 0;
CHECK_WINDOW_MAGIC(window, 0);
if (_this->GetDisplayForWindow) {
displayID = _this->GetDisplayForWindow(_this, window);
}
@ -1257,10 +1258,41 @@ SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
if (!displayID) {
displayID = GetDisplayForRect(window->x, window->y, window->w, window->h);
}
if (!displayID && (window->flags & SDL_WINDOW_FULLSCREEN)) {
/* Use the explicit fullscreen display if retrieval via the window position fails */
if (!displayID) {
/* Use the primary display for a window if we can't find it anywhere else */
displayID = SDL_GetPrimaryDisplay();
}
return displayID;
}
SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
{
SDL_DisplayID displayID = 0;
CHECK_WINDOW_MAGIC(window, 0);
/* An explicit fullscreen display overrides all */
if (window->flags & SDL_WINDOW_FULLSCREEN) {
displayID = window->fullscreen_mode.displayID;
}
if (!displayID && _this->GetDisplayForWindow) {
displayID = _this->GetDisplayForWindow(_this, window);
}
/* A backend implementation may fail to get a display for the window
* (for example if the window is off-screen), but other code may expect it
* to succeed in that situation, so we fall back to a generic position-
* based implementation in that case. */
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(window->windowed.x);
}
if (!displayID) {
displayID = SDL_GetDisplayForWindowCoordinate(window->windowed.y);
}
if (!displayID) {
displayID = GetDisplayForRect(window->x, window->y, window->w, window->h);
}
if (!displayID) {
/* Use the primary display for a window if we can't find it anywhere else */
displayID = SDL_GetPrimaryDisplay();
@ -1270,7 +1302,7 @@ SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window)
void SDL_CheckWindowDisplayChanged(SDL_Window *window)
{
SDL_DisplayID displayID = SDL_GetDisplayForWindow(window);
SDL_DisplayID displayID = SDL_GetDisplayForWindowPosition(window);
if (displayID != window->last_displayID) {
int i, display_index;
@ -1507,17 +1539,8 @@ int SDL_SetWindowFullscreenMode(SDL_Window *window, const SDL_DisplayMode *mode)
if (SDL_WINDOW_FULLSCREEN_VISIBLE(window)) {
SDL_UpdateFullscreenMode(window, SDL_TRUE);
} else if (window->flags & SDL_WINDOW_FULLSCREEN) {
/* If fullscreen and not visible, just update the position so the window will be
* on the correct display when shown/restored.
*/
if (mode) {
SDL_Rect r;
if (SDL_GetDisplayBounds(mode->displayID, &r) == 0) {
SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MOVED, r.x, r.y);
}
}
}
return 0;
}

View file

@ -1348,6 +1348,11 @@ static void X11_SetWindowFullscreenViaWM(_THIS, SDL_Window *window, SDL_VideoDis
X11_XSendEvent(display, RootWindow(display, displaydata->screen), 0,
SubstructureNotifyMask | SubstructureRedirectMask, &e);
/* Set the position so the window will be on the target display */
if (fullscreen) {
X11_XMoveWindow(display, data->xwindow, displaydata->x, displaydata->y);
}
/* Fullscreen windows sometimes end up being marked maximized by
window managers. Force it back to how we expect it to be. */
if (!fullscreen) {