Commit Graph

6029 Commits

Author SHA1 Message Date
Ethan Lee 2aa8974f97 Add SDL_SIMDRealloc 2020-06-11 12:03:33 -04:00
Sam Lantinga 20aada0efc Fixed bug 5170 - Build fails when using Visual Studio 2017 with Windows 10 SDK 10.0.19041.0 in uwp
JackBoosY

In src/video/winrt/SDL_winrtgamebar.cpp line 55:

    virtual HRESULT STDMETHODCALLTYPE add_VisibilityChanged(
        __FIEventHandler_1_IInspectable *handler,
        Windows::Foundation::EventRegistrationToken *token) = 0;

The macro __FIEventHandler_1_IInspectable defined in windows.fondation.h(Windows10 SDK 10.0.17763.0) line 3576:
#define __FIVector_1_Windows__CFoundation__CPoint ABI::Windows::Foundation::Collections::__FIVector_1_Windows__CFoundation__CPoint_t

but no longer exists in Windows 10 SDK 10.0.19041.0.
After searching this macro in the sdk include path, I found that it was defined in many header files. But it should be replaced in windows.system.h .
2020-06-10 09:38:43 -07:00
Sam Lantinga 4d15b5b893 Fixed building with Visual Studio 2019 2020-06-10 09:36:10 -07:00
Sam Lantinga 44f50c647e Fixed bug 5171 - PollEvent impacts performance in 2.0.12
On some systems, GetClipCursor() impacts performance when called frequently, so only call it every once in a while to make sure we haven't lost our capture.
2020-06-09 21:47:41 -07:00
Sam Lantinga 511a9702fc Fixed whitespace 2020-06-09 21:43:00 -07:00
Sam Lantinga aefe19ff08 Added support for the NACON Revolution Pro Controller 3 and the GameStop PS4 Fun Controller 2020-06-09 11:31:39 -07:00
Sam Lantinga 6f241bd520 Fixed build 2020-06-09 10:47:29 -07:00
Sam Lantinga 086be21e7a ControllerList: add support for NACON asymetric controller and Revolution 3, Hori mini wireless ps4 controller, and 2 PDP switch controllers 2020-06-09 10:47:27 -07:00
Sam Lantinga 3b76109f64 ControllerList: remove giotek controller from list - vid/pid appears to be reused in bunch of devies including ones with different fw/protocol and treating as ps4 controller breaks them. 2020-06-09 10:47:25 -07:00
Sam Lantinga a9cfac3835 Controller: Deadzone improvements 2020-06-09 10:47:23 -07:00
Sam Lantinga 9fa8d6d0be Define constants not available on older kernels 2020-06-08 17:07:55 -07:00
Sam Lantinga 3ac24bfc1a Fixed mouse drag with an external mouse on iOS 2020-06-08 17:01:50 -07:00
Sam Lantinga d0947c1483 Fixed exception if getManifestEnvironmentVariables() is called without a current SDL activity 2020-06-04 12:30:25 -07:00
Sam Lantinga ff53521bc6 Fixed Bluetooth audio output on Apple TV 2020-06-04 12:26:57 -07:00
Sam Lantinga cced5eb937 Fixed bug 5169 - Can not build current sources because of recent thread management changes
Manuel Alfayate Corchete

I'm trying to build SDL2 with threads support here in GNU/Linux, both X86 and ARM, and it does not seem to be possible ATM:


/home/manuel/src/SDLLLL/src/core/linux/SDL_threadprio.c:233:26: error: 'rtkit_max_realtime_priority' undeclared (first use in this function)
2020-06-04 09:23:18 -07:00
Sam Lantinga 958c42827c Fixed build warning 2020-06-04 09:13:49 -07:00
Sam Lantinga 49501a9860 Updated configure with changes from configure.ac 2020-06-04 09:10:49 -07:00
Sam Lantinga 22ce194b17 Make sure SDL_locale.h is included in the Xcode Framework for macOS 2020-06-03 14:58:38 -07:00
Sam Lantinga b9d5aebb3a Make sure SDL_locale.h is included in the Xcode Framework for tvOS 2020-06-03 14:56:35 -07:00
Sam Lantinga 550b209e90 Make sure SDL_locale.h is included in the Xcode Framework 2020-06-03 14:26:37 -07:00
Ryan C. Gordon 60435712f2 video: Set window->surface NULL after freeing it.
Otherwise, when SDL_CreateWindowFramebuffer() is called again, it will return
the free'd surface instead of creating a new one.
2020-06-03 16:42:19 -04:00
Sam Lantinga eea0b0e088 Fixed bug 5168 - Memory leak in RAWINPUT_JoystickOpen
meyraud705

