Commit Graph

7917 Commits

Author SHA1 Message Date
Ryan C. Gordon
0714da37a4 audio: Fix audio stream callback calculations when future buffer has space.
We were subtracting backwards.  :/
2023-08-08 21:42:48 -04:00
Sam Lantinga
8a1afc9b10 Fixed Android not sending controller event timestamps 2023-08-08 09:47:49 -07:00
Sam Lantinga
463c456b98 Fill the correct member with the joystick ID in SDL_EVENT_JOYSTICK_UPDATE_COMPLETE 2023-08-08 09:47:49 -07:00
Sam Lantinga
79a190aa23 Fixed setting invalid bpp for FOURCC formats in SDL_GetMasksForPixelFormatEnum() 2023-08-07 22:20:40 -07:00
Sam Lantinga
b903ccf945 SDL_rwops read/write functions return size_t again
The current status is stored in the SDL_rwops 'status' field to be able to determine whether a 0 return value is caused by end of file, an error, or a non-blocking source not being ready.

The functions to read sized datatypes now return SDL_bool so you can detect read errors.

Fixes https://github.com/libsdl-org/SDL/issues/6729
2023-08-07 20:36:21 -07:00
Brick
c03f5b4b69 Fixed rounding up in SDL_PrintFloat
This wasn't caught by the 9.9999999 case, because that value is actually just equal to 10.0
2023-08-07 14:15:19 -07:00
Sam Lantinga
75a020aa6b Only query serial number and firmware versions from Sony PS5 controllers
I don't know of any specific issue with this, but third party PS4 controllers have had issues with reports that are specific to Sony hardware, so this is a speculative change to prevent issues with future controllers.

