Commit Graph

858 Commits (c7351c2dea57b772f21dacb3c7f8743db8381459)

Author SHA1 Message Date
Alex Baines 7543092add Call setlocale + XSetModifiers before XOpenIM, Work around ibus+xim duplicate events. 2015-09-30 04:16:09 +01:00
Sam Lantinga 64180d2261 Fixed bug 3138 - c_dfDIJoystick2 already defined in dinput8.lib
Machiel van Hooren

In SDL_dxjoystick.c line 349 there is a constant c_dfDIJoystick2.
However, this constant is aparently also defined in dinput8.lib.

I encountered a linking error when statically linking to SDL:
SDL2_static.lib(SDL_dxjoystick.obj) : error LNK2005: _c_dfDIJoystick2 already defined in dinput8.lib
My application is also linking to dinput8.lib because we rolled our own joystick input and are not using the joystick functionality from SDL.
2016-10-01 14:05:35 -07:00
Sam Lantinga da6197c5a8 Fixed 3149 - Mouse Pointer Raspberry Pi corrupt when moving over screen edges
Patrick Gutlich

The mouse cursor gets corrupted when the mouse moves over the screen edges (right and bottom) a weird type of scaling seems to occur and you end up with a blank square.
2016-10-01 13:59:59 -07:00
Sam Lantinga 1a31bbe2c8 Fixed bug 3157 - Rudimentary touchscreen support in SDL_evdev (supports Raspberry Pi)
tvc

I've spent the last few days implementing touchscreen support in core/linux/SDL_evdev.c. It's fairly rudimentary at the moment, as can be seen from the multiple TODO's and FIXME's littered throughout, but I'm mainly submitting this patch for review. I've tested this patch on my Raspberry Pi 2 with the official touchscreen and it works fantastically, reporting all 10 multitouch points. I'm happy to work on this further, the evdev logic also needs a bit of a cleanup I think (I may have included a few changes). But if it's good enough in its current state to be committed then I'm sure there'd be plenty of people pleased, as currently the only other framework/library that supports touchscreens on the Raspberry Pi is Kivy.
2016-10-01 13:51:56 -07:00
Sam Lantinga 473051f6bb Fixed bug 3159 - SDL_blit_slow with BLENDING does not work
Fritzor

Source Suface is ABGR and Destination Surface is ABGR. We use software blending. In the Switch-Case statement for SDL_COPY_BLEND (Line 126) the alpha-channel is not calculated like in every SDL_blit_auto - function. So if the destination Surface has alpha - channel of zero the resulting surface has zero as well.
Add:  ?dstA = srcA + ((255 - srcA) * dstA) / 255;? to code and everything is okay.
2016-10-01 13:40:01 -07:00
Sam Lantinga 13dd2ccda8 Fixed bug 3161 - SDL_WINDOWEVENT_EXPOSED event possible queue overflow
Marcel Bakker

Observed when resizing or moving a window in Windows 7.

Depending on how you resize/move your window
, you may receive none or a lot of SDL_WINDOWEVENT_EXPOSED events
, at the moment you release the mouse button.

Maybe add this event to an already existing list of overflow candidates ?
2016-10-01 13:38:30 -07:00
Sam Lantinga 614cb35a4d Fixed bug 3165 - define numbers don't match types in Swift
C.W. Betts

Swift is very strict with types, so much that those of different signedness/size must be cast. Most of the defines are imported as 32-bit signed integers, while the corresponding field in a struct is a 32-bit unsigned integer. Appending a "u" would cause the defined types to be imported as 32-bit unsigned integers.
2016-10-01 13:35:36 -07:00
Sam Lantinga ecea3c4a24 Fixed bug 3169 - GLES2_CreateRenderer does not check SDL_GL_GetAttribute result, causing use of uninitialized data
Yann Dirson

