Commit graph

6111 commits

Author SHA1 Message Date
Ryan C. Gordon
0ea9cabb50 Don't close already-closed audio devices during SDL_Quit().
Otherwise, we spam a bunch of unnecessary SDL_SetError() calls.

Fixes Bugzilla #1791.
2013-07-05 00:30:23 -04:00
Sam Lantinga
197f525783 Added SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS to the documentation for the joystick and game controller APIs 2013-07-03 12:31:40 -07:00
Edward Rudd
60315067e3 add in alt+enter keyboard shortcut to test common to toggle fullscreen desktop 2013-06-04 12:02:18 -04:00
Sam Lantinga
7ff764a482 Fixed the logical size for rendering to texture, thanks to Mason Wheeler.
Mason Wheeler

The SDL_RenderGetLogicalSize function should always return the amount of pixels that are currently available for rendering to.  But after updating to the latest SDL2, I started getting crashes because it was returning (0,0) as the logical size!  After a bit of debugging, I tracked it down to the following code in SDL_SetRenderTarget:

    if (texture) {
        renderer->viewport.x = 0;
        renderer->viewport.y = 0;
        renderer->viewport.w = texture->w;
        renderer->viewport.h = texture->h;
        renderer->scale.x = 1.0f;
        renderer->scale.y = 1.0f;
        renderer->logical_w = 0;
        renderer->logical_h = 0;
    }

This is obviously wrong; 0 is never the correct value for a valid renderer.  Those last two lines should read:

        renderer->logical_w = texture->w;
        renderer->logical_h = texture->h;
2013-06-29 14:40:55 -07:00
Philipp Wiesemann
fd6dde1327 Changed paths and name of header file in text of VisualC.html. 2013-06-29 22:08:38 +02:00
Sam Lantinga
563185f19c Only check for keyboard focus if the video subsystem was initialized.
Check the hint at initialization time, as an optimization.  This isn't something we expect the application to change at runtime, and if it is we should add an API for it.
2013-06-28 23:29:13 -07:00
Sam Lantinga
66328f31b9 Removing old dangerous signal catching code.
* None of the supported platforms are hosed if the program crashes without cleaning up the graphics display connection.
* It's very likely to be unsafe to call SDL_Quit() at an arbitrary point from an arbitrary thread.
* Catching signals can prevent applications from getting correct stack traces from crashes.
2013-06-28 22:49:03 -07:00
Sam Lantinga
78a7a1b54e Not using SDLmain on Windows is just fine, don't fail the initialization if the program implements WinMain() and then doesn't call SDL_SetMainReady().
This broke Steam's Big Picture game controller support.

I also added some more documentation so people know why main() is overridden on various platforms.
2013-06-28 22:44:49 -07:00
Sam Lantinga
324a14d847 Added testgamecontroller to the Visual Studio 2012 solution. 2013-06-28 22:42:10 -07:00
Sam Lantinga
8cf62ac298 Merged 2013-06-28 20:46:11 -07:00
Sam Lantinga
0535b41f0c Merged 2013-06-28 09:53:13 -07:00
Sam Lantinga
d049796b23 Updated the name of the copyright file 2013-06-28 09:52:36 -07:00
Sam Lantinga
3d1c05ee6b Merged 2013-06-27 17:53:05 -07:00
Sam Lantinga
9fe349d213 Whoops, this controller had already been added. 2013-06-27 17:49:22 -07:00
Jørgen P. Tjernø
b066315e36 Remove / update references to 1.2.
--HG--
extra : histedit_source : 374adabd4332afcb1a85517ef8b82fe997f830c1
2013-06-27 17:07:24 -07:00
Jørgen P. Tjernø
f72a821566 sdl - added comment with URL to windows scancode definition document
--HG--
extra : histedit_source : f915f6603661ea4190976914f4e6cdbe9bb66c01
2013-06-27 17:07:18 -07:00
Sam Lantinga
a7879829ef Added game controller support for an older XBox Controller 2013-06-27 16:32:45 -07:00
Sam Lantinga
1b4d1f20c1 We don't want to save the alpha modulation, we want to save the blend mode. 2013-06-27 11:49:19 -07:00
Sam Lantinga
a61d6e4500 Updated testshader for the SDL 2.0 API 2013-06-27 11:44:07 -07:00
Sam Lantinga
54060becd3 Fixed bug updating the clip rect for the software renderer 2013-06-27 11:27:19 -07:00
Sam Lantinga
a8055a9808 Fixed bug: SDL2 Xinput joystick axis jumps from positive to negative
Franz Schrober

