Commit Graph

1718 Commits (5abd7d16d7482049a51ad94f7d4f500834bd2970)

Author SHA1 Message Date
Sam Lantinga 758156a765 Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
We're going to push the manifest environment variables from the Java side instead of continually querying for them from the native side.
2017-11-04 09:37:29 -07:00
Sam Lantinga 7334a2a1b5 Fixed bug 3940 - Add support for EGL_SURFACE_TYPE
tomwardio

Add support to be able to set EGL_SURFACE_TYPE bits when creating an EGL config. This is usefule when wanting to create pixel buffer surfaces in custom video drivers.
2017-11-04 09:07:33 -07:00
Conn O'Griofa bf3e363d4b Raspberry Pi: fix ES 1/PVR support & autodetect Mesa driver
* The brcmGLESv2 vendor library also supports ES PVR/1 profiles
* Fallback to standard Mesa libraries if the VC4 driver is loaded
2017-11-04 09:04:19 -07:00
Conn O'Griofa 547448df6f SDL_video: try to bootstrap KMSDRM before RPI video driver
Allow better coexistence between RPI's vendor libraries and VC4 mesa driver.
2017-11-04 09:03:20 -07:00
Johannes Bader 1724313349 Emscripten: use cursor hotspot
the cursor's hotspot simply wasn't translated to it's CSS equivalent, yet
see https://developer.mozilla.org/en-US/docs/Web/CSS/cursor?v=example#Syntax. no explicit hotspot if (0|0) for compatibility with Edge and IE, which indeed don't support custom hot spots
2017-11-04 11:16:49 +00:00
Sam Lantinga c954b53830 Fixed bug 3935 - Not find joysticks if android run 24-48 days.
Alexander Orefkov

In src\joystick\android\SDL_sysjoystick.c in SDL_SYS_JoystickDetect when SDL_GetTicks return number grater 2147483648 (after 24.85 days uptime) SDL_TICKS_PASSED(SDL_GetTicks(), timeout) return FALSE and Android_JNI_PollInputDevices is never calling.
And in JoystickByDeviceId - when search for newly added joystic - after SDL_SYS_JoystickDetect item not reinitilized, and always stay NULL, cause return NULL instead of added joystick.
2017-11-02 08:48:14 -07:00
Sam Lantinga 1475e6984a Fixed bug 3917 - Android, issues with getManifestEnvironmentVariable
Sylvain

Some issue with this commit:
https://hg.libsdl.org/SDL/rev/97387a8b88d3

There is a memory allocation missing.
2017-11-01 19:19:21 -07:00
Sam Lantinga 9192c93e90 Fixed bug 3932 - Android, GetDisplayDPI release local reference
Sylvain

When writing JNI code, one has to make sure all local references are released otherwise the app end up crashing.
2017-11-01 17:30:02 -07:00
Sam Lantinga a7d2d12c64 Fixed building on non-Android platforms 2017-11-01 10:07:04 -07:00
Sam Lantinga a90be440e8 Added controller mapping for Android TV remotes
Also fixed the back button on the remote exiting the application
2017-11-01 10:06:58 -07:00
Sam Lantinga 4478707b0a Add SDL_GetDisplayDPI implementation on Android. (thanks Rachel!) 2017-10-31 13:49:59 -07:00
David Ludwig 0e032d5860 WinRT: Move Windows::Foundation::Initialize to SDL2.dll, from SDL_main.
This allows C# UWP applications to use SDL2's SDL_WinRTRunApp function.

Kudos to Ethan Lee (flibitijibibo@flibitijibibo.com) for the patch.  Thanks!
2017-10-24 13:21:11 -04:00
Brandon Schaefer 2ac567b715 Fixed bug 3902 - Add a specific KMSDRM hint for low latency video 2017-10-26 16:37:20 -07:00
Sam Lantinga 213b249094 Added missing keyinfotable.h 2017-10-26 10:42:14 -07:00
Sam Lantinga 8e37bed3b6 android: Fix softkeyboard issue in SDL on Android. 2017-10-26 10:41:38 -07:00
Ryan C. Gordon 9bbf92e3da cocoa: Don't change the NSWindow background color.
Changing the background color causes the titlebar to blend against it on
modern macOS releases, making all SDL windows look wrong by default. This was
set to make the window not flash white before a GL context is ready, but we
can accomplish this in our window's view's drawRect implementation, too.
2017-10-25 18:02:11 -04:00
Sam Lantinga 8fd0c22adc Added the ability to set SDL hints from AndroidManifest.xml (thanks Rachel!)
This is especially useful for things like the accelerometer hint which could be needed before application main().
2017-10-24 00:17:07 -07:00
Sven Hesse b89cac6761 Don't X error in SDL_CreateWindow with unsupported GL attributes 2017-10-22 20:24:58 +02:00
Sam Lantinga 10376eb926 Fixed bug 3901 - Fix vsync-ed pageflips on the KMSDRM video driver
Manuel

I noticed that, at least on Intel GPU hardware, passing SDL_RENDERER_PRESENTVSYNC would result on a static console instead of the program graphics.
That was due to the fact that calling drmModePageFlip() only works if we have previously set up CRTC to one of the GBM buffers with a drmModeSetCrtc() call, so now it's done and things work as expected.

The KMSDRM_GLES_SetupCrtc() call is done only one time, only when needed (when egl_swapinterval is not 0: when it's 0, there's no need for it because we flip by calling drmModePageFlip() anyway).
The place where KMSDRM_GLES_SetupCrtc() call is done may look strange, but it's right: it needs EGL completely ready because it needs to call eglSwapBuffers() internally to work (see more comments about it in the code).
2017-10-21 04:20:57 -07:00
Sam Lantinga e830ef3458 Fixed typo converting 4 channel audio to 2 channel 2017-10-20 16:53:42 -07:00
Sam Lantinga 9a291c1e59 Added a note about adjusting channel weights when converting to fewer channels 2017-10-20 14:51:22 -07:00
Ryan C. Gordon 729329068b audio: Added SDL_AudioStreamFlush(). 2017-10-19 18:05:42 -04:00
Ryan C. Gordon e98920f5f3 Check correct variable for malloc() results. 2017-10-18 23:49:46 -04:00
Sam Lantinga afefcbfeba Fixed bug 3876 - Resampling of certain sounds adds heavy distortion
Simon Hug

Patch that adds [-1, 1] clamping to the scalar audio type conversions.

This may come from the SDL_Convert_F32_to_X_Scalar functions. They don't clamp the float value to [-1, 1] and when they cast it to the target integer it may be too large or too small for the type and get truncated, causing horrible noise.

The attached patch throws clamping in, but I don't know if that's the preferred way to fix this. For x86 (without SSE) the compiler (I tested MSVC) seems to throw a horrible amount of x87 code in it. It's a bit better with SSE, but probably still quite the performance hit. And SSE2 uses a branchless approach with maxss and minss.
2017-10-18 19:30:47 -07:00
Sam Lantinga 653ab5d9c4 Added a staging buffer to the audio stream so that we can accumulate small amounts of data if needed when resampling 2017-10-18 19:26:36 -07:00
Sam Lantinga 80f8464d97 Added audio stream conversion functions:
SDL_NewAudioStream
    SDL_AudioStreamPut
    SDL_AudioStreamGet
    SDL_AudioStreamAvailable
    SDL_AudioStreamClear
    SDL_FreeAudioStream
