Commit Graph

873 Commits (d1c35febce490c4784b50356f1b394e8ac389607)

Author SHA1 Message Date
Philipp Wiesemann f662f68066 iOS: Updated demo README. 2016-10-09 20:30:49 +02:00
Sam Lantinga 42f85aa29e Fixed building and using fcitx IME support on Linux 2016-10-08 11:30:07 -07:00
Sam Lantinga 27d4f09929 Implemented SDL_GetHintBoolean() to make it easier to check boolean hints 2016-10-07 23:40:44 -07:00
Ethan Lee 92d700f199 SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING 2016-09-30 09:26:57 -04:00
Sam Lantinga 52ae92eaf7 ALSA_snd_pcm_drop() can hang on some systems (Steam Link) so don't use that when shutting down the ALSA audio driver. 2016-10-07 19:08:22 -07:00
Sam Lantinga 808c75d1cf Fixed bug 2824 - Add Fcitx Input Method Support
Weitian Leung

Just moved ibus direct call to SDL_IME_* related functions, and adds fcitx IME support (uses DBus, too),
enable with env: SDL_IM_MODULE=fcitx (ibus still the default one)
2016-10-07 18:57:40 -07:00
Sam Lantinga 89abbbfe9e Fixed bug 3438 - SDL_GameControllerEventWatcher: Log on event with value >= k_nMaxReverseEntries 2016-10-07 18:24:34 -07:00
Alex Baines 752931d85e Improve X11 key handling when XKB isn't available + add xvnc scancodes.
Based on a patch by Bill Lash (see bug 3094).
2016-10-03 11:35:34 +01:00
Bill Lash cceca2ac99 Additional patch to correct the number key assignments, and add assignments for keys that were missed 2015-08-15 00:25:52 -05:00
Sam Lantinga eea76fc199 Fixed bug 3063 - Wayland: SDL resizes EGL surface to 0x0.
x414e54

Wayland will sometimes send empty resize events (0 width and 0 height) to the client. I have not worked out the exact conditions a client would receive these but I can assume it might be if the window is offscreen or not mapped yet.

This causes issues with some SDL clients as they receive the 0x0 event and unexpected resize event or might not request to resize back to the correct size.

As per the wl_shell Wayland spec configure events are only a suggestion and the client is free to ignore or pick a different size (this is how min/max and fixed aspect ratio is supped to be implemented).

A patch is attached but is just the first iteration and I will fix any issues such as checking for FULLSCREEN/MAXIMIZED or RESIZABLE flags unless someone else fixes this first.

I have update to take into account non resizable and fullscreen windows. Also adding in maximize/restore and title functions for Wayland.
2016-10-07 18:11:03 -07:00
Sam Lantinga 62b9e1c797 Fixed bug 3061 - Selecting the dummy video driver on Mac OS X results in an error
Darren Kulp

The dummy video driver is not available on Mac OS X if SDL_VIDEO_OPENGL is set at library compilation time.

In src/video/SDL_video.c, there is a compile-time check in SDL_CreateWindow() for (SDL_VIDEO_OPENGL && __MACOSX__). When it succeeds, SDL_WINDOW_OPENGL is always requested. Since the dummy video driver does not supply an OpenGL implementation, the error "No OpenGL support in video driver" is supplied to the user, and SDL_CreateWindow() is exited early.
2016-10-07 18:09:09 -07:00
Sam Lantinga abefe78507 Fixed bug 3043 - fix alsa configury and cmake checks
Ozkan Sezer

SDL's alsa uses snd_pcm_recover() which has been available only since alsa-lib-1.0.11.
2016-10-07 18:03:08 -07:00
Sam Lantinga 9c48365524 Fixed bug 3029 - software renderer cuts off edges when rotate-blitting with a multiple of 90 degrees
Adam M.

