Commit Graph

1209 Commits

Author SHA1 Message Date
Ryan C. Gordon
878c2324b1 winmm: Let audio callback buffer size be less than 1/4 second (thanks, Jon!).
Maybe this was here for Win9x? There's no reason to insert this much latency
by default.

Fixes Bugzilla #2835.
2015-03-24 02:13:25 -04:00
Ryan C. Gordon
c76130c9cc X11: Reenabled setlocale() and fork() for message boxes.
Fixes Bugzilla #1658.
2015-03-23 19:54:33 -04:00
Ryan C. Gordon
331a434fa1 Windows: Report window HDC in SDL_SysWMinfo.
Fixes Bugzilla #2668.
2015-03-23 19:47:08 -04:00
Philipp Wiesemann
528e48b980 Android: Removed not needed include statement. 2015-03-23 20:24:04 +01:00
Ryan C. Gordon
b42c259752 Cocoa: Handle more cases of lost focus when Key window closes (thanks, Alex!).
Sort of fixes Bugzilla #1825 a little more. It's an ongoing effort.  :)
2015-03-22 01:25:12 -04:00
Ryan C. Gordon
eb49f8caa3 Patched to compile on OpenGL ES-based platforms. 2015-03-21 00:09:22 -04:00
Ryan C. Gordon
34415c4557 Windows: support for OpenGL extension WGL_ARB_context_flush_control. 2015-03-20 12:23:53 -04:00
Emmanuel Gil Peyrot
89be609adf Wayland: Properly discover displays and their modes.
Fixes Bugzilla #2913.
2015-03-18 01:14:45 +01:00
Alex Baines
a4458a7002 Fix DBus error message if IBus couldn't be initialized. 2015-03-20 19:47:03 +00:00
Ryan C. Gordon
8011557458 Refuse to make a window that's too large. Some systems (x11) freak out at this.
Fixes Bugzilla #2255.
2015-04-06 18:26:13 -04:00
Marc Di Luzio
f5d96416ad Allow setting of GL_CONTEXT_RELEASE_BEHAVIOR when creating the GL context when GLX_ARB_context_flush_control is available.
This extension allows the user to specify whether a full flush is performed when making a context not current.
The only way to set this currently is at context creation, so this patch provides that functionality.
Defualt behaviour is set at FLUSH, as per the spec.

This patch does not contain the changes to WGL, appleGL or other platforms as I do not have access to GL 4.5 hardware on those platforms.

Full details on the use of KHR_context_flush_control can be found here:
https://www.opengl.org/registry/specs/KHR/context_flush_control.txt
2015-03-06 16:03:40 +00:00
Ryan C. Gordon
182a7768e1 Audio hotplug fixes for winmm and XAudio2 backends. 2015-03-20 11:11:44 -04:00
Ryan C. Gordon
6c072917e9 Patched to compile on gcc2. 2015-03-19 23:54:35 -04:00
Ryan C. Gordon
06e85acd72 Removed unused variable. 2015-03-19 23:45:34 -04:00
Ryan C. Gordon
b24ff44692 Make static analysis happy. 2015-03-19 23:44:47 -04:00
Ryan C. Gordon
277e07e700 Fixed a compiler warning on Visual Studio. 2015-03-19 23:39:53 -04:00
Ryan C. Gordon
1877f5745b Patched to compile on Windows. 2015-03-19 23:35:43 -04:00
Ryan C. Gordon
537b68b9f0 Zero out the audio hotplug event structure, so the "padded" fields are sane.
Just in case we ever need those bits in the future.
2015-03-19 22:11:20 -04:00
Ryan C. Gordon
cafd030ba6 PulseAudio: Hotplug support! 2015-03-19 22:08:12 -04:00
Ryan C. Gordon
11cffe1dc9 SDL_RemoveAudioDevice() should specify capture vs output.
This lets us reuse values between the two categories without conflicting, etc.
2015-03-19 15:43:00 -04:00
Ryan C. Gordon
1e78ef2155 Removed the broken audio streaming code, other small cleanups. 2015-03-19 13:34:17 -04:00
Ryan C. Gordon
5cbb32ef57 Disconnected/broken/lost audio devices now continue to fire their callback.
The data produced by the callback is just thrown away and the audio thread
delays as if it's waiting for the hardware to drain.