2017-10-18 15:54:05 -07:00
Sam Lantinga 9fd0d6191c Fixed bug 3821 - Allow SDL_CreateWindow and SDL_CreateRenderer with OpenGL ES 3.0 (GLES3) for Angle (Windows)
Carlos

Angle supports GLES3 but when using these functions (SDL_CreateWindow and SDL_CreateRenderer), defaults again to GLES2.0.

A current workaround (hack) to retrieve a GLES3.0 context with Angle is:

1) set

    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);

after InitSDL AND after calling SDL_CreateWindow  (before SDL_CreateRenderer)

2) Comment lines 2032-2044 in SDL_render_gles2.c, funtion GLES2_CreateRenderer

    window_flags = SDL_GetWindowFlags(window);
    if (!(window_flags & SDL_WINDOW_OPENGL) ||
        profile_mask != SDL_GL_CONTEXT_PROFILE_ES || major != RENDERER_CONTEXT_MAJOR || minor != RENDERER_CONTEXT_MINOR) {

        changed_window = SDL_TRUE;
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, RENDERER_CONTEXT_MAJOR);
        SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, RENDERER_CONTEXT_MINOR);

        if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) {
            goto error;
        }
    }

This retrives a GLES3 context as confirmed using glGetString(GL_VERSION). This should be fixed by modifying a few if's.
2017-10-18 08:52:04 -07:00
Sam Lantinga 556a854438 Fixed compiler warning on iOS 2017-10-16 15:22:40 -07:00
Sam Lantinga e4ef1885d9 Fixed bug 3890 - Incomplete fix for CVE-2017-2888
Felix Geyer

http://hg.libsdl.org/SDL/rev/a31ee4d64ff6 tries to fix CVE-2017-2888.
Unfortunately compilers may optimize the second condition "(size / surface->pitch) != surface->h" away.
See https://bugzilla.redhat.com/show_bug.cgi?id=1500623#c2
I've verified that this is also the case on Debian unstable (gcc 7.2).
2017-10-16 14:57:42 -07:00
Sam Lantinga 8e98bdaa6f Fixed bug 3883 - SDL_assert / SDL_PromptAssertion in TTY mode does not accept options ("abriA")
shoerbaffen

fgets can read a newline and SDL_strcmp will never return zero.
2017-10-15 21:21:19 -07:00
Sam Lantinga a223560a7f Fixed bug 3880 - X Error upon quit since rev. 11607
Ozkan Sezer

Since changeset 11607:60cd425a2f14, I am getting the following
error upon quit.  Running testsprite2, clicking the mouse, and
quiting it is enough to trigger it.  This is on my old Fedora9
x86-Linux:

X Error of failed request:  BadCursor (invalid Cursor parameter)
  Major opcode of failed request:  2 (X_ChangeWindowAttributes)
  Resource id in failed request:  0xb057340
  Serial number of failed request:  905
  Current serial number in output stream:  906

Reverting  https://hg.libsdl.org/SDL/rev/60cd425a2f14  removes
the error.
2017-10-13 19:30:34 -07:00
Sam Lantinga cf9236488a Fixed bug 3879 - add missing SDLCALL to SDLTest_TrackedMalloc & co.
Ozkan Sezer

The attached trivial patch adds missing SDLCALL to SDLTest_TrackedMalloc & co.
2017-10-13 09:50:04 -07:00
Ryan C. Gordon fa15674134 coreaudio: changed device close procedure to prevent long hangs in some cases.
The audioqueue thread needs to keep running, and processing the CFRunLoop
until the AudioQueue is disposed of, otherwise CoreAudio will hang waiting for
final data to feed the device.

At least, I think this is how it all works. It definitely fixes the bug here!

Since AudioQueueDispose() calls AudioQueueStop() internally, there's no need
for our thread to handle this, either, which is good because the AudioQueue
would be disposed by this point. So now the AudioQueue is disposed first, and
then our thread is joined, and everything works out okay.

Just in case, we mark the device "paused" before setting everything in motion,
so any further callbacks from CoreAudio will write silence and not fire the
app's audio callback again.

Fixes Bugzilla #3868.
2017-10-13 01:15:29 -04:00
Sam Lantinga fc60db86b3 Fixed compiler warning 2017-10-12 17:17:09 -07:00
Sam Lantinga 22b6df511b Use the lower-case hex output to match other stack trace printouts 2017-10-12 14:46:28 -07:00
Sam Lantinga 7079195697 Fixed compiler warning 2017-10-12 14:44:54 -07:00
Sam Lantinga 5fc2017661 Fixed bug 3877 - missing SDLCALL in SDLTest_ExampleHitTestCallback
Ozkan Sezer

Following trivial patch adds missing SDLCALL to SDLTest_ExampleHitTestCallback()
2017-10-12 14:25:07 -07:00
Sam Lantinga 41a60394d0 Added missing file 2017-10-12 14:20:17 -07:00
Sam Lantinga 21cd2df694 Fixed compiler warning 2017-10-12 14:02:24 -07:00
Sam Lantinga ba10d2b654 Fixed compiler warning 2017-10-12 13:55:35 -07:00
Sam Lantinga 9c580e14c9 Added functions to query and set the SDL memory allocation functions:
SDL_GetMemoryFunctions()
    SDL_SetMemoryFunctions()
    SDL_GetNumAllocations()
2017-10-12 13:44:28 -07:00
Sam Lantinga 1887c54c68 Fixed memory leak in Cocoa mouse code
The video quit call cleans up the mouse cursor driver data, which happens after mouse quit
2017-10-12 13:28:48 -07:00
Sam Lantinga f4f9e39f62 Fixed bug 3874 - Compiler warnings SDL_Surface.c and SDL_cocoakeyboard.m 2017-10-12 08:41:11 -07:00
Sam Lantinga a7c79c5e25 Normalize touch events to the render viewport (thanks Sylvain!) 2017-10-12 08:37:55 -07:00
Sam Lantinga 5bed4ca92e Fixed divide by zero with a 1x1 sized window 2017-10-12 08:27:22 -07:00
Ozkan Sezer bef0fec121 make sure that SDL_malloc(0) or SDL_calloc(0,x) doesn't return NULL. 2017-10-12 14:28:05 +03:00
Sam Lantinga 0ce23a5498 Updated version to 2.0.7 2017-10-12 08:08:04 -07:00
Ethan Lee 84fb4893cf Check SDL_UDEV_DYNAMIC first, then SDL_UDEV_LIBS separately 2017-10-10 20:22:15 -04:00
Sam Lantinga c0019b7f49 Fixed bug 3871 - Touch events are not normalised on X11
Trent Gamblin

The documentation for SDL_TouchFingerEvent says that the x and y coordinates are normalised between 0-1. I've found that to be true on Windows, Android and iOS but on X11 they are in pixel coordinates. This patch fixes the issue. This was the cleanest way I could do it with what was available without changing things around a lot but you may know a better way.
2017-10-11 13:31:21 -07:00
Sam Lantinga b53c35df43 Fixed size in realloc 2017-10-11 13:26:58 -07:00
Ryan C. Gordon 5e5f2290f2 audio: Turns out the accumulation errors sound better. :/
Moving to double fixed the overflows, but using "time = i * incr" instead of
"time += incr" causes clicks in the output.
2017-10-11 12:07:43 -04:00
Ryan C. Gordon 9bd2c6b491 audio: Moved the resampler state up to double precision.
Fixes more buffer overflows.
2017-10-11 11:51:14 -04:00
Ryan C. Gordon b2f5123b65 audio: calculate resampling time directly, don't increment (thanks, Eric!).
Fixes buffer overruns as floating point errors accumulate.

