Commit graph

7066 commits

Author SHA1 Message Date
Sylvain 93ed3148ba Fixed bug #7302 - Memory 'leak' in SDL_SetMouseSystemScale() 2023-02-13 09:42:12 +01:00
Sylvain eea4711110 gendynapi.py: add option to check doc formating (eg \param \returns \since) 2023-02-12 20:43:30 +01:00
Francisco Javier Trujillo Mata b728de788e Fixed audio 2023-02-11 13:23:08 -08:00
Frank Praznik 4a6f3cf47e x11: Set the window position when entering fullscreen
Set the window position when entering fullscreen as both real Xorg and XWayland need this in order for the window to be on the correct display.
2023-02-11 14:44:02 -05:00
Frank Praznik d6a19c8cc6 video: Use the explicit fullscreen display for a window unless the window was moved
When an exclusive fullscreen display is specified, it overrides any positioning, including from driver specific functions. Allows for the proper placement of fullscreen windows on macOS and Windows when the floating window is on a display that differs from the one specified by the exclusive fullscreen mode.

 A specific position-only function has been split out for use when a window has been moved.
2023-02-11 14:44:02 -05:00
Sam Lantinga 68e2f23066 Sorted controller list 2023-02-10 17:18:02 -08:00
Alfredo Escobar 76552e4780 Add Hori Pokken Tournament DX Pro Pad 2023-02-10 17:16:26 -08:00
Sam Lantinga e4face7c1d Fixed the share button on the ThrustMaster eSwap PRO Controller Xbox 2023-02-10 16:46:21 -08:00
Sam Lantinga b55bb02723 Constrain the mouse position before it's used to generate mouse deltas
Also clamp the mouse position to the maximum of *max and the last mouse position

Fixes https://github.com/libsdl-org/SDL/issues/7221#issuecomment-1426054481
2023-02-10 09:08:12 -08:00
Sylvain 7c4ec1867b Remove some vim config lines 2023-02-10 11:00:48 +01:00
Sylvain a2f3711c80 SDL_AndroidGetExternalStorageState(): return 0 on success, and fills *state with flags 2023-02-10 09:30:31 +01:00
Bruce Mitchener a8e89f2567 emscripten: Update deprecated calls to EM_ASM*.
`EM_ASM_` and `EM_ASM_INT_V` are calls that have been deprecated
for a long time.

Since the return value isn't used for the call to `EM_ASM_`, it
can be replaced with `EM_ASM`.