This lets apps that rely on their audio callback firing regularly continue
to make progress to function as properly as possible in the face of disaster.
Apps that want to know that the device is really gone and deal with that
scenario can use the new hotplug functionality.
2015-03-19 13:27:10 -04:00
Ryan C. Gordon
75973f81b2 Don't assert if an audio backend reports the same device disconnected twice. 2015-03-19 13:15:28 -04:00
Ryan C. Gordon
7c4b88f2db PulseAudio: Improved multidevice support.
Added capture device enumeration, report human-readable device name, other
cleanups.
2015-03-18 10:29:04 -04:00
Ryan C. Gordon
f9cfd9fa14 Bunch of reworking to how we manage audio devices.
Device enumeration now happens at startup and then is managed exclusively
through hotplugging instead of full redetection. The device name list now has
a unique "handle" associated with each item and SDL will pass this to the
backend so they don't have to figure out how a human readable name maps to
real hardware for a second time.

Other cleanups, fixes, improvements, plus all the audio backends updated to
the new interface...largely untested at this point, though.
2015-03-18 02:01:17 -04:00
Ryan C. Gordon
0e02ce0856 Initial work on audio device hotplug support.
This fills in the core pieces and fully implements it for Mac OS X.

Most other platforms, at the moment, will report a disconnected device if
it fails to write audio, but don't notice if the system's device list changed
at all.
2015-03-16 02:11:39 -04:00
Ryan C. Gordon
338bf5d297 Changed some SDL_memset() calls to SDL_zero(). 2015-03-18 10:09:39 -04:00
Ryan C. Gordon
97ff10c63c Tweaked a couple comments, added some FIXMEs. 2015-03-18 10:09:23 -04:00
Ryan C. Gordon
43674503e1 Patched to compile on C89 compilers. 2015-03-18 10:05:36 -04:00
Ryan C. Gordon
9a83151e9c PulseAudio: Added multiple device support, other cleanups.
Thanks to Dominik Frizel for most of the effort on this!

Fixes Bugzilla #2730.
2015-03-18 09:59:22 -04:00
Ryan C. Gordon
73feb8c042 Fixed a compiler warning. 2015-03-18 00:56:33 -04:00
David Ludwig
522fd82901 WinRT: made OpenGL window-init work with latest round of ANGLE/WinRT updates
Various constants in ANGLE/WinRT, both in MSOpenTech's ms-master branch, and
in Google's branch, were changed again.  This change makes SDL/WinRT work with
them.

To note, the ms-master branch (of ANGLE) was updated via this merge:
bbd2eb0a9c (diff-d1377fbe747de154e1bfcf7221d3de67)
2015-03-17 19:45:47 -04:00
David Ludwig
b12ea75991 WinRT: another ANGLE/OpenGL-initialization, error messaging tweak 2015-03-17 10:25:21 -04:00
David Ludwig
1083ae22e6 WinRT: ANGLE/OpenGLES-initialization, error message improvements 2015-03-17 10:22:36 -04:00
Ryan C. Gordon
809b7be27f Cleaning out a silly coding style I used to use.
Changed all the "return (x);" lines to "return x;"
2015-03-13 12:20:17 -04:00
Ryan C. Gordon
3a53258814 Removed an unnecessary #ifdef. 2015-03-13 00:48:30 -04:00
Philipp Wiesemann
da843f6a8d Updated internal documentation comments. 2015-03-11 21:14:21 +01:00
Philipp Wiesemann
060d243f66 Windows: Fixed ignoring return value of internal function.
If the function WIN_ConvertUTF32toUTF8() failed (should currently not be
possible) a not terminated string would have been sent as text input event.

