Commit Graph

1487 Commits (e763dac6dd8bf56956021022ecd7c0ec529ace22)

Author SHA1 Message Date
Alfred Reynolds 51c72e10f7 Add X11 implementation of SDL_GetDisplayDPI. 2015-07-29 17:19:02 -07:00
Alfred Reynolds 61c7415071 Add SDL_GetDisplayDPI routine and implement for Windows. 2015-07-29 17:18:56 -07:00
Ryan C. Gordon f5cf86769a x11: Catch fatal X errors when calling glXMakeCurrent().
In extremely rare cases, probably due to misconfigured drivers, one might
see this happen, and rather than terminate the process, we try to recover
by reporting an error to the app.

Fixes Bugzilla #3068.
2015-07-28 00:12:50 -04:00
Alex Szpakowski c344b734f4 iOS: Avoid generating an OpenGL error (but still fail to create the context) if the specified MSAA sample count is unsupported. 2015-07-19 19:56:16 -03:00
Alex Szpakowski 6ea942dae3 Added MSAA support for OpenGL ES contexts on iOS.
Note that extra steps must be taken when using glReadPixels to read the contents of the main OpenGL ES framebuffer on iOS, if multisampling is used. See the OpenGL ES section of README-ios.md for details.
2015-07-19 19:44:40 -03:00
Ryan C. Gordon b24586309c Fixed dynapi for new SDL_WarpMouseGlobal() function signature. 2015-07-18 00:04:49 -04:00
Ryan C. Gordon 9d3d643742 Patched to compile on Raspberry Pi. 2015-07-18 00:03:34 -04:00
Ryan C. Gordon e346f14277 SDL_WarpMouseGlobal() should return non-void.
There are platforms it isn't implemented on (and currently can't be
implemented on!), and there's currently no way for an app to know this.

This shouldn't break ABI on apps that moved to a revision between 2.0.3 and
2.0.4.
2015-07-17 21:03:58 -04:00
Philipp Wiesemann 16e18817e9 Windows: Fixed wrong debugger output if logging empty string as info or warning. 2015-07-16 21:31:21 +02:00
Philipp Wiesemann 2919905620 PSP: Fixed error handling in SDL_SemWaitTimeout().
Signed integers were converted to unsigned before being checked if smaller 0.