If it turns out that these reports are valid and useful for third party controllers, we can back this change out.
2023-08-07 14:06:10 -07:00
Sam Lantinga
fa189d302e Added the Victrix Pro FS for PS4/PS5 to the controller list 2023-08-07 14:04:34 -07:00
Sam Lantinga
26205b659d Fixed PS4/PS5 touchpad for third party controllers
We should always report touchpad and battery status if they are available. We just want to make sure we don't enable enhanced reports unless the application wants that behavior.
2023-08-07 10:48:52 -07:00
Ryan C. Gordon
e7d56dd0b2 audio: Renamed new API SDL_UnpauseAudioDevice to SDL_ResumeAudioDevice. 2023-08-05 19:20:14 -04:00
Mathieu Eyraud
2b0c0f5b6b Don't pass NULL to strncmp 2023-08-05 18:17:21 -04:00
Mathieu Eyraud
778e8185cd Fix size of memcpy in SDL_AudioDeviceFormatChangedAlreadyLocked
And add diagnostic that allows to find this kind of issue in clang-tidy
2023-08-05 14:14:45 -04:00
meyraud705
3a752ce650 Reapply "Changed 'freesrc' parameter from int to SDL_bool" to SDL_wave.c
Commit bea99d4 was partially reverted by 905c4ff "audio: First shot at the SDL3 audio subsystem redesign!"
2023-08-05 13:44:48 -04:00
Ozkan Sezer
2ba03b4db0 fix build after previous commit. 2023-08-05 18:15:10 +03:00
Ozkan Sezer
0026adffd4 apply force_align_arg_pointer attribute to correct version of SDL_RunApp 2023-08-05 18:10:10 +03:00
Ozkan Sezer
77446e2029 Unaligned stacks on i686-w64-mingw32 may lead to crashes
Port of original SDL2 patch by Christopher Wellons (@skeeto, #7607)
to SDL3.
2023-08-05 17:39:30 +03:00
Sam Lantinga
d3bcc3f057 Fixed build errors when OpenGL isn't enabled 2023-08-05 00:25:12 -07:00
Frank Praznik
70323a8350 Add a function to display the system menu for a window
Add SDL_ShowWindowSystemMenu() to display the system-level menu for windows. Typically, this is done by right-clicking on the system provided window decorations, however, if an application is rendering its own client-side decorations, there is currently no way to display it. This menu is provided by the system and can provide privileged desktop functionality such as moving or pinning a window to a specific workspace or display, setting the always-on-top property, or taking screenshots. In many cases, there are no APIs which allow applications to perform these actions manually.

Implemented for Wayland via functionality provided by the xdg_toplevel protocol, Win32 via the undocumented message 0x313 (typically called WM_POPUPSYSTEMMENU), and X11 via the "_GTK_SHOW_WINDOW_MENU" atom (supported in GNOME and KDE).
2023-08-04 13:39:45 -04:00
Ryan C. Gordon
18c59cc969 Merge the SDL3 audio subsystem redesign!
This rips up the entire SDL audio subsystem! While we still feed the audio device from a separate thread, the audio callback into the app is now gone a totally optional alternative.

Now the app will bind an SDL_AudioStream to a given device and feed data to it. As many streams as one likes can be bound to a device; SDL will mix them all into a single buffer and feed the device from there.

So not only does this function as a basic mixer, it also means that multiple device opens are handled seamlessly (so if you want to open the device for your game, but you also link to a library that provides VoIP and it wants to open the device separately, you don't have to worry about stepping on each other, or that the OS will fail to allow multiple opens of the same device, etc).

Merged from pull request #7704.

Fixes #7379.
Reference Issue #6889.
Reference Issue #6632.
2023-08-03 21:27:54 -04:00
Sam Lantinga
99b0e31788 The Steam Controller D-Pad is only pressed when the button is pressed down 2023-08-03 13:07:51 -07:00
Sam Lantinga
e063f662e9 Enable the controller update complete events
It's not intuitive from a developer's point of view that you wouldn't get these events. If they're impacting performance they can be explicitly disabled for applications that don't want them.
2023-08-03 10:19:54 -07:00
Sam Lantinga
06bea1eb55 Added a gamepad mapping for the G-Shark GS-GP702
Fixes https://github.com/libsdl-org/SDL/issues/8068
2023-08-02 14:35:39 -07:00
Ozkan Sezer
fb3ab3f113 SDL_video.c: move ngage video before offscreen.
Reference issue: https://github.com/libsdl-org/SDL/pull/8069.
2023-08-02 17:02:02 +03:00
Sam Lantinga
843572d993 Don't mark autorelease keys as virtual
Also make sure we time out the hardware_timestamp even if SDL_HardwareKeyboardKeyPressed() isn't called.
2023-08-02 01:32:13 -07:00
Sam Lantinga
648de4f9b8 Fixed duplicate key press/release events on iOS
When a hardware keyboard is attached, it can take over 100 ms for the keyboard event to generate text input. In that case we want to record that we recently received a keyboard event so we don't synthesize duplicate virtual key press/release events for the input text.
2023-08-02 01:08:00 -07:00
Sam Lantinga
a8abe612ed Only pass keypresses up the responder chain when text input is active
This is another attempt to make sure we don't cause beeps from unhandled key presses while still allowing full text input functionalty.

If this isn't selective enough, we might need to go up the responder chain to see what's going to handle the event before passing it along.

Fixes https://github.com/libsdl-org/SDL/pull/6962
2023-08-02 00:19:57 -07:00
Sam Lantinga
c3288d113e Synchronize on-screen keyboard state with text input active state
When a hardware keyboard is attached to an iPad, you can easily trigger a set of on-screen keyboard transitions that will take place over time, and we need to track whether we're currently showing or hiding the keyboard and make sure we don't clobber the existing state during those transitions.

Testing:
* Connected a hardware keyboard to an iPad
* Launched checkkeys
* Noted the keyboard bar was active at the bottom of the screen and text input was active
* Tapped with both fingers to quickly toggle text input off and back on
* Noted the keyboard bar slid down and then back up, and text input was active
* Tapped on the keyboard bar to bring up the full on-screen keyboard and then closed it so the keyboard bar was still active, and text input was still active
* Tapped on the screen to turn text input off, noted the keyboard bar slid down
* Tapped with both fingers to quickly toggle text input on and back off
* Noted that the keyboard bar slid up and then back down, and text input was inactive
* Tapped on the screen to turn text input on, tapped on the keyboard bar to bring up the full on-screen keyboard, and text input was active
* Pressed a key on the physical keyboard, the on-screen keyboard closed, the key press and release was delivered (with no text input) and then the keyboard bar slid up, and text input was active again

Fixes https://github.com/libsdl-org/SDL/issues/7979
2023-08-02 00:11:17 -07:00
Sam Lantinga
5fb92ef2f7 Fixed whitespace 2023-08-02 00:11:17 -07:00
Sam Lantinga
f5ea6ae18d Revert "Stop beep when running iOS apps on ARM-based Macs"
This reverts commit bbf38bbbc3, which prevented text input from working when a hardware keyboard was connected, since key strokes don't get to the text input field.

Fixes https://github.com/libsdl-org/SDL/issues/7958
2023-08-02 00:08:07 -07:00
Sam Lantinga
68a4bb01e0 Allocate displays as an array of pointers instead of an array of objects
This fixes current_mode from pointing at the wrong data when displays are moved around
2023-08-01 19:24:29 -07:00
Sam Lantinga
07578fde3d Fixed crash if a display is enumerated twice
This can happen if a monitor is in the process of becoming primary because another monitor was disconnected.
2023-08-01 18:28:55 -07:00
Sam Lantinga
c94cb3a5d8 Simplified the Xcode project to a single Framework target
Static and shared libraries can be built using CMake support in SDL 3.0

Built tests for macOS, iOS, and tvOS
2023-07-31 18:38:18 -07:00
Semphris
d4a867a256 Rename SDL_GetPath to SDL_GetUserFolder
The documentation has been edited accordingly, and certain parts have been clarified.
2023-07-31 16:39:33 -07:00
Sam Lantinga
71099149b8 Fall back to Xlib if XRandR isn't available
This fixes video initialization on headless systems with VNC

Fixes https://github.com/libsdl-org/SDL/issues/8054
2023-07-31 14:38:48 -07:00
Ryan C. Gordon
87eae9a0a1 aaudio: We need a mixbuf on capture devices, too. 2023-07-30 20:24:27 -04:00
Frank Praznik
fb68e84646 wayland: Fix memory leaks
Fix some memory leaks reported by Valgrind due to not destroying objects.
2023-07-30 12:46:02 -04:00
Ryan C. Gordon
ae3090c387 androidaudio: Move Init/bootstrap code to bottom of source code.
I can't ever find this when it's in the middle! It's a "me" problem.  :)
2023-07-30 11:56:43 -04:00
Ryan C. Gordon
18fc0db9e5 aaudio: Rearranged source code to match other backends. 2023-07-30 11:56:43 -04:00
Ryan C. Gordon
2507c1d68b aaudio: Disconnect playing devices if error callback fires. 2023-07-30 11:56:42 -04:00
Ryan C. Gordon
32a3fc3783 aaudio: Use the callback interface.
This is allegedly lower-latency than the AAudioStream_write interface,
but more importantly, it let me set this up to block in WaitDevice.

Also turned on the low-latency performance mode, which trades battery life
for a more efficient audio thread to some unspecified degree.
2023-07-30 11:56:42 -04:00
Ryan C. Gordon
b49ce86765 audio: Fixed compiler warning on Android NDK. 2023-07-30 11:56:42 -04:00
Ryan C. Gordon
1c074e8d97 android: Fixed audio device detection. 2023-07-30 11:56:42 -04:00
Ryan C. Gordon
82ce05ad01 pulseaudio: Be more aggressive with hotplug thread synchronization.
(Borrowed from the SDL2 branch.)
2023-07-30 11:56:41 -04:00
Ryan C. Gordon
5cbdf1168e androidaudio: Fixed incorrect JNI call (thanks, @madebr!) 2023-07-30 11:56:41 -04:00
Ryan C. Gordon
ab68428a64 aaudio: Fixed for older SDKs and Android releases. 2023-07-30 11:56:41 -04:00
Ryan C. Gordon
5ff87c6d4a android: Reworked audio backends for SDL3 audio API.
This involved moving an `#ifdef` out of SDL_audio.c for thread priority,
so the default ThreadInit now does the usual stuff for non-Android platforms,
the Android platforms provide an implementatin of ThreadInit with their
side of the `#ifdef` and other platforms that implement ThreadInit
incorporated the appropriate code...which is why WASAPI is touched in here.

The Android bits compile, but have not been tested, and there was some
reworkings in the Java bits, so this might need some further fixes still.
2023-07-30 11:56:41 -04:00
Ryan C. Gordon
7f4488f625 wasapi: More fixes for Clang warnings. 2023-07-30 11:56:40 -04:00
Ryan C. Gordon
29a0c689c9 wasapi: Patched to compile with Clang. 2023-07-30 11:56:40 -04:00
Ryan C. Gordon
4aa95c21bc pspaudio: Patched to compile. 2023-07-30 11:56:40 -04:00
Ryan C. Gordon
9a2a0a1463 ps2audio: Delete errant character that got inserted before previous commit. 2023-07-30 11:56:39 -04:00