This also fixed converting characters more often than needed on key repetition.
2015-03-06 21:34:10 +01:00
Philipp Wiesemann
8f4c2a8f9c Emscripten: Fixed ignoring return value of internal function.
If the function Emscripten_ConvertUTF32toUTF8() failed (should currently not be
possible) a not terminated string would have been sent as text input event.
2015-03-06 21:29:25 +01:00
Philipp Wiesemann
1686af726e Emscripten: Partially fixed not removing key event callbacks if hint was used.
The key event callbacks were always removed from the same target although it is
possible to set them to different targets using the hint. This is only a partial
fix because it assumes that the hint is not changed to a different value later.
2015-03-06 21:26:37 +01:00
Alfred Reynolds
d34d608e59 SDL
- fix crash on OSX when removing a device. If the remove happened due to the CFRunLoopRunInMode call in SDL_SYS_JoystickDetect then we would delete the device right away, before SDL_SYS_JoystickUpdate could clean it up. So move the CFRunLoopRunInMode to after the cleanup logic, preventing this case. This does mean that adds and removes of joysticks now take 1 extra frame to show up.
2015-03-02 11:43:24 -08:00
David Ludwig
d6c4296653 Fixed bug 2868 - SDL_FillRect can crash if surface's clip-rect is out-of-bounds
Thanks to John Skaller for the research into this, and for the fix!
2015-02-22 20:34:08 -05:00
Philipp Wiesemann
8321efba33 Emscripten: Fixed out of range joystick device index after joystick disconnect.
After disconnecting a joystick the remaining kept their original device index.
This was not correct because the device index must be a number between 0 and
SDL_NumJoysticks(). It was fixed with ideas from SDL's joystick implementation
for Android. Some range checks were removed as the caller already checks them.
2015-02-22 23:21:32 +01:00
Philipp Wiesemann
5c43207fad Emscripten: Fixed sending button and motion events for not opened joysticks.
SDL_SYS_JoystickUpdate() was implemented incorrectly. For every call to it all
attached joysticks were checked. But actually only the given SDL_Joystick should
be checked then. This allowed sending broken events for attached but not opened
joysticks. It also checked the opened joysticks more often than actually needed.
2015-02-22 21:00:35 +01:00
Ryan C. Gordon
201868156e Mac OS X: Better way to stop duplicate joystick reports (thanks, Kyungdahm!).
Fixes Bugzilla #2822.
2015-02-19 23:52:10 -05:00
Ryan C. Gordon
33b9d9ad7f Windows: Added a FIXME. 2015-02-19 21:51:13 -05:00
Ryan C. Gordon
674eb55638 Windows: Free the argv we allocated for console_wmain(). 2015-02-19 21:50:40 -05:00
Ryan C. Gordon
e974ccf828 Windows: Added a FIXME. 2015-02-19 21:49:30 -05:00
Ryan C. Gordon
f7c4c3d010 Windows: Make a distinction between ANSI mainline and UTF-8 mainline. 2015-02-19 21:49:15 -05:00
Ryan C. Gordon
e93ee5d7b1 Windows: Support unicode arguments for console applications (thanks, Jorgen!).
Fixes Bugzilla #2864.
2015-02-19 21:44:41 -05:00
Ryan C. Gordon
1b2cb70ca0 Mac OS X: replace some deprecated APIs with modern equivalents (thanks, Alex!).
Fixes Bugzilla #2858.
2015-02-19 19:55:30 -05:00
Edward Rudd
635a369c9d SDL_SetWindowPosition respects display num for SDL_WINDOWPOS_CENTERED_DISPLAY.
This allows for this kind of code in an application:

int monitorID = 1;  // the second monitor!
SDL_SetWindowPosition(sdlWin,
                      SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID),
                      SDL_WINDOWPOS_CENTERED_DISPLAY(monitorID));

Fixes Bugzilla #2849.
2015-02-19 19:40:58 -05:00
Edward Rudd
b88ca1b4a6 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here.
Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here.  Not 5 or 10 depending on the architecture.