Partially fixes Bugzilla #3848.
2017-10-11 11:43:35 -04:00
Ryan C. Gordon 763c387149 audio: clamp resampler interpolation values to prevent buffer overflow.
Partially fixes Bugzilla #3848.
2017-10-11 02:33:55 -04:00
Ryan C. Gordon 0085f917e0 audio: Moved unchanging variable out of loop. 2017-10-11 02:31:58 -04:00
Ryan C. Gordon cb8bf6bbaf audio: Make sure audio stream resampling doesn't overflow buffers. 2017-10-11 02:03:05 -04:00
Ryan C. Gordon 459e2b0bbe audio: Fixed check for minimum audio stream put size. 2017-10-11 01:37:11 -04:00
Sam Lantinga 8446d4a05a Changed overlapping memcpy to memmove 2017-10-10 20:11:05 -07:00
Sam Lantinga eb9e6938cc Fixed potentially calling a callback after it has been removed (and userdata possibly deleted) 2017-10-10 19:44:33 -07:00
Ryan C. Gordon 903ff6414e audio: SDL_ResampleCVT() should use memmove instead of memcpy.
This copy can overlap.

Fixes Bugzilla #3849.
2017-10-10 22:31:02 -04:00
Ryan C. Gordon 42fff7ce2b audio: Don't stack-allocate resampler padding.
(I thought padding size ranged from 5 frames to ~30 frames (based around
RESAMPLER_ZERO_CROSSINGS, which is 5), but it's actually between 512 and
several thousands (based on RESAMPLER_SAMPLES_PER_ZERO_CROSSING)). It gets
big fast when downsampling.
2017-10-10 22:18:46 -04:00
Sam Lantinga b647bd0692 The event filter and event watch functions are now thread-safe 2017-10-10 17:41:41 -07:00
Ryan C. Gordon 37d89aa10f audio: reworked audio streams to have right-hand resampling padding available.
Fixes Bugzilla #3851.
2017-10-10 16:12:56 -04:00
Ryan C. Gordon 28149e11c8 Added SDL_PeekIntoDataQueue(). 2017-10-10 11:56:54 -04:00
Sam Lantinga d90fce3c9e Exposed the joystick locking functions for multi-threaded access to the joystick API 2017-10-10 11:10:15 -07:00
Sam Lantinga 2657dfae49 Fixed crash in SDL_IsGameController() on Windows if called when a controller is being removed 2017-10-09 11:45:15 -07:00
Sam Lantinga b120fb879a Fixed bug 3865 - [PATCH] Support for GreenAsia Inc. PSX to USB converter as SDL_GameController
Manuel

I would like this small patch merged that adds support for my GreenAsia Inc. PSX to USB converter, so SDL_IsGameController() returns true when using this adaptor.
It's interesting because PSX/PS2 controllers connected using this model won't be detected as gamecontrollers otherwise, only as joysticks.
2017-10-08 10:59:03 -07:00
Sam Lantinga d2a2b0c139 Fixed bug 3857 - SDL_ConvertPixels misses YUV conversions
Sylvain

There are various YUV-RGB conversion coefficients, according to https://www.fourcc.org/fccyvrgb.php
I choose the first (from Video Demystified, with integer multiplication),
but the current SDL2 Dither functions use in fact the next one, which follows a specifications called CCIR 601.

Here's a patch to use the second ones and with previous warning corrections.
There are less multiplications involved because Chroma coefficient is 1.
Also, doing float multiplication is as efficient with vectorization.
In the end, the YUV decoding is faster: ~165 ms vs my previous 195 ms.

Moreover, if SDL2 is compiled with -march=native, then YUV decoding time drops to ~130ms, while older ones remains around ~220 ms.


For information, from jpeg-9 source code:
jpeg-9/jccolor.c

   * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
   * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
   * The conversion equations to be implemented are therefore
   * Y  =  0.29900 * R + 0.58700 * G + 0.11400 * B
   * Cb = -0.16874 * R - 0.33126 * G + 0.50000 * B  + CENTERJSAMPLE
   * Cr =  0.50000 * R - 0.41869 * G - 0.08131 * B  + CENTERJSAMPLE

jpeg-9/jdcolor.c

   * YCbCr is defined per CCIR 601-1, except that Cb and Cr are
   * normalized to the range 0..MAXJSAMPLE rather than -0.5 .. 0.5.
   * The conversion equations to be implemented are therefore
   *
   * R = Y                + 1.40200 * Cr
   * G = Y - 0.34414 * Cb - 0.71414 * Cr
   * B = Y + 1.77200 * Cb
2017-10-07 15:26:55 -07:00
Sam Lantinga 1bfe6d6026 Fixed restoring window size when coming out of fullscreen desktop mode.
Use the style of the window as it will be, not as it currently is at the
time of the AdjustWindowRect call.
2017-10-06 21:43:59 -07:00
Sam Lantinga e9652b1987 Fixed bug 3857 - SDL_ConvertPixels misses YUV conversions
Sylvain

Few issues with YUV on SDL2 when using odd dimensions, and missing conversions from/back to YUV formats.

1) The big part is that SDL_ConvertPixels() does not convert to/from YUV in most cases. This now works with any format and also with odd dimensions,
  by adding two internal functions SDL_ConvertPixels_YUV_to_ARGB8888 and SDL_ConvertPixels_ARGB8888_to_YUV (could it be XRGB888 ?).
  The target format is hard coded to ARGB888 (which is the default in the internal of the software renderer).
  In case of different YUV conversion, it will do an intermediate conversion to a ARGB8888 buffer.

  SDL_ConvertPixels_YUV_to_ARGB8888 is somehow redundant with all the "Color*Dither*Mod*".
  But it allows some completeness of SDL_ConvertPixels to handle all YUV format.
  It also works with odd dimensions.

  Moreover, I did some benchmark(SDL_ConvertPixel vs Color32DitherYV12Mod1X and Color32DitherYUY2Mod1X).
  gcc-6.3 and clang-4.0. gcc performs better than clang. And, with gcc, SDL_ConvertPixels() performs better (20%) than the two C function Color32Dither*().
  For instance, to convert 10 times a 3888x2592 image, it takes ~195 ms with SDL_ConvertPixels and ~235 ms with Color32Dither*().
  Especially because of gcc vectorize feature that optimises all conversion loops (-ftree-loop-vectorize).

  Nb: I put no image pitch for the YUV buffers. because it complexify a little bit the code and the API :
  There would be some ambiguity when setting the pitch exactly to image width:
  would it a be pitch of image width (for luma and chroma). or just contiguous data ? (could set pitch=0 for the later).


2) Small issues with odd dimensions:
  If width "w" is odd, luma plane width is still "w" whereas chroma planes will be "(w + 1)/2". Almost the same for odd h.
  Solution is to strategically substitute "w" by "(w+1)/2" at the good places ...

- In the repository, SDL_ConvertPixels() handles YUV only if yuv source format is exactly the same as YUV destination format.
  It basically does a memcpy of pixels, but it's done incorrectly when width or height is odd (wrong size of chroma planes). This is fixed.

