Commit Graph

839 Commits

Author SHA1 Message Date
Ryan C. Gordon
30178a9b24 audio: Added SDL_AudioStream. Non-power-of-two resampling now works! 2017-01-05 19:29:38 -05:00
Ryan C. Gordon
f12ab8f2b3 audio: More effort to improve and simplify audio resamplers. 2017-01-05 19:12:20 -05:00
Ryan C. Gordon
52130bde40 diskaudio: Use SDL_Log, not fprintf. 2017-01-05 19:30:45 -05:00
Sam Lantinga
d024c724d1 Fixed signedness issue when blitting on a big endian platform, as reported by capehill
For example, if sR is 0 and dR is 255, we will get -255*sA casted to an unsigned value. Basically results are quite large numbers instead of the expected 0-255 range.
2017-01-05 08:16:39 -08:00
Sam Lantinga
e6e6613ca4 Fixed build warning on Haiku 2017-01-05 02:53:29 -08:00
Sam Lantinga
4938c5054e Added SDL_JoystickGetAxisInitialState() to get a joystick axis' initial value.
This is useful for controller mapping programs to determine an axis' zero state
2017-01-04 10:28:07 -08:00
Sam Lantinga
99e10ef506 Assume D-pad or thumbstick style axes are centered at 0 2017-01-04 07:06:48 -08:00
Sam Lantinga
26f84d7447 Added mappings for several GameCube and SNES controllers 2017-01-04 06:21:17 -08:00
Sam Lantinga
d2a01b6e53 Added the NEXT SNES Controller to the list of zero-centered joysticks 2017-01-04 06:19:56 -08:00
Sam Lantinga
c7780497dc Increased joystick jitter tolerance for PS3 controllers 2017-01-04 05:56:47 -08:00
Ryan C. Gordon
9d04205263 x11: deal with xrandr display size in millimeters being zero.
Xquartz on macOS reports a zero size, which leads to a division by zero here.
2017-01-04 09:33:47 -05:00
Sam Lantinga
082132a70c Fixed binding the D-pad on some Super NES style controllers
Fixed a case where partial trigger pull could be bound to another button

There is a fundamental problem not resolved by this commit:

Some controllers have axes (triggers, pedals, etc.) that don't start at zero, but we're guaranteed that if we get a value that it's correct. For these controllers, the current code works, where we take the first value we get and use that as the zero point and generate axis motion starting from that point on.

Other controllers have digital axes (D-pad) that assume a zero starting point, and the first value we get is the min or max axis value when the D-pad is moved. For these controllers, the current code thinks that the zero point is the axis value after the D-pad motion and this doesn't work.

My hypothesis is that the first class of devices is more common and that we should solve for that, and add an exception to SDL_JoystickAxesCenteredAtZero() as needed for the second class of devices.
2017-01-03 23:39:28 -08:00
Sam Lantinga
d359180040 Fixed bug 3519 - SDL_GetDisplayMode fails to report mode.format when using Wayland backend
Ryan C. Gordon

Kristian says you can't do it with Wayland, and that going forward, it'll just handle whatever you throw at it anyhow.

https://twitter.com/hoegsberg/status/816148272402165761

So I say we mark it SDL_PIXELFORMAT_RGB888, which is what my X11 display currently reports, and leave it at that.
2017-01-03 00:44:05 -08:00
Ryan C. Gordon
2e2572a4f1 Added SDL_ReserveSpaceInDataQueue() to make space without copying data. 2016-12-27 23:48:43 -05:00
Sam Lantinga
18d9b23c65 Fixed bug 3539 - SDL2, missing MIR LDFLAGS
Gianfranco

Hello, this is the failure I got

https://launchpadlibrarian.net/300679206/buildlog_ubuntu-zesty-amd64.libsdl2_2.0.5+dfsg1-2ubuntu1_BUILDING.txt.gz

  LTLINK build/libSDL2.la
build/.libs/SDL_mirvideo.o: In function `MIR_InitDisplayFromOutput':
././src/video/mir/SDL_mirvideo.c:258: undefined reference to `mir_output_get_current_mode'
collect2: error: ld returned 1 exit status
2017-01-02 10:30:32 -08:00
Sam Lantinga
67ed894353 Fixed bug 3529 - SDL_EGL_UnloadLibrary is not called at all on SDL_Quit
kaisyu

In case of OpenGLES, the sequences of loading and unloading driver library should be like that:

SDL_Init
  ...
  SDL_GL_LoadLibrary
    SDL_EGL_LoadLibrary
...
SDL_Quit
  ...
  SDL_GL_UnloadLibrary
    SDL_EGL_UnloadLibrary
...


However, according to my test results, the varible '_this->gl_config.driver_loaded' does not allow 'SDL_GL_UnloadLibrary' to call 'SDL_EGL_UnloadLibrary'.
2017-01-01 19:10:36 -08:00
David Ludwig
0cfa0aa11c improved SDL_GetError() output generated by EGL code
This change attempts to report the EGL error codes generated by SDL's calls
into EGL, along with the name of the EGL function that failed.
2016-12-29 11:49:18 -05:00
Sam Lantinga
45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga
49225f5f04 We don't currently support blitting to < 8 bpp surfaces, return an error instead of corrupting memory in that case. 2016-12-31 18:11:19 -08:00
Sam Lantinga
2ba66d0525 Fixed bug 3535 - Misplaced comment #if/#endif closure comment
Coriiander