Found by Cppcheck.
2015-07-15 21:11:24 +02:00
Ryan C. Gordon 27055ea0ad X11: center parentless message boxes on the primary display if possible.
This relies on a successful SDL_Init(SDL_INIT_VIDEO) to work, since it's
silly to reproduce all the Xinerama/XRandR code in the message box parts. If
X11 is available but SDL hasn't been initialized, the message box will center
in the primary screen, which will be positioned weirdly on multi-head setups,
but this should fix the most significant common case.
2015-07-14 23:46:35 -04:00
Ryan C. Gordon 0c19501eeb x11: Patched to compile on systems without the Xutf8LookupString() function. 2015-07-11 00:59:56 -04:00
Philipp Wiesemann 4679195dbf Fixed memory leak in test harness.
Found by Cppcheck.
2015-07-06 21:02:20 +02:00
Sam Lantinga 396b3b8992 Better fix for bug 3048, don't crash if the window title is NULL 2015-07-05 15:45:48 -07:00
David Ludwig d0ba0c1d8a Fixed bug 3048, "Crashes in Cocoa_SetWindowTitle" 2015-07-04 21:04:49 -04:00
Ryan C. Gordon 65a1a3e7e9 Cocoa: support drag-and-drop of multiple objects. 2015-07-04 14:09:09 -04:00
Sam Lantinga b5c43a88b4 Fixed style 2015-07-03 09:18:14 -07:00
Sam Lantinga 35c4468f9d commit a7d7af2a419b453188ffe87386455fc26c1306fa
Author: Benoit Pierre <benoit.pierre@gmail.com>
Date:   Fri Jul 3 02:17:10 2015 +0200

    fix 14dd48ae5bc43b61b2a0dd0b3177d22edec707ef regression

    The window manager detection code in X11_HasWindowManager does not work
    with Awesome (http://awesome.naquadah.org/). Remove it, and reuse the
    result of the more correct checks in X11_CheckWindowManager.
2015-07-03 09:17:24 -07:00
Philipp Wiesemann 26ecab9010 Removed redundant variable check when processing gestures. 2015-07-01 21:10:54 +02:00
Sam Lantinga e8954d5d8c Hack to fix missing window decorations after toggling fullscreen mode in Mac OS X 10.10 2015-06-30 19:30:02 -07:00
Ryan C. Gordon 1e3c28ac64 X11: Added a test for a weird X11 error we get with Xinerama, rarely. 2015-06-30 15:00:48 -04:00
Ryan C. Gordon 20ec137763 X11: Call XRefreshKeyboardMapping() when we get various MappingNotify events.
According to the Xlib docs, you need to do this or Xlib's internal state gets
out of sync.
2015-06-30 14:41:17 -04:00
Ryan C. Gordon acdb494ffd X11: Don't ignore keyboard mapping changes.
MappingNotify events don't have a window associated with them, so SDL was
dropping these before the point where we would have handled them.
2015-06-30 14:39:39 -04:00
Ryan C. Gordon 4986563d2f Fixed assertion failure in diskaudio target caused by new hotplugging support.
Fixes Bugzilla #3032.
2015-06-30 13:46:06 -04:00
Sam Lantinga f1b7a8434f Fixed compiling if SDL_VIDEO_DRIVER_X11_HAS_XKBKEYCODETOKEYSYM is not defined 2015-06-25 07:17:08 -07:00
Sam Lantinga 3a08b46336 Fixed bug 2834 - Patch to support dead keys on Windows
Elise Maurer

When inputting text, dead-keys are currently not handled correctly on Windows with the latest SDL2 tip as well as the 2.0.3 release.

Using a French AZERTY keyboard, when I type the `^` key followed by `e` key to compose the `` character, I erroneously get two SDL_TEXTINPUT events, one with the `^` character and one with the `e` character.

I've looked at the history for SDL_windowsevents.c and there's been some back-and-forth with several methods for handling text input:

  * r8142 removed any handling of WM_CHAR because keyboard input was being handled through WM_KEYDOWN along with ToUnicode since r7645.

  * But using ToUnicode actually breaks dead-keys (googling for "ToUnicode dead keys" reports many horror stories of people trying to work around that and failing).

  * It seems like r7645 introduced a double-fix: it fixed WM_CHAR to properly handle Unicode, and also (unnecessarily?) added text input handling to WM_KEYDOWN. Later, r8142 removed the WM_CHAR stuff instead of the WM_KEYDOWN stuff.

The attached patch restores handling of text input through WM_CHAR and removes it from WM_KEYDOWN. I've tested it with French, English and Russian layouts and it seems to do its job. Obviously, with such matters, it's still a risky change.
2015-06-25 11:49:48 -07:00
Sam Lantinga 82eec4b630 Fixed whitespace in SDL_evdev.c 2015-06-24 17:55:38 -07:00
Sam Lantinga 9f50d63dd5 Fixed an issue with mouse/keyboard removal
Sometimes, on removal SDL_EVDEV_udev_callback() gets called with zero udev_class. This in turn seems to be caused the SDL_udev.c:guess_device_class() failing to find the attributes of the parent device.

Apparently this is normal, attributes are not guaranteed to be in place during removal, depending on timing. This lack of attributes causes guess_device_class() to return zero.

This fix mimics the code in linux/SDL_sysjoystick.c:joystick_udev_callback() which effectively has the same fix already in place.
2015-06-24 17:54:39 -07:00
Alfred Reynolds cbbdd27ad3 SDL
- disable compiling in XAudio2 support. We both need the DX SDK to make this code plus we need to work out the runtime dependency problem this code bring in on windows (needing the DX runtime installed).

CR: SamL
2015-06-24 10:56:51 -07:00
Alfred Reynolds e4e4e1b82a SDL
- do the scancode to keyboard code lookup for the grave key, so that we can show users the correct keyface for the key, rather than forcing it to "`".  Note that if a game is using SDLK_* for its KB mapping then after this change on some keyboards the top left key will no longer be mapped correctly with the old data.

CR: SamL
2015-06-24 10:56:37 -07:00
Sam Lantinga b7aa856c8f Fixed bug 3030 - SDL_RecreateWindow fails to restore title, icon, etc.
Adam M.

It loses the title and icon when window recreation fails. For instance, this may happen when trying to create an OpenGL ES window on a system that doesn't support it. But at that point, the title and icon have already been lost.
2015-06-22 23:36:06 -07:00
Ryan C. Gordon ded3a16e72 Fixed compiler warning about shadowed local variables. 2015-06-23 01:44:44 -04:00
Philipp Wiesemann 8cea1b986e Windows: Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 19:37:37 +02:00
Philipp Wiesemann 72590685c0 Backed out changeset 4ad56dbf4a6f 2015-06-21 19:36:35 +02:00
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00
Eric Wing 7d5147bad3 resync'd overscan patch with SDL mainline. 2015-04-17 21:25:19 -07:00
Philipp Wiesemann 5a578a0783 Fixed return value of SDL_SaveBMP_RW() depending on set errors after NULL input.
If SDL_SaveBMP_RW() was called with NULL passed as SDL_RWops argument, different
values were returned depending on SDL_GetError(). If no error was set before the
call (or SDL_ClearError() was called) then 0 was returned. This is wrong because
nothing was saved. If an error was set before the call then -1 was returned.

This was fixed by directly returning -1 for NULL input instead of deciding based
on SDL_GetError(). No new error is set because this would otherwise override a
maybe more useful error set in SDL_RWFromFile() which is used by SDL_SaveBMP().
2015-04-16 22:04:35 +02:00
Philipp Wiesemann db878a4336 Linux: Removed not needed platform info from two entries of controller database.
Not needed because entries of this file are selected by conditional compilation.
2015-04-16 22:02:03 +02:00
Philipp Wiesemann 3e1d36299a Fixed typo in internal joystick documentation comments. 2015-04-15 21:29:55 +02:00
Philipp Wiesemann e6b7b38c6c Emscripten: Simplified implementation of joystick update function.
The function was implemented using four loops but only needed two.
2015-04-15 21:27:10 +02:00
Philipp Wiesemann 86fb92a7da Emscripten: Fixed memory leak if SDL_GetPrefPath() failed. 2015-04-15 21:25:15 +02:00
Philipp Wiesemann 0fbd3372d4 WinRT: Fixed format string for error message. 2015-04-13 20:52:18 +02:00
Ryan C. Gordon 3a0270593e Patched to compile on C89 compilers. 2015-04-12 21:02:21 -04:00
Ryan C. Gordon c539b3f9e9 Make X11 and Wayland ProcessHitTest() code less verbose. 2015-04-12 20:59:48 -04:00
Ryan C. Gordon d10201be08 Implemented SetWindowHitTest() for Wayland (thanks, x414e54!).
Fixes Bugzilla #2941.
2015-04-12 20:40:06 -04:00
Alex Szpakowski a27fad1e24 Fixed orientation issues in the iOS extended launch screen. 2015-04-12 01:50:28 -03:00
Alex Szpakowski fe6c797cad Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called. 2015-04-10 23:30:31 -03:00
David Ludwig a6df21cd00 Partial fix for bug 2726 - Win32 'mouse' events not applying 'SDL_TOUCH_MOUSEID'
This is a Win32-specific fix for bug 2726.  A WinRT fix for this bug was applied
separately, via https://hg.libsdl.org/SDL/rev/91f56dcad879

This fix applies SDL_TOUCH_MOUSEID to 'mouse' events coming from touch devices,
but only when relative-mouse-mode is turned OFF.  This bug is still present
when relative-mouse-mode is ON, however Microsoft does not provide documentation
on whether or not those input events (which come from WM_INPUT) can be
identified as touch-specific or not.  Unofficially, that data might be available
(via GetMessageExtraInfo()), however this patch only uses MS-documented APIs.
2014-12-20 11:45:39 -05:00
Sam Lantinga 719bb6fcee Fixed X11 build, added code to print initial modifiers to checkkeys 2015-05-28 09:52:48 -07:00
Sam Lantinga 0694baf260 Fixed bug 2736 - X11 doesn't set KMOD_NUM and KMOD_CAPS to system state
Zack Middleton

Using X11 (on Debian Wheezy), SDL_GetModState() & KMOD_NUM and KMOD_CAPS are not set to system state (numlock/capslock LEDs). Pressing numlock or capslock toggles the mod state, though if num/caps lock is enabled before starting the program it's still reversed from system state. This makes getting KMOD_NUM and KMOD_CAPS in programs unreliable. This can be seen using the checkkeys test program.

The function that appears to have handle this in SDL 1.2 is X11_SetKeyboardState. The function call is commented out with "FIXME:" in SDL 2.

Using Windows backend through WINE; on first key press if numlock and/or capslock is enabled on system, numlock/capslock SDL_SendKeyboardKey is run and toggles KMOD_NUM/KMOD_CAPS to the correct state. On X11 this does not happen.

The attached patch makes X11 backend set keyboard state on window focus if no window was previously focused. It sets all keys to system up/down state and toggles KMOD_NUM/KMOD_CAPS via SDL_SendKeyboardKey to match system if needed. The patch is based on SDL 1.2's X11_SetKeyboardState.
2015-05-28 09:33:47 -07:00
Sam Lantinga 779d403563 Fixed Windows build 2015-05-28 08:51:59 -07:00
Sam Lantinga 0669a224f5 Fixed bug 2860 - SetProp must be paired with RemoveProp especially for properties added to external windows
Coriiander

Upon creating a window, a window property is added to it through the Win32-function "SetProp". This is done in the SDL-function "SetupWindowData" in file "src\video\windows\SDL_windowswindow.c".

Whenever you call "SetProp" to add a property to a Win32-window, you should also call the Win32-function "RemoveProp" to remove it before destroying that Win32-window.

While you might think that it's ok and that Windows will clean up nicely itself, it is not ok. It is against all Win32-API guidelines and is mostlikely a leak. Especially on external windows (CreateWindowFrom) you want to have things done right, not messy and leaky, affecting some other module. Even if SDL gets shutdown entirely that external window will now forever still have the "SDL_WindowData" prop attached to it.
2015-05-28 08:41:07 -07:00
Ryan C. Gordon 84ce000670 I think this will be the time... 2015-05-28 01:27:24 -04:00
Ryan C. Gordon 7964f3adb2 Still trying to get this to compile... 2015-05-28 01:22:14 -04:00
Ryan C. Gordon cae4fd7fb2 More patching to compile... 2015-05-28 01:16:55 -04:00
Ryan C. Gordon e90f87bab0 Another attempt to get this to compile. 2015-05-28 01:08:33 -04:00
Ryan C. Gordon 4add16943e Patched to compile on MingW.
(I think!)
2015-05-28 01:02:03 -04:00
Ryan C. Gordon 58447b24c1 Move tests from SDL_config higher up in Windows joystick/haptic code.
Fixes Bugzilla #2932.
2015-05-28 00:54:52 -04:00
Ryan C. Gordon 2a75782553 X11: Add Xdbe support to message boxes (thanks, Melker!).
Without this, message boxes with a lot of text will noticibly flicker as
you mouse over buttons.

Fixes Bugzilla #2343.
2015-05-28 00:30:21 -04:00
Ryan C. Gordon bea1854cac Patched to compile on C89 compilers. 2015-05-27 19:00:56 -04:00
Ryan C. Gordon 9c343681c4 Wayland: Avoid NULL dereference after window destruction (thanks, "x414e54"!).
Fixes Bugzilla #2934.
2015-05-27 18:54:06 -04:00
Sam Lantinga 7f17e0ab9e Fixed detecting PS4 wired controller on Windows 2015-05-27 10:29:43 -07:00
Ryan C. Gordon 80cfccbf8d Back out changeset b80349dd6d40.
This change didn't do what I thought it did, sorry.
2015-05-26 22:57:42 -04:00
Ryan C. Gordon c69a559239 X11: generate clipboard update events (thanks, "chw"!).
Partially fixes Bugzilla #2266.
2015-05-26 21:29:45 -04:00
Ryan C. Gordon 059a030716 Uh, yeah, it helps to press "Save" before committing... 2015-05-26 21:30:41 -04:00
Ryan C. Gordon cc493d7195 X11: use XA_STRING for text SDL puts on the clipboard (thanks, "chw"!).
Partially fixes Bugzilla #2266.
2015-05-26 21:26:27 -04:00
Ryan C. Gordon baea64e642 Stack hint should look for 0, not -1, and not care about environment variables. 2015-05-26 21:19:23 -04:00
Ryan C. Gordon a8fa7bd1f7 Added a hint to specify new thread stack size (thanks, Gabriel!).
Fixes Bugzilla #2019.

(we'll do a better fix when we break the API in SDL 2.1.)
2015-05-26 21:13:27 -04:00
Alex Baines dae40bff0d [IBus] Only register interest in messages sent to our input context. 2015-02-27 21:17:29 +00:00
Alex Baines 42d9cf6978 [ibus] Send an empty TextEditing event when the text is cleared by pressing backspace. 2015-02-01 21:08:54 +00:00
Ryan C. Gordon 21d0cdedb3 Added some unknown keys from Japanese 106/109 keyboards (thanks, "ver0hiro"!).
This adds them for Windows and X11.

Fixes Bugzilla #2820.
2015-05-26 20:55:03 -04:00
Alex Szpakowski 262e8ef3f0 Mac: Send a window resize event when the window's backing scale factor changes.
The backing scale factor can change when the window moves between retina and non-retina displays.

The only other way to detect such a change is to compare the output of SDL_GL_GetDrawableSize or SDL_GetRendererOutputSize every frame, which is less than desirable, especially since the necessary app logic is likely already being executed when a window resize event is received.
2015-05-26 21:51:47 -03:00
Ryan C. Gordon be89fa09ef Reset the keyboard state when launching a message box (thanks, Sean!).
Otherwise, pressed keys get stuck.

Fixes Bugzilla #2776.
2015-05-26 20:49:27 -04:00
Ryan C. Gordon 41908548b9 Windows: Alt-F4 hotkey should be checked on keydown, not keyup (thanks, Matt!).
Fixes Bugzilla #2780.
2015-05-26 20:40:00 -04:00
Ryan C. Gordon 72a244da41 Android: Added basic drop file support (thanks, "noxalus"!).
This lets SDL-based apps respond to "Open With" commands properly, as they
can now obtain the requested path via a standard SDL dropfile event.

This is only checked on startup, so apps don't get drop events at any other
time, even if Android supports that, but this is still a definite
improvement.

Fixes Bugzilla #2762.
2015-05-26 20:36:45 -04:00
Alex Baines ae6555dff8 Pump IBus events after X events. 2015-05-26 20:22:14 -04:00
Alex Szpakowski a4f0daedae EGL: OpenGL ES 3.0 contexts can now be created without the EGL_KHR_create_context extension.
Fixes bugzilla #2994.
2015-05-26 19:34:56 -03:00
Ryan C. Gordon d5a578531b Drop out of SDL_UpdateTexture() early if the rectangle is zero pixels.
Hopefully makes static analysis happy about a zero-byte malloc elsewhere.
2015-05-26 16:42:36 -04:00
Ryan C. Gordon 2e2b84fb32 Some setups need _GNU_SOURCE to make LLONG_MAX available (thanks, Ozkan!).
Fixes Bugzilla #2721.
2015-05-26 16:31:11 -04:00
Ryan C. Gordon 59f69f6317 Whoops, fix the static analysis fix. 2015-05-26 16:14:25 -04:00
Ryan C. Gordon d1980b93fb Mac: Fix compiler warning when building with a min target >= 10.6. 2015-05-26 12:52:28 -04:00
Ryan C. Gordon 37f4eb5379 Darwin haptic: Fixed a static analysis warning if axes==0. 2015-05-26 12:47:03 -04:00
Ryan C. Gordon f99d6e1df8 Linux joystick: Look at entire axis namespace for controls (thanks, "spaz16"!).
This apparently has fallout: the PS4 (and maybe PS3?) controllers apparently
report some bogus axes, but it won't change the axes we currently expect, and
thus the game controller config string is still stable.

Fixes Bugzilla #2719.
2015-05-26 12:03:51 -04:00
Sam Lantinga 523064592a Fixed bug 2869 - Controllers connected on launch are reported twice.
Since all device detection/removal happens on the main thread now, post events inline with when the status changes occur.
Also fixed rare cases when joystick API functions could return data about removed joysticks when called with a device index.
2015-05-26 08:52:02 -07:00
Ryan C. Gordon 80916e01f3 Cocoa: Fixed relative mouse mode when app loses/regains focus (thanks, Eric!).
Fixes Bugzilla #2718.
2015-05-26 11:38:04 -04:00
Ryan C. Gordon b11b3493b9 Windows: don't beep on Alt-* key combos (Thanks, historic_bruno!).
Fixes Bugzilla 2669.
2015-05-26 11:08:30 -04:00
Ryan C. Gordon bb437f0233 Cocoa: report SDL_WINDOWEVENT_EXPOSED events to the app (thanks, David!).
Fixes Bugzilla #2644.
2015-05-26 11:01:19 -04:00
Ryan C. Gordon 22704ac2df Cocoa: don't fail outright if we see an unknown display format.
Just treat it as ARGB8888.
2015-05-26 09:55:41 -04:00
Ryan C. Gordon aba4d78384 Don't look for (and fail without) glGetIntegerv() until we need to.
Fixes Bugzilla #2615.
2015-05-26 10:25:15 -04:00
Sam Lantinga 2c4a6ea0a2 Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Sam Lantinga 507157abdb Wait for devices to finish initializing when inserted, before using them. Fixes hotplug issue with XBox 360 game controller. 2015-05-25 16:22:09 -07:00
Sam Lantinga b0c5e201f8 Added support for Razer Serval Bluetooth mode 2015-05-25 14:52:41 -07:00
Victor Luchits afc97cbd5d Fix duplicate raw mouse events with XInput2
Make XGrabPointer calls in X11_SetWindowGrab and X11_CaptureMouse
consistent by passing False to owner_mask along with proper event_mask.
2015-05-14 14:40:56 +03:00
Sam Lantinga 6365381422 Added game controller support for the Razer Serval 2015-05-20 16:28:21 -07:00
Alex Szpakowski fcee3e734d Code style cleanup in the GLES and GLES2 render backends. 2015-05-16 17:35:36 -03:00
Alex Szpakowski 240a3fbffe iOS: Added support for SDL_DisableScreenSaver and SDL_EnableScreenSaver. 2015-05-16 16:55:56 -03:00
Philipp Wiesemann a54d038b64 Emscripten: Fixed wrong source comment and updated web link. 2015-05-16 21:15:27 +02:00
Alex Szpakowski d57b973518 Mac: Use CoreFoundation headers instead of Carbon headers, in GetPowerInfo code. 2015-05-16 12:05:42 -03:00
Sam Lantinga 1c6ea0f226 Added a userdata parameter to SDL_SetWindowsMessageHook() 2015-05-13 22:39:32 -07:00
Sam Lantinga b2be9253e3 Fixed Mac and Linux builds 2015-05-13 22:39:27 -07:00
Sam Lantinga 7de242e72c Added SDL_SetWindowsMessageHook() to facilitate full IME support on Windows 2015-05-13 22:39:20 -07:00
Sam Lantinga 094c4a160f Added generic xinput fallback for XBox compatible controllers on Linux 2015-05-13 22:37:26 -07:00
Alex Szpakowski f1a7c00d06 Refactored SDL_EGL_CreateContext: It now supports context flags and OpenGL ES 3+ contexts, and its behavior more closely matches the GLX and WGL context creation code.
Improved the code style consistency of SDL_egl.c.

Fixes bugzilla #2865.
2015-05-11 21:03:36 -03:00
Philipp Wiesemann 5919a859b4 Android: Fixed empty parameter list in signatures of internal functions. 2015-05-09 22:42:23 +02:00
Philipp Wiesemann 3f51758ec5 Emscripten: Fixed touch coordinates not being normalized. 2015-05-06 21:10:48 +02:00
Alex Szpakowski ac27b511bf Fixed SDL_GL_GetAttribute queries for framebuffer component sizes in Core Profile OpenGL contexts.
Fixes bugzilla #2060.
2015-05-06 12:54:51 -03:00
Alex Szpakowski 4fc4026660 Replaced all remaining uses of NSAutoreleasePool with @autoreleasepool blocks (bugzilla #2680.) 2015-05-05 19:01:55 -03:00
Alex Szpakowski d1372bb92c Fixed the window offset on iOS when resuming an app with a borderless or fullscreen window that has the on-screen keyboard visible. 2015-05-05 16:20:11 -03:00
Alex Szpakowski d603bb30e6 Fixed a crash on iOS when none of the orientations in Info.plist match the SDL window's actual orientation.
Fixes bug #2967.
2015-05-05 16:16:10 -03:00
Sam Lantinga 74d83ead35 Fixed bug 2976 - Fix RGBA<->RGBA blit that was broken with the optimization from Bug 11
id.zeta

The optimization from Bug 11 added a code branch on cases where the source RGB masks match the destination RGB masks and a optimized blit function Blit4to4MaskAlpha that always overrides the source alpha info would be chosen. Unfortunately, the branch also errorneously took over the RGBA<->RGBA blitting cases where the source alpha info should be copied, while they would instead get overriden in Blit4to4MaskAlpha.

The attached patch fixes that by handling the RGBA<->RGBA cases correctly in that branch with the original BlitNtoNCopyAlpha as well as uses an optimized Blit4to4CopyAlpha along the same vein.
2015-05-04 21:47:40 -07:00
Ryan C. Gordon 589c46dd65 X11: send keypress events before textinput events. 2015-05-01 01:20:28 -04:00
Philipp Wiesemann 9979bab20b Android: Deactivated debug log messages on joystick device events. 2015-04-30 21:45:29 +02:00
Dimitris Zenios d9d1a1b980 X11: Use our own cut-buffer for intermediate clipboard storage.
XA_CUTBUFFER0 is not defined for holding UTF8 strings.
2015-04-26 13:53:46 +03:00
Eric Wing 313881175d Adds support to control the scaling policy/mode of SDL_RenderSetLogicalSize for both letterbox (current behavior) and a new overscan mode (expand to fill the entire screen, even if some parts draw off the screen).
The expected use case is for games that are designed with multiple aspect ratios already in mind and leave optional margins on the edges of the game which won't hurt if they are cut off.

An example use case is a game is designed for wide-screen/16:9, but then wants to deploy on an iPad which is 4:3. Normally, SDL will letterbox, which will shrink things and result in wasted space. But the designer already thought about 4:3 and designed the edges of the game so they could be cut off without any functional loss. So rather than wasting space with letterboxing, "overscan" mode will zoom the rendering to fill up the entire screen. Parts on the edges will be drawn offscreen, but since the game was already designed with this in mind, it is fine. The end result is the iPad (4:3) experience is much better since it feels like a game designed for that screen aspect ratio.

This patch introduces a new SDL_hint: SDL_HINT_RENDER_LOGICAL_SIZE_MODE.
Valid values are "letterbox" or "0" for letterboxing and "overscan" or "1" for overscan.
The default mode is letterbox to preserve existing behavior.

// Example usage:
SDL_SetHint(SDL_HINT_RENDER_LOGICAL_SIZE_MODE, "overscan");
SDL_RenderSetLogicalSize(renderer, SCREEN_WIDTH, SCREEN_HEIGHT);
2014-12-03 04:41:26 -08:00
David Ludwig 5fee84f24b WinRT: removed SDL_HINT_WINRT_PREF_PATH_ROOT (introduced post-2.0.3 & pre-2.0.4)
A WinRT app's Roaming folder-path can still be retrieved via calls to
SDL_WinRTGetFSPathUTF8() or SDL_WinRTGetFSPathUNICODE(), if need be.
2014-12-02 21:18:50 -05:00
Andreas Schiffler 52760dcdf1 Fix assert format strings/parameters in testautomation modules; improve output of SDL_CompareSurfaces to aid debugging; update platform_testSetErrorInvalidInput for SDL changes 2014-11-30 20:55:27 -08:00
Sam Lantinga 265b219e3e Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification
Elias Vanderstuyft

Remove the dependency of the calculation of Linux "phase" on "period",
currently the "phase" parameter is interpreted as a time shift, instead of a phase shift.
The Linux input documentation is not clear about the exact units of the "phase" parameter (see http://lxr.free-electrons.com/source/include/uapi/linux/input.h?v=3.17#L1075 ),
but we're about to standardize the 'phase shift' interpretation into the Linux input documentation,
since this will ease the job of a driver to recalculate the effect's state when the user dynamically updates the "period" parameter.
2014-11-29 11:51:13 -08:00
Sam Lantinga ef8c3d89ce Fixed bug 2766 - Haptic coding bugs and fixes for Linux FF: periodic.phase handled as time instead of angle; + direction clarification
Elias Vanderstuyft

It's not obvious from the general "haptic direction" description what the SDL direction actually means in terms of force magnitude sign,
currently its meaning is only reflected by the example.
2014-11-29 11:48:43 -08:00
David Ludwig ce64b4ad3a WinRT: bug and data-integrity fixes for SDL_GetPrefPath()
This change does a few things, all with regards to the WinRT implementation of
SDL_GetPrefPath():

1. it fixes a bug whereby SDL_GetPrefPath() did not create the directory it
returned.  On other SDL platforms, SDL_GetPrefPath() will create separate
directories for its 'org' and 'app' folders.  Without this, attempts to create
files in the pref-path would fail, unless those directories were first created
by the app, or by some other library the app used.  This change makes sure
that these directories get created, before SDL_GetPrefPath() returns to its
caller(s).


2. it defaults to having SDL_GetPrefPath() return a WinRT 'Local' folder
on all platforms.  Previously, for Windows Store apps, it would have used a
different, 'Roaming' folder.  Files in Roaming folders can be automatically,
and synchronized across multiple devices by Windows.  This synchronization can
happen while the app runs, with new files being copied into a running app's
pref-path.  Unless an app is specifically designed to handle this scenario,
there is a chance that save-data could be overwritten in unwanted or
unexpected ways.

The default is now to use a Local folder, which does not get synchronized, and
which is arguably a bit safer to use.  Apps that wish to use Roaming folders
can do so by setting SDL_HINT_WINRT_PREF_PATH_ROOT to "roaming", however it
is recommended that one first read Microsoft's documentation for Roaming
files, a link to which is provided in README-winrt.md.

To preserve older pref-path selection behavior (found in SDL 2.0.3, as well as
many pre-2.0.4 versions of SDL from hg.libsdl.org), which uses a Roaming path
in Windows Store apps, and a Local path in Windows Phone, set
SDL_HINT_WINRT_PREF_PATH_ROOT to "old".

Please note that Roaming paths are not supported on Windows Phone 8.0, due to
limitations in the OS itself.  Attempts to use this will fail.
(Windows Phone 8.1 does not have this limitation, however.)


3. It makes SDL_GetPrefPath(), when on Windows Phone 8.0, and when
SDL_HINT_WINRT_PREF_PATH_ROOT is set to "roaming", return NULL, rather than
silently defaulting to a Local path (then switching to a Roaming path if and
when the user upgraded to Windows Phone 8.1).
2014-11-29 10:09:30 -05:00
Sam Lantinga 4dab32a2bc Fixed bug 2786 - "UCS-2-INTERNAL" iconv encoding is not supported everywhere, use UTF-16LE instead
Jonas Kulla

src/main/windows/SDL_windows_main.c:137:
cmdline = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)(text), (SDL_wcslen(text)+1)*sizeof(WCHAR));

I'm trying to compile an SDL2 application for windows using the mingw-w64 32bit toolchain provided by my distro (Fedora 19). However, even the simplest test program that does nothing at all fails to startup with a "Fatal error - out of memory" message because the mingw iconv library provided by my distro does not support the "UCS-2-INTERNAL" encoding and the conversion returns null.

From my little bit of research, it turns out that even though this encoding is supported by the external GNU libiconv library, some glibc versions (?) don't support it with their internal iconv routines, and will instead provide the native endian encoding when "UCS-2" is specified.

Nonetheless, I wonder why the native endianness is considered in the first place when Windows doesn't even run on any big endian archs (to my knowledge). And true enough, 'WIN_StringToUTF8' from core/windows/SDL_windows.h is used everywhere else in the windows backend, which is just a macro to iconv with "UTF-16LE" as source. Therefore it would IMO make sense to use this macro here as well, which would solve my problem (patch attached).
2014-11-28 04:51:33 -08:00
Sam Lantinga 767bb36364 Fixed bug 2676 - xdnd_version check issue in case ClientMessage
Nitz

I added xdnd_version check to XdndPosition case also
under DEBUG_XEVENTS macro.
by this we can get the action requested by user.

I analysed further and found out that removing xdnd_version check at XdndDrop case is a bad idea because
in XConvertSelection API timestamp should be passed if(xdnd_version >= 1)
otherwise CurrentTime should be passed
So xdnd_version check is important at XdndDrop case

I made xdnd_version as a static so that it can store the version in other cases also.
2014-11-28 04:42:46 -08:00
Sam Lantinga 7ed41da0b0 Fixed bug 2411 - Even if built with --enable-clock_gettime, SDL2 still calls gettimeofday()
Ben Swick

Makes SDL_syscond.c and SDL_syssem.c use clock_gettime(CLOCK_REALTIME) when HAVE_CLOCK_GETTIME is defined.
2014-11-28 04:37:50 -08:00
Eric Wing ef559ddb4c iOS: Added support for iOS 8 LaunchScreen NIBs.
iOS 8 introduces LaunchScreen NIBs which use autolayout to handle all devices and orientations with a single NIB instead of multiple launch images. This is also the only way to get the App Store badge "Optimized for iPhone 6 and iPhone 6 Plus". So if the application is running on iOS 8 or greater AND has specified a LaunchScreen in their Info.plist, this patch will use the NIB as the launch screen. Otherwise, the code falls back to the legacy code path.

Note: Upon audit of the legacy path, it appears that it does not properly handle the UILaunchImages Info.plist convention. I've added comments inline to the code about this. However, in about a year from now, nobody is going to care about this path since everybody should be using LaunchScreen NIBs.
2014-11-02 20:55:13 -08:00
David Ludwig ecc014740a WinRT: added SDL_HINT_WINRT_PREF_PATH_ROOT
SDL_HINT_WINRT_PREF_PATH_ROOT allows WinRT apps to alter the path that
SDL_GetPrefPath() returns.  Setting it to "local" uses the app's
OS-defined Local folder, setting it to "roaming" uses the app's OS-defined
Roaming folder.

Roaming folder support is not available in Windows Phone 8.0.  Attempts to
make SDL_GetPrefPath() return a Roaming folder on this OS will be ignored.

Various bits of documentation on this were added to SDL_hints.h, and to
README-winrt.md
2014-11-27 09:55:34 -05:00
David Ludwig 506a1efc22 WinRT: removed a completed TODO item from an inline comment 2014-11-27 08:50:11 -05:00
David Ludwig 6a5b3bb425 WinRT: added initial SDL_TEXTINPUT support
Further support regarding IME and on-screen keyboards is pending, some of
which might not be 100% compatible with other platforms, given WinRT platform
restrictions.  An MSDN article at http://msdn.microsoft.com/en-us/library/windows/apps/hh465404.aspx
indicates that on-screen keyboard display requires that the user first tap on
a Windows/XAML text control.

This change adds basic SDL_TEXTINPUT support, with input coming from hardware
keyboards, at a minimum, and without the need for XAML integration (which is
still pending integration into SDL, by and large).
2014-11-26 21:34:15 -05:00
Philipp Wiesemann 8cab5ae300 Fixed limitation for number of custom main() arguments on Android.
Limitation was size of the reference table because local refs were not deleted.
2014-11-25 22:31:14 +01:00
J?rgen P. Tjern? 94539137a2 Mac: Add drag & drop support.
Fixes bug https://bugzilla.libsdl.org/show_bug.cgi?id=2757

Thanks to Alex Szpakowski for the patch!
2014-11-24 11:46:20 -08:00
Edward Rudd 084642d3f4 Cocoa: add in handling of "lost" touches on OS X. [bug #2635]
This scenario can occur, for example, when the 4-finger touch sequence is used to switch spaces.  the SDL window does not receive the touch up events and ends up thinking there are far more fingers on the pad than there are.

So the solution here is everytime a new "touch" appears we can through and check if there are any existing known touches by the OS and if there are none, abut SDL things there are, we simply go through and cancel the SDL touches.

Side affects.
- the "touch up" won't occur until the users sends a new touch (could be well after the actual release really did occur)
2014-11-23 15:48:52 -05:00
Philipp Wiesemann 097ad55000 Fixed local reference leaks in messagebox implementation for Android. 2014-11-23 20:38:18 +01:00
David Ludwig d9a42c76b1 WinRT: fixed an invalid comment in SDL_GetPrefPath() (for WinRT) 2014-11-23 08:59:01 -05:00
David Ludwig 13c511697c WinRT: allowed 'roaming' and 'temp' folder paths to be retrieved on WinPhone 8.1
Windows Phone 8.0 either did not define, or provide access to, a 'RoamingFolder'
or 'TemporaryFolder' for apps to use.  Windows 8.0 and 8.1 do, as does
Windows Phone 8.1.  This change allows SDL-based Windows Phone 8.1 apps to
access these folders, via either the SDL_WinRTGetFSPathUNICODE() or
SDL_WinRTGetFSPathUTF8() functions.

SDL_GetPrefPath(), which on WinRT, is based on SDL_WinRTGetFSPathUTF8(), will
continue to return the app's 'local' folder, despite Windows 8.x
counterpart apps using the 'roaming' folder, in order to preserve compatibility
when 8.0-based Phone apps upgrade to 8.1-based Phone apps.
2014-11-23 08:52:10 -05:00
David Ludwig 5575948b37 Fixed bug 2726 - WinRT touches not setting 'which' field in virtual mouse events
This patch makes sure that any SDL_MOUSEBUTTONDOWN, SDL_MOUSEBUTTONUP, and
SDL_MOUSEMOTION events, as triggered by a touch event in a WinRT app, set the
event's 'which' field to SDL_TOUCH_MOUSEID.  Previously, this was getting set
to the same value as events from a real mouse, '0'.

Thanks to Diego for providing information on this bug, and to Tamas Hamor for
sending over a patch!
2014-11-22 21:13:46 -05:00
Philipp Wiesemann 9c398852e6 Corrected header file documentation comment. 2014-11-22 22:20:40 +01:00
Wander Lairson Costa eff61ee39d Add an entry for X11 "/" key for Brazilian keyboard.
SDL2 reports the following message when we type the "/" on br-abnt2 keyboards:

The key you just pressed is not recognized by SDL. \
To help get this fixed, please report this to the SDL mailing list \
<sdl@libsdl.org> X11 KeyCode 97 (89), X11 KeySym 0x2F (slash).

That's because the corresponding entry in the scancodes table is
marked with value SDL_SCANCODE_UNKNOWN.

This commit fixes that adding the value SDL_SCANCODE_SLASH for this entry.
2014-06-05 11:55:37 -03:00
Ryan C. Gordon 69f6f646a2 Cleaned up the macro salsa in the Windows timer code.
- Removed USE_GETTICKCOUNT code; it's never used now.
- Reduced the number of preprocessor checks for WinRT.
- Renamed timeSetPeriod() so it doesn't look like a Win32 API call.
2015-04-20 13:43:24 -04:00
Ryan C. Gordon b72938c861 Windows: Always set the system timer resolution to 1ms by default.
An existing hint lets apps that don't need the timer resolution changed avoid
this, to save battery, etc, but this fixes several problems in timing, audio
callbacks not firing fast enough, etc.

Fixes Bugzilla #2944.
2015-04-20 12:22:44 -04:00