Commit Graph

6380 Commits

Author SHA1 Message Date
Sam Lantinga cb36189692 Fixed bug 5235 - All internal sources should include SDL_assert.h
Ryan C. Gordon

We should really stick this in SDL_internal.h or something so it's always available.
2020-12-09 07:16:22 -08:00
Sam Lantinga 479db43058 Fixed bug 5250 - updaterev.sh failed using CMake Tools on VSCode Remote
Sebastian Vargas Vargas

Running CMake configure from a Windows Subsystem for Linux using Visual Studio Code Remote doesn't generate the header file with the current source revision, it throws "/home/sebva/SDL/build-scripts/updaterev.sh: 13: cannot create /mnt/c/Users/sebva/.vscode/extensions/ms-vscode-remote.remote-wsl-0.44.4/include/SDL_revision.h.new: Directory nonexistent".
2020-12-09 06:56:34 -08:00
Alistair Leslie-Hughes a69c61fbfd Only assign context and mainloop once we have connected successfully
If we fail to connect to the the pa server, we have an assigned context
and mainloop that isn't connected. So, when PULSEAUDIO_pa_context_disconnect
is called, pa asserts and crashes the application.

Assertion 'pa_atomic_load(&(c)->_ref) >= 1' failed at pulse/context.c:1055, function pa_context_disconnect(). Aborting.
2020-08-14 12:08:58 +10:00
Sam Lantinga 88cb4962cd Fixed bug 5291 - SDL_SetRenderTarget unnecessarily changes target when current target is the native texture of the passed in texture 2020-12-09 06:42:31 -08:00
Sam Lantinga f2fff21762 Fixed bug 5374 - WGI: Use fast-pass strings.
Joel Linn

Eliminate additional heap allocation for short-lived HSTRINGs.
Uses `WindowsCreateStringReference()` to disable reference counting and memory management by the Window Runtime.
2020-12-09 06:24:40 -08:00
Sam Lantinga 42c5b4acde Fixed bug 5366 - cmake build doesn't detect Metal on macOS
Tom Seddon

2nd time lucky, perhaps. patch 2 applies to current HEAD at time of writing - 4eb049c9bb1ca94efe3c40b57beda3169984d0cb from https://github.com/SDL-mirror/SDL.

This basically goes back to what was there originally, but now manually adding "-x objective-c" to the clang command line rather than "-ObjC". clang is then invoked without the "-x c" that was causing the problem, the snippet builds, and Metal is detected. (I had a quick trawl through the cmake code, but I couldn't see where this is handled.)

I was moved to try this after finding SDL's own CHECK_OBJC_SOURCE_COMPILES macro, and noting what it does: 4eb049c9bb/cmake/macros.cmake (L67)

An alternative fix of course would be to use CHECK_OBJC_SOURCE_COMPILES instead of cmake's check_objc_source_compiles - but that had the same problem of getting confused by "return 0;". (Maybe that's because it's a macro? I'll defer to a cmake expert on this one.)

I decided in the end to err on the side of leaving things looking basically the same as they were before my first patch.
2020-12-09 06:17:55 -08:00
Ozkan Sezer 475405e036 CMakeLists.txt: sync DYLIB_CURRENT_VERSION to Xcode project 2020-12-09 12:03:24 +03:00
Ozkan Sezer 250a055727 fix bug #5384 -- define DLL_EXPORT in DLL builds and adjust begin_code.h 2020-12-09 12:01:10 +03:00
Sam Lantinga 50203d58b3 Fixed bug 5329 - SDL_SetWindowGrab(SDL_FALSE) fails to unlock cursor if window is partially offscreen
Ivan Mogilko

With SDL 2.0.12 under MS Windows, if the window is partially offscreen calling SDL_SetWindowGrab(w, SDL_TRUE) works, but subsequent call to SDL_SetWindowGrab(w, SDL_FALSE) does not work.

I tested this in both real program, and a small test app, where unlocking cursor worked perfectly while window is fully in desktop bounds, but did not work if it was at least few pixels outside.

For the reference, following code is enough to reproduce the issue:

#include <windows.h>
#include <SDL.h>

int WinMain(
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR     lpCmdLine,
    int       nShowCmd)
{
    SDL_Init(SDL_INIT_VIDEO);
    SDL_Window* w = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 640, 400, 0);

    bool grabbed = false;
    bool want_quit = false;
    while (!want_quit)
    {
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            switch (event.type)
            {
            case SDL_QUIT: want_quit = true; break;
            case SDL_KEYDOWN:
                if (event.key.keysym.scancode == SDL_SCANCODE_SPACE)
                {
                    SDL_SetWindowGrab(w, static_cast<SDL_bool>(!grabbed));
                    grabbed = !grabbed;
                }
            }
        }
    }

    SDL_DestroyWindow(w);
    SDL_Quit();
    return 0;
}
2020-12-08 22:00:06 -08:00
Alice Rowan 3835f2008d Fix Nyko Airflo Ex Windows mapping, add Linux/Mac mappings 2019-03-03 12:38:23 -07:00
Sam Lantinga 43aad96681 Fixed bug 5222 - Crash when running with -DHIDAPI=ON
Mathieu Eyraud