This notice is about a misplaced comment.

Often times when we use an #if #endif sequence, the #endif is followed by a comment to indicate what #if statement it belonged to. The SDL_xaudio2.c file contains a misplaced comment, as follows (I stripped the other comments):

#ifdef __GNUC__
#  define SDL_XAUDIO2_HAS_SDK 1
#elif defined(__WINRT__)
#  define SDL_XAUDIO2_HAS_SDK
#include "SDL_xaudio2.h"
#else
#if 0
#include <dxsdkver.h>
#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284))
#  pragma message("Your DirectX SDK is too old. Disabling XAudio2 support.")
#else
#  define SDL_XAUDIO2_HAS_SDK 1
#endif
#endif
#endif /* 0 */



That final /* 0 */ should be moved one line up. Like this (I tabbed it out for you to make it more clear):
2016-12-31 16:21:55 -08:00
Sam Lantinga
880842cfdf Fixed bug 3531 - internal SDL_vsnprintf implementation access memory outside given buffer ranges
Tristan

The internal SDL_vsnprintf implementation accesses memory outside buffer. The bug existed also inside the format (%) processing, which was fixed with Bug 3441.

But there is still an invalid access, if we do not have any format inside the source string and the destination string is shorter than the format string. You can use any string for this test, as long it is longer than the buffer.

Example:

va_list argList;
char buffer[4];
SDL_vsnprintf(buffer, sizeof(buffer), "Testing", argList);

The bug is located on the 'else' branch of the format char test:

while (*fmt) {
  if (*fmt == '%') {
    ...
  } else {
    if (left > 1) {
      *text = *fmt;
      --left;
    }
    ++fmt;
    ++text;
  }
}
if (left > 0) {
  *text = '\0';
}

As you can see that text is always incremented, even when left is already one. When then on the last lines, *text is assigned the NULL char, the pointer is located outside bounds.
2016-12-31 16:14:51 -08:00
Sam Lantinga
7f2068daca Fixed bug 3541 - DisplayIndex out of bounds in SDL_SetWindowPosition
Intellectual Kitty