- SDL Renderers don't support odd width/height for YUV textures.
  This is fixed for software, opengl, opengles2. (opengles 1 does not support it and fallback to software rendering).
  This is *not* fixed for D3D and D3D11 ... (and others, psp ?)
  Only *two* Dither function are fixed ... not sure if others are really used.

- This is not possible to create a NV12/NV12 texture with the software renderer, whereas other renderers allow it.
  This is fixed, by using SDL_ConvertPixels underneath.

- It was not possible to SDL_UpdateTexture() of format NV12/NV21 with the software renderer. this is fixed.

Here's also two testcases:
- that do all combination of conversion.
- to test partial UpdateTexture
2017-10-06 16:50:24 -07:00
Sam Lantinga d9e1036e0f Fixed potential overflow in surface allocation (thanks Yves!) 2017-10-06 16:17:50 -07:00
Sam Lantinga 312da2623a Fixed bug 3854 - arguments to dbus_type_is_basic() were incorrect
Aaron

As of 2.0.6, all of my games are failing with the following error:

process 31778: arguments to dbus_type_is_basic() were incorrect, assertion "dbus_type_is_valid (typecode) || typecode == DBUS_TYPE_INVALID" failed in file dbus-signature.c line 322.
This is normally a bug in some application using the D-Bus library.
  D-Bus not built with -rdynamic so unable to print a backtrace

(patch by  Ozkan Sezer)
2017-10-05 09:37:28 -07:00
Brandon Schaefer db20e71d54 Fixed bug 3855 - Memory leak in SDL_FreeSurface 2017-10-02 10:50:33 -07:00
Brandon Schaefer e564da78b7 revert files I didnt mean to commit! 2017-09-29 10:15:44 -07:00
Brandon Schaefer e27f12e0da wayland: Fix bug 3814 -Wmissing-field-initializers 2017-09-29 10:07:37 -07:00
Sam Lantinga aad58c622c Fixed bug 3852 - SDL_FreeSurface deallocates surface->map even if the surface is not yet freed
Evgeny Kapun

Commit 490bb5b49f11 [1], which was a fix for bug #3790, introduced a new bug: now, calling SDL_FreeSurface(surface) deallocates surface->map even if there are other references to the surface. This is bad, because some functions (such as SDL_ConvertSurface) assume that surface->map is not NULL.
2017-09-29 07:44:30 -07:00
Sam Lantinga 54685787ca Fixed bug 3847 - Hit Test x coordinate wrong on secondary monitor
Robert Turner

SDL_windowsevents.c contains code to retrieve the x and y coordinate for a requested hit test. It does this as follows:

    POINT winpoint = { (int) LOWORD(lParam), (int) HIWORD(lParam) };

LOWORD(lParam) does not correctly mask off high bits that are set if the point is on a second (or third, etc.) monitor. This effectively offsets the x-coordinate by a large value.

MSDN documentation suggests that LOWORD() and HIWORD() are the wrong macros for the task, instead suggesting we should be doing something like the following:

    POINT winpoint = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };

Testing this change on my Windows 10 machine with 2 monitors gives the correct results.
2017-09-26 15:07:35 -07:00
Alex Szpakowski fb071a4cd9 Mac: Fix the menu bar not always working for non-.app-bundled apps. Fixes bug #3051. 2017-09-25 20:49:31 -03:00
Ryan C. Gordon 099ae43e81 audio: Fixed compiler warning on Visual Studio. 2017-09-22 22:28:21 -04:00
Sam Lantinga 58d1c54d06 Fixed spacing 2017-09-22 17:32:05 -07:00
Sam Lantinga 0fea9164eb Added an example for SDL_SetWindowHitTest() when you create a borderless resizable window. 2017-09-22 17:29:32 -07:00
Sam Lantinga 2fd5235145 Added stubs for simple Steam Controller support 2017-09-22 08:32:31 -07:00
Sam Lantinga d828647944 Added stubs for simple Steam Controller support 2017-09-22 08:30:52 -07:00
Sam Lantinga 53b2c91d26 Separated out SDL Android java code so audio, controller, and filesystem APIs can be used independently of the SDL activity, in Qt apps for example. 2017-09-22 08:30:46 -07:00
Sam Lantinga ad86eff1a8 Guarded EGL code with SDL_VIDEO_OPENGL_EGL 2017-09-22 08:30:37 -07:00
Sam Lantinga 499f928c33 borderless windows will have WM_NCCALCSIZE return 0 for the non-client area. When this happens, it looks like windows will send a resize message expanding the window client area to the previous window + chrome size, so shouldn't need to adjust the window size for the set styles. 2017-09-22 07:15:41 -07:00
Sam Lantinga 3176a7f5e9 sdl
- Fixing rendering borderless window. Need to force windows to send a WM_NCCALCSIZE then return 0 for non-client area size.

- Adding WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX to borderless windows, for reasons noted in comments.

- Fix SetupWindowData() setting SDL_WINDOW_BORDERLESS. This was being cleared at window creation, causing hanlding for the first WM_NCCALCSIZE message to fail
2017-09-22 07:11:36 -07:00
Sam Lantinga fe6b8f1c31 Fixed Mac OS X build 2017-09-22 11:25:52 -07:00
Sam Lantinga 407e1693ae Fixed audio being silent on older iOS devices
Tested on an iPod running iOS 6.1
2017-09-22 11:15:14 -07:00
Sam Lantinga 5ab5c9b767 Avoid duplicate joystick axis events 2017-09-22 08:56:09 -07:00
Sam Lantinga d74c00e67d Fixed memory leak when HAVE_ALLOCA isn't defined 2017-09-22 08:51:45 -07:00
Mark Callow 59d17bdee0 Avoid hitting ERR_MAX_STRLEN limit. 2017-09-22 22:30:02 +09:00
Ryan C. Gordon 6d206a7b28 audio: Stream resampling now saves some samples from previous run for padding.
Previously, the padding was silence, which was a problem when streaming since
you would sample a little bit of this silence between each buffer.

We still need a means to get padding data for the right hand side, but this
patch makes the resampler output more correct.
2017-09-22 07:42:24 -04:00
Brandon Schaefer 466ba57d42 [egl/mir] Need eglGetProc to find gl 4.5 core profile extensions 2017-09-21 18:38:07 -07:00
Alex Szpakowski e5cfb58f4a iOS MoltenVK code style cleanup. 2017-09-21 20:30:25 -03:00
Sam Lantinga b3ac0b6fb0 A hint with an empty string should be treated as the default value 2017-09-21 14:48:03 -07:00
Sam Lantinga eaab6098eb Only apply the jitter filter to prevent unexpected motion on axes that haven't been touched. 2017-09-21 10:29:17 -07:00
Sam Lantinga 5ae90ef67a Fixed bug 3788 - software renderer crashes in SDL_RenderCopyEx with rotation and dstrect w or h is 0
Anthony

This is what's making the software renderer crash with rotated destination rectangles of w or h = 0:

SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2");
2017-09-21 01:22:40 -07:00
Sam Lantinga 8b660c5046 Added some missing "extern" declarations 2017-09-21 00:55:29 -07:00
Ryan C. Gordon f40bd5ee24 audio: removed my perl experiment script. 2017-09-21 02:06:53 -04:00
Ryan C. Gordon 1a3b95a11e audio: Replaced the resampler. Again.
This time it's using real math from a real whitepaper instead of my previous
amateur, fast-but-low-quality attempt. The new resampler does "bandlimited
interpolation," as described here: https://ccrma.stanford.edu/~jos/resample/