Attached is my patch. It ensures that the values are correctly limitted between -32767 and 32767 (otherwise the negator - and the conversion to sint16 would corrupt the result)

I am using Motioninjoy (Dualshock 3 Sixaxxis controller on Windows 7)  together with a recent SDL2 (post rc1) and noticed with the testjoystick binary that the axis 3 (left analog up/down) jumps when going in down direction from 32257 to -32768. This seems obviously wrong and I have never seen this before. In my games the people are now going backwards before they start to sprint forward when the player actually wants to run as fast as possible backwards. This also happens on the axis 2 (right analog stick up/down)

This problem doesn't happen in DX mode
2013-06-27 11:21:37 -07:00
Sam Lantinga
98cdee1ebc Fixed warning about unused variable. 2013-06-27 11:17:48 -07:00
Sam Lantinga
bc51b6f628 Fixed initializing the haptic system from an XInput joystick
Thanks to Franz Schrober for the fix inspiration.
2013-06-27 10:59:30 -07:00
Sam Lantinga
86e40a29d3 Fixed bug 1929 - SDL_Texture* from SDL_CreateTexture() causes GL_BindTexture() to segfault
Charles Huber

If SDL_CreateTexture() takes the !IsSupportedFormat() path it will return a SDL_Texture* with a NULL driverdata member.

If you then SDL_GL_BindTexture() this will cause a segfault in GL_BindTexture() when it unconditionally dereferences driverdata.
2013-06-25 20:21:31 -07:00
Sam Lantinga
eb00bbd7f9 Better text printing for UTF-8 characters 2013-06-24 22:06:50 -07:00
Sam Lantinga
75894c0d8b Updated timer test and fixed performance counter on Mac OS X 2013-06-23 22:19:38 -07:00
Andreas Schiffler
7827720b8b Update testsprite2 for visual testing: user fuzzer and add --iteration parameter to enable deterministic screen end-state 2013-06-23 15:00:23 -07:00
Andreas Schiffler
319984251f Add VS Express Edition sln files (drop the unsupported solution folders for tests); update VisualC documentation 2013-06-23 14:05:27 -07:00
Sam Lantinga
3fb130cb39 Fixed bug 1913 - state->index may get negative in SDL_wave.c file.
Nitz

In function:
static Sint32
IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble)
{
 const Sint32 max_audioval = ((1 << (16 - 1)) - 1);
    const Sint32 min_audioval = -(1 << (16 - 1));
    const int index_table[16] = {
        -1, -1, -1, -1,
        2, 4, 6, 8,
        -1, -1, -1, -1,
        2, 4, 6, 8
    };
    const Sint32 step_table[89] = {
        7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
        34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
        143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
        449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
        1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
        3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
        9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
        22385, 24623, 27086, 29794, 32767
    };
    Sint32 delta, step;

    /* Compute difference and new sample value */
    step = step_table[state->index];
    // Some Code
}

Here step_table array have the state->index, which might be negative, so it is unsafe to assign this index to step_table array directly.
There would be a check before that to confirm its value.
2013-06-18 00:50:35 -07:00
Sam Lantinga
9293678409 Fixed bug 1916 - SDL_Keysym contains a deprecated field for unicode which may be removed.
Philipp Wiesemann

SDL_Keysym contains a deprecated field for unicode which may be removed for SDL 2.0 release.

As far as I can tell the field is not set on all "major" platforms and therefore will not be useful for most users. Its existence in a public header therefore becomes (in my opinion) only confusing.
2013-06-18 00:39:47 -07:00
Sam Lantinga
46487bd122 Improved include paths for projects using SDL on Android
Isaac Burns