More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
2015-02-10 16:28:56 -05:00
Alex Szpakowski
66867e654c Merged default into iOS-improvements 2015-01-24 23:58:07 -04:00
Alex Szpakowski
3e17fbee7e Fixed the extended launch screen causing minor visual issues when rotating the screen in some circumstances. 2015-01-24 23:53:41 -04:00
Philipp Wiesemann
a26a4e9ee2 Fixed bug 2816 - [patch] Android: Expose screen refresh rate
Jonas Kulla

Display::getRefreshRate() is available on all API levels.
2015-01-23 20:29:08 +01:00
Philipp Wiesemann
2b53ffc77c Fixed wrong documentation in joystick implementation source. 2015-01-16 23:07:10 +01:00
Alex Szpakowski
ea5d1a8a3f Merged default into iOS-improvements 2015-01-15 01:15:24 -04:00
Alex Szpakowski
01bfc2158a Several improvements to the iOS backend:
- Added new custom launch screen code. It uses the launch screen nib when available on iOS 8+, the launch images dictionary if the launch screen nib isn't available, and the old standard image names if the launch image dictionary isn't in the plist.
The launch screen is now hidden during the first call to SDL_PumpEvents rather than SDL_CreateWindow so apps can have the launch screen still visible if they do time-consuming loading after creating their window. It also fades out in roughly the same way as the system launch screen behavior.
It can be disabled by setting the SDL_IPHONE_LAUNCHSCREEN define in SDL_config_iphoneos.h to 0.

- A blank UIView is now created and displayed when the window is first created. The old behavior was to defer creating any view until SDL_GL_CreateContext, which prevented rotation, touch events, and other windowing-related things from working until then. This also makes it easier to use SDL_GetWindowWMInfo after creating a window.

- Moved the keyboard and animation callback code from SDL's UIView subclasses to its UIViewController subclass, which lets them work properly in all cases when a SDL window is valid, even before SDL_GL_CreateContext is called and after SDL_GL_DeleteContext is called.

- SDL_GL_CreateContext, SDL_GL_SwapWindow, SDL_GL_MakeCurrent, and SDL_GL_DeleteContext are more robust.

- Fixed some edge cases where SDL windows weren't rotating properly or their reported sizes were out of sync with their actual sizes.

- Removed all calls to [UIApplication setStatusBarOrientation:]. It doesn't seem to work as expected in all cases in recent iOS versions.

- Some code style cleanup.
2015-01-15 01:06:14 -04:00
Arne Janbu
aefcd86dea Fix build on Linux when wayland is enabled
Bug: https://bugzilla.libsdl.org/show_bug.cgi?id=2838
2015-01-10 13:47:37 +01:00
Ryan C. Gordon
a309755961 Remove unnecessary parentheses and an unnecessary free() of a NULL pointer.
(Thanks, Simon!)

Fixes Bugzilla #2881.
2015-02-19 13:11:19 -05:00
Philipp Wiesemann
6dda14c0d8 Emscripten: Fixed receiving joystick events after failed init or subsystem quit.
The callbacks used to receive the HTML events were not removed if the joystick
subsystem initialization failed or if the joystick subsystem was quit. Also, the
already connected joysticks were not deleted if the initialization failed later.
2015-02-18 21:34:07 +01:00
Ryan C. Gordon
f75d6c0915 X11: Don't create a window and GL context to look up the glX extension string.
It's not necessary.
2015-02-17 23:00:46 -05:00
Ryan C. Gordon
f0c061d141 glX HasExtension(): check for NULL ext string first.
It's slightly faster than failing later, after a strchr() call, since this
will get called multiple times with a NULL string if the system totally
fails elsewhere.
2015-02-17 22:59:56 -05:00
Philipp Wiesemann
052720f7d5 Emscripten: Removed unused internal function. 2015-02-15 21:47:10 +01:00
Philipp Wiesemann
bd2d014645 Emscripten: Changed return type of callback implementations from int to EM_BOOL.
The prototypes are declared with EM_BOOL (which is currently an int) in html5.h.
2015-02-15 21:44:36 +01:00
David Ludwig
8a700d4db2 WinRT: a minor, nit-picky cleanup of some OpenGL code 2015-02-15 12:11:44 -05:00
David Ludwig
5ad34f7a79 WinRT: improved OpenGL ES compatibility on WinPhone/ARM and Surface RT
This change integrates initialization settings for ANGLE/WinRT, as suggested in
MSOpenTech's latest ANGLE template-projects (for MSVC).