`EM_ASM_INT_V` is now (for the last few years) `EM_ASM_INT`.
2023-02-09 23:10:17 -08:00
Sam Lantinga b9773be3b3 Don't clamp mouse coordinates until they're fully outside the containing area
A window 1920x1080 pixels wide at 125% scaling will have a width and height of 1536x864, but at pixel (1919,1079) the mouse coordinate will be (1535.2,863.2), which is within the bounds of 1536x864, but larger than (1535,863).
2023-02-09 18:29:47 -08:00
Sam Lantinga 5b77ad54c4 Fixed order and constness of parameters to SDL_ConvertAudioSamples() 2023-02-09 17:49:35 -08:00
Sam Lantinga e65e2c8ed7 SDL_CloseJoystick() should return void, not int 2023-02-09 17:26:16 -08:00
Sam Lantinga a9650d440a Fixed MFI controller being opened while HIDAPI controller was being opened
This was the callstack:
    frame #3: 0x00000001004e1930 libSDL3.1.0.0.dylib`IOS_AddJoystickDevice(controller=0x0000600003b0c000, accelerometer=SDL_FALSE) at SDL_mfijoystick.m:528:14
    frame #4: 0x00000001004e1a54 libSDL3.1.0.0.dylib`__IOS_JoystickInit_block_invoke(.block_descriptor=0x0000000100547760, note=@"GCControllerDidConnectNotification") at SDL_mfijoystick.m:673:45
    frame #5: 0x000000018601e578 CoreFoundation`__CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 128
    frame #6: 0x00000001860bc074 CoreFoundation`___CFXRegistrationPost_block_invoke + 88
    frame #7: 0x00000001860bbfbc CoreFoundation`_CFXRegistrationPost + 440
    frame #8: 0x0000000185fefbac CoreFoundation`_CFXNotificationPost + 708
    frame #9: 0x0000000186edc72c Foundation`-[NSNotificationCenter postNotificationName:object:userInfo:] + 88
    frame #10: 0x000000019b054a18 GameController`__60-[_GCControllerManagerAppClient _onqueue_publishController:]_block_invoke + 156
    frame #11: 0x0000000185dc19dc libdispatch.dylib`_dispatch_call_block_and_release + 32
    frame #12: 0x0000000185dc3504 libdispatch.dylib`_dispatch_client_callout + 20
    frame #13: 0x0000000185dd1d1c libdispatch.dylib`_dispatch_main_queue_drain + 928
    frame #14: 0x0000000185dd196c libdispatch.dylib`_dispatch_main_queue_callback_4CF + 44
    frame #15: 0x000000018606ad6c CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
    frame #16: 0x00000001860287ec CoreFoundation`__CFRunLoopRun + 2036
    frame #17: 0x00000001860278a4 CoreFoundation`CFRunLoopRunSpecific + 612
    frame #18: 0x00000001003b1194 libSDL3.1.0.0.dylib`process_pending_events at hid.c:509:9
    frame #19: 0x00000001003aebe8 libSDL3.1.0.0.dylib`PLATFORM_hid_open_path(path="USB_054c_05c4_0x11a104290", bExclusive=0) at hid.c:823:2
    frame #20: 0x00000001003b051c libSDL3.1.0.0.dylib`SDL_hid_open_path_REAL(path="USB_054c_05c4_0x11a104290", bExclusive=0) at SDL_hidapi.c:1419:19
    frame #21: 0x00000001004dabdc libSDL3.1.0.0.dylib`HIDAPI_SetupDeviceDriver(device=0x0000600003518000, removed=0x000000016fdfee3c) at SDL_hidapijoystick.c:399:19
    frame #22: 0x00000001004da890 libSDL3.1.0.0.dylib`HIDAPI_AddDevice(info=0x000060000212c2d0, num_children=0, children=0x0000000000000000) at SDL_hidapijoystick.c:843:5
    frame #23: 0x00000001004d9148 libSDL3.1.0.0.dylib`HIDAPI_UpdateDeviceList at SDL_hidapijoystick.c:1000:21
    frame #24: 0x00000001004d9940 libSDL3.1.0.0.dylib`HIDAPI_JoystickDetect at SDL_hidapijoystick.c:1205:13
    frame #25: 0x00000001003bc6d8 libSDL3.1.0.0.dylib`SDL_UpdateJoysticks_REAL at SDL_joystick.c:1703:9
    frame #26: 0x00000001003a13a8 libSDL3.1.0.0.dylib`SDL_PumpEventsInternal(push_sentinel=SDL_FALSE) at SDL_events.c:855:9
    frame #27: 0x00000001003a1340 libSDL3.1.0.0.dylib`SDL_PumpEvents_REAL at SDL_events.c:879:5
    frame #28: 0x000000010038b380 libSDL3.1.0.0.dylib`SDL_PumpEvents at SDL_dynapi_procs.h:572:1
    frame #29: 0x0000000100004524 testgamepad`loop + 40
    frame #30: 0x00000001000063d8 testgamepad`main + 2140