I wanted to suggest a few changes I've found that help the Android build.  By adding LOCAL_EXPORT_C_INCLUDES to the Android.mk file, anything that references the SDL Android project will inherit the include paths.
2013-06-17 07:14:20 -07:00
Sam Lantinga
cfd8d8141d Removed obsolete Xcode templates and documentation 2013-06-17 06:35:41 -07:00
Philipp Wiesemann
05c75b191f Changed comment to be used by doxygen. 2013-06-16 12:00:54 +02:00
Sam Lantinga
de9566518f Fixed some Visual Studio analyze warnings 2013-06-15 02:46:32 -07:00
Sam Lantinga
6971a5dd1c Allow users to define SDL_STDINC_NO_INLINES if they don't want the inline functions defined.
This is useful, for example, if the standard config defines HAVE_SETENV but you're building with C99 that doesn't include that feature.
2013-06-13 22:30:02 -07:00
Sam Lantinga
5aa3492ef8 Fixed SDL building with the minimal configuration 2013-06-13 22:10:10 -07:00
Sam Lantinga
5971051d9e Added an arbitrary limit to the number of queued events so it doesn't grow unbounded. 2013-06-11 08:37:03 -07:00
Sam Lantinga
4abe8a906b Update the queued event wmmsg pointer to point to the queued event data. 2013-06-11 08:32:55 -07:00
Sam Lantinga
e0fe2d1b2c Made the SDL event queue dynamically allocated so we don't ever drop events. 2013-06-10 23:24:02 -07:00
Philipp Wiesemann
ad82c94c55 Updated names of README files in source comments. 2013-06-09 11:58:31 +02:00
Philipp Wiesemann
f54e7cdaa8 Fixed Android Lint warning in AndroidManifest.xml.
If targetSdkVersion not set it becomes same as minSdkVersion and causes warning.
2013-06-09 11:51:59 +02:00
Sam Lantinga
d8de838dfe Updated configure 2013-06-07 21:50:29 -07:00
Sam Lantinga
b7c62a83d9 Improved find_lib, gets the latest version of libpng, etc. 2013-06-07 21:47:23 -07:00
Sam Lantinga
4c59063d54 Check for well known XInput device GUIDs before enumerating the device list. 2013-06-07 18:26:55 -07:00
Sam Lantinga
80917f1537 Removed redundant "Controller" names from gamepads, added mapping for Logitech F710 in DirectInput mode 2013-06-07 09:40:07 -07:00
Sam Lantinga
612ec5d29d Slightly more efficient to check the event type first 2013-06-07 09:39:10 -07:00
Sam Lantinga
7de1fa00ff It's better not to have the full range of the axis (by 1 on the negative side) than turn 0 value into -1 2013-06-07 08:48:25 -07:00
Sam Lantinga
f26e1bc175 Fixed bug 1897 - CPU spike on Windows with WM_EVENT and OpenGL
buckyballreaction

On some Windows systems, when switching from fullscreen to windowed mode in my game, the CPU will spike and the application never shows the window again.

See the part of the e-mail thread here:

http://lists.libsdl.org/pipermail/sdl-libsdl.org/2013-June/088626.html

I change the window by calling:

SDL_SetWindowFullscreen(gScreenInfo.sdlWindow, SDL_FALSE);
SDL_SetWindowSize(gScreenInfo.sdlWindow, sdlWindowWidth, sdlWindowHeight);

which you can see in our source:

https://code.google.com/p/bitfighter/source/browse/zap/VideoSystem.cpp#377

Then all of a sudden the application gets stuck in WIN_PumpEvents() in SDL_windowsevents.c.  I turned on WMMSG_DEBUG and found that there was an endless stream of WM_EVENT messages.  I also found that where WM_PAINT is being handled in the callback WIN_WindowProc(), ValidateRect is somehow not clearing, or it is persisting, the WM_EVENT message like it's supposed to (according to the docs).

This may be a hardware issue.  The issue has appeared on three different systems, one of them sporadically:
 - Windows XP SP3 running in VMware 9.0 (without VMWare 3D acceleration, but with the tools and drivers installed), Host: openSUSE 12.3 x86_64, NVidia NVS 3100M
 - Windows XP SP3 64bit running in VirtualBox, Host: Debian Wheezy (stable), Mobility Radeon HD 4100 (this was the sporadic one)
 - Windows 7 64 bit, Radeon 6770
2013-06-06 23:18:36 -07:00
Sam Lantinga
6879bf00c4 Fixed crash trying to get the GUID of an invalid joystick index 2013-06-06 18:20:06 -07:00
Sam Lantinga
0e48e3563b The triggers should be expanded out to the full range to match DirectInput behavior.
The game controller code will scale them back to 0 - 32767 when it converts the triggers axes.
2013-06-06 17:59:01 -07:00