This should fix some OpenGL initialization issues on WinPhone 8.1 on ARM, and
on the 1st-generation Surface RT.
2015-02-15 11:53:24 -05:00
Philipp Wiesemann
ec2df6490e Fixed crash if using clipboard functions without having initialized video. 2015-02-15 11:35:07 +01:00
David Ludwig
df3299627d WinRT: fixed crash when using up-to-date versions of ANGLE/WinRT 2015-02-15 00:08:27 -05:00
Philipp Wiesemann
2ef8b1a76f Emscripten: Fixed sending SDL_JOYDEVICEADDED events with an index out of range.
SDL_JOYDEVICEADDED events must contain the device index which is a value between
0 and the number of connected joysticks. The old implementation included a value
based on the instance id instead. It worked in some cases because the values are
similar initially. But after disconnecting joysticks this is no more the case
and the always increasing instance id becomes larger than number of joysticks.
2015-02-14 15:22:04 +01:00
Philipp Wiesemann
3941848838 Emscripten: Deactivated and corrected debug log messages on joystick events. 2015-02-14 15:16:41 +01:00
Philipp Wiesemann
6abd242b93 Emscripten: Fixed throwing JavaScript exception if no audio context available.
Handling the error in C provides the possibility to just continue without audio.
2015-02-14 00:16:27 +01:00
Philipp Wiesemann
c5179c6acf Emscripten: Fixed not including SDL_internal.h. 2015-02-14 00:13:00 +01:00
Philipp Wiesemann
697c5c5758 Emscripten: Fixed framebuffer error message. 2015-02-14 00:10:58 +01:00
Philipp Wiesemann
2bb73d170c Emscripten: Fixed SDL_GetPlatform() returning "Unknown" instead of "Emscripten". 2015-02-14 00:08:48 +01:00
Ryan C. Gordon
7fd15e7e2c X11: Set dialog hint on message boxes (thanks, Melker!).
This helps the window manager do the right thing with these windows.
2015-02-11 01:48:52 -05:00
Philipp Wiesemann
e3f9bf3378 Fixed two inconsistencies on failed allocation. 2015-02-08 22:50:16 +01:00
David Ludwig
78f3a80cf2 WinRT: made note that VSync is always enabled on WinPhone, due to OS
Windows Phone does not appear to allow VSync to be turned off.  Doing so appears
to either result in content not getting drawn (when the D3D debug runtime is
turned off), or forcing VSync back on and logging an error (when the D3D debug
runtime is turned on).

VSync had been getting turned on anyways, this change just notes such:
- via the WinRT README
- by always setting the SDL_RENDERER_PRESENTVSYNC flag when creating an
  SDL_Renderer on Windows Phone
2015-02-08 15:44:15 -05:00
Philipp Wiesemann
fe586d077f Fixed three memory leaks on failed allocation. 2015-02-08 21:25:37 +01:00
Philipp Wiesemann
60329e6a1e Added missing guards. 2015-02-03 21:22:25 +01:00
Ryan C. Gordon
56edbb4062 X11: Add events related to maximizing a window (thanks, Andrei and Gergely!).
Fixes Bugzilla #1447.
2015-02-02 01:21:02 -05:00
Ryan C. Gordon
ece8d2bb05 X11: Fixes for OpenGL 3.0 and later context creation.
- Don't create a temporary context first; this was probably due to Windows
needing one to get the address of wglCreateContextAttribsARB(), but that's
a unique quirk of WGL, and doesn't apply to glX. The glX spec explicitly says
you have to get a function pointer that works with any context from
glXGetProcAddress(), including when no context exists.