2023-02-09 12:07:11 -08:00
Ozkan Sezer ae91dcbcf4 fix dynapi after commit dc74a67a 2023-02-09 22:50:00 +03:00
Sylvain dc74a67a57 SDL_UnlockTexture: change from 'int' to 'void' 2023-02-09 20:17:27 +01:00
Sylvain cee245b6a9 SDL_*SceenSaver(): change return value to int. // add SDL_Unsupported() errors 2023-02-09 08:16:46 -08:00
Sylvain e2e5e670bf Remove returns int from Destroy/Close/Unlock functions 2023-02-09 07:57:14 -08:00
Linus Probert 3bd737d44c Add error returns to void functions that can fail/set errors.
This takes care of the last set of void functions that could
potentially be shifted to instead return an int indicating success and
setting an error in case of an error.
2023-02-09 07:23:21 -08:00
Sylvain b305d9e3c0 Change return type from void to int for audio function. Eventually set invalid parameter error. 2023-02-08 17:43:44 -08:00
Sam Lantinga 824b9b0a58 Removed SDL_GetDisplayDPI()
This function wasn't consistently correct across platforms and devices.

If you want the UI scale factor, you can use display_scale in the structure returned by SDL_GetDesktopDisplayMode(). If you need an approximate DPI, you can multiply this value times 160 on iPhone and Android, and 96 on other platforms.
2023-02-08 17:35:54 -08:00
Sam Lantinga b7c6fec10a Make sure we synchronously re-enable USB reporting mode for Switch controllers (thanks @SortaCore!)
Fixes https://github.com/libsdl-org/SDL/issues/3450
2023-02-08 14:22:39 -08:00
Sam Lantinga 50575ed223 Note the Google Stadia controller doesn't support rumble over Bluetooth 2023-02-08 14:16:24 -08:00
Sam Lantinga 00e02de77b Fixed mis-detecting the share button on the Xbox controller over NDIS 2023-02-08 14:16:21 -08:00
Sam Lantinga d1c72bb0bc Dynamically update the serial number if it isn't available at first
This happens for Xbox One controllers using newer firmware connected over NDIS
2023-02-08 14:16:17 -08:00
Sylvain c5c94a6be6 Change return type from void to int, for functions that set an error
(SDL_SetError(), SDL_OutOfMemory(), SDL_Unsupported(), SDL_InvalidParam())

Update prototype to forward errors to generic layer, for the functions:
MoveCursor, WarpMouse, GL_DeleteContext, GetDisplayModes.