Variable 'hwdata' is not freed in RAWINPUT_JoystickOpen if device->driver->OpenJoystick() fails.
2020-06-02 17:08:31 -07:00
Cameron Gutman 134362e745 Enable Xbox One HIDAPI driver on macOS
The Xbox One HIDAPI driver is required on macOS for Xbox One S Bluetooth
support since https://hg.libsdl.org/SDL/rev/10c3a10908e9
2020-04-25 19:15:51 -07:00
Sam Lantinga ac1f174ad5 Fixed bug 5167 - Memory leak in GuessXInputDevice
meyraud705

Variable 'devices' is not freed if function GuessXInputDevice, in SDL_xinputjoystick.c, return early.
2020-06-02 17:02:37 -07:00
Sam Lantinga 06267f5028 Fixed whitespace in SDL_vulkan.h 2020-06-02 16:59:54 -07:00
Sam Lantinga d48c97c4a4 Fixed bug 5147 - KMSDRM: SetWindowFullscreen() failing with SDL_WINDOW_FULLSCREEN_DESKTOP
Manuel Alfayate Corchete

This patch is needed so programs that do this work as expected:
1) Start in a different video mode than the mode used by the system and then...
2) Try to go fullscreen with the mode originally used by the system via SetWindowFullScreen() with the SDL_WINDOW_FULLSCREEN_DESKTOP flag.

An example would be pt2-clone in https://github.com/8bitbubsy/pt2-clone.
This program does this:

Starts with:

video.window = SDL_CreateWindow("", SDL_WINDOWPOS_CENTERED,
    SDL_WINDOWPOS_CENTERED, screenW, screenH, windowFlags);


and then, *IF* the user has configured it in fullscreen mode in its .ini, it tries to go fullscreen with the desktop mode:

SDL_SetWindowFullscreen(video.window, SDL_WINDOW_FULLSCREEN_DESKTOP);


This sequence of operations is currently failing because SDL_SetDisplayModeForDisplay() in SDL_video.c fails because display->desktop_mode is not being initialized with its correct value: SetDisplayMode() in SDL_kmsdrmvideo.c will not be able to set the mode because it detects the mode to have a driverdata of 0x0 ("if (!modedata)") and rightfully returns an error.

So, the included patch fixes this small problem, and programs that first change the video mode and then try to go fullscreen with the system video mode will now work.
The patch simply fixes an small omission, but its really needed now that dynamic video mode changing was implemented on the KMSDRM backend.
2020-06-02 16:57:20 -07:00
Sam Lantinga 9325b22ef0 Fixed bug 5113 - SDL_UpdateWindowSurfaceRects BitBlt the entire surface on Win32
Ryan C. Gordon

As discussed here:
https://discourse.libsdl.org/t/question-about-implementation-of-sdl-updatewindowsurfacerects/27561

"As you can see this function [WIN_UpdateWindowFramebuffer, in src/video/windows/SDL_windowsframebuffer.c] calls BitBlt on entire screen, even though it accepts the rects. Rects variable is not even used in this function at all. Now my question is why is that the case?"
2020-05-29 21:26:32 -07:00
Sam Lantinga d000c1cd6d Fixed bug 5155 - HIDAPI_JoystickDisconnected incorrect array shift
Anthony Pesch

I was looking into my own input bug and noticed an issue in the HIDAPI code while looking over it. I don't have a controller that goes down this path to test and try to provoke the issue, but it looks pretty straight forward.

The memmove to shift the joystick id array on disconnect isn't scaling the size by sizeof(SDL_JoystickID), likely corrupting the ids on disconnect.
2020-05-29 21:22:11 -07:00
Sam Lantinga a8400dc3bf Fixed bug 5105 - sndio support not working in dynamic mode (dlopen)
Giovanni Bajo

The CMake build system supports several audio frameworks for Linux: one of them is sndio.

All frameworks can be built with "runtime linking" (that is, using dlopen to load the library at runtime). In sdlchecks.cmake, there's code to do the same with sndio:

=================================================================
# Requires:
# - n/a
# Optional:
# - SNDIO_SHARED opt
# - HAVE_DLOPEN opt
macro(CheckSNDIO)
  if(SNDIO)
    # TODO: set include paths properly, so the sndio headers are found
    check_include_file(sndio.h HAVE_SNDIO_H)
    find_library(D_SNDIO_LIB sndio)
    if(HAVE_SNDIO_H AND D_SNDIO_LIB)
      set(HAVE_SNDIO TRUE)
      file(GLOB SNDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/sndio/*.c)
      set(SOURCE_FILES ${SOURCE_FILES} ${SNDIO_SOURCES})
      set(SDL_AUDIO_DRIVER_SNDIO 1)
      if(SNDIO_SHARED)
        if(NOT HAVE_DLOPEN)
          message_warn("You must have SDL_LoadObject() support for dynamic sndio loading")
        else()
          FindLibraryAndSONAME("sndio")
          set(SDL_AUDIO_DRIVER_SNDIO_DYNAMIC "\"${SNDIO_LIB_SONAME}\"")
          set(HAVE_SNDIO_SHARED TRUE)
        endif()
      else()
        list(APPEND EXTRA_LIBS ${D_SNDIO_LIB})
      endif()
      set(HAVE_SDL_AUDIO TRUE)
    endif()
  endif()
endmacro()
=================================================================

The feature is gated by an option called SNDIO_SHARED. It is also fully implemented in SDL_sndioaudio.c

Unfortunately, it seems there is a missing line in CMakeLists.txt, so SNDIO_SHARED is not defined:

======================================================================
set_option(ALSA                "Support the ALSA audio API" ${UNIX_SYS})
dep_option(ALSA_SHARED         "Dynamically load ALSA audio support" ON "ALSA" OFF)
set_option(JACK                "Support the JACK audio API" ${UNIX_SYS})
dep_option(JACK_SHARED         "Dynamically load JACK audio support" ON "JACK" OFF)
set_option(ESD                 "Support the Enlightened Sound Daemon" ${UNIX_SYS})
dep_option(ESD_SHARED          "Dynamically load ESD audio support" ON "ESD" OFF)
set_option(PULSEAUDIO          "Use PulseAudio" ${UNIX_SYS})
dep_option(PULSEAUDIO_SHARED   "Dynamically load PulseAudio support" ON "PULSEAUDIO" OFF)
set_option(ARTS                "Support the Analog Real Time Synthesizer" ${UNIX_SYS})
dep_option(ARTS_SHARED         "Dynamically load aRts audio support" ON "ARTS" OFF)
set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
set_option(NAS_SHARED          "Dynamically load NAS audio API" ${UNIX_SYS})
set_option(SNDIO               "Support the sndio audio API" ${UNIX_SYS})
set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
======================================================================

You can see that all frameworks define a "dep_option" NAME_SHARED, and SNDIO is the only one where the option is missing.

This means that runtime loading of sndio is never activated. If sndio is found at configuration time, it is always activated in "linked" mode, so that the final binary will have a load-time dependency with libsdnio. This is unfortunate.

To fix the problem, it is sufficient to add this line:

dep_option(SNDIO_SHARED        "Dynamically load the sndio audio API" ${UNIX_SYS} ON "SNDIO" OFF)

I've verified that this fixes the bug, and sndio can now be dynamically loaded as expected.
2020-05-29 16:31:05 -07:00
Sam Lantinga 2303d92188 Fixed bug 5145 - Fix whitespace in SDL_vulkan.h
Colin Caine

Everywhere else seems to use spaces.

See patch diffed from a fresh hg checkout yesterday.
2020-05-29 16:28:56 -07:00
Cameron Gutman 77b0dad271 cocoa: Change Caps Lock behavior to toggle instead of locking
It currently behaves like a locking key which is pressed
when Caps Lock is enabled and released when disabled. This
means that apps that trigger events on Caps Lock key down will
only fire these events every other time Caps Lock is pressed.
2020-05-25 20:55:29 -07:00
Sam Lantinga bdfd1b68ba Fixed bug 5146 - SDL_RenderFillRect doesn't work in DirectFB
Lacky

It looks like refactoring of SDL2 internal API has broken SDL_RenderFillRect for DirectFB. In new version function SDL_RenderFillRect returns 0, but rectangle is not visible.

Replacing "count" with "len" in the argument list for SDL_memcpy in DirectFB_QueueFillRects fixes problem.
2020-05-29 16:02:49 -07:00
Tudor Brindus a6ca61d732 wayland: update pointer position on initial enter event 2020-05-21 00:06:09 -04:00
Sam Lantinga 68e1731e02 Don't bother logging security exception getting the device serial number
This can happen anytime we haven't opened the device yet
2020-05-29 15:40:17 -07:00
Sockmonsters eea450bc99 - Added exception handler for the new SecurityException in USBDevice getSerialNumber 2020-05-29 15:37:03 -07:00
Sam Lantinga ae9ff11bae The zero happens at a higher level now 2020-05-29 14:54:07 -07:00
Sam Lantinga 39c958bbaa Initialize the raw_map before getting controller mappings from the driver 2020-05-29 14:48:39 -07:00
Sam Lantinga 2db049473b Fixed variable names to be consistent across functions 2020-05-29 14:48:05 -07:00
Sam Lantinga 345b4d7e14 Fixed bug 5161 - Autodetect controller mappings based on the Linux Gamepad Specification
Jan Bujak

I wrote a new driver for my gamepad on Linux. I'd like SDL to support it out-of-box, as currently it just treats it as a generic joystick instead of a gamepad. From what I can see the only way to do that is to either 1) pick one of the already supported controllers' PID, VID and button layouts and have my driver send that (effectively lying that it's something else), or 2) submit a preconfigured, hardcoded mapping to SDL.

Both of those, in my opinion, are silly when we already have the Linux Gamepad Specification which standarizes this:

https://www.kernel.org/doc/html/v4.15/input/gamepad.html

Unfortunately SDL doesn't make use of it currently. So I've took it upon myself to add it; patch is in the attachments.

Basically what the patch does is that if SDL finds no built-it controller mappings for a given joystick it then asks the joystick backend to autodetect it, and that uses the relevant evdev bits to figure out which button/axis is which. (See the specs for more details.)

With this patch applied my own driver for my controller works out-of-box with SDL with no extra configuration and is correctly recognized as a gamepad; this is also going to be the case for any other driver which follows the Linux Gamepad Specification.
2020-05-29 13:37:21 -07:00
James Legg e2dbed9cfe SDL_blit: Fix undefined bitshift operations
Arithmatic operations promote Uint8 to signed int. If the top bit of a
Uint8 is set, and it is left shifted 24 places, then the result is not
representable in a signed 32 bit int. This would be undefined behaviour
on systems where int is 32 bits.
2020-05-29 13:05:37 +01:00
Brendan Shanks 032fa681a8 Add Logitech G29 to steering wheel list 2020-04-24 14:03:30 -07:00
Ryan C. Gordon aa259ed52d wayland: Changed output removal in handle_surface_leave()
No longer needs an extra malloc, handles unexpected cases like the same
output being listed twice.
2020-05-28 15:18:41 -04:00
Ryan C. Gordon ce7ae4ec8d wayland: Move buffer copy into mime_data_list_add()
It makes it clearer who owns the memory, and more reasonable to free it on
failure in the creating function.

(and, of course, pacifies static analysis.)
2020-05-28 14:57:10 -04:00
Ryan C. Gordon 22da9d4d77 wayland: assert that mmap() didn't return NULL.
In practice, it never _would_, but in theory it _might_, so this assertion
tells the static analyzer not to worry about it.
2020-05-28 14:47:55 -04:00
Sam Lantinga 1a1f1704a2 Don't include the iOS joystick driver if joysticks are disabled 2020-05-27 10:35:43 -07:00
Sam Lantinga 57149c2410 Fixed building with --disable-joystick on iOS 2020-05-27 10:27:20 -07:00
Sam Lantinga cf01ee1694 Fixed building with --disable-joystick on Linux 2020-05-27 10:27:04 -07:00
Sam Lantinga e9f567c707 Fixed building on iOS with MFI controllers disabled 2020-05-27 10:14:08 -07:00
Sam Lantinga 97ca96bdee Use nil instead of NULL for Objective-C objects 2020-05-27 10:13:01 -07:00
Sam Lantinga 2aec184e36 Fixed mkdir warning when running iosbuild.sh multiple times 2020-05-27 09:57:51 -07:00