The output appears to sound cleaner, especially at high frequencies, and of
course works with non-power-of-two rate conversions.

There are some obvious optimizations to be done to this still, and there is
other fallout: this doesn't resample a buffer in-place, the 2-channels-Sint16
fast path is gone because this resampler does a _lot_ of floating point math.
There is a nasty hack to make it work with SDL_AudioCVT.

It's possible these issues are solvable, but they aren't solved as of yet.
Still, I hope this effort is slouching in the right direction.
2017-09-21 02:51:14 -04:00
Mark Callow 3c45e662f5 macOS: remove unneeded #includes. 2017-09-21 14:01:12 +09:00
Sam Lantinga f0a324f8eb Reverted Alex's commit 131cba1768a5 - we're about to release 2.0.6, don't remove support for the iOS 7 SDK yet. 2017-09-20 19:59:34 -07:00
Alex Szpakowski d452b89f9b iOS: I don't think SDL compiles with the iOS 7 SDK anymore, so we might as well drop the #ifdefs trying to guard for that. 2017-09-20 11:01:32 -03:00
Alex Szpakowski 12fb004fba iOS: remove an unused static variable 2017-09-20 10:53:41 -03:00
Sam Lantinga c08a7a74a5 Added a hint SDL_HINT_AUDIO_CATEGORY to control the audio category,
determining whether the phone mute switch affects the audio
2017-09-15 17:27:32 -07:00
Patrice Mandin 46ec130528 Fix for 3829. Revert adding GameSir G4s, uses same GUID as PS3 controller. 2017-09-14 21:45:14 +02:00
Patrice Mandin 73c85e986c Readd support for GameSir G4s, lost with changeset 11431 2017-09-14 19:33:32 +02:00
Sam Lantinga cfe72c76e2 Fixed iOS keyboard positioning, based on the final position rather than the initial one 2017-09-14 09:55:27 -07:00
Ryan C. Gordon 76176486ce surface: Make sure SDL_ConvertSurface() deals with palettes (thanks, Sylvain!).
Fixes Bugzilla #3826.
Fixes Bugzilla #2979.
2017-09-14 08:37:27 -04:00
Sam Lantinga ac782d7122 Added support for the PDP Battlefield One Xbox One controller on Linux 2017-09-12 05:53:47 -07:00
David Ludwig 78b83d3a6d WinRT: build fix when using recent versions of the Windows 10 SDK 2017-09-11 18:20:56 -04:00
Sam Lantinga e98fc8972d Fixed bug 3812 - Fallthrough warnings gcc-7 2017-09-10 12:54:40 -07:00
Sam Lantinga 5f48ce0b64 Fixed bug 3815 - implicit-fallthrough warning - DUFFS_LOOP4 and friends 2017-09-10 12:49:41 -07:00
Sam Lantinga 19114b0378 Fixed bug 3813 - gcc7 fallthrough warnings in SDL_iconv.c and SDL_pixels.c 2017-09-10 12:42:38 -07:00
Sam Lantinga 849c4c1472 Fixed tabs to spaces 2017-09-10 12:40:45 -07:00
Sam Lantinga 8ed16ea465 Fixed compile warning 2017-09-10 10:43:04 -07:00
Ryan C. Gordon 93583d461c alsa: removed snd_pcm_wait() call before writing to playback device.
This would cause playback problems in certain situations, such as on the
Raspberry Pi. The device that the wait was added for seems to not benefit from
it in modern times, and standard desktop Linux seems to do the right thing
when a USB device is unplugged now, without this patch.

Fixes Bugzilla #3599.
2017-09-09 21:17:46 -04:00
Sam Lantinga b2ba8963b3 Fixed bug 3809 - Restore after maximize leads to wrong size
Andreas Falkenhahn

My app opens a 640x480 window. When I click on the window's maximize button, the window correctly fills the entire screen and loses its borders. But clicking on the restore button now doesn't restore the window to its original 640x480 size. Instead, the window size is identical to the screen size now. The only difference to the previous state is that the window now has borders again but it isn't restored to 640x480.
2017-09-09 11:00:25 -07:00
Sam Lantinga 676c3a9263 Fixed bug 3719 - Cocoa - Incorrect window size when leaving fullscreen
bastien.bouclet

The window is now resized to its specified size, but it moves to the top left corner of the screen. That is unexpected because neither the user nor the program moved it there. Test program attached (the same one as before).
2017-09-09 10:31:44 -07:00
Sam Lantinga fcd9c19022 Fixed window size when leaving fullscreen mode (thanks Eric!) 2017-09-09 09:31:12 -07:00
Sam Lantinga f465f24d73 Fixed bug 3760 - RWops doesn't check for integer overflow when stdio_fseek only supports 32 bits
Simon Hug

When RWops seeks with fseek or fseeko it uses the types long or off_t which can be 32 bits on some platforms. stdio_seek does not check if the 64-bit integer for the offset fits into a 32-bit integer. Offsets equal or larger than 2 GiB will have implementation-defined behavior and failure states would be very confusing to debug.

The attached patch adds range checking by using the macros from limits.h for long type and some bit shifting for off_t because POSIX couldn't be bothered to specify min and max macros.

It also defines HAVE_FSEEKI64 in SDL_config_windows.h so that the Windows function gets picked up automatically with the default config.

And there's an additional error message for when ftell fails.
2017-09-09 08:36:37 -07:00
Sam Lantinga 9a73909bbd Fixed bug 3808 - fix a typo in SDL_stretch.c
Ozkan Sezer

The following patch fixes a minor _MSC_VER typo in SDL_stretch.c,
and also does a tiny tidy-up for assembly opcodes cpp checks.
2017-09-09 08:20:56 -07:00
Sam Lantinga 222d25ad4b Fixed bug 3805 - Why is there no --enable-video-rpi option in configure?
Andreas Falkenhahn

When compiling SDL for the Raspberry Pi, I have to use the --host parameter to enable compilation of the native Raspberry Pi video driver, like so:

    --host=arm-raspberry-linux-gnueabihf

It took me a while to figure out that this was necessary in order to have the native Raspberry Pi video driver compiled in. I think it would be better if there was an option like --enable-video-rpi that could be passed to configure and that would also show up when saying configure --help. Currently, it?s rather difficult to figure out that you have to use the --host parameter with arm-raspberry-linux-gnueabihf in order to get Raspberry Pi video support. It?s also somewhat inconsistent because most other video drivers can in fact be enabled/disabled through specific configure parameters but there is no such parameter for the native Raspberry Pi video driver.
2017-09-08 22:21:01 -07:00
Sam Lantinga e8059221bd Fixed bug 3806 - Fixes for MSVC compiler warnings
Simon Hug

These are the remaining compiler warnings I see in the current tip cb049cae7c3c.

- SDL_test_log.c defines _CRT_SECURE_NO_WARNINGS without checking if it was already set.