Check invalid parameter in SDL_SetTextInputRect() generic layer.
2023-02-07 13:51:45 -08:00
Frank Praznik 6c37d5b57f x11: Cast the dot clock value to 64-bit when calculating the refresh rate
The Xrandr dot clock value is declared as an unsigned long and the result when multiplying by 100 can overflow on a 32-bit system. Explicitly cast it to Sint64 to ensure that no overflow will occur.
2023-02-07 13:39:38 -05:00
Sam Lantinga 20a4e31a12 Re-added the internal hint SDL_BORDERLESS_WINDOWED_STYLE
sdl2-compat should set this to "0"
2023-02-07 09:47:17 -08:00
Pierre Wendling fa8fba3812 Add clang-tidy config and CMake/CI support. 2023-02-06 21:02:25 -08:00
Sam Lantinga 5fded632d6 Added support for the Turtle Beach REACT-R and Recon Xbox controllers 2023-02-06 20:14:12 -08:00
Frank Praznik d603371848 video: Try to get the display for fullscreen windows via the window position
Attempt to retrieve the display for fullscreen windows using the window position so that the correct display ID is returned if an exclusive fullscreen window is moved to another display.
2023-02-06 17:18:35 -08:00
Sam Lantinga 0208a0eeb3 Added support for the Logitech ChillStream 2023-02-06 13:28:59 -08:00
Ozkan Sezer b82a8b76b1 windows/SDL_systhread.c: remove some dead code. 2023-02-07 00:22:20 +03:00
Sam Lantinga 22bafe8729 Removed debug code accidentally committed 2023-02-06 11:23:53 -08:00
Sam Lantinga f8b41919da Fixed warning running a command queue without any vertex operations 2023-02-06 11:22:00 -08:00
Linus Probert 375bde8a4f
[SDL3] Cleanup void functions (#7253)
Some functions that do call SDL_SetError but return void changed to instead return non-zero in case of errors.
2023-02-06 08:53:52 -08:00
Sam Lantinga 9d8f98c735 Don't change presentation modes when resizing the logical target
Fixes https://github.com/libsdl-org/SDL/issues/7251
2023-02-06 08:51:58 -08:00
Sylvain 6f0acca8bd Return the SDL_SetError value 2023-02-06 11:42:38 +01:00
Sean Ridenour a077cc8e4d
[SDL3] macOS SetCursor performance fix (fixes #7151) (#7249)
* Setting the same mouse cursor twice is a no-op

* Cocoa: Call [NSCursor set] to change mouse cursor

The previous way, changing the mouse cursor was handled by invalidating
the mouse cursor rectangles and then recreating them (with the new
cursor) the next event loop. This is extremely slow; sometimes it can
take over a millisecond! With [NSCursor set] it happens instantly and
very quick performance-wise.

The downside is that it sets the cursor for the whole screen, so we
have some guards in place to change it to the system cursor if
the mouse moves outside the window or the window loses focus.

* Cocoa: Remove unneeded resetCursorRects: function
2023-02-05 17:58:33 -08:00
Sylvain fbe0352764 SDL_DestroyRenderer: drop all commands first
and don't queue new command from SDL_DestroyTexture() (memory leak)
2023-02-05 13:35:08 -08:00
Sam Lantinga ec1b42557f Fixed memory leak at shutdown (thanks @1bsyl!)
Clean up the textures first, as destroying the current render target will queue viewport and clip rectangle commands
2023-02-05 09:10:21 -08:00
Leonardo Brondani Schenkel 6f06e4bc80 Add Linux mapping for 8BitDo Pro 2 Wired Controller for Xbox
Without these mappings, this controller "kinda" works out of the box:
- `SDL_GameControllerMapping()` works because it will notice "Xbox" in
  the name and use the default XInput mappings
- `SDL_GameControllerMappingForGUID()` will not find any mapping

lsusb:
```
ID 2dc8:2000 8BitDo 8BitDo Pro 2 Wired Controller for Xbox
```

In Linux this controller is supported by two drivers:
- `xpad` (built-in to the kernel), exposes the controller name from the
  USB descriptor and the GUID starts with 03 (0x03 = BUS_USB)
- `xone` (https://github.com/medusalix/xone), exposes a virtual
  controller which is always named "Microsoft X-Box One pad" and the
  GUID starts with 06 (0x06 = BUS_VIRTUAL)

This commit adds the 2 GUIDs from both drivers so mappings will always
be found and the real controller name will always be reported.

(cherry picked from commit 4266cf8504)
2023-02-05 08:45:24 -08:00
Sam Lantinga 1c03ddefc3 Sorted controller list 2023-02-05 08:43:26 -08:00
Antonis Geralis 52cd9fcbb0 Added Elecom 8button gamepad 2023-02-05 08:41:07 -08:00
Frank Praznik b2d8a1a58c wayland: Transform mode values for native portrait displays
Portrait displays may have native, physical resolutions that are taller than wide. Reverse the mode dimensions when dealing with these displays as well as those rotated via software means.
2023-02-04 11:40:55 -05:00
Sam Lantinga 2a83093b36 Use a reasonable upper bound on the number of pixels we'll try to draw when traversing a line
Fixes https://github.com/libsdl-org/SDL/issues/6116
2023-02-03 20:53:30 -08:00
Alynne 4dea13e02f Adds Stadia BT mapping 2023-02-03 15:01:49 -08:00
Sam Lantinga 14a4ce8b59 Fixed SDL_ScaleMode values for consistency 2023-02-03 14:20:51 -08:00