When attempting to force use of opengles2 renderer with:

    int wanted_renderer = -1;
     for (int i = 0; i < numrenderers; i++) {
 	SDL_RendererInfo renderer_info;
 	if (SDL_GetRenderDriverInfo(i, &renderer_info) != 0) {
 	    SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't get renderer driver info: %s\n",
 			 SDL_GetError());
 	    quit(2);
 	}
 	std::cerr << "Renderer " << i << " '" << renderer_info.name << "': flags=0x"
 		  << std::hex << renderer_info.flags << std::dec
 		  << ", " << renderer_info.num_texture_formats << " texture formats, max="
 		  << renderer_info.max_texture_width << "x"
 		  << renderer_info.max_texture_height << "\n";
	if (!strcmp(renderer_info.name, "opengles2")) {
	    std::cerr << " selecting!\n";
	    wanted_renderer = i;
	}
     }

    renderer = SDL_CreateRenderer(window, wanted_renderer, 0);

... on banana pi or raspberry pi I get an error like the following (the actual
context profile value varies, being used uninitialized)

 ERROR: Couldn't create renderer: Unknown OpenGL context profile 900

With this patch I get the following, which should help more pointing to a real problem:

 ERROR: Couldn't create renderer: Failed getting OpenGL glGetString entry point

I pushed a patch (based on master branch of unofficial git mirror):

550389c89f


I'll be opening a different bug for the underlying issue.
2016-10-01 13:33:32 -07:00
Sam Lantinga 67901f537c Fixed bug 3174 - SDL_SetRenderTarget clip rect
Marcel Bakker

In SDL_SetRenderTarget(),
i think the intended behavior was to clear the clip rect when a new target is set.
2016-10-01 13:29:30 -07:00
Sam Lantinga f4b26cd8e0 Removed carriage returns from previous patch 2016-10-01 13:16:31 -07:00
Sam Lantinga 7b0ccd32e5 Fixed bug 3405 - Wrong default icon size on windows systems
Evgeny Vrublevsky

Original code in the video/windows/SDL_windowsevents.c registers obsolete WNDCLASS (not WNDCLASSEX). As the result only one icon size is used as the small and normal icons. Also original code doesn't specify required size of an icon. As the result when 256x256 icon is available, the program uses it as a default icon, and it looks ugly.

We have to use WNDCLASSEX and load icons with proper sizes which we can get using GetSystemMetrics.

Better idea. We could use the first icon from resources, like the Explorer does. Patch is included. It also correctly loads large and small icons, so it will look nice everywhere.
2016-10-01 13:14:51 -07:00
Sam Lantinga 86b4319d21 Fixed bug 3422 - OpenGL ES 1.1 renderer: SDL_UpdateTexture breaks later function calls (missing glDisable)
ny00