In SDL_video.c, on line #1756, in SDL_SetWindowPosition (from today's distribution, 12-31-2016, https://hg.libsdl.org/SDL/shortlog/bf19e0c84483):

        if (displayIndex > _this->num_displays) {

should be:

        if (displayIndex >= _this->num_displays) {
2016-12-31 10:30:07 -08:00
Philipp Wiesemann
af26379881 Fixed crash if allocating memory for game controller failed. 2016-12-28 20:10:48 +01:00
Sam Lantinga
cb8685c022 Fixed comment style 2016-12-27 02:04:38 -08:00
Sam Lantinga
6d7da0887d Split controller axes into positive and negative sides so each can be bound independently.
Using this a D-Pad can be mapped to a thumbstick and vice versa.
Also added support for inverted axes, improving trigger binding support
2016-12-27 01:39:07 -08:00
Ryan C. Gordon
7c31636666 x11: Don't loop forever if the X server refuses a pointer grab. 2016-12-26 23:02:14 -05:00
Sam Lantinga
b4e069e7f8 Fixed bug 3517 - Compiler warnings with gcc -Wstrict-prototypes
felix

Compiling even a simple SDL2 'hello world' program with gcc -Wstrict-prototypes (GCC 6.2.1) results in warnings like:

/usr/include/SDL2/SDL_gamecontroller.h:143:1: attention : function declaration isn't a prototype [-Wstrict-prototypes]
 extern DECLSPEC int SDLCALL SDL_GameControllerNumMappings();
 ^~~~~~

It seems there is a missing 'void' between the parentheses.
2016-12-26 02:12:21 -08:00
Sam Lantinga
9492492d5f Fixed bug 3516 - fix build on illumos
Sylvain

trivial patch to fix the build on illumos

 -Werror=declaration-after-statement

https://gist.github.com/wiedi/15b71456667f7aa2a7f8815663723bb3
2016-12-26 01:56:52 -08:00
Alex Szpakowski
fd85f5748d Mac: back out commit 3e9b2ae41adf. It causes significant overhead on many GPUs. 2016-12-23 22:49:37 -04:00
Alex Szpakowski
d719374cb9 Mac: Fix over-saturated colors on P3 displays (e.g. the 2016 MBPs). 2016-12-23 22:08:18 -04:00
Philipp Wiesemann
3e9284519a Windows: Fixed compile error. 2016-12-23 20:36:24 +01:00
Sam Lantinga
4fc0fe1f69 Removed debug print statements 2016-12-23 02:23:44 -08:00
Sam Lantinga
ad26769cd7 Fixed compile errors on various platforms 2016-12-22 18:43:00 -07:00
Sam Lantinga
ca019dada5 Fixed issue where the throttle and other axes on racing wheels don't start at zero and show up as immediate input when the wheel is turned for the first time. Wait until they are actually moved before generating input from them. 2016-12-22 17:33:45 -08:00
Sam Lantinga
b2f6c4c1bd Fixed bus error when converting 16-bit to float for non-integral-multiple sample rates 2016-12-19 11:15:53 -08:00
Ryan C. Gordon
366c77a9f0 audio: fixed one more incorrectly-hardcoded value in the resamplers. 2016-12-18 20:17:33 -05:00
Alex Szpakowski
eda74fda96 tvOS: Expose remote swipe gestures as arrow key presses (thanks oviano!) 2016-12-18 13:05:14 -04:00
Alex Szpakowski
787a54c84b iOS bug #3377: work around bugs in some third party iOS libraries (e.g. Google admob) where they assume the optional UIApplicationDelegate ?window? property always exists and will crash if it doesn?t. 2016-12-18 12:28:28 -04:00
Ryan C. Gordon
f956df23bb audio: fixed arbitrary upsampling (thanks, Sylvain!).
This was a leftover of simplifying the resamplers down from autogenerated
code; I forgot to make something that the generator hardcoded into something
variable.

Fixes Bugzilla #3507.
2016-12-17 16:15:24 -05:00
Sam Lantinga
b4ea63ec2c Fixed crash if there are multiple joysticks closed during the joystick update loop 2016-12-14 06:25:09 -08:00
Ryan C. Gordon
f50a04009c windows: add whitespace to fix macro preprocessing issue (thanks, Sven!).
Apparently without a space here, "fastbuild -cache" breaks.
2016-12-13 00:22:42 -05:00
Sam Lantinga
85d8a79f65 Fixed updated return value for SDL_GL_SwapWindow()
Ozkan Sezer

http://hg.libsdl.org/SDL/rev/464a2676d8ab seems to have
forgotten removing the return from SDL_dynapi_procs.h, and this patch
does that. Without it, MSVC warns:
c:\sdl2\src\dynapi\SDL_dynapi_procs.h(598) : warning C4098:
'SDL_GL_SwapWindow_DEFAULT' : 'void' function returning a value
c:\sdl2\src\dynapi\SDL_dynapi_procs.h(598) : warning C4098:
'SDL_GL_SwapWindow' : 'void' function returning a value
2016-12-12 09:19:48 -08:00
Sam Lantinga
e81bf12b85 Fixed edid parsing code for older gcc compilers
Ozkan Sezer

This adds the name 'ad' to two unnamed unions in edid.h
and adjusts edid-parse.c for it.  Nameless unions are not supported in
ancient gcc, which I happened to use on one of my ancient setups.
2016-12-12 09:18:42 -08:00
Sam Lantinga
8414c3d4ae Fixed ABI, don't change the return type of SDL_GL_SwapWindow() 2016-12-11 12:01:44 -08:00
Sam Lantinga
6211668e9f Fixed creating a renderer on the dummy driver on Mac OS X 2016-12-11 12:01:01 -08:00
Sam Lantinga
cb5a0b0f6a Fixed crash when creating a dummy window on Mac OS X 2016-12-11 11:45:33 -08:00
David Ludwig
d6bcec8f6a WinRT: build fixes
These fixes are lumped into two categories:

1. add new file, SDL_dataqueue.c, to UWP/WinRT build-inputs (via MSVC project
   files)

2. implement a temporary, hack-fix for a build error in SDL_xinputjoystick.c.
   Win32's Raw Input APIs are, unfortunately, not available for use in UWP/WinRT
   APIs.  There does appear to be a replacement API, available in the
   Windows.Devices.HumanInterfaceDevice namespace.

   This fix should be sufficient to get SDL compiling again, without affecting
   Win32 builds, however using the UWP/WinRT API (in UWP/WinRT builds) would
   almost certainly be better (for UWP/WinRT builds).

   TODO: research Windows.Devices.HumanInterfaceDevice, and use that if and as
   appropriate.
2016-12-10 15:23:17 -05:00
Sam Lantinga
454d9cb96d PP_OK isn't available in the NaCl build environment on buildbot. It's defined as 0 2016-12-09 05:19:31 -08:00
Sam Lantinga
97d05b0da8 Fixed a bunch of SwapWindow calls that needed their return value updated 2016-12-09 05:12:27 -08:00
Sam Lantinga
7a39681ea5 Fixed X11 OpenGL ES build 2016-12-09 05:04:18 -08:00
Sam Lantinga
fed8cbcdb6 Fixed build for EGL platforms 2016-12-09 05:00:35 -08:00
Sam Lantinga
b936a4c360 Added support for the XiaoMi Game Controller 2016-12-09 04:57:54 -08:00
Sam Lantinga
524bf3c282 Fixed bug 3513 - SDL_GL_SwapWindow does not return error status
Return an error code from SDL_GL_SwapWindow(), like the other SDL APIs.
2016-12-09 01:47:43 -08:00
Sam Lantinga
3b18c796ed Fixed bug 3512 - Memory leak of SDL_Joystick axes_zero array
Benjamin Harris

Found with valgrind and confirmed in the 2.0.5 source code.
One-line fix in SDL_JoystickClose?
2016-12-09 01:29:52 -08:00
Sam Lantinga
a525017139 Protect the game controller API the same way the joystick API is protected from multi-threaded access 2016-12-08 10:13:45 -08:00
Sam Lantinga
1b08f0c179 Added the guide button for the NVIDIA Shield Controller 2016-12-07 11:41:20 -08:00
Sam Lantinga
91491824ae Removed unneeded warning when running from Visual Studio 2016-12-07 11:02:02 -08:00
Sam Lantinga
acabb5d5fd Added support for XBox One controllers on Mac OS X, using the driver at: https://github.com/360Controller/360Controller/releases 2016-12-06 14:22:28 -07:00
Ryan C. Gordon
c023187548 audio: Fixed compiler warnings. 2016-12-06 12:23:17 -05:00
Ryan C. Gordon
a0e003eebb Refactored the audio queueing code to a generic SDL_DataQueue interface.
This is not a public API (at the moment), but we will be needing this for
other internal things soon.
2016-12-06 02:23:54 -05:00
Ryan C. Gordon
8b960d4e0f Added SDL_VARIABLE_LENGTH_ARRAY so this #ifdef is localized to one place. 2016-12-06 02:20:58 -05:00
Sam Lantinga
264138cceb Added support for the Hori Fighting Commander 4 2016-12-03 08:39:21 -08:00
Sam Lantinga
54188c8b9e Fixed crash at startup 2016-12-03 09:59:43 -08:00
Sam Lantinga
e7efcfbaa4 Added Linux mapping for the DragonRise Inc. Generic USB Joystick 2016-12-03 00:40:13 -08:00
Sam Lantinga
16074e6749 Fixed compile warning on Visual Studio 2016-12-02 22:18:05 -08:00
Sam Lantinga
4eda58ba6a Added SDL_HINT_MOUSE_NORMAL_SPEED_SCALE and SDL_HINT_MOUSE_RELATIVE_SPEED_SCALE to scale the speed of the mouse.
This currently doesn't affect absolute motion, which would need to be implemented on each windowing system so the cursor matches the reported mouse coordinates.
2016-12-02 21:01:13 -08:00
Sam Lantinga
26f05ecb4d Fixed missing prototypes on Android, patch from Sylvain 2016-12-02 02:25:12 -08:00
Sam Lantinga
84c0780e25 Fixed bug 3305 - Fixed TextInput status when the keyboard was dismissed with the dismiss key on the iPad
Diego

I was previously unaware that rotating the device to a different orientation when the keyboard is shown causes a keyboardWillHide followed by a keyboardWillShow notification. The previous patch would then mistakenly StopTextInput when rotating. This patch fixes that by checking if the device is rotating before stopping text input.
2016-12-02 02:21:35 -08:00
Sam Lantinga
a738a6fb49 Added Linux controller mapping for the Nostromo n45 Dual Analog Gamepad 2016-12-01 07:31:08 -08:00
Sam Lantinga
1b689c335c Fixed bug 3503 - osx builds don't run on 10.6 as of rev. 10651
Ozkan Sezer

With rev. 10651, i.e. http://hg.libsdl.org/SDL/rev/747a6a795b21 ,
SDL2 - OS X builds fail to run on 10.6 (my setup: i686 / 10.6.8)
because the symbol _IOPMAssertionCreateWithDescription is missing.
The SDK listing it for 10.7+ does seem correct.  Reverting r10651
and rebuilding makes it to function again.
2016-12-01 11:52:47 -08:00
Sam Lantinga
4905cd9c09 Fixed bug 3340 - SDL_BlitScaled causes access violation in some cases.
Simon Hug

The SDL_BlitScaled function runs into an access violation for specific blit coordinates and surface sizes. The attached testcase blits a 800x600 surface to a 1280x720 surface at the coordinates -640,-345 scaled to 1280x720. The blit function that moves the data then runs over and reads after the pixel data from the src surface causing an access violation.

I can't say where exactly it goes wrong, but I think it could have something to do with the rounding in SDL_UpperBlitScaled. final_src.y is 288 and final_src.h is 313. Together that's 601, which I believe is one too much, but I just don't know the code enough to make sure that's the problem.

Sylvain

I think this patch fix the issue, but maybe it's worth re-writing "SDL_UpperBlitScaled" using SDL_FRect.
2016-11-30 22:06:05 -08:00
Sam Lantinga
cb8748b719 Fixed the controller mappings for the OUYA controller 2016-11-30 12:58:03 -08:00
Sam Lantinga
5fcf2577fb Added PS4 controller entries for the new Sony HID driver
https://git.kernel.org/cgit/linux/kernel/git/jikos/hid.git/log/?h=for-4.10/sony
2016-11-30 12:34:50 -08:00
Sam Lantinga
663afa911f Added support for the DS4 USB Wireless Adaptor 2016-11-30 12:25:19 -08:00
Philipp Wiesemann
a7655d77d1 Fixed warning about storing an unused value.
Found by buildbot.
2016-11-30 23:31:23 +01:00
Sam Lantinga
d834c08ac7 Add the controller mappings to the linked list in order 2016-11-29 22:02:37 -08:00
Sam Lantinga
dd5d85a4e7 Added an API to iterate over game controller mappings 2016-11-29 06:36:57 -08:00
Sam Lantinga
1e8f074c43 Avoid conflicts with multiple versions of udev by first trying the library that is linked with the executable, if any, and then picking the one that is in the build environment.
This fixes joystick detection for applications using the Steam Linux Runtime
2016-11-29 05:34:20 -08:00
Sam Lantinga
5220759f03 Made it safe to update joysticks from multiple threads, fixes crash in Steam 2016-11-29 05:04:42 -08:00
Sam Lantinga
7f764bd8d3 once more - iterating on this is annoying 2016-11-26 10:26:36 -08:00
Sam Lantinga
51ccc9ed8c if the tap is explicitly disabled by code or by another program, let it remain disabled! this is different than the automatic "event tap was too slow therefore we stopped processing it" timeout which we want to re-enable after. 2016-11-26 10:26:32 -08:00
Sam Lantinga
25f54f0f4f tap should default to disabled, not enabled 2016-11-26 10:26:26 -08:00
Sam Lantinga
354a8f276e SDL for Mac - only enable global event tap when actually necessary (app has focus and has requested relative mouse mode or has asked for a mouse grab). in other situations the event tap impacts system performance and battery life with no benefit. 2016-11-26 10:26:22 -08:00
Ryan C. Gordon
d1c35febce macOS: removed deprecated UpdateSystemActivity() call.
The non-deprecated approach (IOPMAssertion) already exists in SDL, and is
available in Mac OS X 10.6 and later (although it was incorrectly listed as
10.7 and later in SDL). Since SDL now requires 10.6 or later, this is no
longer conditionally used.
2016-11-25 00:13:13 -05:00
Ryan C. Gordon
fb5fd67ccb Fixed all known static analysis bugs, with checker-279 on macOS. 2016-11-24 21:41:09 -05:00
Sam Lantinga
2f6ba615ee Guess the USB VID/PID of XInput devices 2016-11-24 12:24:22 -08:00
Sam Lantinga
e9983c7b0f We are comparing 16-bit values 2016-11-24 11:53:23 -08:00
Ryan C. Gordon
e93e91f0b5 Pacify some GCC strict-aliasing compiler warnings. 2016-11-23 21:52:48 -05:00
Sam Lantinga
5232b8e952 Fixed XBox One S controller mapping for firmware revision 3.1.1221.0, including back and guide buttons 2016-11-23 06:54:19 -08:00
Ryan C. Gordon
232ae68864 Still more compiler warning fixes for various platforms. 2016-11-23 17:20:28 -05:00
Ryan C. Gordon
40c2a6fb55 Fixed more compiler warnings. 2016-11-23 11:49:26 -05:00
Ryan C. Gordon
52827361ae directsound: fixed compiler warnings. 2016-11-23 10:51:44 -05:00
Sam Lantinga
aa03b9d7af The XBox One S controller sends keys outside the standard joystick button range 2016-11-22 22:14:28 -08:00
Sam Lantinga
6558ecdbf6 Added mapping for XBox One S controller firmware version 3.1.1221.0 2016-11-22 04:42:07 -08:00
Ryan C. Gordon
a949882a98 cpuinfo: fix SDL_HasNEON() on older iOS devices, fixed C++ comment. 2016-11-21 20:35:59 -05:00
Sam Lantinga
3615633571 Renaming of guard header names to quiet -Wreserved-id-macro
Patch contributed by Sylvain
2016-11-20 21:34:54 -08:00
Sam Lantinga
abe9271065 Fixed warning building under mingw, patch contributed by Sylvain 2016-11-20 21:29:27 -08:00
Sam Lantinga
eaca3958ad Fixed bug 3494 - SDL_test_fuzzer.c fails compile since r10604
Ozkan Sezer

As of hg rev. 10604 (http://hg.libsdl.org/SDL/rev/4fe01fd25855),
SDL_test_fuzzer.c fails to build again
2016-11-20 21:24:09 -08:00
Sam Lantinga
4a089ca1c8 Fixed bug 3486 - Can't get HINSTANCE of my window
realitix

SDL2 allows to create widow and to get information through SDL_SysWMinfo.
But it misses something, with Vulkan, you need the HWND and HINSTANCE of the window for Win32 system.
Sadly, SDL2 provides only HWND but not HINSTANCE.

In some context, it can be difficult to get the HINSTANCE, indeed, I'm using pySDL2 (Python) and I can only access properties that SDL2 gives me.
I have to use a dirty trick like that to get the HINSTANCE:  (https://raw.githubusercontent.com/bglgwyng/pyVulkan/master/examples/win32misc.py)
2016-11-20 21:18:55 -08:00
Philipp Wiesemann
eb9cc03068 Fixed two memory leaks if added game controller mapping has lower priority.
Found by buildbot.
2016-11-19 23:27:37 +01:00
Philipp Wiesemann
a49ac09c02 Windows: Fixed crash if using current SDL_GetWindowWMInfo() from older programs. 2016-11-18 00:06:09 +01:00
Philipp Wiesemann
d05a39d0a6 Wayland: Fixed file descriptor leaks if device was not initialized. 2016-11-18 00:05:54 +01:00
Philipp Wiesemann
c345126266 Emscripten: Fixed handling of deactivated mouse events.
SDL_GetEventState() was called with a button state instead of an event type.
2016-11-18 00:05:28 +01:00
Ryan C. Gordon
32cb34945e cpuinfo: patched to compile for getauxval() path. 2016-11-17 17:03:43 -05:00
Ryan C. Gordon
0b33a1188b cpuinfo: more patching for Android. Legacy platform targets are a pain. 2016-11-17 16:10:32 -05:00
Ryan C. Gordon
a298e56349 cpuinfo: Patched to compile on Android, Linux. 2016-11-17 16:04:00 -05:00
Ryan C. Gordon
e8f4b7c4f5 cpuinfo: patched to compile.
Nothing quite like experimentation via Buildbot!  :/
2016-11-17 16:01:59 -05:00
Ryan C. Gordon
74eb78dcbf cpuinfo: more work on SDL_HasNEON(). 2016-11-17 15:57:58 -05:00
Ryan C. Gordon
db97c3d3e8 cpuinfo: silence compiler warnings on non-Intel CPU architectures. 2016-11-17 01:41:56 -05:00
Ryan C. Gordon
66a36d5660 cpuinfo: disable NEON detection on Android for now.
Will fix this properly soon.
2016-11-17 01:34:18 -05:00
Ryan C. Gordon
5c6b2ebf2d cpuinfo: more robust ARM preprocessor checks. 2016-11-17 01:26:56 -05:00
Ryan C. Gordon
35430a73f2 cpuinfo: first attempt at SDL_HasNEON() implementation. 2016-11-17 01:15:16 -05:00
Ryan C. Gordon
7592b40b39 cpuinfo: Removed code duplication, cached CPUID details. 2016-11-16 22:49:04 -05:00
Philipp Wiesemann
6fe15d6347 Wayland: Fixed memory leak if output retrieval failed.
Found by Cppcheck.
2016-11-16 22:09:40 +01:00
Philipp Wiesemann
97aa577589 Fixed empty parameter list in signatures of internal functions. 2016-11-16 22:08:51 +01:00
Sam Lantinga
818d1d3e80 Fixed bug 1646 - Warnings from clang with -Weverything 2016-11-15 01:30:08 -08:00
Sam Lantinga
0d24495b15 Removed unused constants
Except for SDL_bmp.c where they are historically interesting and I've left them in.
2016-11-15 01:24:58 -08:00
Thomas Perl
acce865911 [qtwayland] Set orientation and window flags via SDL hints 2016-11-13 10:39:04 +01:00
Sam Lantinga
009a3f5aa6 Fixed bug 3490 - Build failure with --enable-video-directfb
felix

Building SDL 2.0.5, or even the Mercurial snapshot (r10608) with GCC 6.2.1 and --enable-video-directfb generates a number of compiler diagnostics and fails.
2016-11-15 01:14:30 -08:00
Sam Lantinga
ab8bd3d96b Fixed bug 3359 - Software renderer does incorrect blending with SDL_RenderCopyEx
Simon Hug

The software renderer produces incorrect results when blending textures at an angle with certain blend modes. It seems that there were some edge cases that weren't considered when the SW_RenderCopyEx function was last changed. Or another bug possibly covered up the problem. (More on that in another bug report.)

Most of the issues come from the fact that the rotating function sets a black colorkey. This is problematic because black is most likely appearing in the surface and the final blit will ignore these pixels. Unless a colorkey is already set (the software renderer currently never sets one), it's very hard to find a free color. Of course it could scan over the whole image until one is found, but that seems inefficient.

The following blend modes have issues when drawn at an angle.

NONE: The black pixels get ignored, making them essentially transparent. This breaks the 'dstRGBA = srcRGBA' definition of the NONE blend mode.

MOD: Again, the black pixels get ignored. This also breaks the 'dstRGB = dstRGB * srcRGB' definition of the MOD blend mode, where black pixels would make the destination black as well. A white colorkey will work though, with some preparations.

BLEND: There are some issues when blending a texture with a translucent RGBA target texture. I - uh - forgot what the problem here exactly is.

This patch fixes the issues mentioned above. It mainly changes the code so it tries to do things without the colorkey and removes the automatic format conversion part from the SDLgfx_rotateSurface function. Getting the format right is something the caller has to do now and the required code has been added to the SW_RenderCopyEx function.

There's a small change to the SW_CreateTexture function. RLE encoding a surface with an alpha mask can be a lossy process. Depending on how the user uses the RGBA channels, this may be undesired. The change that surfaces with an alpha mask don't get encoded makes the software renderer consistent with the other renderers.

The SW_RenderCopyEx function now does these steps: Lock the source surface if necessary. Create a clone of the source by using the pixel buffer directly. Check the format and set a flag if a conversion is necessary. Check if scaling or cropping is necessary and set the flag for that as well. Check if color and alpha modulation has to be done before the rotate. Check if the source is an opaque surface. If not, it creates a mask surface that is necessary for the NONE blend mode. If any of the flags were set, a new surface is created and the source will be converted, scaled, cropped, and modulated. The rest of the function stays somewhat the same. The mask also needs to be rotated of course and then there is the NONE blend mode...

It's surprisingly hard to get the pixel from a rotated surface to the destination buffer without affecting the pixel outside the rotated area. I found a way to do this with three blits which is pretty hard on the performance. Perhaps someone has an idea how to do this faster?

As mentioned above, the SDLgfx_rotateSurface now only takes 8-bit paletted or 32-bit with alpha mask surfaces. It additionally sets the new surfaces up for the MOD blend mode.

I shortly tested the 8-bit path of SDLgfx_rotateSurface and it seemed to work so far. This path is not used by the software renderer anyway.
2016-11-15 01:12:27 -08:00
Sam Lantinga
c1e292fcf8 Fixed build error with missing function prototype in the SDL_test_harness.h header 2016-11-13 23:09:42 -08:00
Sam Lantinga
c2837ef634 Fixed unresolved symbol on Visual Studio 2016-11-13 23:04:47 -08:00
Sam Lantinga
57d01d7d67 Patch from Sylvain to fix clang warnings 2016-11-13 22:57:41 -08:00
Sam Lantinga
c13a077d15 Fixed bug 3488 - Random crashes (because Memory overlap in audio converters detected by Valgrind)
Vitaly Novichkov

Okay, when I researched code and algorithm, I tried to replace condition "while(dst >= target)" with "while(dst > target)" and crashes are gone.
Seems on some moments it tries to write into the place before memory block begin, therefore phantom crashes appearing after some moments.
2016-11-13 00:09:02 -08:00
Sam Lantinga
37696150e2 Fixed build on various platforms 2016-11-11 13:47:40 -08:00
Sam Lantinga
77000ff8cb Fixed bug 1822 - Inconsistent renderer behaviour on rotation
Sylvain 2016-11-07 08:49:34 UTC

when rotated +90 or -90, some transparent lines appears, though there is no Alpha or ColorKey.

if you set a dummy colorkey, it will remove the line ...
if you set a some alpha mod, the +90/-90 get transparent but not the 0/180  ...
2016-11-11 13:38:39 -08:00
Sam Lantinga
23c01c1890 Fixed bug 3079 - Allow non destructive SDL_GameControllerAddMappingsFromFile
x414e54

It is a bit of a pain to update the library or rely on whatever version the user has on their computer for default mappings.

So providing an easily updatable text file via SDL_GameControllerAddMappingsFromFile is still currently the most viable way. However using this replaces all mappings provided by the SDL_HINT_GAMECONTROLLERCONFIG environment variable which may have come from the user's custom Steam mapping.

There should be an easy way for games to supply extra game controller mappings to fill in the differences between SDL versions without it clobbering the SDL_HINT_GAMECONTROLLERCONFIG environment variable.

Internally the mappings could use a priority system and if the priority is lower then it will not overwrite the mappings.

For now it just assumes SDL_HINT_GAMECONTROLLERCONFIG is the highest priority, the default hardcoded are the lowest and anything set via the API is medium.
2016-11-11 13:29:23 -08:00
Sam Lantinga
74e1dd4c6f Define _GNU_SOURCE when building SDL 2016-11-11 13:14:00 -08:00
Sam Lantinga
302a6e62aa Fixed bug 3484 - DSP driver does not detect /dev/dsp0
Tobias Kortkamp

using SDL 2.0.5 (and a repository checkout) on FreeBSD 11.0 I get this output
from testaudioinfo with SDL_AUDIODRIVER=dsp:

INFO: Found 8 output devices:
INFO:   0: /dev/dsp
INFO:   1: /dev/dsp1
INFO:   2: /dev/dsp2
INFO:   3: /dev/dsp3
INFO:   4: /dev/dsp4
INFO:   5: /dev/dsp5
INFO:   6: /dev/dsp6
INFO:   7: /dev/dsp7
INFO:
INFO: Found 3 capture devices:
INFO:   0: /dev/dsp
INFO:   1: /dev/dsp4
INFO:   2: /dev/dsp5
INFO:

This is /dev/sndstat:

Installed devices:
pcm0: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm3: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm4: <Realtek ALC887 (Rear Analog 7.1/2.0)> (play/rec)
pcm5: <Realtek ALC887 (Front Analog)> (play/rec) default
pcm6: <Realtek ALC887 (Rear Digital)> (play)
pcm7: <Realtek ALC887 (Onboard Digital)> (play)
No devices installed from userspace.

I'd expect to find /dev/dsp0 in the output device list.  It's not detected
because of a a small logic error in SDL_audiodev.c (see attached patch).

With the patch applied I get this which is what I'd expect:

INFO: Found 9 output devices:
INFO:   0: /dev/dsp
INFO:   1: /dev/dsp0
INFO:   2: /dev/dsp1
INFO:   3: /dev/dsp2
INFO:   4: /dev/dsp3
INFO:   5: /dev/dsp4
INFO:   6: /dev/dsp5
INFO:   7: /dev/dsp6
INFO:   8: /dev/dsp7
2016-11-11 12:41:06 -08:00
Sam Lantinga
160e719449 Fixed whitespace and added code to support older game controller GUIDs 2016-11-11 04:35:06 -08:00
Sam Lantinga
b6542ab237 Fixed whitespace 2016-11-11 04:30:09 -08:00
Sam Lantinga
47418f2d5a Updated Windows game controller support 2016-11-11 03:35:37 -08:00
Sam Lantinga
79f6ba5a84 Fixed signed/unsigned comparison warnings in Visual Studio 2016-11-11 03:18:16 -08:00
Sam Lantinga
801a9eaf64 Updated Mac OS X game controller support 2016-11-11 04:06:00 -07:00
Sam Lantinga
0cc6207c68 Added Linux entries for the Logitech Dual Action game controller 2016-11-10 18:53:29 -08:00
Sam Lantinga
ac74e16cde Standardized the format of the SDL joystick GUID and added functions to retrieve the USB VID/PID from a joystick and game controller. 2016-11-10 17:19:34 -08:00
Ryan C. Gordon
2898ada338 wayland: fixed compiler warning about pipe2(). 2016-11-10 12:07:34 -05:00
Philipp Wiesemann
6380d5c24e Fixed audio conversion for unsigned 16 bit data. 2016-11-07 21:10:01 +01:00
Sam Lantinga
057bca8a68 Better fix for last point in D3D11 renderer, thanks to Nader Golbaz 2016-11-06 15:15:32 -08:00
Sam Lantinga
40b571c91e Fixed bug 3468 - _allshr in SDL_stdlib.c is not working properly
Mark Pizzolato

On Windows with Visual Studio, when building SDL as a static library using the x86 (32bit) mode, several intrinsic operations are implemented in code in SDL_stdlib.c.

One of these, _allshr() is not properly implemented and fails for some input.  As a result, some operations on 64bit data elements (long long) don't always work.

I classified this bug as a blocker since things absolutely don't work when the affected code is invoked.  The affected code is only invoked when SDL is compiled in x86 mode on Visual Studio when building a SDL as a static library.  This build environment isn't common, and hence the bug hasn't been noticed previously.

I reopened #2537 and mentioned this problem and provided a fix.  That fix is provided again here along with test code which could be added to some of the SDL test code.  This test code verifies that the x86 intrinsic routines produce the same results as the native x64 instructions which these routines emulate under the Microsoft compiler.  The point of the tests is to make sure that Visual Studio x86 code produces the same results as Visual Studio x64 code.  Some of the arguments (or boundary conditions) may produce different results on other compiler environments, so the tests really shouldn't be run on all compilers.  The test driver only actually exercised code when the compiler defines _MSC_VER, so the driver can generically be invoked without issue.
2016-11-06 10:01:08 -08:00
Sam Lantinga
d780031277 Fixed bug 3476 - round() needs _GNU_SOURCE on some old systems
Ozkan Sezer

On systems with old glibc, such mine with glibc-2.8, the following warning
is issued and is fixed easily by defining _GNU_SOURCE:

/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c: In function 'CalculateXRandRRefreshRate':
/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c:263: warning: implicit declaration of function 'round'
/home/me/SDL2-2.0.5/src/video/x11/SDL_x11modes.c:263: warning: incompatible implicit declaration of built-in function 'round'
2016-11-06 09:30:06 -08:00
Sam Lantinga
330e2952d8 Fixed bug 2421 for D3D11 - SDL_RenderCopyEx off by one when rotating by 90 and -90.
Nader Golbaz

Updated patch for direct3d renderers
2016-11-06 08:47:40 -08:00
Sam Lantinga
4ed4997cc4 Fixed bug 2421 for D3D9 - SDL_RenderCopyEx off by one when rotating by 90 and -90
Nader Golbaz

Updated patch for direct3d renderers
2016-11-06 08:42:46 -08:00
Sam Lantinga
d767a450dc Fixed 2942 - Wayland: Drag and Drop / Clipboard
x414e54

I have implemented Drag and Drop and Clipboard support for Wayland.

Drag and dropping files from nautilus to the testdropfile application seems to work and also copy and paste.
2016-11-06 08:34:27 -08:00
Philipp Wiesemann
7ad3a46d76 ALSA: Fixed compile warning about unused function.
Found by buildbot.
2016-11-05 21:23:17 +01:00
Philipp Wiesemann
5819923212 WinRT: Corrected header file guard comment. 2016-11-05 21:22:58 +01:00
Philipp Wiesemann
062ca2b261 Removed empty statement. 2016-11-05 21:22:39 +01:00
Sam Lantinga
6ed8213049 Fixed Windows build 2016-11-05 01:52:28 -07:00
Ryan C. Gordon
a17abf10b7 Also patched to compile on C89 compilers. 2016-11-05 03:56:55 -04:00
Ryan C. Gordon
067f0c8482 Patched to compile on C89 compilers. 2016-11-05 03:53:59 -04:00