- SDL_windowskeyboard.c converts integers to pointers without going over the (U)INT_PTR types. That bothers MSVC.
2017-09-08 18:26:25 -07:00
Sam Lantinga 0ddac338b0 keep joystick thread from waking unnecessarily, and from possibly blocking for 300ms at shutdown if a joystick was just plugged in
CR: SamL
2017-09-08 07:15:47 -07:00
Sam Lantinga 1b2492ed8a Fixed 64-bit build warning 2017-09-08 15:08:03 -07:00
Sam Lantinga 4657d9f33c We don't need to pass the renderer into SDLTest_CleanupTextDrawing() 2017-09-08 04:53:31 -07:00
Sam Lantinga 65c55fdd84 Fixed build 2017-09-08 04:38:46 -07:00
Sam Lantinga b0b3da7702 Added a function to clean up test text drawing 2017-09-08 04:14:05 -07:00
Ryan C. Gordon ca15c7d67f wave: SDL_LoadWAV now supports 24-bit audio. 2017-09-07 10:56:08 -04:00
Ryan C. Gordon fb28393200 vulkan: use "unsigned int" instead of "unsigned" 2017-09-06 19:35:36 -04:00
Ryan C. Gordon 0c892abcd0 raspberrypi: The latest Raspbian moved its EGL and GLES2 libs elsewhere.
Now we try the new (hardware-specific) pathnames first, and if those fail to
load, we'll try the more generic names that earlier versions of Raspbian used.

Fixes Bugzilla #3800.
2017-09-06 19:34:23 -04:00
Sam Lantinga fa0eeff7f5 sdl:
Cleans up AdjustWindowEx calls
2017-09-06 07:29:34 -07:00
Sam Lantinga 20c5bc9135 You can have a borderless resizable window 2017-09-06 05:23:26 -07:00
Sam Lantinga 4ca5d8622a Fixed bug 3780 - GCC 7 implicit fallthrough warnings
Martin Gerhardy 2017-08-28 06:58:01 UTC

SDL_blit.h, SDL_fillrect.c and SDL_stdinc.h produces a lot of the (new) gcc-7 implicit fallthrough warnings.
2017-09-06 04:32:30 -07:00
Sam Lantinga c8e3e0c414 Fixed bug 3799 - SDL_CreateWindow fails with SDL_WINDOW_VULKAN (libvulkan.so.1 not found)
Manuel Sabogal

Android NDK defines Vulkan as libvulkan.so, not libvulkan.so.1. This is causing the program to not being able to create a window using SDL_WINDOW_VULKAN.

To fix this issue just change the line http://hg.libsdl.org/SDL/file/bbaec41e93b5/src/video/android/SDL_androidvulkan.c#l53 from "libvulkan.so.1" to "libvulkan.so"
2017-09-06 01:10:10 -07:00
Ryan C. Gordon c9e73c3e00 x11: make sure SDL_GetGlobalMouseState notices mouse warping through SDL APIs. 2017-09-05 16:15:54 -04:00
Sam Lantinga 0782f9be51 Fixed bug 3273 - Fix for slow video subsystem initialization when using XRandR.
Mart?n Golini

I'm having a very slow initialization of the video subsystem that locks the window creation for about 500 ms ( tested in at least 4 different systems ). What i found is that X11_InitModes_XRandR is using XRRGetScreenResources, that explicitly ask to poll the hardware for changes. This is not really necessary since if the data is already available you can use XRRGetScreenResourcesCurrent.
I attached a tentative patch that fix this issue. With the patch there's no lock when the subsystem is initialized and the window creation is instant in my applications. The patch only uses XRRGetScreenResourcesCurrent in X11_InitModes_XRandR but it could be potentially used in X11_GetDisplayModes and X11_SetDisplayMode.
2017-09-05 08:24:38 -07:00
Sam Lantinga c1fd0fbb32 Fixed compiler warning with mingw-w64 2017-09-04 22:14:57 -07:00
Sam Lantinga 67f9348baa Fixed bug 3790 - Memory leak with surfaces blitting on each other
bastien.bouclet

When creating two surfaces and blitting them onto the other, SDL's internal reference counting fails, and one of the surfaces is not freed when calling SDL_FreeSurface.

Example code :

SDL_Surface *s1 = SDL_CreateRGBSurfaceWithFormat(0, 640, 480, 32, SDL_PIXELFORMAT_ARGB8888);
SDL_Surface *s2 = SDL_CreateRGBSurfaceWithFormat(0, 640, 480, 32, SDL_PIXELFORMAT_ARGB8888);

SDL_BlitSurface(s1, NULL, s2, NULL);
SDL_BlitSurface(s2, NULL, s1, NULL);

SDL_FreeSurface(s2);
SDL_FreeSurface(s1);

With this example, s1 is not freed after calling SDL_FreeSurface, its refcount attribute is still positive.
2017-09-04 11:46:14 -07:00
David Ludwig 532446a6bd macOS: bug-fix for #3793, "fullscreen toggle does not maintain SDL_Renderer's logical size"
This also seems to fix the follow-up issue in bug #3719, whereby the initial fix caused the SDL window to move, after transitioning from fullscreen to windowed-mode
2017-09-03 17:33:49 -04:00
Ryan C. Gordon 167398b363 video: Let video targets optionally decide their default OpenGL configs.
This is necessary because the Raspberry Pi is a strange beast, that believes
it has OpenGL support (through glX?) but generally has GLES2 support.

So when using the raspberry video target, we need to force this to default
to a GLES2 context, or by default SDL_CreateWindow() will fail, deep down
when it tries to load the proper GL library.