Using the OpenGL ES 1.1 renderer, after updating a texture with SDL_UpdateTexture (or SDL_UnlockTexture), a following call to SDL_RenderFillRect draws a rectangle with the wrong color (which appears to be the same as the texture's top-left pixel).

Comparing SDL_render_gles.c:GLES_UpdateTexture to SDL_render_gl.c:GL_UpdateTexture, a missing call to glDisable appears to be the cause. After adding it back, the bug is resolved.
2016-10-01 13:07:36 -07:00
Alex Szpakowski 571f4ce8a6 Fix CMake setting an incorrect video backend on iOS 2016-10-01 17:05:29 -03:00
Sam Lantinga c2e2565144 Fixed bug 3424 - SDL_GameController: Increase k_nMaxReverseEntries
ny00

On Android, the keycodes KEYCODE_BUTTON_1..16 (actual values 188-203) are translated to SDL_Joystick buttons no. 20-35. These are currently ignored in SDL_gamecontroller.c.

The attached patch fixes this, by increasing k_nMaxReverseEntries from 20 to another arbitrary bound of 48.

Side-note: Maybe some log should be emitted in case of going over any such bound?
2016-10-01 13:02:20 -07:00
Sam Lantinga 8d8e490dc3 Fixed bug 3262 - Premake scripts are not compatible with "Genie" (premake fork)
jfverdon

Genie (https://github.com/bkaradzic/genie) is a well known premake fork which uses internally Lua 5.3 (as opposed to version 5.1 used in premake4).
As there is some Lua's API breaks in Lua 5.2, SDL premake scripts do not works with premake.

The two incompatibilities I noticed were:
* unhandle modes "rt" and "wt" for io.open. Has io.open opens files in text mode by default, the "t" flag is not needed (this flag is not supported in Genie).
* os.execute signature change, the return value is a tuple from Lua 5.2, before it was just the called program exit code.
2016-10-01 12:56:28 -07:00
Sam Lantinga 671f2a4914 Fixed bug 3268 - CMAKE: ios fixes
Martin Gerhardy

ios is not properly handled in the cmake file.

this patch is a start to do so - it properly builds for me with it.
2016-10-01 12:54:48 -07:00
Sam Lantinga 6a9ee8fa4b Fixed bug 3276 - build-scripts/showrev.sh prints the tip, which isn't useful if you're on a different -# branch, or just not sync'd to the tip.
winterknight

The showrev.sh script shows the tip, instead of the current hg revision. This can be mismatched if one were to use hg update -r ??? to revert to a previous revision.

Patch uses parents instead of tip, which will show the revision that the source is compiled with, instead of the latest revision that the user who is compiling has downloaded.
2016-10-01 12:52:55 -07:00
Sam Lantinga bb24662c79 Fixed bug 3301 - IBus support on Linux with CMake
joe.gsoc16

I recently looked into Unicode support in SDL2 and realized that
SDL_TEXTEDITING doesn't get triggered at all (Japanese IME).
According to others on IRC it works fine on Windows/Mac but not
for me on (arch)Linux.
When compiling SDL with autotools, IBus support is enabled by
default but not so with CMake.
I never used CMake before but got it working and also included
that pkg-config determines flags for dbus (FIXME in CMakeLists).
2016-10-01 12:48:08 -07:00
Sam Lantinga 765d8bea01 Fixed bug 3305 - Fixed TextInput status when the keyboard was dismissed with the dismiss key on the iPad
Diego

The keyboard on iPads has a dismiss button that hides the keyboard. When the keyboard was hidden using that button, instead of the return key, SDL was still reporting IsTextInputActive as true. This patch adds an extra SDL_StopTextInput when iOS reports the keyboard will hide.
2016-10-01 12:46:36 -07:00
Ethan Lee c3e48e71b4 Force WM_PAINT events on window resize 2016-04-12 10:45:56 -04:00
Sam Lantinga f032f811a3 Fixed bug 3318 - testime.c enhancement with GNU Unifont support
Simon Hug

I'm proposing some changes to the IME test program test/testime.c. The patch includes support for the GNU Unifont hex file, making the SDL_ttf dependency optional. There were also one or two bugs that prevented the text and underline from showing up poperly.
2016-10-01 12:43:14 -07:00
Sam Lantinga 3ac201cf7f Fixed bug 3319 - Getting the POSIX out of testqsort.c
Simon Hug

There's a call to the POSIX function random in test/testqsort.c. Naturally, Windows doesn't do that. The attached patch changes the call to the SDLtest framework random functions and adds some seed control.

Looking at SDLTest_RandomInitTime, I just want to say that 'srand((unsigned int)time(NULL)); a=rand(); srand(clock()); b=rand();' is an absolutely terrible way to initialize a seed on Windows because of its terrible LCG.
2016-10-01 12:33:26 -07:00
Sam Lantinga d870f2719b Fixed bug 3320 - SDL_windows_main.c defines both console application entry points
Simon Hug

The SDLmain file src/main/windows/SDL_windows_main.c defines both entry points for console applications, main and wmain. This seems to confuse MSVC. It outputs a LNK4067 warning and then chooses main, which is a shame because only wmain has the unicode handling. Using SDLmain.lib provided on libsdl.org, the linker also goes for main.

I'm proposing to not define the main entry point at all. wmain should be supported well enough with MSVC.
2016-10-01 12:31:31 -07:00
Sam Lantinga 2cbe9e2b77 Fixed bug 3322 - Missing error checking in testaudioinfo and testaudiohotplug
Simon Hug

The two tests test/testaudioinfo.c and test/testaudiohotplug.c are missing error checking when they call SDL_GetAudioDeviceName. This function can return NULL which the tests pass straight to SDL_Log.
2016-10-01 12:29:55 -07:00
Sam Lantinga 6f11545a2d Fixed bug 3323 - SDL_LogOutput prints message twice on Windows when linked with libc
Simon Hug

If SDL2 is compiled with HAVE_LIBC on Windows, the SDL_LogOutput function has two ways of printing a message. WriteConsole and fprintf.
2016-10-01 12:28:05 -07:00
Sam Lantinga 0b576962ca Reset dead keys when the SDL window loses focus, so dead keys pressed in SDL applications don't affect text input into other applications. 2016-10-01 12:17:42 -07:00
Sam Lantinga 1e6e595484 Fixed bug 3332 - Win32: reset deadkeys in StartTextInput/StopTextInput
Eric Wasylishen

The bug here is that a dead keys pressed before calling SDL_StartTextInput() carries over into future text input, so the next key pressed will have the deadkey applied to it.

This in undesirable, imho, and doesn't occur on OS X (haven't check Linux or elsewhere). It's causing a problem for Quakespasm on German keyboard layouts, where we use the ^ deadkey to toggle the console (which enables/disables text input), and ^ characters are showing up in the TEXTINPUT events.
2016-10-01 11:54:02 -07:00
Sam Lantinga 708def87f3 Fixed bug 3338 - console_wmain doesn't null terminate the argv array
Simon Hug

The function console_wmain in src/main/windows/SDL_windows_main.c does not null terminate the argument list it is creating. As specified by the C standard, "argv[argc] shall be a null pointer."

The SDLTest framework makes use of that null pointer and some test programs can cause an access violation because it's missing.
2016-10-01 11:48:15 -07:00
Sam Lantinga 77305d47c2 Fixed bug 3345 - SDL_RenderClear inconsistency with ClipRect
Simon Hug

The description of the SDL_RenderClear function in the SDL_render.h header says the following:

"This function clears the entire rendering target, ignoring the viewport."

The word "entire" implies that the clipping rectangle set with SDL_RenderSetClipRect also gets ignored. This is left somewhat ambiguous if only the viewport is mentioned. Minor thing, but let's see what the implementations actually do.

The software renderer ignores the clipping rectangle when clearing. It even has a comment on this: /* By definition the clear ignores the clip rect */

Most other render drivers (opengl, opengles, opengles2, direct3d, and psp [I assume. Can't test it.]) use the scissor test for the ClipRect and don't disable it when clearing. Clearing will only happen within the clipping rectangle for these drivers.

An exception is direct3d11 which uses a clear function that ignores the scissor test.
2016-10-01 11:46:32 -07:00
Sam Lantinga 89c868f4f8 Fixed bug 3347 - OpenGL ES renderer doesn't flip projection matrix for target textures
Simon Hug

When updating the viewport in GLES_UpdateViewport, the OpenGL ES renderer doesn't flip the projection matrix for target textures. The lines, rectangles and textures (if drawn with glDrawArrays) are upside down when drawing to target textures.
2016-10-01 11:40:57 -07:00
Sam Lantinga 061cc5e75f Fixed bug 3349 - GLES2_RenderReadPixels doesn't use target texture format
Simon Hug

The OpenGL ES 2 renderer does not check the target texture format when using SDL_RenderReadPixels and just always uses ABGR8888. This can result in swapped or wrong colors.

The attached patch adds a check and selects the target texture format, if a texture is set as the target.
2016-10-01 11:38:53 -07:00
Sam Lantinga 51d6371ec1 Fixed bug 3350 - GL renderers don't need to flip rows after reading back pixels from the target texture
Simon Hug

All OpenGL renderers always flip the rows of the pixels that come from glReadPixels. This is unnecessary for target textures since these are already top down.

Also, the rect->y value can be used directly for target textures for the same reason. I don't see any code that would handle the logical render size for target textures. Or am I missing something?

The attached patch makes the renderers only the flip rows if the data comes from the default framebuffer.
2016-10-01 11:34:04 -07:00
Sam Lantinga 9fff05f8d6 Fixed bug 3352 - Adding alpha mask support to SDL_SaveBMP_RW
Simon Hug

The current SDL_SaveBMP_RW function that saves surfaces to a BMP uses an old bitmap header which doesn't officially support alpha channels. Applications just ignore the byte where the alpha is stored. This can easily be extended by using a newer header version and setting the alpha mask.

The attached patch has these changes:

- Extending the description of the function in the SDL_surface.h header with the supported formats.
- Refining when surfaces get stored to a 32-bit BMP. (Must have bit depth of 8 or higher and must have an alpha mask or colorkey.)
- Fixing a small bug that saves 24-bit BGR surfaces with a colorkey in a 24-bit BMP.
- Adding code that switches to the bitmap header version 4 if the surface has an alpha mask or colorkey. (I chose version 4 because Microsoft didn't lose its documentation behind a file cabinet like they did with version 3.)
- Adding a hint that can disable the use of the version 4 header. This is for people that need the legacy header or like the old behavior better. (I'm not sure about the hint name, though. May need changing if there are any rules to that.)
2016-10-01 11:29:13 -07:00
Sam Lantinga 53e22e4be8 Only use GCC pragmas when we're building with GCC 2016-10-01 11:22:39 -07:00
Sam Lantinga a42c396a57 Fixed bug 3361 - Texture color modulation doesn't work with active NONE blend mode (opengl and opengles)
Simon Hug

The GL_SetBlendMode and GLES_SetBlendMode functions of the opengl and opengles renderers call the glTexEnvf to set the texture env mode to either GL_MODULATE (the default) or GL_REPLACE for the NONE blend mode. Using GL_REPLACE disables color and alpha modulation for textures.

These glTexEnv calls were put in the SetBlendMode function back in 2006 [1], but there the NONE code still used the GL_DECAL mode. The GL_REPLACE mode came in 2008 [2]. I'm a bit confused why that wasn't always GL_MODULATE and a bit surprised nobody reported that yet (unless I missed it). I guess only a few use the gles renderer and the newish shaders mask the issue.
2016-10-01 11:04:45 -07:00
Sam Lantinga 3f1b1629c4 Fixed bug 3362 - OpenGL renderer doesn't check if framebuffers are supported when creating target textures
Simon Hug

The GL_CreateTexture function doesn't have any checks for the case where the driver doesn't support the framebuffer object extension. It will call into GL_GetFBO which will call the non-existent glGenFramebuffersEXT.

Also, for some reason GL_CreateContext always sets the SDL_RENDERER_TARGETTEXTURE info flag, even if it is not supported. Changeset cc226dce7536 [1] makes this change, but doesn't explain why. It seems to me like the code would already have taken care of this [2].

The attached patch adds some checks and stops SDL from reporting render target support if there is none. The application can then properly inform the user instead of just crashing.
2016-10-01 10:52:24 -07:00
Sam Lantinga fd1d692bef Fixed bug 3368 - SDL_Blit_Slow doesn't ignore alpha values in colorkey comparison
Simon Hug

When the SDL_Blit_Slow function compares the pixel to the color key it does so without removing the alpha component from the pixel value and the key. This is different from the optimized 32-bit blitters which create a rgb mask and apply it to both to filter the alpha out. SDL_Blit_Slow will only skip the pixels with the exact alpha value of the key instead of all pixels with the same color.

The attached test case blits a surface with a color key and prints the pixel values to the console. The third row is expected to be skipped.
2016-10-01 10:46:10 -07:00
Sam Lantinga 2ccb46cebc Fixed bug 3373 - OpenGL implementation differences of glDrawTexfOES
Simon Hug

It seems not everyone implemented glDrawTexfOES the same. Intel and Mesa ignore the viewport entirely, whereas the Raspberry Pi implementation offsets the coordinates and does viewport clipping.

The glDrawTexfOES extension text [1] for the function says "Xs and Ys are given directly in window (viewport) coordinates." I guess this wasn't clear enough.

Alex Szpakowski

Honestly I'd probably remove that codepath from SDL_Render entirely. It's an OpenGL ES 1-specific extension that isn't likely to give huge performance gains and adds additional maintenance overhead to SDL_Render while also having bugs in some drivers (as seen here).
2016-10-01 10:43:01 -07:00
Bastien Nocera ca8ef2b73f Fix running autogen.sh out-of-tree
As done in GNOME's jhbuild building tool.

https://bugzilla.libsdl.org/show_bug.cgi?id=3374
2016-10-01 10:39:03 -07:00
Sam Lantinga 9dfe54006e We should be using a string constant for the strftime format string 2016-10-01 10:38:15 -07:00
Bastien Nocera 7edd2261e7 Fix "format not a string literal" errors
With GCC 6.1.

https://bugzilla.libsdl.org/show_bug.cgi?id=3375
2016-10-01 10:36:24 -07:00
Jonathan Dowland 461336a23e Add gamecontrollerdb lines for SFC30 controller in various modes
SFC30 controller: http://www.8bitdo.com/sfc30/

The SFC30 controller can present itself in a variety of modes and it offers up
different names in each. This patch captures data for three modes (one USB and
two Bluetooth) on three platforms (Mac OS X, Windows, Linux).

However, USB mode on Linux and Windows is missing as the button events did not
make it through to SDL's controllermap tool on Fedora 24/Linux 4.5.5 nor Steam
Big Picture mode on Windows. The two Bluetooth modes were indistinguishable on
Windows. Two modes on OS X were indistinguishable.

There exists a similar controller called the SNES30 (And some others) that are
very likely identical except for the name, but I have not verified this yet so
haven't synthesized lines for those controllers until I can.
2016-07-01 16:47:27 +01:00
Cole Campbell 8f17b20388 Commit KEYCODE_SPACE as text input on Android 2016-07-04 10:39:32 -04:00
Sam Lantinga b7e45f8a1a Fixed bug 3336 - Failure to build with MinGW-w64
Kai Sterker
There are already patches available from mingw64 that fix the issue

https://github.com/Alexpux/MINGW-packages/tree/master/mingw-w64-SDL2

With those applied, I could compile SDL2 without problems. But of course, it would be preferable if SDL built cleanly from source.
2016-10-01 10:28:00 -07:00
Sam Lantinga 9f854cdbe0 Fixed bug 3388 - Fail to build src/thread/windows/SDL_systhread.c on MinGW 4.9.3
Vitaly Novichkov

Line 124
====================================================================
const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION : 0;
====================================================================

Error of compiler:
====================================================================
  CC     build/SDL_systhread.lo
src/thread/windows/SDL_systhread.c: In function 'SDL_SYS_CreateThread':
src/thread/windows/SDL_systhread.c:124:45: error: 'STACK_SIZE_PARAM_IS_A_RESERVA
TION' undeclared (first use in this function)
     const DWORD flags = thread->stacksize ? STACK_SIZE_PARAM_IS_A_RESERVATION :
 0;
                                             ^
src/thread/windows/SDL_systhread.c:124:45: note: each undeclared identifier is r
eported only once for each function it appears in
make: *** [build/SDL_systhread.lo] Error 1
====================================================================

Fixing when I adding into begin of the file:
====================================================================
#ifndef STACK_SIZE_PARAM_IS_A_RESERVATION
#define STACK_SIZE_PARAM_IS_A_RESERVATION 0x00010000
#endif
====================================================================
2016-10-01 10:08:34 -07:00
Philipp Wiesemann c2cb0b0ff4 iOS: Removed unused constant in demo. 2016-09-30 23:31:24 +02:00
Philipp Wiesemann 7b23eef3b0 Fixed crash if allocating memory for mouse clicks failed. 2016-09-30 23:30:54 +02:00
Ryan C. Gordon e64c5186e2 windows: Removed hardcoded "1" for mouse clickthrough hint. 2016-09-29 23:42:18 -04:00
Ryan C. Gordon f10db4071d haiku: Patched to compile. 2016-09-29 23:15:56 -04:00
Ryan C. Gordon f2fcd324c5 windows: fix borderless windows at desktop resolution (thanks, Evgeny!).
Fixes Bugzilla #3404.
2016-09-29 23:12:58 -04:00