- Properly check for the GLX_ARB_create_context instead of just looking for a
non-NULL glXCreateContextAttribsARB()...some implementations, like Mesa,
never return NULL for function lookups (Mesa returns pointers into a jump
table that is filled out when the GL is initialized; since you can look up
functions before you have a valid context, it can't definitely say a function
isn't valid at that point).
2015-02-02 01:05:41 -05:00
Philipp Wiesemann
86f87bf755 Added missing guards in implementation for PSP.
Thanks to Martin Gerhardy for pointing this out.
2015-01-31 22:45:54 +01:00
Philipp Wiesemann
d036ad84ae Added missing include statements in implementation for PSP.
SDL_internal.h should be included to support dynamic API and fix warnings.
2015-01-31 22:43:05 +01:00
Philipp Wiesemann
43500a78b8 Fixed comment in implementation for NaCl. 2015-01-31 21:06:37 +01:00
Philipp Wiesemann
f4b7cf6e81 Fixed including SDL_config.h in implementation for Android.
SDL_internal.h should be included to support dynamic API.
2015-01-31 21:02:56 +01:00
Philipp Wiesemann
7384f147f8 Fixed names in implementation for PSP. 2015-01-31 10:33:48 +01:00
Philipp Wiesemann
f1a56cd565 Changed static variable to local variable in implementation for Android. 2015-01-30 23:18:14 +01:00
Sam Lantinga
a725806662 Fixed game controller hotplug support for some embedded Linux devices
When guessing the device class, it ends up being 0 for devices that have been removed (because the device node no longer exists)
2015-01-29 13:33:53 -08:00
Sam Lantinga
0874eb9713 Add binding layout for Xbone pad. 2015-01-29 13:33:20 -08:00
Ryan C. Gordon
203ea98173 X11: Don't delay delivery of focus events unless we just changed vidmodes.
Normally there's a 200 millisecond delay on all focus events in case there
was a vidmode change, now we note the last vidmode change and only impose this
delay if a change happened extremely recently.

Thanks to Epic Games for reporting this issue.
2015-01-26 17:46:39 -05:00
Philipp Wiesemann
f64e6742bc Fixed memory leak in video quit implementation for Android. 2015-01-26 22:12:38 +01:00
Philipp Wiesemann
b48e54aafe Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation
Jonas Kulla

The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c.

I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
2015-01-26 22:00:29 +01:00
Philipp Wiesemann
86c5c3f219 Replaced include of SDL_types.h with SDL_stdinc.h in internal header file.
SDL_types.h is deprecated and currently only includes SDL_stdinc.h itself.
2015-01-08 21:45:46 +01:00
Ryan C. Gordon
a823982e02 Clang static analysis builds should use C runtime directly.
This is a little macro magic to use malloc() directly instead of SDL_malloc(),
 etc, so static analysis tests that know about the C runtime can function
 properly, and understand that we are dealing with heap allocations, etc.

This changed our static analysis report from 5 outstanding bugs to 30.

5x as many bugs were hidden by SDL_malloc() not being recognized as malloc()
 by the static analyzer!
2015-01-05 01:41:42 -05:00
Ryan C. Gordon
2a1e422375 Dynamic API: don't leak if a library loaded but didn't have the entry point. 2015-01-05 01:07:36 -05:00
Philipp Wiesemann
f5fa9a59d0 Removed unused enumeration and constant from internal header file. 2014-12-31 21:00:32 +01:00
Ryan C. Gordon
16f3cbfc02 Cleaned up some compiler warnings. 2014-12-26 23:16:54 -05:00
Ryan C. Gordon
f5bbbe417d GLES2: Only use VBOs for Emscripten (for now).
This is causing a regression on actual iOS hardware, which we should revisit
 after 2.0.4 ships.
2014-12-26 22:30:19 -05:00