When doing a rotated texture copy with the software renderer, where the angle is a multiple of 90 degrees, one or two edges of the image get cut off. This is because of the following line in sw_rotate.c:
    if ((unsigned)dx < (unsigned)sw && (unsigned)dy < (unsigned)sh) {
which is effectively saying:
    if (dx >= 0 && dx < src->w-1 && dy >= 0 && dy < src->h-1) {

As a result, it doesn't process pixels in the right column or bottom row of the source image (except when they're accessed as part of the bilinear filtering for nearby pixels). This causes it to look like the edges are cut off, and it's especially obvious with an exact multiple of 90 degrees.
2016-10-07 18:00:30 -07:00
Sam Lantinga 5c2320f113 Fixed bug 3022 - SDL_UnlockMutex(SDL_EventQ.lock) in SDL_PeepEvents can cause error when lock is null 2016-10-07 17:58:02 -07:00
Sam Lantinga d3cbc664d5 Fixed bug 2983 - Update Android.readme to include Tegra Graphics Debugger compatibility tip
Michael Labb?

NVidia has released some pretty nice Tegra profiling tools for their Android devices. The NVidia Tegra Graphics Debugger works by providing an interposer library that intercepts ES2 and EGL calls.  You must link against these libraries.

Unfortunately, this quietly fails with SDL2 because libEGL and libGLES2 are dynamically loaded with dlopen().

NVidia offers a secondary approach to using the Tegra Graphics Debugger: root your device and install a global interposer library.  Almost no devs will try this first if they don?t have a rooted device.

I propose an update to the Android readme that explains why the static linking approach recommended by NVidia doesn?t work.
2016-10-07 17:49:33 -07:00
Sam Lantinga 104c9541d9 Converted README documentation to DOS text format 2016-10-07 17:46:58 -07:00
Sam Lantinga bf076c22ad Fixed bug 2957 - De-reference rz_src without NULL check in SDLgfx_rotateSurface function
Nitz

In function SDLgfx_rotateSurface:

rz_dst =
            SDL_CreateRGBSurface(SDL_SWSURFACE, dstwidth, dstheight + GUARD_ROWS,
            rz_src->format->Rmask, rz_src->format->Gmask,
            rz_src->format->Bmask, rz_src->format->Amask);

Here rz_src get De-referenced without NULL check, which is risky.
2016-10-07 17:30:21 -07:00
Sam Lantinga 8b64a78da9 Fixed bug 2956 - De-reference videodata without NULL check in X11_DispatchEvent(_THIS) function 2016-10-07 17:26:25 -07:00
Sam Lantinga 93ff12ce83 Fixed bug 2952 - SDL_MixAudioFormat does not support audio format AUDIO_U16LSB/AUDIO_U16MSB
Simon Sandstr?m

As stated in Summary. The switch statement will execute the default case and set a SDL error message: "SDL_MixAudio(): unknown audio format".

There are atleast two more problems here:

1. SDL_MixAudioFormat does not notify the user that an error has occured and that a SDL error message was set. It took me awhile to understand why I couldn't mix down the volume on my AUDIO_U16LSB formatted audio stream.. until I started digging in the SDL source code.

2. The error message is incorrect, it should read: "SDL_MixAudioFormat(): unknown audio format".
2016-10-07 17:23:20 -07:00
Sam Lantinga d2676c2985 Fixed bug 2924 - SDL_CreateRGBSurface[From] versions that take SDL_PIXELFORMAT enum
Daniel Gibson

Currently, SDL_CreateRGBSurface() and SDL_CreateRGBSurfaceFrom() take Uint32 masks for RGBA to "describe" the Pixelformat of the surface.
Internally those value are only used to map to one of the SDL_PIXELFORMAT_* enum values that are used for further processing.

I think it would be both handy and more efficient to be able to specify SDL_PIXELFORMAT_* yourself without using SDL_PixelFormatEnumToMasks() to create masks first, so I implemented functions that do that:
SDL_CreateRGBSurfaceWithFormat() and SDL_CreateRGBSurfaceWithFormatFrom() which are like the versions without "WithFormat" but instead of taking 4 Uint32s for R/G/B/A masks, they take one for a SDL_PIXELFORMAT_* enum value.

Together with https://bugzilla.libsdl.org/show_bug.cgi?id=2923 creating a SDL_Surface* from RGBA data (e.g. from stb_image)  is as easy as
  surf = SDL_SDL_CreateRGBSurfaceWithFormat(0, w, h, bppToUse*8, SDL_PIXELFORMAT_RGBA32);
2016-10-07 17:04:58 -07:00
Sam Lantinga 73f2c5413d Fixed bug 2885 - SDL_stdinc.h doesn't need to include iconv.h
Ryan C. Gordon

We still include iconv.h in SDL_stdinc.h, probably because this header might have referenced the native iconv functions and types directly. Since these are hidden behind a stable ABI now and never just a #define for the system iconv, we shouldn't need this header included from a public SDL header anymore, slowing down external apps compiles and pulling tons of stuff into the namespace.
2016-10-07 16:44:42 -07:00
Ryan C. Gordon 7d2108ce81 audio: Backed out the audio-thread detaching changes.
It added a ton of complexity. A simpler solution might arise at some
point though.
2016-10-07 19:39:43 -04:00
Sam Lantinga 24df68ea33 Fixed bug 2833 - Access Violation on SDL_PollEvent after init, delay and quit of joystick subsystem
Jan Klass

Not sure if this is limited to the joystick subsystem,
but I created a minimal program for reproducibility,
which is attached.

The issue occurs with my gamepad Razer Onza (an xbox-style gamepad) plugged in.
On initialization, the gamepad is being recognized.
After quitting the subsystem, the poll will receive the joystick added event,
which it instantly handles itself, calling SDL_SYS_JoystickDetect again,
which this time calls IDirectInput8_EnumDevices with dinput = NULL (after it was released on quit).
This seems to lead to an access violation within said function, which I have no source for.
2016-10-07 16:32:58 -07:00
Sam Lantinga dac3892816 Fixed bug 2832 - Inverted arrow-key navigation in MessageBox
Jan Hellwig

On Windows, you are able to navigate between the buttons on a MessageBox that was created using SDL_ShowMessageBox using the arrow keys. However, if you press the left arrow key, the selection jumps to the button on the right of the currently selected one (and vice versa).

This can be fixed by reversing the order in which the buttons are added to the dialog.

The attached patch files fixes this problem. However the first press of an arrow key leads to the selection of the leftmost or rightmost button on the MessageBox, not to the selection of the button left/right of the one that is selected by default.
2016-10-07 16:19:50 -07:00
Sam Lantinga 8bc5c57d2e Fixed recentering triggers when the application doesn't have focus 2016-10-07 16:13:37 -07:00
Sam Lantinga 72164985b0 Fixed bug 2823 - Release events for triggers receive wrong centered value
Ryochan7

I have been using SDL 2 for a little project that I have been developing for a while. My project is called antimicro and it takes gamepad input and then translates gamepad events into keyboard and mouse events. SDL is used to read the input from an XInput gamepad and it works great for the most part. However, there is one glaring problem that I have encountered.

When a device is unplugged and SDL sends the centered value release events for all axes, buttons, and hats, SDL does not use the proper centered value for the triggers. It pushes an SDL_JOYAXISMOTION event onto the queue with a value of 0 for all axes. That value is converted to around 16,000 for a Game Controller. That value is incorrect for triggers and, in my program, that causes any bindings that are assigned to the triggers to get activated. With most profiles, that will typically mean that a mouse right click and left click will be activated before the device is finally seen as removed and then those bindings are released by antimicro.
2016-10-07 16:04:15 -07:00
Sam Lantinga f674f2311a Fixed bug 2808 - Fix SDL reporting wrong window size on resume
Jonas Kulla

At startup time, the single android window is assigned a "windowed" (window->windowed.{w,h}) size based on the current orientation of the mobile device; this size is never updated throughout the lifetime of the app.

This becomes problematic when the app is paused and then resumed in an orientation that it did not start up in. Eventually, 'SDL_OnWindowRestored()' is called, which calls 'SDL_UpdateFullscreenMode()'. This function is very problematic because it is written with a desktop monitor in mind: it tries to find a matching display mode for the windowed size, doesn't find any, and finally applies the windowed size as the fullscreen one. In the end, the windowed size is reported in a RESIZED event, which doesn't correspond to the actual surface size.

To see this in action: Start an orientation aware SDL app in eg. portrait mode, suspend the app, put the device into landscape orientation and resume the app. It will erroneously render in portrait mode (until the device is rotated again).
2016-10-07 15:21:19 -07:00
Sam Lantinga 5c1ab40302 Applied Ubuntu patch bug_822210_fix_sdl2-config.cmake_whitespace.patch 2016-10-07 15:08:37 -07:00
Ryan C. Gordon f6a280ab7f audio: Don't trust audio drivers to drain pending audio.
This tends to be a frequent spot where drivers hang, and the waits were
often unreliable in any case.

Instead, our audio thread now alerts the driver that we're done streaming audio
(which currently XAudio2 uses to alert the system not to warn about the
impending underflow) and then SDL_Delay()'s for a duration that's reasonable
to drain the DMA buffers before closing the device.
2016-10-07 15:13:46 -04:00
Ryan C. Gordon 551cdc8dec audio: better way to calculate buffer drain wait times. 2016-10-07 14:42:24 -04:00
Ryan C. Gordon 76f48acf63 audio: threading and device hang improvements.
This tries to make SDL robust against device drivers that have hung up,
apps don't freeze in catastrophic (but not necessarily uncommon) conditions.

Now we detach the audio thread and let it clean up and don't care if it
never actually runs to completion.
2016-10-07 14:35:25 -04:00
Sam Lantinga 3b0c79363d Some systems include both "default:" and "hw:" for the same usb device 2016-10-07 11:18:55 -07:00
Sam Lantinga 8e1994614c fix for finding ALSA hotplug devices on Steam Link
James Zipperer

The device names show up as "default:", not "hw:"
2016-10-06 06:08:16 -07:00
Sam Lantinga 9257b72d53 Backed out a very unsafe change that was trying to prevent audio hang at quit.
Ryan and I have ideas on a better way to handle this.
2016-10-05 00:12:16 -07:00
Sam Lantinga bac61096d8 ensure SDL_AUDIODEVICEREMOVED gets sent when hotplug removes a device
James Zipperer

The problem I was seeing was that the the ALSA hotplug thread would call SDL_RemoveAudioDevice, but my application code was not seeing an SDL_AUDIODEVICEREMOVED event to go along with it.   To fix it, I added some code into SDL_RemoveAudioDevice to call SDL_OpenedAudioDeviceDisconnected on the corresponding open audio device.  There didn't appear to be a way to cross reference the handle that SDL_RemoveAudioDevice gets and the SDL_AudioDevice pointer that SDL_OpenedAudioDeviceDisconnected needs, so I ended up adding a void *handle field to struct SDL_AudioDevice so that I could do the cross reference.

Is there some other way beside adding a void *handle field to the struct to get the proper information for SDL_OpenedAudioDeviceDisconnected?
2016-10-04 06:48:07 -07:00
Sam Lantinga 69cf170356 fix deadlock on close device
James Zipperer

snd_pcm_drain doesn't always drain when you unplug a usb device.  Use snd_pcm_drop instead
2016-10-04 06:46:46 -07:00
Sam Lantinga 2558c9c836 fix audio deadlock
James Zipperer

Close the audio device before waiting for the audio thread to complete, which fixes a situation where the audio thread never completes

Add an additional check in the audio thread to see if the device is enabled and bail out if the device is no longer enabled
2016-10-04 06:45:28 -07:00
Sam Lantinga 56c88c4531 Modified the custom cursor test to be able to load BMP files as cursors 2016-10-04 04:08:02 -07:00
Sam Lantinga a21a227a87 Fixed bug 3021 - HapticOpenFromJoystick() problems
Joe Thompson

With Direct Input device (MOMO Steering Wheel w/FF)
with SDL 2.0.3,
SDL_HapticOpenFromJoystick() would fail. (Can't set exclusive mode)
Now with 2.0.4 rc1,
SDL_HapticOpenFromJoystick() succeeds but the the returned SDL_Haptic* cannot be used. Calls to SDL_HapticNewEffect() fail with "Haptic error Unable to create effect"

If SDL_HapticOpen() is used instead of HapticOpenFromJoystick(), the device is usable. Calls to HapticNewEffect() succeed with the exact same parameters as the previous failing call.

I have attached a proposed patch for this issue.

When using SDL_HapticOpenFromJoystick(), the original code did not (re)enumerate the axes. This returned a new haptic device with 0 axes. Later, when a new effect is created, SDL_SYS_SetDirection() would set the flags to include DIEFF_SPHERICAL, regardless of what the caller actually set. (see Line 566 in SDL_dinputhaptic.c). This would cause the SDL_HapticNewEffect() to fail (or interpret the coordinates incorreclty.)

The patch moves the call to IDirectInputDevice8_EnumObjects() outside of the if() block so that the axes are (re)enumerated for the new haptic device.

Note: For steering wheels it is common for the joystick to have multiple axes (ie steering, throttle, brake), but the haptic portion of the joystick usually only applies to steering.
2016-10-04 03:50:28 -07:00
Sam Lantinga 1051dceb14 Fixed compiler warning about missing field initializers 2016-10-04 03:42:42 -07:00
Sam Lantinga 5d5127c4a0 Fixed compiler warning - this should have been a const char pointer 2016-10-04 03:38:39 -07:00
Ryan C. Gordon 46f44f66f8 Fixed potential buffer overflow in SDL_vsnprintf() (thanks, Taylor!).
Fixes Bugzilla #3441.

"When using internal SDL_vsnprintf(), and source string length is greater
than destination, the final NULL char will be written beyond destination size.

Primary issue that is SDL_strlcpy returns length of source string
(SDL_PrintString()), not how much is written to destination. The destination
ptr is then incremented by this length before the sanity check is done.
Destination string is properly terminated, but an extra NULL char will be
written beyond destination buffer length.

Patch used internally is attached which fixes primary issue with SDL_strlcpy()
in SDL_PrintString() and adjusts sanity checks to increment destination ptr
safely."
2016-10-04 14:25:31 -04:00
Sam Lantinga 351adf156a Fixed bug 2157 - Caps Lock key produces key down & key up events while key is still pressed.
Tim McDaniel

Using checkkeys test app:
* Press and hold Caps Lock key.
* checkkeys reports a CapsLock key pressed event and a CapsLock key released event.
* Release Caps Lock key.
* checkkeys reports no further events.

This patch fixes OSX Caps Lock up/down event detection by installing a HID callback.
2016-10-04 02:11:52 -07:00
Sam Lantinga 34eebfba9b Fixed setting the version info in the shared library when using CMake
Ray Molenkamp

When building sdl as shared lib, the version info is lacking in the final binary.

CMake gathers the right resource files into ${VERSION_SOURCES} but then doesn't do anything with them.
2016-10-03 03:42:10 -07:00
Philipp Wiesemann 05ca784e5b Android: Fixed compile error. 2016-10-02 22:32:50 +02:00
Philipp Wiesemann 67bf5cac1a Fixed wrong pixel format if reading pixels from OpenGL renderer. 2016-10-02 22:32:35 +02:00
Philipp Wiesemann f8aa4291ca Added brackets to function names in header comments so that doxygen links them. 2016-10-02 22:32:18 +02:00
David Ludwig 969c316797 Fixed MinGW-w64 build warnings in SDL_render_d3d11.c
Some of these were legitimate bugs, including:
- a malformed SDL_snprintf call
- a probably-invalid enum comparison
2016-10-01 18:49:15 -04:00
Sam Lantinga 702d9348ac Added SDL prefix to local IID constants 2016-10-01 15:23:43 -07:00
David Ludwig 3c8a26984d WinRT: build fix in joystick code 2016-10-01 18:10:50 -04:00