SDL dynamically loads libusb but does not check the return value of 'SDL_LoadFunction'.

Also libusb is loaded and initialized several time because 'SDL_hidapi_wasinit' is never set to true.

I made a patch if you want to test:
  - check that 'hid_init' is called once and only once,
  - check return value of 'hid_init',
  - check return value of 'SDL_LoadFunction',
  - check return value of 'SDL_malloc',
  - add some debug logging.
2020-12-08 19:03:50 -08:00
Sam Lantinga a2098a47b6 Updated SDL to 2.0.14 in preparation for release candidate 2020-12-08 18:56:06 -08:00
Sam Lantinga 2a9591a9ea Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/fix-space-in-path.patch 2020-12-08 09:16:34 -08:00
Mikhail Paulyshka 146d9b8201 win32: fix symbols leakage for static libraries 2017-09-24 14:32:30 +03:00
Sam Lantinga 7f1c6e82b9 Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/enable-winrt-cmake.patch 2020-12-08 09:13:08 -08:00
Sam Lantinga 7665f8870a Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/disable-wcslcpy-and-wcslcat-for-windows.patch 2020-12-08 09:07:21 -08:00
Sam Lantinga 695499ae6c Accepted patch https://github.com/microsoft/vcpkg/blob/master/ports/sdl2/disable-hidapi-for-uwp.patch 2020-12-08 09:04:28 -08:00
Ozkan Sezer 5610e5ae48 Makefile.os2: disable W303 (add -wcd=303 to CFLAGS)
newer OpenWatcom versions enable W303 by default.  without this, we get
multiple "Parameter '%s' has been defined, but not referenced" warnings.
2020-12-08 00:11:10 +03:00
Sam Lantinga c9723c407f Fixed potential hang in joystick close if the rumble thread is blocked for some reason
It's still possible to hang when shutting down, if the rumble thread is still hung, but it won't block indefinitely at runtime.
2020-12-07 09:38:21 -08:00
Sam Lantinga 3c68051eaf Allow background input when testing game controllers 2020-12-04 15:47:28 -08:00
Sam Lantinga 09909d029d Fixed handling of BACK button on newer Xbox One S controllers 2020-12-03 19:44:47 -08:00
Sam Lantinga 54e5136b50 Refactored Xbox One Bluetooth protocol and verified Xbox One S, Xbox Series X, and Xbox One Elite Series 2 controllers 2020-12-03 18:17:04 -08:00
Sam Lantinga 1031231b29 Fixed duplicating a device between XInput and HIDAPI 2020-12-03 18:17:03 -08:00
Sam Lantinga 59f28b7f4b Fixed whitespace 2020-12-03 18:17:01 -08:00
Sam Lantinga f487d63a6b Fixed crash when printing NULL wide character string 2020-12-03 18:16:56 -08:00
Sylvain Becker 754286c61c SDL Renderer: specify the correct flag when recreating the window 2020-12-02 13:45:24 +01:00
Sylvain Becker 035f8f2391 SDL_RecreateWindow: allow clearing VULKAN when recreating the window 2020-12-02 13:37:59 +01:00
Sylvain Becker 93fbab0fac SDL_ReCreateWindow: allow to unload METAL window and switch back to OpenGL.
On older mac, where METAL Renderer METAL fails to create, it allows to switch back to OpenGL SDL_Renderer
by re-creating the window (METAL flags was previously persistent).
2020-12-02 11:04:53 +01:00
Cameron Gutman 9d40a0f317 Fix joystick device add events containing invalid device indexes
This can happen if the application has not yet processed SDL_JOYDEVICEADD when
the same joystick is removed. It may also happen if two joysticks are added
and the second joystick is removed before the first joystick's SDL_JOYDEVICEADD
has been processed by the application.
2020-08-29 16:50:26 -07:00
Sam Lantinga 7854f43b6d Disable SDL_JOYSTICK_HIDAPI on iOS and tvOS by default
It's only needed for Steam Controller support, and introduces a Bluetooth framework dependency which requires additional permissions on the App Store.
2020-12-01 14:43:15 -08:00
Sam Lantinga ebf315e0f2 Fixed bug 5369 - iOS static library build copies public headers files into xcode archive
Dominik Reichardt

Trying to integrate the latest SDL2 changes into our iOS project of Exult I've stumbled over the fact that when I added the static iOS library the public header files were copied to the archive of our project when you let Xcode build the archive.
This makes the archive invalid for upload to the AppStore Connect.

To fix this you need to delete the public headers from the build phase:
Open the xcode project, select the target "Static Library-ios", got to build phases, and in "headers" delete all the headers in the "public" group. This is safe to do as this actually just copies the public headers for some odd counterintuitive reason.

I think this needs to be done for all the library build targets but likely not for the framework targets.
2020-12-01 14:01:12 -08:00
Sam Lantinga 4b35a18d8b Fixed bug 5366 - cmake build doesn't detect Metal on macOS
Tom Seddon