Fixes testsprite2 (and basically everything else that wasn't testgles2) when
run on a Raspberry Pi without a X server.

Please note that other targets might also need this filled in, the Raspberry
Pi is just the most prominent and readily-available System-On-A-Chip style
thing on my desk.  :)
2017-09-02 19:35:32 -04:00
Ryan C. Gordon 3267398d15 sndio: Patched to compile if SIO_DEVANY isn't defined.
(It isn't in whatever Raspbian is currently shipping.)
2017-09-02 16:41:14 -04:00
Sam Lantinga c26946e9f2 Fixed bug 3792 - [KMS/DRM] Wrong GBM format
Romain Tisserand

Using KMS/DRM driver from WIP SDL2.0.6 on Linux/ARM SoC RockChip RK3328 (ARM Mali 450 MP2 GPU).

The current code is using GBM_BO_FORMAT_XRGB8888 as GBM buffer format specifier.

The Mali driver (it has been confirmed some other vendor implementations too) expects GBM_FORMAT_XRGB8888.

The Mesa implementation is actually handling both values as the same, but it's not implemented like this into every gbm.h vendor header.

https://github.com/ideak/mesa/blob/master/src/gbm/backends/dri/gbm_dri.c

So with stock SDL2 on my card (Mali vendor implementation), it does not work, eglCreateWindowSurface fails, and gbm_is_format_supported fails too (with the BO variant).
It runs fine with GBM_FORMAT_XRGB8888.

Here is a link of the gbm.h from Mali user-space driver :

https://github.com/rockchip-linux/libmali/blob/rockchip/include/gbm.h
2017-09-01 12:54:38 -07:00
Ryan C. Gordon 74043994b8 x11: Correctly restore previous GL context after sacrificial context is done. 2017-09-01 14:08:09 -04:00
Ryan C. Gordon a3dda100f4 x11: don't try to make a NULL GL context current when we already did that. 2017-09-01 14:00:11 -04:00
Ryan C. Gordon 4649ac463c x11: Clean up sacrificial GL context code.
Check for failures, restore any previously-current context.
2017-09-01 13:57:40 -04:00
Ryan C. Gordon 507659c6ac x11: Make a sacrificial glX context to check for extensions during init.
This is necessary because we need to see if GLES compat extensions exist.

All of this code (including ShouldUseTextureFramebuffer()) should be
revisited after 2.0.6 ships; ideally we don't make throwaway contexts if
we can avoid it...but maybe we can't. I hear Vulkan is pretty cool.

Fixes Bugzilla #3725.
2017-09-01 13:27:53 -04:00
Alex Szpakowski 20207abf80 macOS: Update controller mapping of Steelseries Stratus XL to account for reversed thumbstick y-axis values (bug #3483). 2017-08-31 22:07:28 -03:00
Alex Szpakowski d7ae313134 macOS: Fix menubar items being enabled when they shouldn't be. 2017-08-31 21:34:29 -03:00
Alex Szpakowski b959be2569 Code style cleanup in the Cocoa and UIKit vulkan files. 2017-08-31 21:26:13 -03:00
Alex Szpakowski cfd7a7fac6 macOS: Prevent unwanted native fullscreen (Spaces) toggles when the window is in fullscreen or isn't resizable. Fixes bug #3691. 2017-08-31 21:13:32 -03:00
Sam Lantinga b54bcb34d0 Fixed bug 3483 - Steelseries Nimbus MFi controller reversed Y-axis analog stick
benjamin.feng

Probable underlying cause: https://bugzilla.libsdl.org/show_bug.cgi?id=3124#c5

"If you download and build the HID Calibrator sample you can see that these are totally legitimate HID devices (except for inverting the Y-axis of joysticks, which is contrary to the HID specification but does make them more compatible with games compiled expecting XBOX controllers)."
2017-08-30 23:30:24 -07:00
Sam Lantinga 8e160a34a7 Convert tabs to spaces in game controller database entries 2017-08-30 23:02:39 -07:00
Sam Lantinga 9ca6292372 Added some missing render capability flags 2017-08-29 23:14:39 -07:00
Sam Lantinga c3d428d402 Fixed line breaks in verbose test logging output 2017-08-29 23:12:26 -07:00
Sam Lantinga 94e0f3e95b Added some debug messaging for previously unhandled events 2017-08-29 22:52:17 -07:00
Sam Lantinga 2d10a3f2b9 The dummy video driver check is now covered by explicitly checking for cocoa above. 2017-08-29 22:24:59 -07:00
Sam Lantinga 92bf608527 Fixed bug 3616 - SDL_GL_CreateContext fails with SDL_GL_CONTEXT_DEBUG_FLAG and ANGLE/GLES 2.0
Colin Barrett

Using the pre-built x86 devel libs from here:
https://www.libsdl.org/release/SDL2-devel-2.0.5-VC.zip

If I have:

SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_FLAGS, SDL_GL_CONTEXT_DEBUG_FLAG);

and I'm using ANGLE/(a GL driver that doesn't provide an ES2 context) such that SDL_EGL_CreateContext is called by SDL_GL_CreateContext, I get the error "Could not create EGL context (context attributes are not supported)" and no context is created.

Looking at the code in SDL_EGL_CreateContext - if gl_config.flags is non-zero, it looks like the code in the section guarded with "#ifdef EGL_KHR_create_context" should be executed - but it apparently isn't.

Is it possible this section hasn't been compiled into the pre-built libraries? If I build SDL2.dll myself using the Visual C++ solution (VS2015 Community Update 3) then the call succeeds as I expect
2017-08-29 22:04:43 -07:00
Sam Lantinga 8fc1fb0805 Fixed bug 3719 - Cocoa - Incorrect window size when leaving fullscreen
bastien.bouclet

When exiting a "fullscreen space" on OS X, windows don't go to their defined "windowed mode size", but go back to their previous size.

Steps to reproduce:
1. Create a windowed mode SDL window
2. Toggle it to fullscreen with the SDL_WINDOW_FULLSCREEN_DESKTOP flag
3. While in fullscreen, change the windowed mode size using SDL_SetWindowSize
4. Toggle the window back to windowed mode

Expected result:
- The window has the size specified during step 3.

Actual result:
- The window has the size specified when creating the window in step 1.

Attached is a minimal reproduction test case.
The attached test case works as expected on X11 and Windows.
2017-08-29 21:42:22 -07:00
Ryan C. Gordon 21e32bac10 egl: Cast to size_t, in case platform's NativeDisplayType isn't a pointer.
(fixes compiler warnings on QNX.)
2017-08-29 16:30:49 -04:00
Ryan C. Gordon ae667da638 Fixed a bunch of compiler warnings. 2017-08-29 15:52:49 -04:00
Sam Lantinga 130138fa59 Fixed bug 3785 - fix windows build after revision 11382
Ozkan Sezer

fix windows build after revision 11382: commit 2026e42e377a renamed
_SDL_msctf_h to SDL_msctf_h_ . SDL_windowskeyboard.c relies on that
macro, so update it accordingly.
2017-08-28 22:44:48 -07:00
Sam Lantinga 8ac85744cd Fixed Vulkan configure check for Android and added one for Mac OS X 2017-08-28 22:36:45 -07:00
Sam Lantinga 90b38a5d61 Fixed bug 3786 - building against a Mac OS X SDK < 10.11 fails since the vulkan merge
Ozkan Sezer

Since the Vulkan merge, building against a Mac OS X SDM older than
10.11 fails in SDL_cocoametalview.m because Metal.framework is not
present. There is no conditional compiling in SDL_cocoametalview.m
either, so --disable-video-vulkan doesn't help with anything. (The
configury doesn't check darwin for x86_64 either, but it's another
story.)

I cross-build against 10.8 SDK on linux using clang-3.4.2 and this
is a problem for me.  Will this be fixed?
2017-08-28 22:13:45 -07:00
Sam Lantinga d619d88560 Fixed bug 3662 - Error message when using the audio conversion setup without an initialized audio subsystem is a bit vague
Simon Hug

This issue actually raises the question if this API change (requirement of initialized audio subsystem) is breaking backwards compatibility. I don't see the documentation saying it is needed in 2.0.5.
2017-08-28 21:42:39 -07:00
Ryan C. Gordon b128e8802d audio: A whole bunch of improvements to audio conversion (thanks, Solra!).
"Major changes, roughly in order of appearance:

- Use float math everywhere, instead of promoting to double and casting back
all the time.
- Conserve sound energy when downmixing any channel into two other channels.
- Add a QuadToStereo filter. (The previous technique of reusing StereoToMono
never worked, since it assumed an incorrect channel layout for 4.0.)
- Add a 71to51 filter. This removes just under half of the cases the previous
code would silently break in.
- Add a QuadTo51 filter. More silent breakage fixed.
- Add a 51to71 filter, removing another almost-half of the silently broken
cases.
- Add 8 to the list of values SDL_SupportedChannelCount will accept.
- Change SDL_BuildAudioCVT's channel-related logic to handle every case, and
to actually fail if it fails instead of silently corrupting sound data and/or
crashing down the road."

(Note that SDL doesn't otherwise support 7.1 audio yet, but hopefully it will
soon and the 7.1 converters are an important piece of that.  --ryan.)

Fixes Bugzilla #3727.
2017-08-29 00:41:45 -04:00
Ryan C. Gordon 620f5342b5 stdlib: An implementation of SDL_scalbn using ldexp() (thanks, Ozkan!).
Fixes Bugzilla #3767.
2017-08-29 00:36:17 -04:00
Ryan C. Gordon a0cd7d6bce audio: Converting audio samples from int to float was using wrong equation.
Fixes Bugzilla #3775.
2017-08-29 00:02:04 -04:00
Sam Lantinga 1067b528d3 Fixed building with an older Mac OS X SDK 2017-08-28 20:52:05 -07:00
Sam Lantinga aa85436ec7 Fixed compile warning 2017-08-28 14:45:19 -07:00
Sam Lantinga da84c3bf6e Added a log message for nativeRunMain() 2017-08-28 14:44:21 -07:00
Sam Lantinga dbb0a2aa74 Removed the need for libSDL2main.a on Android, and separated JNI initialization out for other integrations 2017-08-28 14:34:15 -07:00
Sam Lantinga 9341589925 Removed unneeded Vulkan symbol definitions 2017-08-28 13:40:32 -07:00
Sam Lantinga 2a945b44cb Fixed bug 2361 - [Android] Joysticks do not have unique IDs
David Brady

When I attempted to make a mapping file for Android gamepads, I quickly discovered that most of the ones that I have here show up as the same device (Broadcom Bluetooth HID), meaning that it was impossible to make mappings on Android, since every device looked the same.

This patch will check for the existence of the getDescriptor function added in Jelly Bean, and use it if it's there.  The Android Dashboard says that the majority of Android phones should support this function, and doing it this way will not force us to bump up our API version.
2017-08-28 10:03:39 -07:00
Sam Lantinga 0560544d1c Fixed 3783 - Default libGL path for directFB on Linux differs from x11 path
Clayton Craft

The default path used by directfb for libGL is different than the default path used by x11 in SDL2:

./src/video/directfb/SDL_DirectFB_opengl.c:
path = "libGL.so";

./src/video/x11/SDL_x11opengl.c:
#define DEFAULT_OPENGL  "libGL.so.1"

On at least one distro (Alpine Linux), libGL.so is not created (or more accurately the symlink to libGL.so.1 is not created). For consistency, the 'path' variable in SDL_DirectFB_opengl.c should patch the DEFAULT_OPENGL in SDL_x11opengl.c ("libGL.so.1")
2017-08-28 09:51:25 -07:00
Sam Lantinga 959ae9019d Instantiate the CAMetalLayer so SDL_Vulkan_CreateSurface() doesn't fail
Error message was:
[mvk-info] MoltenVK version 0.18.2. Vulkan version 1.0.51.
[***MoltenVK ERROR***] VK_ERROR_INITIALIZATION_FAILED: On-screen rendering requires a view that is backed by a layer of type CAMetalLayer.
2017-08-28 02:17:29.579 testvulkan[95627:1716939] ERROR: SDL_Vulkan_CreateSurface(): vkCreateMacOSSurfaceMVK failed: VK_ERROR_INITIALIZATION_FAILED
2017-08-28 02:30:41 -07:00
Sam Lantinga 6dd3f55d55 Fixed WinRT build after changing the header guard preprocessor symbol 2017-08-28 01:59:53 -07:00
Sam Lantinga ff8d2e1493 Fixed build when Wayland is dynamically loaded 2017-08-28 01:42:18 -07:00
Sam Lantinga edaa0ef53f Fixed analyzer warning "Call to 'calloc' has an allocation size of 0 bytes" 2017-08-28 00:54:02 -07:00
Sam Lantinga 3c7f9d692a Fixed redefinition of typedef warnings and errors on BSD 2017-08-28 00:51:14 -07:00
Sam Lantinga 50efbda736 Fixed mingw Windows build, since SDL_vulkan_internal.h includes windows.h 2017-08-28 00:43:14 -07:00
Sam Lantinga 0d011ec66d Renaming of guard header names to quiet -Wreserved-id-macro 2017-08-28 00:22:23 -07:00
Sam Lantinga ce2b16445e Be clear that disabling Vulkan surface support disables the entire SDL Vulkan integration 2017-08-28 00:11:38 -07:00
Sam Lantinga 5cd1a95910 Fixed Android build with Vulkan support 2017-08-27 23:53:09 -07:00
Sam Lantinga 0cebef607b Fixed code style for new Vulkan API functions 2017-08-27 23:39:55 -07:00
Sam Lantinga 37ce9f2773 Fixed typedef redefinition errors when including both SDL_vulkan.h and vulkan.h
You should always include vulkan/vulkan.h first, then include SDL_vulkan.h
2017-08-27 23:13:15 -07:00
Sam Lantinga 9da4717d12 Fixed Windows warning 2017-08-27 22:36:03 -07:00
Sam Lantinga 82ffabc86a Fixed Android build 2017-08-27 22:34:15 -07:00
Sam Lantinga ded5b3a4b4 Fixed crash at shutdown if the window couldn't be created 2017-08-27 21:05:18 -07:00
Sam Lantinga eb5392ad61 Added the new Vulkan API functions to exported functions 2017-08-27 20:41:29 -07:00
Ryan C. Gordon c722e58d1f vulkan: Include a copy of vulkan.h and vk_platform.h.
Now we can provide Vulkan support in the build even if the build box doesn't
have a Vulkan SDK, since we dynamically link to the library anyhow.
2017-08-27 23:25:12 -04:00
Ryan C. Gordon 25e3a1ec90 vulkan: Initial Vulkan support!
This work was done by Jacob Lifshay and Mark Callow; I'm just merging it
into revision control.
2017-08-27 22:15:57 -04:00
Sam Lantinga 8e7998e19d Fixed bug 3710 - SDL_OpenAudio(desired, obtained) doesn't update desired's size when obtained is NULL
David Ludwig

I've created a new set of patches.  I am happy to create more, if it would help.

One version only copies 'size'.

A second version copies both 'size' and 'silence'.  When looking over the documentation for SDL_OpenAudio in SDL_audio.h, it mentioned that both 'size' and 'silence' were things that SDL_OpenAudio would calculate.

Regarding *both* patches, I did notice that SDL 1.2 appears to have always modified desired's size and silence fields.  The SDL wiki, at https://wiki.libsdl.org/SDL_OpenAudio#Remarks , does note:
2017-08-27 19:10:30 -07:00
Sam Lantinga 003d491f86 Fixed bug 3724 - Allow Angle Static Link
Carlos

We would like to add a switch (define) that allows us to compile Angle statically with SDL. That is, getting rid of the OpenGL DLL. Usually you need OpenGL to be loaded dynamically as DLL because implementation is provided by the system but no need with Angle.

Only 2 files need modification and it shouldn't affect current behaivor:
include/SDL_egl.h and src/video/SDL_egl.c, as in here

https://github.com/native-toolkit/sdl/pull/10/files

The flag name could be SDL_VIDEO_STATIC_ANGLE (instead of NATIVE_TOOLKIT_STATIC_ANGLE) as discussed here https://github.com/native-toolkit/sdl/pull/10

We have tested this with both Windows and UWP, using NME engine (https://github.com/haxenme/nme).

Releated issue: https://bugzilla.libsdl.org/show_bug.cgi?id=1820
2017-08-27 19:05:57 -07:00
Sam Lantinga b7c5d15152 SDL_dynapi.c: add missing SDLCALL to macros. 2017-08-27 18:53:30 -07:00
Sam Lantinga a38f127e88 Swapped conditional arguments for standard SDL readability 2017-08-27 18:52:43 -07:00
Sam Lantinga 30fe9a6799 SDL_dynapi.h: revert commit ee88fe3e353e in order to enable dynapi
[ optional ]
2017-08-27 18:49:36 -07:00
Sam Lantinga 50d3fe21aa SDL_dynapi_procs.h: adjust SDL_CreateThread for os/2 2017-08-27 18:49:11 -07:00