This is as of commit 50d804ea729accf9e3a9ce83238d0a2976a17545 from https://github.com/SDL-mirror/SDL, which is HEAD as I write (apologies, not confident with Mercurial)

# Config

macOS: 10.14.6 (18G6042)
cmake --version: cmake version 3.16.20200101-g23e782c
clang --version: Apple clang version 11.0.0 (clang-1100.0.33.17)
Xcode version: Version 11.3.1 (11C504)

# Repro steps

Run the following commands in the shell.

 cd /tmp/
 git clone https://github.com/SDL-mirror/SDL
 mkdir build.SDL
 cd build.SDL
 cmake -G ../SDL/

Examine cmake output.

# Expected result

Metal is detected.

# Actual result

It appears that Metal is not detected! Note this line in the summary:

 --   RENDER_METAL           (Wanted: 0): OFF

# Fix

Change check_c_source_compiles to check_objc_source_compiles. The cmake script tries to add -ObjC to the clang command line, but, for whatever reason, this doesn't seem to work.

Change the test source to have an empty main. The "return 0;" line seems to confuse cmake somehow, causing it to crap out with an error about HAVE_FRAMEWORK_METAL being an unknown argument. (Maybe I'm just dense, but it's not obvious to me what the problem is here.)

With these two changes:

 --   RENDER_METAL           (Wanted: ON): ON

Patch attached.
2020-12-01 13:50:42 -08:00
Sam Lantinga 798b228806 Fixed bug 5367 - SDL_OpenUrl disabled on iOS due to unified Xcode project file
Dominik Reichardt

When you unified the Xcode project file you forgot to add the iOS file (/src/misc/ios/SDL_sysurl.m) to the project file, so the dummy in that folder takes over and the call does not work.

Relevant commits:
http://hg.libsdl.org/SDL/rev/c86bbf75f55e (SDL_OpenUrl enabled for macOS/iOS)

http://hg.libsdl.org/SDL/rev/282c3dc1cf65 (and following: unified Xcode project files)

Adding an ios group in the misc group of the project file and then adding /src/misc/ios/SDL_sysurl.m to it fixes the problem.
2020-12-01 13:46:34 -08:00
Sam Lantinga c78ca2d170 Fixed bug 5371 - Rawinput: Fix truncating cast of string length.
Joel Linn

Fixes an implicit truncation of a string length on 64bit systems.
2020-12-01 13:38:42 -08:00
Sam Lantinga a3ccf9adca Fixed bug 5373 - [PATCH] Rawinput: Get correlated XInput battery info
Joel Linn

Currently the rawinput driver always reports a device as "wired". This changes that to "unknown" and updates it once the device is correlated with xinput.
2020-12-01 13:36:41 -08:00
Sam Lantinga e3966e25ca Use the correct internal API for updating the battery level for PS5 controllers 2020-11-30 13:04:30 -08:00
Sam Lantinga f4ed07de06 We don't know whether the PS5 controller is Bluetooth or not when we open it 2020-11-30 13:02:34 -08:00
Sam Lantinga 04f0fd13b5 Remember to close the game controller when we're done with it 2020-11-27 18:57:42 -08:00
Sam Lantinga 1f2f536bd2 Fixed XInput correlation for raw input controllers after hotplug events 2020-11-27 18:57:40 -08:00
Sam Lantinga 012471e959 Open and test all connected controllers 2020-11-27 18:57:38 -08:00
Sam Lantinga 1c865c460b Load the raw input device list at init time so it's available when DirectInput is doing device detection 2020-11-27 18:57:36 -08:00
Sam Lantinga a0c5bfa3bd Moved raw input event processing from the main thread to the joystick thread
This allows fast joystick event delivery regardless of what the main thread is doing.
2020-11-27 13:08:40 -08:00
Sam Lantinga 4fbefbe20d Sort the raw input axes by usage, so X comes before Y, etc. 2020-11-27 11:33:53 -08:00
Sam Lantinga 4ddac485db Backed out minor optimization that prevented correlation_id from being set 2020-11-27 11:33:51 -08:00
Sam Lantinga 8973a25849 Enable dispatching of WM_INPUT_DEVICE_CHANGE events directly, in case the application hasn't created a window with the normal message loop 2020-11-27 10:44:56 -08:00
Sam Lantinga e8adc64810 Enable dispatching of WM_INPUT events directly, in case the application hasn't created a window with the normal message loop 2020-11-27 10:44:55 -08:00
Sam Lantinga 0252235e82 Recheck devices if another API queries raw input for a new device 2020-11-27 10:44:53 -08:00
Sam Lantinga a7dede7e36 Re-enable axis correlation for raw input controllers, for twin stick shooters that don't need face buttons 2020-11-27 10:44:51 -08:00
Sam Lantinga ce77966da8 Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers 2020-11-27 10:44:49 -08:00
Sam Lantinga 8a449de20d Fixed Xbox 360 wireless controller being picked up by WGI when it's being managed by RAWINPUT 2020-11-27 10:44:47 -08:00