Commit Graph

2404 Commits

Author SHA1 Message Date
Ryan C. Gordon
3323b355c9 android: use cpufeatures to support SDL_HasNEON() (thanks, Sylvain!).
Fixes Bugzilla #4406.
2018-12-01 12:19:11 -05:00
Ryan C. Gordon
fac40f8e4c Patched to compile on Linux with threads enabled. (whoops!) 2018-12-01 11:14:20 -05:00
Ryan C. Gordon
c4bc59a50e Patched to compile on Linux with --disable-threads.
Fixes Bugzilla #4393.
2018-12-01 10:36:26 -05:00
Sam Lantinga
f205f3a8c2 Added support for the Razer Raiju Mobile 2018-11-27 15:10:26 -08:00
Sam Lantinga
a95291c9c8 Fixed the hotspot for cursors on Raspberry Pi 2018-11-27 11:16:04 -08:00
Sam Lantinga
aea483577a Fixed bug changing cursors on Raspberry Pi 2018-11-27 10:20:29 -08:00
Alex Szpakowski
37b1f989ce metal: use a staging texture in SDL_UpdateTexture, to make sure it doesn't stomp texture data being drawn in a previous frame on the GPU. 2018-11-25 22:13:09 -04:00
Alex Szpakowski
872936a485 metal: Fix an incorrect division. 2018-11-21 23:46:37 -04:00
Alex Szpakowski
4a58722b9f metal: SDL_RenderFillRects uses one draw call per 16k rectangles (within the given FillRects call), instead of one draw call per rectangle. Reduces CPU usage when drawing many rectangles. 2018-11-21 23:37:23 -04:00
Sebastian Krzyszkowiak
5f98051457 wayland: ask xdg-decoration protocol extension to use server-side decorations if possible. 2018-11-04 21:08:40 +01:00
Sam Lantinga
5c5ba0e331 Fixed bug 4394 - Crash in SDL_PumpEvents() after SDL_DestroyWindow()
Cameron Gutman

After updating to SDL 2.0.9, I got a user report that my app was crashing when closing a SDL_WINDOW_FULLSCREEN window to return to my Qt-based UI. It looks like the dead SDL window is getting a spurious updateLayer call which is causing SDL to dereference a null SDL_WindowData pointer.

For some reason, this only happens when using SDL_WINDOW_FULLSCREEN and not windowed or SDL_WINDOW_FULLSCREEN_DESKTOP. I was also unsuccessful in my attempt to get a simple reproducer for this crash. The Session.cpp code is available 688c4a90d9/app/streaming/session.cpp but I slightly modified it (adding a SDL_PumpEvents() call at 1179 to immediately trigger the issue, otherwise it happened when Qt next pumped the event loop).

The crashing line is:

    NSMutableArray *contexts = data->nscontexts;
2018-11-19 21:35:59 -08:00
Sam Lantinga
b73703b9c6 Fixed bug 4391 - hid_enumerate() sometimes causes game to freeze for a few seconds
Daniel Gibson

Even though my game (dhewm3) doesn't use SDL_INIT_JOYSTICK, SDL_PumpEvent() calls SDL_JoystickUpdate() which ends up calling hid_enumerate() every three seconds, and sometimes on my Win7 box hid_enumerate() takes about 5 seconds, which causes the whole game to freeze for that time.
2018-11-19 21:17:00 -08:00
Ozkan Sezer
d3fa42b8c4 os/2 bits for SDL_malloc.c -- from libffi 2018-11-18 19:28:20 +03:00
Ozkan Sezer
1a02403ea7 libm: Watcom defines huge=__huge: undefine it to fix build using Watcom. 2018-11-18 11:50:20 +03:00
Ryan C. Gordon
457e58c40b opengles: Fixed compiler warnings. 2018-11-17 16:24:52 -05:00
Sam Lantinga
9719f89db2 Back out change initializing renderer blend mode incorrectly. 2018-11-17 12:12:29 -08:00
Ryan C. Gordon
fde7592ada direct3d11: Fixed missing rendering of solid primitives.
Fixes Bugzilla #4388.
2018-11-17 14:39:42 -05:00
Ryan C. Gordon
782f1685ff Fixed a few compiler warnings. 2018-11-17 14:37:51 -05:00
Sam Lantinga
29e15ce62d The default draw blendmode is SDL_BLENDMODE_NONE 2018-11-17 00:58:45 -08:00
Sylvain Beucler
1f6bd95110 Emscripten: make CloseAudio actually close audio
cf. https://bugzilla.libsdl.org/show_bug.cgi?id=4176
2018-11-15 18:22:30 +00:00
Ryan C. Gordon
9262c0de9b software: fix blits with color mods that change during a command queue run. 2018-11-14 22:38:58 -05:00
Sam Lantinga
2e348c1f59 Fixed bug 3193 - Dualshock 3's motion sensors overwrite analog stick
maxxus

The Dualshock 3's motion sensors don't seem to be reported by the call to EVIOCGBIT but they still send EV_ABS events.  Because they're not reported by EVIOCGBIT they're not assigned a proper axis ids and the default of 0 is used, which is the valid id for the left analog sticks left/right axis.
2018-11-14 13:37:22 -08:00
Sam Lantinga
b815ad56fc Fixed bug 4366 - Compile throws a warning on RPI (Raspbian Stretch)
midwan

When trying to compile on a Raspberry Pi 3, running Raspbian Stretch (fully updated), a warning appears:

/home/pi/projects/SDL/src/test/SDL_test_memory.c: In function ?SDL_TrackAllocation?:
/home/pi/projects/SDL/src/test/SDL_test_memory.c:112:109: warning: format ?%llx? expects argument of type ?long long unsigned int?, but argument 5 has type ?unw_word_t {aka unsigned int}? [-Wformat=]
                 snprintf(entry->stack_names[stack_index], sizeof(entry->stack_names[stack_index]), "%s+0x%llx", sym, offset);
2018-11-12 16:42:49 -08:00
Alex Szpakowski
c525ff354d cocoa: fix building with the macOS 10.7 SDK (thanks Riccardo!)
Fixes bug #4368
2018-11-10 20:56:23 -04:00
Alex Szpakowski
5029d50ea8 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id).
Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates).

Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
2018-11-10 16:15:48 -04:00
Sam Lantinga
9665a50891 Added Vulkan headers version 1.1.91
Downloaded from https://github.com/KhronosGroup/Vulkan-Headers
2018-11-06 16:57:07 -08:00
Sebastian Krzyszkowiak
48917e0e70 wayland: fix resizing and fullscreen toggling
For starters, we need to correctly respond to 0,0 configure after unsetting
fullscreen. Also, turns out that there should be no drawing calls at all
in between eglSwapBuffers and wl_egl_window_resize, as otherwise EGL can
already allocate a wrongly sized buffer for a next frame, so handle those
together.
2018-11-07 01:08:35 +01:00
Alex Szpakowski
244b79e194 metal: SDL_RenderReadPixels on macOS synchronizes the render target's texture data if it's managed, before reading from it. 2018-11-04 14:31:56 -04:00
Alex Szpakowski
c9fed27289 metal: fix the SDL_RENDERER_PRESENTVSYNC flag not being set on the renderer info on macOS, when vsync is used. 2018-11-04 12:31:02 -04:00
Alex Szpakowski
c2bba9e448 metal: fix the size of the buffer used for constant data. 2018-11-04 12:24:05 -04:00
Ryan C. Gordon
bc57ac27f9 mir: Removed mir client support.
Fixes Bugzilla #4288.
2018-11-02 21:34:17 -04:00
Sam Lantinga
47fb450beb Fixed bug 4315 - little Warning in Android_JNI_CaptureAudioBuffer
Sylvain

SDL_android.c
src/core/android/SDL_android.c:1302:5: warning: variable 'br' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
    default:
    ^~~~~~~
src/core/android/SDL_android.c:1306:12: note: uninitialized use occurs here
    return br;
           ^~
src/core/android/SDL_android.c:1270:12: note: initialize the variable 'br' to silence this warning
    jint br;
           ^


Maybe we could add some basics warning flags, not to see all warnings, but so that new warnings are caught sooner.

I would go for -Wall -Wextra, and some -Wno-warning for the allowed warnings.
2018-11-02 17:18:03 -07:00
Alex Szpakowski
457390fcf8 metal: avoid an extra buffer allocation and GPU data copy in RunCommandQueue, it's not needed. Improves overall performance. 2018-11-01 20:24:21 -03:00
Alex Szpakowski
4e86dfd8d1 metal: remove an obsolete section of a constant buffer. 2018-11-01 19:49:01 -03:00
Ozkan Sezer
0d79a8a1b2 fix build using Watcom :
./src/render/SDL_render.c(2168): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2168): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2175): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2175): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2322): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant
./src/render/SDL_render.c(2329): Error! E1054: Expression must be constant

./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
./src/render/software/SDL_render_sw.c(602): Error! E1054: Expression must be constant
2018-11-01 20:04:24 +03:00
Ryan C. Gordon
4659e73892 merge fallout: Patched to compile, fixed some compiler warnings, etc. 2018-11-01 12:31:45 -04:00
Ryan C. Gordon
62494a2e27 Merge SDL-ryan-batching-renderer branch to default. 2018-10-31 15:03:41 -04:00
Ryan C. Gordon
a5ebd4d775 wayland: ask KDE protocol extension to use server-side decorations if possible. 2018-10-29 10:14:59 -04:00
Ryan C. Gordon
8340b0f0e2 render: Add floating point versions of various draw APIs. 2018-10-23 01:34:03 -04:00
Steven M. Vascellaro
ff3bb857ff joystick: Add Linux mappings for "Xbox One Wireless Controller (Model 1708)"
Adds controller bindings to support the "Xbox One Wireless Controller
(Model 1708)" on Linux. The Model 1708 was released in 2016 alongside the
Xbox One S. It is the current model being sold by Microsoft as of writing.
(October 22, 2018)
2018-10-22 10:55:18 -04:00
Ozkan Sezer
d42728ec10 fix NetBSD C90 build failure
src/vendor/SDL2/src/joystick/bsd/SDL_sysjoystick.c:353:5: error:
ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]

reported by 'bch' at https://discourse.libsdl.org/t/25231
2018-11-01 12:35:00 +03:00
Cameron Gutman
329f2eb99e Fix crash when GL_LoadFunctions()/GLES2_LoadFunctions() fails
https://bugzilla.libsdl.org/show_bug.cgi?id=4350

We can't safely call GL_DestroyRenderer() until GL_LoadFunctions()
succeeds because we will be missing functions that we try to use
when activating the renderer for destruction if we have an GL context.
2018-10-31 20:17:53 -07:00
Sam Lantinga
aeee424f65 Fixed bug 4349 - SDL_CreateWindow fails with KMS/DRM after upgrading Mesa to 18.2.3
Rainer Sabelka

After I did an upgrade of my arch Linux installation (resulting in an update of Mesa to version 18.2.3), all my SDL2 applications which use the KMS/DRM driver stopped working.
Reason: Creating a Window with SDL_CreateWindow failed because the call to EGL
eglCreateWindowSurface() returns an error "EGL_BAD_MATCH".
After investigating with the debugger I figured, that the configuration, which has been selected from the output of eglChooseConfig(), has an "EGL_NATIVE_VISUAL_ID" which does not match the "format" of the underlying gbm surface.

The attached patch fixes the problem. It does so, by mimicking Weston's behavior.
All configurations returned from eglChooseConfig() which have an visual_id different from the gbm format are discarded, and only from the remaining ones the "best" match is selected.
2018-10-31 15:16:51 -07:00
Sam Lantinga
9af581bd75 Fixed bug 4347 - Keyboard LEDs don't work on linux console
Rainer Sabelka

When using SLD2 on a Linux console with the KMS/DRM video backend and Linux evdev keyboard support, the caps lock, scroll lock, and num lock leds do not work.

The attached patch adds ioctls for setting the LED state in SDL_evdev_kbd.c
2018-10-31 15:01:20 -07:00
Sam Lantinga
da56cefa8b Fixed bug 4188 - Software renderer SDL_RenderCopyEx blits corrupt image under certain cases
Sylvain

Re-opening this issue.

It fixes the test-case, but it introduces a regression with another bug (bug #4313).

So here's a new patch that activate cropping of the source surface to solve the issue.
It also reverts the wrong changeset.
It prevents unneeded colorkey error message.
2018-10-30 07:00:03 -07:00
Ryan C. Gordon
e542d1a36d winmain: Patched to compile on C89 compilers. 2018-10-29 20:18:50 -04:00
Ryan C. Gordon
f434a98c26 winmain: Don't use SDL_malloc (or SDL_stack_alloc, which might be malloc).
Otherwise, we are using the allocator before the app can set up its own hooks.

Now we use VirtualAlloc, and WideCharToMultiByte (because SDL_iconv uses
SDL_malloc, too!) to get ready to call into SDL_main.

This also makes console_wmain() call into the same routines as everything
else, so we don't have to deal with those allocations, too. Hopefully we
end up with the same results from GetCommandLine() as we do in wargv.

Fixes Bugzilla #4340.
2018-10-29 20:00:03 -04:00
Micha? Janiszewski
91820998fc Add and update include guards
Include guards in most changed files were missing, I added them keeping
the same style as other SDL files. In some cases I moved the include
guards around to be the first thing the header has to take advantage of
any possible improvements compiler may have for inclusion guards.
2018-10-28 21:36:48 +01:00
Sam Lantinga
14c55ac890 This change looks okay in the general case.
If we run into problems where these events aren't dispatched (initialized on a different thread than the main thread?) we may need to create a separate thread to handle device notifications like we do with the windows joystick subsystem.
2018-10-26 20:20:28 -07:00
Ryan C. Gordon
be8ef94f18 hidapi: Don't run a separate event loop for device notifications.
Fixes Bugzilla #4286.
2018-10-26 14:43:39 -04:00
Sam Lantinga
b08bdc4401 Don't build SDL_JOYSTICK_HIDAPI by default on iOS
If you enable this, you'll need to link with CoreBluetooth.framework and add something like this to your Info.plist:
<key>NSBluetoothPeripheralUsageDescription</key>
<string>MyApp would like to remain connected to nearby bluetooth Game Controllers and Game Pads even when you're not using the app.</string>
2018-10-26 09:27:31 -07:00
Sam Lantinga
14329256cb Generalized the XInput user index into a player index 2018-10-25 16:53:14 -07:00
Sam Lantinga
545febcf21 Fixed initializing XInput user index 2018-10-25 13:22:34 -07:00
Sam Lantinga
9987ca69f3 Added SDL_JoystickGetXInputUserIndex() 2018-10-25 12:54:42 -07:00
Sam Lantinga
4d4e18c4bb Added vi style for the Emscripten joystick code 2018-10-25 12:54:39 -07:00
Sam Lantinga
c4918db580 Add exception handling to Android hidapi. 2018-10-22 14:55:42 -07:00
Ryan C. Gordon
4a50a04213 wasapi/win32: Sort initial device lists by device GUID.
This makes an unchanged set of hardware always report devices in the same
order on each run.
2018-10-21 22:40:17 -04:00
Ryan C. Gordon
1ec56f7302 x11: Fixed incorrect function signature for XkbSetDetectableAutoRepeat.
It needs to use Bool (which is an int) and not BOOL (which is CARD8), which
causes problems on platforms with different byte order and alignment, etc.

Fixes Bugzilla #4326.
2018-10-20 21:35:48 -04:00
Ryan C. Gordon
1fb20f0ab9 cocoa: Put a mutex around GL_SwapBuffers.
Prevents deadlock when swapping two different GL contexts on two different
threads at the same time on macOS 10.14 ("Mojave").

Fixes Bugzilla #4278.
2018-10-18 23:38:27 -04:00
Ryan C. Gordon
cad0a2f730 cocoa: Fix OpenGL rendering on macOS 10.14 ("Mojave").
Fixes Bugzilla #4272.
(transplanted from 54729119b348e8a4a916192d1d6cb8d115656255)
2018-10-18 12:05:05 -04:00
Ryan C. Gordon
072e17bf98 cocoa: GL_GetDrawableSize only uses -[NSView convertRectToBacking] for highDPI.
On Mojave, this will report large numbers for retina displays in fullscreen
mode, which isn't how it works on previous versions.
(transplanted from c6c1731780e2bef94f944a4795e2dfbba46d9500)
2018-10-18 11:59:48 -04:00
Ryan C. Gordon
b262b0ebc9 Small stack allocations fall back to malloc if they're unexpectedly large. 2018-10-22 20:50:32 -04:00
Ryan C. Gordon
eedf2c965d opengles2: Fixed several incorrect things. 2018-10-06 17:08:04 -04:00
Ryan C. Gordon
6ecd0b2c35 opengles2: removed useless memcpy. 2018-10-04 21:10:42 -04:00
Ryan C. Gordon
ef3d970ace opengles2: Fixed incorrect cliprect state. 2018-10-04 20:22:28 -04:00
Ryan C. Gordon
208c4b0361 metal: CopyEx transform matrix must be aligned for constant buffer access. 2018-10-04 20:21:58 -04:00
Ryan C. Gordon
638d624f5a metal: Don't try to create a zero-byte vertex buffer.
(Which will cause a crash in Metal, or an assert in the validation layer.)
2018-10-04 20:21:23 -04:00
Ryan C. Gordon
1ecf4dfc5f render: Added SDL_RenderFlush(). 2018-10-04 16:34:44 -04:00
Ryan C. Gordon
09140bd8bc render: Move PSP backend to new interface.
I have no idea if this works (or if it ever worked, having now examined this
code), as I have no way to compile or test this.

If it's broken, send patches.  :)
2018-10-04 16:11:43 -04:00
Ryan C. Gordon
9fedff997b render: moved software renderer to new interface. 2018-10-03 23:37:29 -04:00
Ryan C. Gordon
bd08a4e6b1 render: D3D11 now cycles through 8 vertex buffers.
This means it doesn't have to block while the current frame finishes using the
vertex buffer; it just moves on to the next, probably-not-in-use buffer.
2018-10-03 19:05:20 -04:00
Ryan C. Gordon
a9094a21a8 render: D3D11 renderer patched to compile. 2018-10-03 18:23:53 -04:00
Ryan C. Gordon
6e6f7382a7 render: first (untested!) shot at converting D3D11 renderer to new interfaces.
Probably doesn't even compile yet.
2018-10-03 00:52:37 -04:00
Ryan C. Gordon
0c2e10dce4 render: Make the GL backends cache and defer more state changes. 2018-10-01 22:53:45 -04:00
Ryan C. Gordon
fcb4681336 render: D3D9 doesn't need to check for stream offset support anymore.
We don't use offsets at all now. Too slow.
2018-10-01 13:41:15 -04:00
Ryan C. Gordon
709f5ee417 render: Set the D3D9 stream source once and choose offsets during draw calls.
This is _much_ faster than setting the offsets with SetStreamSource!
2018-10-01 11:32:08 -04:00
Ryan C. Gordon
9870746bd9 render: Patched to compile. 2018-10-01 03:02:54 -04:00
Ryan C. Gordon
5e644cfdfb render: first shot at moving Direct3D 9 backend to new interface. Untested! 2018-10-01 01:23:02 -04:00
Ryan C. Gordon
fdc52a65dd render: patched to compile on C89 compilers, other untested code fixes. 2018-09-29 04:00:38 +00:00
Ryan C. Gordon
daad53af13 opengles1: set some non-zero drawstate defaults. 2018-09-28 19:48:14 -04:00
Ryan C. Gordon
c20a858da5 render: moved opengles2 over to new interface. 2018-09-28 19:47:44 -04:00
Ryan C. Gordon
22475bf3f0 cocoa: Force an OpenGL context update when the window becomes key.
Fixes missing rendering on macOS 10.14 ("Mojave").

Fixes Bugzilla #4272.
(transplanted from aee4797c84ef90464e270b1f6095a6dd7ce280c1)
2018-09-26 20:10:32 -04:00
Ryan C. Gordon
0d588cc4c9 render: Do state cache improvements for GLES1, too. 2018-09-25 21:35:09 -04:00
Ryan C. Gordon
d04e55240e render: OpenGL renderer now caches some state, to improve non-batching mode.
(other minor bug fixes in here, too)
2018-09-25 19:20:31 -04:00
Ryan C. Gordon
06461bba73 render: Move non-batching flushes to different place.
This lets us batch up a few commands that are all related to the same API
call.
2018-09-25 17:04:47 -04:00
Ryan C. Gordon
43f15e05dd render: opengles renderer actually works now. :) 2018-09-25 16:17:10 -04:00
Ryan C. Gordon
b2db99cb9f render: First shot at converting opengles renderer to new interfaces. 2018-09-25 10:41:25 -04:00
Ryan C. Gordon
c01da21756 render: get rid of the predeclared functions in the GL and Metal renderers.
(others to come as I continue to update render backends!)
2018-09-24 12:30:47 -04:00
Ryan C. Gordon
051d1cfcd1 render: Make opengl backend take advantage of new high-level features. 2018-09-24 02:08:34 -04:00
Ryan C. Gordon
8ac5c00a43 render: Add command queue debug logging. 2018-09-24 02:07:35 -04:00
Ryan C. Gordon
2241b33f55 render: Update Metal and GL backends to use new high-level features, etc.
Now nothing is uploaded as dynamic data with Metal's setVertexBytes, etc; it's
all in the one big vertex buffer, now.
2018-09-23 23:22:56 -04:00
Ryan C. Gordon
cc56de44a4 render: A bunch of high-level improvements.
- high-level filters out duplicate render commands from the queue so
  backends don't have to.
- Setting draw color is now a render command, so backends can put color
  information into the vertex buffer to upload with everything else instead
  of setting it with slower dynamic data later.
- backends can request that they always batch, even for legacy programs,
  since the lowlevel API can deal with it (Metal, and eventually Vulkan
  and such...)
- high-level makes sure the queue has at least one setdrawcolor and
  setviewport command before any draw calls, so the backends don't ever have
  to manage cases where this hasn't been explicitly set yet.
- backends allocating vertex buffer space can specify alignment, and the
  high-level will keep track of gaps in the buffer between the last used
  positions and the aligned data that can be used for later allocations
  (Metal and such need to specify some constant data on 256 byte boundaries,
  but we don't want to waste all that space we had to skip to meet alignment
  requirements).
2018-09-23 23:20:40 -04:00
Ryan C. Gordon
8955fb9b31 render: First shot at moving metal backend over to new batching system. 2018-09-20 16:40:04 -04:00
Ryan C. Gordon
55cb9966db render: first shot at reworking opengl backend for new batching system. 2018-09-20 16:36:54 -04:00
Ryan C. Gordon
5fb67f9f55 render: Move to a batching system for rendering (work in progress). 2018-09-20 15:46:02 -04:00
Ryan C. Gordon
a2f7af9a47 gles2: Make render command queue dynamic.
It now uses a growable linked list that keeps a pool of allocated items for
reuse, and reallocs the vertex array as necessary. Testsprite2 can scale to
20,000 (or more!) draws now without drama.
2018-09-09 15:09:38 -04:00
Ryan C. Gordon
0d3275297d gles2: Major renderer optimization. Work in progress!
This moves all the rendering to a command list that is flushed to the GL as
necessary, making most common activities upload a single vertex buffer per
frame and dramatically reducing state changes. In pathological cases,
like Emscripten running on iOS's Safari, performance can go from a dozen
draw calls killing your performance to 1000 draw calls running smoothly.

This is work in progress, and not ready to ship. Among other things, it has
a hardcoded array that isn't checked for overflow. But the basic idea is
sound!
2018-09-08 18:26:11 -04:00
Ryan C. Gordon
264b81b481 metal: Make sure layer drawableSize is adjusted on resize.
Fixes Bugzilla #4250.
2018-09-06 00:56:13 -04:00
Sam Lantinga
80021c21b6 Speculatively disable rumble on the Razer Panthera Evo, which doesn't have rumble motors and probably hangs in the same way the Panthera does. 2018-09-05 15:28:06 -07:00
Sam Lantinga
96259f1f85 Don't overwrite the default binding when changing the binding for a controller that was using the default. 2018-09-05 12:16:01 -07:00
Sam Lantinga
963e74d68c Added binding for Mad Catz FightStick TE S+ (PS3) on Mac OS X 2018-09-05 11:24:23 -07:00
Sam Lantinga
c152e380be Added support for the Razer Panthera Fightstick
Fixed bindings for the Mad Catz FightStick TE S+
2018-09-05 11:18:50 -07:00
Ryan C. Gordon
3634e563c4 metal: SDL_UpdateYUVTexture shouldn't swap planes based on format. 2018-09-01 20:47:12 -04:00
Sam Lantinga
34237b80f4 Better fix to make sure we're only returning controllers from the HIDAPI joystick API 2018-08-31 18:10:21 -07:00
Sam Lantinga
4ffcd88ca2 Removed VID/PID 0x1532/0x0037, which was listed in the Linux kernel as a Razer Sabertooth, because at least one variant of the Razer DeathAdder mouse shows up with this VID/PID. 2018-08-31 17:47:34 -07:00
Sam Lantinga
5ef8eb49be Don't show the Razer Raiju sound interface as a game controller 2018-08-29 20:55:02 -07:00
Sam Lantinga
90a5607d32 Fixed compiler warning and use higher precision in angle calculation 2018-08-29 20:23:42 -07:00
Sam Lantinga
207428b444 Don't rumble Bluetooth PS4 controllers by default, as that switches the controller into extended input report mode, which breaks games that use DirectInput. 2018-08-29 20:23:39 -07:00
Sam Lantinga
16ccff3c56 Fixed whitespace 2018-08-29 20:23:36 -07:00
Sam Lantinga
fda14741ac Fixed Xbox One S Bluetooth support on Mac OS X 2018-08-29 18:56:54 -07:00
Ozkan Sezer
b6aaefc791 SDL_evdev.c: undefine _THIS before redefining it.
src/core/linux/SDL_evdev.c:104:1: warning: "_THIS" redefined
In file included from src/core/linux/../../events/SDL_events_c.h:26,
                 from src/core/linux/SDL_evdev.c:45:
src/core/linux/../../events/../video/SDL_sysvideo.h:146:1: warning: this is the location of the previous definition
2018-08-29 11:04:02 +03:00
Sam Lantinga
92396f7d74 Fixed Windows build 2018-08-28 16:19:31 -07:00
Sam Lantinga
404ba5eea8 Fixed bug 4229 - Add support for ABGR format in DirectFB renderer
Alexandre

DirectFB supports 32-bit ABGR pixel format via DSPF_ABGR, but SDL doesn't map SDL_PIXELFORMAT_ABGR8888 to DSPF_ABGR.

A patch is attached and should add support for ABGR pixel format devices.
2018-08-28 13:37:11 -07:00
Andreas M?ller
87bc1fb552 GLES2: Get sin/cos out of vertex shader
The only place angle is activated and causes effect is RenderCopyEx. All other
methods which use vertex shader, leave angle disabled and cause useless sin/cos
calculation in shader.

To get around shader's interface is changed to a vector that contains results
of sin and cos. To behave properly when disabled, cos value is set with offset
-1.0 making 0.0 default when deactivated.

As nice side effect it simplifies GLES2_UpdateVertexBuffer: All attributes are
vectors now.

Additional background:

* On RaspberryPi it gives a performace win for operations. Tested with
  [1] numbers go down for 5-10% (not easy to estimate due to huge variation).
* SDL_RenderCopyEx was tested with [2]
* It works around left rotated display caused by low accuracy sin implemetation
  in RaspberryPi/VC4 [3]

[1] https://github.com/schnitzeltony/sdl2box
[2] https://github.com/schnitzeltony/sdl2rendercopyex
[3] https://github.com/anholt/mesa/issues/110

Signed-off-by: Andreas M?ller <schnitzeltony@gmail.com>
2018-08-28 12:57:51 -07:00
Sam Lantinga
a1ca84411e Update the cursor clipping each frame, in case it was stolen by another application. 2018-08-26 20:37:23 -07:00
Sam Lantinga
15b3794f11 Only reset the clip rect if it's currently the rect we previously clipped.
This prevents us from clearing the clip rect globally when another application has set it.

There's also an experimental change to regularly update the clip rect for a window defensively, in case someone else has reset it. It works well, but I don't know if it's cheap enough to call as frequently as it would be called now, and might have other undesirable side effects.

Also fixed whitespace and SDL coding style
2018-08-26 10:34:23 -07:00
Sam Lantinga
09ab752aa3 Implement SDL_HapticStopEffect on Android (thanks Rachel!) 2018-08-24 10:41:57 -07:00
Jeremy Ong
a794126d56 vulkan: SDL_Vulkan_GetInstanceExtensions should accept a NULL window.
Fixes Bugzilla #4235.
2018-08-24 09:49:48 -04:00
Sam Lantinga
a003fa0a05 Implemented SDL_GetDisplayOrientation() on Android (thanks Rachel!) 2018-08-23 14:05:25 -07:00
Thomas Perl
84e7832018 Fix "unresponsible application" issues in Wayland
Polling without wl_display_flush() never responds to ping requests.
In that case ping-pong works only on other events, such as user input
or on frame swapped.

From https://git.merproject.org/mer-core/libsdl/merge_requests/3
Original author: Alexander Akulich <a.akulich@omprussia.ru>
2018-08-23 14:47:38 +02:00
Ryan C. Gordon
f677377339 cocoa: Fix OpenGL rendering on macOS 10.14 ("Mojave").
Fixes Bugzilla #4272.
2018-10-18 12:05:05 -04:00
Ryan C. Gordon
eac3fd28d8 cocoa: GL_GetDrawableSize only uses -[NSView convertRectToBacking] for highDPI.
On Mojave, this will report large numbers for retina displays in fullscreen
mode, which isn't how it works on previous versions.
2018-10-18 11:59:48 -04:00
Sam Lantinga
708ad1fd8d Fixed updating the rumble parameters on Linux 2018-10-16 14:58:07 -07:00
Sam Lantinga
b0c48dd9dd Support vibration magnitude on Android 8.0 (thanks Rachel!) 2018-10-16 08:29:27 -07:00
Ozkan Sezer
7be4fca62c SDL_power.c: Adjust SDL_POWER_DISABLED ifdefs to avoid zero-size array
Otherwise if SDL_POWER_DISABLED is disabled (eg with --disable-power):

... with clang -pedantic:
src/power/SDL_power.c:48:50: warning: use of GNU empty initializer extension [-Wgnu-empty-initializer]
static SDL_GetPowerInfo_Impl implementations[] = {
                                                 ^
src/power/SDL_power.c:48:50: warning: zero size arrays are an extension [-Wzero-length-array]
2 warnings generated.

... with gcc -pedantic:
src/power/SDL_power.c:48:50: warning: ISO C forbids empty initializer braces [-Wpedantic]
src/power/SDL_power.c:48:50: warning: ISO C forbids empty initializer braces [-Wpedantic]
 static SDL_GetPowerInfo_Impl implementations[] = {
                                                  ^
src/power/SDL_power.c:48:30: error: zero or negative size array ?implementations?
 static SDL_GetPowerInfo_Impl implementations[] = {
                              ^~~~~~~~~~~~~~~

... with Watcom:
./src/power/SDL_power.c(85): Error! E1112: Initializer list cannot be empty
2018-10-15 11:01:00 +03:00
Ryan C. Gordon
dae4a01361 x11: Don't hardcode limit on lines of text in message boxes.
Plus other text parsing fixes.

Fixes Bugzilla #4306.
2018-10-15 00:46:43 -04:00
Ozkan Sezer
703361e47d SDL_GetPowerInfo_Hardwired is static in SDL_power.c
.. therefore, comment out its extern declaration in SDL_syspower.h.
2018-10-14 23:55:02 +03:00
Ozkan Sezer
cbacb0f1ea add missing include. 2018-10-14 23:50:50 +03:00
Alex Szpakowski
e2ad654f2e iOS: Don't ignore the requested alpha bit size when determining whether to use an RGBA8 backbuffer. 2018-10-14 17:26:10 -03:00
Charlie Birks
cd63709ed8 Emscripten: Load eglQueryString and eglGetError
This prevents an assertion on context creation failure (calling a null
function pointer).
2018-10-13 17:18:59 +01:00
Alex Szpakowski
8c41e2624e metal: Fix SDL_RenderReadPixels to wait for the GPU to finish rendering to the active texture before reading its pixels. 2018-10-13 03:36:42 -03:00
Alex Szpakowski
d8022d19b4 macOS: Fixed MoltenVK dynamic library loading code. 2018-10-12 23:23:52 -03:00
Alex Szpakowski
d9094421e1 metal: Fix high dpi and resizing on macOS, and clean up iOS code. Fixes bug #4250. 2018-10-12 17:55:42 -03:00
Sam Lantinga
9a98e4b647 Allow Android haptics to work when SDL is reinitialized (thanks Rachel!) 2018-10-11 15:14:48 -07:00
Ryan C. Gordon
acb05f50d8 thread: make SDL_CreateThreadWithStackSize() a public API. 2018-10-11 16:40:01 -04:00
Cameron Gutman
eff5f65096 Implement SuspendScreenSaver for Win32
Creating a full-screen SDL renderer on Windows will keep the screensaver
suspended by DirectX, as is default for full-screen DX applications. However,
for applications that render in windowed-mode, the screensaver will
still kick in, even if SDL_DisableScreenSaver() is called or
SDL_HINT_VIDEO_ALLOW_SCREENSAVER is set to 0 (default). Implementing
a SuspendScreenSaver() function for Win32 fixes this behavior.
2018-10-09 23:01:43 -07:00
Ryan C. Gordon
04cbf13261 audio: All device names reported by SDL must be unique.
This means that if you have two devices named "Soundblaster Pro" in your
machine, one will be reported as "Soundblaster Pro" and the other as
"Soundblaster Pro (2)".

This makes it so you can't into a position where one of your devices can't
be opened because another is sitting on the same name.
2018-10-10 15:20:56 -04:00
Ryan C. Gordon
0378529e1e audio: clean_out_device_list() already sets this flag to false for us. 2018-10-10 14:55:24 -04:00
Sam Lantinga
f5a21ebf0c Added support for surround sound and float audio on Android 2018-10-09 20:12:43 -07:00
Sam Lantinga
82c2f04e61 Fixed bug 4188 - Software renderer SDL_RenderCopyEx blits corrupt image under certain cases
duckgrease

SDL_RenderCopyEx blits wrong image (in some cases it's bunch of alternating horizontal lines, some cases it's image from the wrong coordinate, and in some cases it's just a bunch of garbled pixels), when the following conditions are met:
- Use software renderer.
- Enable either horizontal or vertical flip.
- source and destination rectangles must have same width and height, and must be smaller than the size of the texture.
- source rectangle's X and Y coordinates must be 0.
2018-10-09 17:41:40 -07:00
Ryan C. Gordon
88b3252555 kmsdrm: find available card if called without index.
This work was done by Michael Grzeschik, I just cleaned up the patch a little.

Fixes Bugzilla #4241.
2018-10-09 00:27:55 -04:00
Sam Lantinga
62f806ed6c This device gets Xinput driver loaded on windows. 2018-10-08 19:46:01 -07:00
Sam Lantinga
337cea4411 Fixed life-cycle issues with two activities sharing HIDDeviceManager 2018-10-08 12:49:30 -07:00
Sam Lantinga
4d771c598a Don't flash the navigation bar when destroying a fullscreen SDL window 2018-10-08 12:49:25 -07:00
Sam Lantinga
53260b31b5 There are legitimate reasons to skip full cleanup at shutdown, don't assert in that case. 2018-10-08 12:49:23 -07:00
Sam Lantinga
3ac9e2aa4e Fixed bug 4296 - kmsdrm video driver leaks 1 bo in KMSDRM_GLES_SetupCrtc()
Icenowy Zheng

One front buffer is locked in GLES_SetupCrtc() and overrides the next_bo just locked in KMSDRM_GLES_SwapWindow, then the next_bo gets lost and is not released even when quitting the video.

It may leads to problems with GLES drivers that doesn't clean up GBM correctly if there's any bo left (e.g. the Mali Utgard r6p2 blob). In the case of Mali Utgard r6p2 blob, the DRM device file is still hold by the blob, and if you try to SDL_Quit to let another program to run (this is done by EmulationStation), the new program will fail to open DRM device.
2018-10-05 17:06:05 -07:00
Ryan C. Gordon
367f9b915c wayland: Fixed missing window sizing events.
Fixes Bugzilla #4242.
2018-10-05 17:24:03 -04:00
Sam Lantinga
f01cdcedbc It turns out HIDAPI for Xbox controllers doesn't allow background input, so we won't enable it by default on Windows. 2018-10-05 01:41:59 -07:00
Sam Lantinga
41ee51b9a8 Fixed updating bindings for controllers using the wildcard mappings 2018-10-04 15:23:42 -07:00
Ryan C. Gordon
93fb710a46 evdev: Don't initialize struct sigaction with "{ 0 }".
It causes warnings on some platforms, depending on the actual definition of
sigaction, and since this is static data, it'll be zero'd out anyhow.
2018-10-03 16:54:24 -04:00
Sam Lantinga
1944556171 Make sure we don't read and write to HIDAPI at the same time, it's not thread-safe on Windows 2018-10-02 20:51:33 -07:00
Sam Lantinga
6e35e42145 Working on bug 3921 - Add some Fastpath to BlitNtoNKey and BlitNtoNKeyCopyAlpha
Sylvain

I did various benches. with clang 6.0.0 on linux, and ndk-r16b on android (NDK_TOOLCHAIN_VERSION=clang).

- still see a x10 speed factor.
- with duff_loops, it does not use vectorisation (but doesn't seem to be a problem).

on linux my patch is already at full speed on -O2, whereas the duff_loops need -O3 (200 ms at -03, and 300ms at -02).

I realized that on Android, I had a slight variation which fits best.
both on linux with -O2 and -O3, and on android with 02/03 and armeabi-v7a/arm64.

Here's the patch.
2018-10-01 14:43:03 -07:00
Ozkan Sezer
922623e1b6 SDL_blit_N.c (BlitNtoNKeyCopyAlpha): fix -Wshadow warnings by adding _
suffix to the temp Pixel local in the DUFFS_LOOP.
SDL_blit.h (ASSEMBLE_RGB):  add _ prefix to temp Pixel locals to avoid
  any possible shadowings.


The warnings were like the following:

In file included from src/video/SDL_blit_N.c:26:0:
src/video/SDL_blit_N.c: In function 'BlitNtoNKeyCopyAlpha':
src/video/SDL_blit_N.c:2421:24: warning: declaration of 'Pixel' shadows a previous local [-Wshadow]
                 Uint32 Pixel = ((*src32 & rgbmask) == ckey) ? *dst32 : *src32;
                        ^
src/video/SDL_blit.h:475:21: note: in definition of macro 'DUFFS_LOOP8'
     case 0: do {    pixel_copy_increment; /* fallthrough */             \
                     ^
src/video/SDL_blit_N.c:2419:13: note: in expansion of macro 'DUFFS_LOOP'
             DUFFS_LOOP(
             ^
src/video/SDL_blit_N.c:2399:12: warning: shadowed declaration is here [-Wshadow]
     Uint32 Pixel;
            ^
2018-10-01 21:29:11 +03:00
Sam Lantinga
b251876126 commit c6b28f46b8116552ec2b38d1d3c8535df28ba7a1
Author: Anthony Pesch <inolen@gmail.com>
Date:   Fri May 4 20:21:21 2018 -0400

    Added SDL_AUDIO_ALLOW_SAMPLES_CHANGE flag enabling users of SDL_OpenAudioDevice to get
    the sample size of the actual hardware buffer vs having a stream created to handle the
    delta
2018-10-01 09:47:10 -07:00
Sam Lantinga
50d5002533 Fixed build 2018-08-23 02:21:17 -07:00
Sam Lantinga
088070e5a8 Moved display orientation handling on iOS out to a separate function for Qt apps 2018-08-22 23:47:29 -07:00
Sam Lantinga
f225af0c1e Added SDL_GetDisplayOrientation() to get the display orientation, and added a new event SDL_DISPLAYEVENT to notify the application when the orientation changes.
Documented the values returned by the accelerometer and gyroscope sensors
2018-08-22 21:48:28 -07:00
Sam Lantinga
f1bc1c1274 Fixed crash trying to open HIDAPI controller as a haptics device on Windows 2018-08-22 17:44:28 -07:00
Sam Lantinga
6f758ad25f Moved SDL_IsTablet() to a cross-platform API function 2018-08-21 20:03:54 -07:00
Sam Lantinga
e9f6805fc6 Removed dependency on C++ runtime on iOS 2018-08-21 19:42:19 -07:00
Sam Lantinga
c6647bf9c9 Added the iOS sensor implementation 2018-08-21 17:24:12 -07:00
Sam Lantinga
3e5dbc694a Added a dummy sensor driver 2018-08-21 13:29:21 -07:00
Sam Lantinga
7c3040e08a First pass on the new SDL sensor API 2018-08-21 12:11:34 -07:00
Sam Lantinga
109544ca04 Add SDL_IsTablet() to Android and iOS SDL. 2018-08-21 11:23:47 -07:00
Sam Lantinga
0d22559e30 Fixed Android build error 2018-08-21 10:25:30 -07:00
Sam Lantinga
5dfa4043a3 Fixed warnings building on Mac OS X 64-bit 2018-08-20 21:19:17 -07:00
Sam Lantinga
6b3f11e2a3 Fixed code style 2018-08-20 21:18:56 -07:00
Ryan Speets
aeea6b9b1f Emscripten: Fixed SDL_SYSTEM_CURSOR_SIZEALL 2018-08-18 12:30:04 +01:00
Ozkan Sezer
90454b1ece SDL_hidapi_ps4.c: define NTDDI_VISTA / _WIN32_WINNT_VISTA if not defined
it still needs a Vista or newer Platform SDK to build, though.
2018-08-16 11:01:02 +03:00
Sam Lantinga
7d3a7ef827 Use a single hint for both Xbox 360 and Xbox One controllers, since they are often the same driver. 2018-08-15 23:35:54 -07:00
Sam Lantinga
a2add1f683 Use the HIDAPI driver for Xbox controllers on Windows, and determine the XInput mapping at runtime for extended functionality like rumble and guide button. 2018-08-15 23:14:45 -07:00
Sam Lantinga
3f5ff751fe Use a unified name list for Xbox 360 and Xbox One controllers for drivers that can handle both 2018-08-15 23:14:43 -07:00
Sam Lantinga
aad340eb86 Added Windows Xbox controller state packet handling, for completeness. 2018-08-15 19:53:36 -07:00
Sam Lantinga
63107524f6 Fixed input from the Steam Virtual Gamepad on Mac OS X 2018-08-15 19:53:34 -07:00
Sam Lantinga
0903e83553 Use SDL specific window class to avoid conflicting with Steam 2018-08-15 19:53:31 -07:00
Sam Lantinga
c88666580e Catch device removal as well as device arrival on Windows 2018-08-15 19:53:30 -07:00
Sam Lantinga
641c674f2a Turned off debug messages 2018-08-15 19:53:28 -07:00
Sam Lantinga
51902010c6 Remove the HIDAPI device if we get a read error from it
This fixes detecting PS4 controller disconnect on Mac OS X, where there isn't any device removed notification
2018-08-15 19:53:26 -07:00
Sam Lantinga
dfbd7f65a9 Fixed Mac OS X build 2018-08-15 19:53:24 -07:00
Sam Lantinga
ec74c318b9 Polling hid_enumerate() every 3 seconds causes freezes and stutters on some USB audio devices and mice.
We'll only enumerate devices when we get notification that the system devices have changed
2018-08-15 19:53:22 -07:00
Ryan C. Gordon
2dc04b4c11 libm: one more static analysis fix. 2018-08-10 15:22:02 -04:00
Ryan C. Gordon
67a48ad13a haiku: Patched to compile with new joystick interfaces. 2018-08-10 15:04:08 -04:00
Ryan C. Gordon
e1ac643b32 bsd: Patched to compile.
(I think.)
2018-08-10 14:54:26 -04:00
Ryan C. Gordon
67764070f0 bsd: Update joystick code for new interfaces.
(this is an untested push to see if buildbot likes it.)
2018-08-10 14:42:40 -04:00
Ryan C. Gordon
b692c35237 emscripten: Patched to compile with new joystick interfaces. 2018-08-10 14:32:30 -04:00
Ryan C. Gordon
941f8ecffd joystick: define inline to SDL_INLINE 2018-08-10 14:10:47 -04:00
Ryan C. Gordon
0b2863d45e joystick: #if 0'd out some things that aren't currently used.
Fixes some compiler warnings.
2018-08-10 14:09:44 -04:00
Ozkan Sezer
a7c3d2af81 SDL_hidapi_ps4.c: lowercase windows header names. 2018-08-10 11:50:55 +03:00
Sam Lantinga
4f41f07d43 Added missing files from previous commits 2018-08-09 16:05:48 -07:00
Sam Lantinga
31b0224397 Added notes that this code was contributed by Valve 2018-08-09 16:04:45 -07:00
Sam Lantinga
99759bac82 There's no controller that's supported by both XInput and HIDAPI 2018-08-09 16:04:34 -07:00
Sam Lantinga
ab07ce1166 Don't update the device list for devices we know aren't supported
This should reduce HID enumeration (hitting the USB bus) if for some reason we're getting spammed with false device insert/removal events
2018-08-09 16:04:30 -07:00
Sam Lantinga
28e0c0eef7 Sam Lantinga <slouken@libsdl.org> 2018-08-06 13:00 -0700
Backed out changeset 794a209b2270
http://hg.libsdl.org/SDL/rev/2e2ecdac957c
2018-08-09 16:04:21 -07:00
Sam Lantinga
25a952e76f Sam Lantinga <slouken@libsdl.org> 2018-08-06 11:58 -0700
Removed mapping for VID/PID 0x0079/0x0006, which is a generic PCB used in many different devices
http://hg.libsdl.org/SDL/rev/794a209b2270
2018-08-09 16:04:18 -07:00
Sam Lantinga
888bf1af69 Worked around bug with Sony PS Now PS3 controller where DirectInput polling will continue to return success after the controller is unplugged.
The code is now reliant on SDL_PrivateJoystickAdded() and SDL_PrivateJoystickRemoved() being called correctly when devices are added or removed on Windows
2018-08-09 16:03:50 -07:00
Sam Lantinga
f35e97ba8a Fixed Windows build 2018-08-09 16:03:29 -07:00
Sam Lantinga
d2042e1ed4 Added HIDAPI joystick drivers for more consistent support for Xbox, PS4 and Nintendo Switch Pro controller support across platforms.
Added SDL_GameControllerRumble() and SDL_JoystickRumble() for simple force feedback outside of the SDL haptics API
2018-08-09 16:00:17 -07:00
Ryan C. Gordon
ba90412cda libm: Don't let Visual Studio generate an implicit memset() call. 2018-08-08 15:39:20 -04:00
Ryan C. Gordon
4cb84b8f4b backout INFINITY change...of course Visual Studio doesn't have it. 2018-08-08 12:36:54 -04:00
Ryan C. Gordon
257071fc20 e_exp: One more compiler warning. 2018-08-08 12:19:01 -04:00
Ryan C. Gordon
550437edbe libm: Fixed all static analysis warnings. 2018-08-08 12:13:56 -04:00
Ryan C. Gordon
c0aa626ba3 e_exp: Fixed compiler warning on Visual Studio. 2018-08-08 10:26:22 -04:00
Ryan C. Gordon
941c5b4760 haiku: Rename internal functions from BE_* to HAIKU_*
Fixes Bugzilla #2349.
2018-08-07 18:07:11 -04:00
Ryan C. Gordon
f59b0056d3 evdev: On sudden termination, make sure keyboard isn't lost (thanks, Tadek!)
"In release 2.0.6, when Linux evdev keyboard support has been moved to a
separate source file, a feature was added to disable normal keyboard event
processing to prevent "spilling" keystrokes to background virtual console.

This feature has one unpleasant side effect: if application fails to call
`SDL_Exit` before termination or crashes with fatal signal, console is left
in unusable state with keyboard not working and no possibility to switch
virtual console. If user has a chance, he can login remotely and restore
keyboard with `kbd_mode`, otherwise the only option is to reboot the machine.

This patch fixes that problem by intercepting fatal signals (with `sigaction`)
and process termination (with `atexit`), to restore keyboard state, if it
wasn't properly restored with `SDL_Exit`.

The function registered with `atexit` also restores original signal handlers,
to prevent leaving invalid handlers after SDL library is unloaded, if it was
loaded dynamically with `dlopen`.

No signal handlers or `atexit` function are installed if SDL boolean hint
`SDL_HINT_NO_SIGNAL_HANDLERS` is `SDL_TRUE`.

Additionally, if environment variable `SDL_INPUT_LINUX_KEEP_KBD` exists,
keyboard initialization function completely skips disabling keyboard. This
can be useful for debugging."

Fixes Bugzilla #4193.
2018-08-07 16:56:46 -04:00
Ryan C. Gordon
623a6defd3 alsa: optionally run entire pipeline non-blocking. 2018-08-07 16:49:18 -04:00
Ryan C. Gordon
56f44cfa0f audio: Deal with device shutdown more carefully.
This would cause problems in various ways, but specifically triggers an
assert when you close a WASAPI capture device in an app running over RDP.

Related to (but not the actual bug) in Bugzilla #3924.
2018-08-07 13:04:15 -04:00
Mai Lavelle
e714f6590e haptic: Fix initial detection of haptic devices on Linux system
SDL_UDEV_Scan must be called during SDL_SYS_HapticInit to ensure devices
outside of the 0-31 range are added to the list of haptic devices.

Fixes Bugzilla #3923.
2018-08-07 12:06:31 -04:00
Sam Lantinga
a37d3e0b1e Backed out changeset 794a209b2270
It turns out the mapping is correct, just the name was confusing
2018-08-06 13:00:11 -07:00
Sam Lantinga
cc682f2013 Removed mapping for VID/PID 0x0079/0x0006, which is a generic PCB used in many different devices
Different device with same vid/pic that is kind of a Saitek shape:
https://www.trust.com/en/product/17416-gxt-24-runa-compact-gamepad

n64 with same ID
https://bbs.archlinux.org/viewtopic.php?id=163488

PS shaped with numbers for buttons
https://pineight.com/mw/index.php?title=USB_game_controller#DragonRise_Inc._Generic_USB_Joystick

fightstick with same vid/pid
https://retropie.org.uk/forum/topic/7594/bartop-2-player-zero-delay-encoders-not-working
2018-08-06 11:58:08 -07:00
Ozkan Sezer
f45f33bdc0 SDL_expf: return SDL_exp() instead of SDL_uclibc_exp() for consistency. 2018-08-05 10:01:01 +03:00
Ethan Lee
b4fe7412f9 SDL_exp 2018-08-04 11:52:46 -04:00
Ryan C. Gordon
e061a92dc9 Some drag'and'drop improvements.
First: disable d'n'd events by default; most apps don't need these at all, and
if an app doesn't explicitly handle these, each drop on the window will cause
a memory leak if the events are enabled. This follows the guidelines we have
for SDL_TEXTINPUT events already.

Second: when events are enabled or disabled, signal the video layer, as it
might be able to inform the OS, causing UI changes or optimizations (for
example, dropping a file icon on a Cocoa app that isn't accepting drops will
cause macOS to show a rejection animation instead of the drop operation just
vanishing into the ether, X11 might show a different cursor when dragging
onto an accepting window, etc).

Third: fill in the drop event details in the test library and enable the
events in testwm.c for making sure this all works as expected.
2018-08-02 16:03:47 -04:00
Ryan C. Gordon
8f0cc4a4b7 Backed out changeset 2e42ec46061e.
This change isn't correct. See comments in Bugzilla #4183.
2018-07-22 19:42:08 -04:00
Ryan C. Gordon
1089944bee libm: Fixed signature mismatches for __ieee754_rem_pio2 and __kernel_rem_pio2.
Fixes Bugzilla #4201.
2018-07-22 19:40:42 -04:00
Ryan C. Gordon
862aa4b47d windows: Fixed some Visual Studio warnings about shadowed variables.
Fixes Bugzilla #4118.
2018-07-22 19:28:27 -04:00
Marc Di Luzio
c3178e67ca Ensure we still clear the X locale modifiers even if not compiled with ibus or fcitx support 2018-07-12 16:52:45 +01:00
Ryan C. Gordon
b5a420cb11 dbus: Deal with undefined behavior with va_args.
Parse out a copy of the varargs ourselves to get to the reply portion, since
the original passed to D-Bus might modify or not modify the caller's copy,
depending on system ABI.
2018-07-13 17:53:24 -04:00
Sam Lantinga
df0d3f1364 More controller drivers support CARTESIAN coordinates.
This fixes rumble on the Saitek Cyborg V.3 Rumble Pad
2018-07-12 13:28:15 -07:00
Sam Lantinga
ff8c9538bc Allow trapping the back button so right mouse click can work on some Android systems (thanks Rachel!)
Also, added a function SDL_AndroidBackButton() so applications can respond to the back button directly
2018-07-12 13:28:13 -07:00
Wohlstand
ff8c62f227 Fixed bug 4210 - SSE2-based converter makes junk result of S32 -> Float
At the HG state abdd17144682, 64-bit assemblies are using SSE2-based resampler, produces junk sound when converting the S32 -> Float32 -> S16 chain. The `NEED_SCALAR_CONVERTER_FALLBACKS` thing works perfectly.

If I will find a reason that caused this mistake, I'll send a patch by myself.
2018-07-02 03:53:57 +03:00
Ozkan Sezer
013b146de9 SDL_windowstaskdialog.h (struct _TASKDIALOGCONFIG): make unions anonymous
otherwise build fails. (at least with my VS2005. and the code accesses the
arms of the unions anonymously anyway.)
2018-06-30 20:55:51 +03:00
Ozkan Sezer
949b8bd8c5 correct the comment correction.. 2018-06-30 20:10:40 +03:00
Ozkan Sezer
67f18a1973 comment correction 2018-06-30 20:04:01 +03:00
Ryan C. Gordon
7c2028f8e9 Attempt to fix "cast from pointer to integer of different size" warnings. 2018-06-29 16:56:11 -04:00
Ryan C. Gordon
52857de251 Corrected a comment. 2018-06-29 16:55:55 -04:00
Ryan C. Gordon
3b173f818d Patched to compile on Visual Studio (typo). 2018-06-25 23:00:38 -04:00
Ryan C. Gordon
58168a8c3c atomic: Fight with all the assemblers that don't like REP NOP. :/ 2018-06-25 16:34:16 -04:00
Ryan C. Gordon
5f123e31a3 atomic: Spin locks now try to use the x86 PAUSE instruction for short waits.
Fixes Bugzilla #4151.
2018-06-25 15:58:35 -04:00
Ryan C. Gordon
5a8ecf4e79 yuv: Patched to make static analysis happy (warned about unused variable). 2018-06-25 13:14:52 -04:00
Ryan C. Gordon
4773690d0f Deal with possible malloc(0) calls, as pointed out by static analysis. 2018-06-25 12:55:23 -04:00
Ryan C. Gordon
915a7e0341 gles2: Whoops, overzealous copy/paste on my part. :) 2018-06-25 01:57:28 -04:00
Ryan C. Gordon
c8ac909674 wayland: Implemented xdg-wm-base support.
This is just in parity with the existing zxdg-shell-unstable-v6 code. Making
the Wayland target robust (and uh, with title bars) is going to take a lot
of work on top of this.
2018-06-24 22:42:36 -07:00
Ethan Lee
0a7faa4ae5 Fix Linux haptic scaling, add 2.1 FIXME 2018-05-04 21:58:39 -04:00
Ethan Lee
de9f5415b3 Filter both SIZE_CHANGED and RESIZED on any SIZE_CHANGED 2018-08-13 12:52:52 -04:00
Sam Lantinga
95579f5f19 Fixed bug 4220 - SDL_GL_CONTEXT_DEBUG_FLAG can fail silently on some Android devices 2018-10-01 09:40:58 -07:00
Sam Lantinga
48f7e7f34d Corrected PS4 controller entry 2018-09-30 22:43:12 -07:00
Sam Lantinga
f8b4cd410b Re-enable drag-and-drop events by default 2018-09-30 19:53:26 -07:00
Alex Szpakowski
fb485986eb macOS: Fix a crash when the video subsystem quits, if SDL_MAC_NO_SANDBOX was defined when SDL was compiled. 2018-09-30 11:26:41 -03:00
Ryan C. Gordon
56ec349d2a audio: disable NEON converters for now.
To be revisited after 2.0.9 ships!

(doesn't fix Bugzilla #4186, but stops the regression for the time being.)
2018-09-29 16:48:15 -04:00
Sam Lantinga
9e8e0fb7b1 Fixed bug 4283 - SDL's version of memset is different from libc's
janisozaur

memset's documentation reads:

* The memset() function shall copy c (converted to an unsigned char) into each of the first n bytes of the object pointed to by s. (http://pubs.opengroup.org/onlinepubs/9699919799/functions/memset.html)
* Sets the first count characters of dest to the character c. (https://msdn.microsoft.com/en-us/library/1fdeehz6.aspx)
* write a byte to a byte string (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/memset.3.html)

The highlight here is they all mean a single _byte_, even though memset receives a parameter of type int, which can hold more data than a single byte. SDL's implementation of memset, however, does not clear any of the higher bits, causing an erroneous behaviour when passed an argument bigger than 0xff.
2018-09-28 20:48:18 -07:00
Sam Lantinga
74638ea3c5 Ensure we wait on the surface resize before returning from setting fullscreen mode. 2018-09-28 20:39:57 -07:00
Ozkan Sezer
31596f23ce SDL_vsnprintf: implemented '+' flag for signed integers printing.
it is, of course, ignored for %u, %x, %o and %p.
2018-09-29 01:24:10 +03:00
Ozkan Sezer
49803c8660 SDL_vsnprintf: fix numerics if both zero-padding and a field are given.
it used to place zeroes between the sign and the number. (space-padding
from within SDL_PrintString() seems OK:  spaces are added before sign.)

also fixed the maxlen handling if the number has a sign.
2018-09-29 00:51:24 +03:00
Ozkan Sezer
5454765a22 replace bool stuff in controller_type.h with SDL_bool.
remove bool<->SDL_bool dance in SDL_joystick.c:SDL_IsJoystickSteamController()
after the controller_type.h change.
2018-09-28 17:01:24 +03:00
Ozkan Sezer
fde82e5972 SDL_hidapi_ps4.c: add HAVE_ENDPOINTVOLUME_H check to win32 volume code.
this makes it build with my old toolchain with mingw-w64 1.0.10 headers
2018-09-28 14:01:40 +03:00
Ozkan Sezer
cf7d64f266 hidapi/windows/hid.c: comment out ntdef.h include after windows.h.
not necessary and can cause redefinition errors in some toolchains.
2018-09-28 13:44:10 +03:00
Sam Lantinga
9aa8a75d26 Fixed building with Xcode 10.0 2018-09-28 01:18:54 -07:00
Ozkan Sezer
283680f2c1 hidapi/windows/hid.c: fix misplaced #if 0
VendorID && ProductID are only used by the test main(),
otherwise they are unwanted globals.
2018-09-28 11:04:55 +03:00
Sam Lantinga
f964ce03b4 Fixed mingw-w64 build 2018-09-28 01:00:47 -07:00
Sam Lantinga
20dfda4489 Fixed mingw-w64 build 2018-09-28 00:40:35 -07:00
Sam Lantinga
7df0f4fdac Fixed bug 4277 - warnings patch
Sylvain

Patch a few warnings when using:
-Wmissing-prototypes -Wdocumentation -Wdocumentation-unknown-command

They are automatically enabled with -Wall
2018-09-27 14:56:29 -07:00
Ozkan Sezer
d9fb77a3c1 SDL_atomic.c, SDL_spinlock.c: use lock prefix with xchg in Watcom asm. 2018-09-27 11:55:02 +03:00
Ozkan Sezer
bb5516ac8e SDL_vsnprintf() updates for zero-padding:
- remove force-enabling of pad_zeroes for %u for compatibility
 (was added in https://hg.libsdl.org/SDL/rev/701f4a25df89)
- ignore pad_zeroes for %s and %S
- ignore pad_zeroes for %d, %i and %u if a precision is given
2018-09-27 09:37:36 +03:00
Ryan C. Gordon
7689162ca0 cocoa: Force an OpenGL context update when the window becomes key.
Fixes missing rendering on macOS 10.14 ("Mojave").

Fixes Bugzilla #4272.
2018-09-26 20:10:32 -04:00
Ozkan Sezer
6eeb8593ba SDL_string.c (SDL_PrintString): avoid MSVC signed/unsigned mismatch warning 2018-09-27 01:10:50 +03:00
Ozkan Sezer
5342ae2bba SDL_string.c (SDL_IntPrecisionAdjust): avoid MSVC generating a memset() 2018-09-27 01:00:50 +03:00
Ozkan Sezer
d2131ac165 SDL_vsnprintf: implement precision for the integral value printers. 2018-09-27 00:32:15 +03:00
Sam Lantinga
55b24b93b4 Fixed bug 4265 - SDL window falls to the bottom of the screen when dragged down and stuck there
Alexei

On WM_WINDOWPOSCHANGED event, WIN_UpdateClipCursor() is called. SDL_WINDOW_INPUT_FOCUS is set even when the mouse pointer is not inside the SDL window and therefore ClipCursor(&rect) is called. When dragging the window and rect.bottom=800 (i.e. the bottom edge of the screen) the SDL window is clipped to the bottom of the screen and it is not possible to move it back to the center of the screen.
2018-09-26 11:17:43 -07:00
Ozkan Sezer
ffc19ee255 SDL_string.c: added comments to three SDL_FormatInfo members. 2018-09-26 20:47:34 +03:00
Sam Lantinga
bc6c199790 Updated version to 2.0.9 2018-09-26 10:08:14 -07:00
Ozkan Sezer
8743e9759e SDL_vsnprintf: when '.' is specified, take precision as 0 if it is < 0. 2018-09-26 17:11:40 +03:00
Ozkan Sezer
69ab8541a9 SDL_vsnprintf: string printer now honors the precision. (bug #4263.) 2018-09-26 10:40:02 +03:00
Ozkan Sezer
d0e9a36460 SDL_vsnprintf: %.* and %* now parse precision and width. (bug #4263.) 2018-09-26 10:38:40 +03:00
Sam Lantinga
e236e8435a Fixed bug 4268 - Android_JNI_OpenAudioDevice function has error
alittle

where iscapture == 1

1.param set error

(*env)->CallStaticIntMethod(env, mAudioManagerClass, midCaptureOpen, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames)

param:audioBuffer16Bit need change to captureBuffer16Bit

2.logic error

if (is16Bit) {
        // ALITTLE Modify the source code
        if (iscapture) {
            audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)captureBuffer);
        } else {
            audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy);
            audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer);
        }
        // if (!iscapture) {
        //     audioBufferPinned = (*env)->GetShortArrayElements(env, (jshortArray)audioBuffer, &isCopy);
        // }
        // audioBufferFrames = (*env)->GetArrayLength(env, (jshortArray)audioBuffer);
    } else {
        // ALITTLE Modify the source code
        if (iscapture) {
            audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)captureBuffer);
        } else {
            audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy);
            audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer);
        }
        // if (!iscapture) {
        //     audioBufferPinned = (*env)->GetByteArrayElements(env, (jbyteArray)audioBuffer, &isCopy);
        // }
        // audioBufferFrames = (*env)->GetArrayLength(env, (jbyteArray)audioBuffer);
    }
2018-09-25 20:08:51 -07:00
Sam Lantinga
60afec79bf Removed redundant SDL_GetColorKey() call. (thanks Sylvain!) 2018-09-25 19:53:16 -07:00
Ethan Lee
7f9854b9b2 WinRT: Wait until audio device activation is complete and PrepDevice during OpenAudio 2018-09-25 01:45:12 -04:00
Sam Lantinga
aa9683bb6f Added 8bitdo SF 30 PRO controller support for Linux / DInput mode (thanks Frank Hartung) 2018-09-25 19:41:33 -07:00
Sam Lantinga
fb0e68ae0f Fixed building with newer Android NDK 2018-09-25 08:23:57 -07:00
Ozkan Sezer
870c44bfed safer this way, just in case.. 2018-09-25 09:20:56 +03:00
Sam Lantinga
ef34704875 Fixed bug 4264 - SDL_CreateTextureFromSurface generates error message but returns ok
Anthony @ POW Games

SDL_CreateTextureFromSurface makes an internal call to SDL_GetColorKey which can return an error and spams the error log with "Surface doesn't have a colorkey" even though the original function didn't return an error.
2018-09-24 16:41:55 -07:00
Sam Lantinga
cd90e2ca58 Fixed bug 4267 - linkage failure with --enable-hidapi because of missing libudev symbols
Ozkan Sezer

hidapi dynamic udev initial patch
2018-09-24 16:33:14 -07:00
Sam Lantinga
5febdfcece Fixed whitespace 2018-09-24 11:49:25 -07:00
Sam Lantinga
d07fe7ad95 Removed button logging message 2018-09-21 09:41:21 -07:00
Sam Lantinga
e8b0859f17 Added missing call to WindowsDeleteString() 2018-09-20 15:55:52 -07:00
Sam Lantinga
600126c90e Added experimental support for Windows.Gaming.Input 2018-09-19 10:03:40 -07:00
Sam Lantinga
f6a537cbfa Store the API device refcount on the device itself, so if the device is disconnected and we have multiple application references to it, we only free it once. 2018-09-17 11:35:24 -07:00
Sam Lantinga
59a2d12cc3 Fixed creating an Android game controller mapping for HIDAPI devices on initialization 2018-09-17 11:35:22 -07:00
Ozkan Sezer
305e5968aa do not export hidapi symbols from SDL dlls (bug #4259). 2018-09-15 14:28:10 +03:00
Sam Lantinga
6b3e893105 Added hints SDL_HINT_MOUSE_DOUBLE_CLICK_TIME and SDL_HINT_MOUSE_DOUBLE_CLICK_RADIUS to allow tuning double-click sensitivity.
Also increased the default double-click radius to 32 pixels to be more forgiving for touch interfaces
2018-09-14 19:26:26 -07:00
Sam Lantinga
e8a0e35e24 Use atomic reference counting for the HID device object 2018-09-14 18:31:01 -07:00
Sam Lantinga
6a7b0c27af Fixed crash launching under Steam on Mac OS X 2018-09-14 12:41:29 -07:00
Sam Lantinga
0b3a350c90 Fixed Chinese IME support (thanks ???!) 2018-09-10 23:01:33 -07:00
Sam Lantinga
af823cc1d9 Fixed building on tvOS 2018-09-10 23:00:09 -07:00
Ozkan Sezer
33381d3d10 hidapi/SDL_hidapijoystick.c: fix build in C90 mode:
src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_InitializeDiscovery':
src/joystick/hidapi/SDL_hidapijoystick.c:281: error: 'true' undeclared (first use in this function)
src/joystick/hidapi/SDL_hidapijoystick.c:281: error: (Each undeclared identifier is reported only once
src/joystick/hidapi/SDL_hidapijoystick.c:281: error: for each function it appears in.)
src/joystick/hidapi/SDL_hidapijoystick.c: In function 'HIDAPI_UpdateDiscovery':
src/joystick/hidapi/SDL_hidapijoystick.c:339: error: 'true' undeclared (first use in this function)
src/joystick/hidapi/SDL_hidapijoystick.c:341: error: ISO C90 forbids mixed declarations and code
2018-09-07 11:03:24 +03:00
Anthony Pesch
c591429542 alsa: avoid hardware parameters with an excessive number of periods.
The previous code attempted to use set_buffer_size / set_period_size
discretely, favoring the parameters which generated a buffer size that was
exactly 2x the requested buffer size. This solution ultimately prioritizes
only the buffer size, which comes at a large performance cost on some machines
where this results in an excessive number of periods. In my case, for a 4096
sample buffer, this configured the device to use 37 periods with a period size
of 221 samples and a buffer size of 8192 samples. With 37 periods, the SDL
Audio thread was consuming 25% of the CPU.

This code has been refactored to use set_period_size and set_buffer_size
together. set_period_size is called first to attempt to set the period to
exactly match the requested buffer size, and set_buffer_size is called second
to further refine the parameters to attempt to use only 2 periods. The
fundamental change here is that the period size / count won't go to extreme
values if the buffer size can't be exactly matched, the buffer size should
instead just increase to the next closest multiple of the target period size
that is supported. After changing this, for a 4096 sample buffer, the device
is configured to use 3 periods with a period size of 4096 samples and a buffer
size of 12288 samples. With only 3 periods, the SDL Audio thread doesn't even
show up when profiling.

Fixes Bugzilla #4156.
2018-05-04 21:21:32 -04:00
Ryan C. Gordon
59574fe2f0 x11: Normalize x11xinput2 touch x to be 1.0 at width (thanks, Zach!).
"Applications (such as SDL's testgesture) do "event.tfinger.x * window_width"
to find window coord. Currently the X11 XInput2 backend expects application
to do "event.tfinger.x * (window_width-1)" instead.

X11 XInput2 touch events are normalized so x is 1.0 at "width - 1" but other
SDL backends appear to have x be 1.0 at "width". Same issue for touch event
y with regards to height."

Fixes Bugzilla #4183.
2018-06-24 13:57:22 -04:00
Tomeu Vizoso
fe6828272a egl: Don't change context when deleting current.
If we change the current context behind the app's back, those tracking
the current context to minimize context changes are going to get
confused.

This brings the EGL backend in line with the GLX one.

Fixes Bugzilla #4199.
2018-06-14 06:12:12 +00:00
Ryan C. Gordon
5308a245a4 Fixed some possible malloc(0) calls reported by static analysis. 2018-06-24 12:16:58 -04:00
Sam Lantinga
88dfa46644 Use a blank cursor instead of PointerIcon.TYPE_NULL since that shows the default cursor on Samsung DeX 2018-06-18 13:14:04 -07:00
Sam Lantinga
a515853569 Added support for external mouse in Samsung DeX mode
relative mode doesn't work, but absolute coordinates are functional
2018-06-18 13:14:02 -07:00
Sam Lantinga
74ec7cabdb Fixed race condition where Android touch events could get scaled by a render target's viewport 2018-06-18 13:13:56 -07:00
Sam Lantinga
9924a8e392 Fixed bug 4094 - No SDL_TEXTEDITING after pressing Alt key on Raspberry Pi Linux
This was reproducible by running an SDL app on the console from an ssh login. In this case the terminal wasn't owned by the user running the app, so we were using the default keymap, which didn't have state transitions defined for ctrl and alt, so once we entered that state keypresses would no longer transition out of that state, nor would they generate text.

As a workaround, we'll just reset to the default shift state if that happens, which means we'll get text for keys pressed while ctrl is held down, but I don't think that's a big problem.

Note that in this case we also can't mute the keyboard, so the keypresses go to the console, which probably isn't what you want...
2018-06-14 00:51:45 -07:00
Ozkan Sezer
08de74ec49 use the 'aborts' pragma of Watcom for SDL_NORETURN functions
SDL_ExitProcess(), SDL_AbortAssertion() and SDLTest_BailOut().

(Commit 303c1e0fb0cf for bug #4100 removed SDL_NORETURN from
SDL_ExitProcess() and SDL_AbortAssertion() in order to avoid
warnings from windows builds, but that's temporary I guess..)
2018-06-13 14:45:02 +03:00
Sam Lantinga
4a4bac95eb Deal with fullscreen limitations under windowed Android environments (Chromebook, DeX, etc.) (Thanks Rachel!) 2018-06-12 13:22:58 -07:00
Sam Lantinga
864b8f89fa Merged in community contributed controller mappings from https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt 2018-06-12 01:04:26 -07:00
Sam Lantinga
1205978244 Added common controllers used with Steam Big Picture
These are entirely untested
Several USB ids refer to multiple packaged products. In those cases I tried to use the most common name, or a general name (e.g. PS3 Controller), or a completely generic name (e.g. USB gamepad) if it wasn't clear what type of controller it was.
Patches welcome!
2018-06-12 00:18:10 -07:00
Sam Lantinga
fe196db774 Track android device panel width & height as well as window surface & height.
Expand SDLActivity::SDLSurface::surfaceChanged() callback to grab the panel width and height at the same time and pass that along to the native code. Only works on API 17+. Duplicates surface dimensions whenever it fails.

Add Android_DeviceWidth/Android_DeviceHeight globals to native code.
Disambiguate Android_ScreenWidth/Android_ScreenHeight -> Android_SurfaceWidth/Android_SurfaceHeight
Use device width/height for all display mode settings.
2018-06-07 17:07:03 -07:00
Sam Lantinga
db86e7a633 Added support for the PS3 controller driver in PlayStation Now 2018-06-07 10:54:54 -07:00
Sam Lantinga
113801b790 Added SDL_IsChromebook() to determine if we're running on a Chromebook. 2018-06-05 12:46:13 -07:00
Sam Lantinga
2dedbc7262 Add Android support for relative mouse mode to SDL. 2018-06-05 12:46:11 -07:00
Sam Lantinga
9d6ac3deff Fix creating a minimized window in SDL to not cause focus to be stolen (because ShowWindow( hwnd, SW_MINIMIZE ) would be called after creation, thus changing focus to the prior window based on some per-app list in windows, rather than the window being created with WS_MINIMIZED to start with).
This means we have to consider SDL_WINDOW_MINIMIZED a window creation flag, but on non-windows platforms we just remove it and let the normal FinishWindowCreation re-apply and do the minimize as I have no idea what is right on them or if anything should change.

CR: Phil
2018-06-05 12:46:09 -07:00
Sam Lantinga
1d25135b71 Fixed bug 4184 - jack audio driver fails in presence of midi ports
Martin ?irokov

Launching an SDL application with SDL_AUDIODRIVER=jack, and then calling SDL_OpenAudioDevice() with whatever parameters fails with an error like this one:

SDL_OpenAudioDevice: Couldn't connect JACK ports: SDL:sdl_jack_output_0 => system:midi_playback_1

This happens because JACK_OpenDevice in src/audio/jack/SDL_jackaudio.c blindly tries to connect to all input ports without checking whether they are for audio or midi.

The fix is to check port types and ignore all non audio ports. Also I removed devports field from struct SDL_PrivateAudioData, because it's never really used and removing unused ports from it would be PITA.
2018-06-01 19:43:53 -07:00
Sam Lantinga
ff6aebc4a1 Added a new GUID for DS3 controller connected over bluetooth, for both Sony and Shanwan (thanks William!) 2018-05-29 08:03:44 -07:00
Ryan C. Gordon
3d3870982c metal: contrary to documentation, we need to set the drawableSize explicitly.
Fixes Bugzilla #4149.
2018-05-27 20:30:03 -04:00
Sam Lantinga
8325df25aa Fixed bug 4169 - Crash due to audio session observer race condition
Jona

The following explains why this bug was happening:
This crash was caused because the audio session was being set as active [session setActive:YES error:&err] when the audio device was actually being CLOSED. Certain cases the audio session being set to active would fail and the method would return right away. Because of the way the error was handled we never removed the SDLInterruptionListener thus leaking it. Later when an interruption was received the THIS_ object would contain a pointer to an already released device causing the crash.

The fix:
When only one device remained open and it was being closed we needed to set the audio session as NOT active and completely ignore the returned error to successfully release the SDLInterruptionListener. I think the user assumed that the open_playback_devices and open_capture_devices would equal 0 when all of them where closed but the truth is that at the end of the closing process that the open devices count is decremented.
2018-05-24 07:30:24 -07:00
Sam Lantinga
b3173d9d3b Added support for the NVIDIA SHIELD handheld gaming device 2018-05-23 17:15:37 -07:00
Sam Lantinga
361043a5f6 Actually left trigger is motion axis 17 and right trigger is motion axis 18, which will map in that order to SDL axes. 2018-05-23 17:15:33 -07:00
Sam Lantinga
4d9a346927 Added additional supported Android controllers 2018-05-23 16:00:21 -07:00
Sam Lantinga
c07656dbcb Fixed default mapping for Android controller triggers (they were reversed) 2018-05-23 16:00:19 -07:00
Ryan C. Gordon
101544d6f0 audio: Needed to fix two more instances for Visual Studio. 2018-05-21 12:05:17 -04:00
Ryan C. Gordon
0ad4b0b697 thread: fixed compiler warnings on non-Linux systems that use pthread.
(static function rtkit_setpriority was unused, moved it in with rest of
__LINUX__ section.)
2018-05-21 12:00:21 -04:00
Ryan C. Gordon
49881861b1 audio: Patched to compile on Visual Studio.
(It gets upset at the -2147483648, thinking this should be an unsigned value
because 2147483648 is too large for an int32, so the negative sign upsets the
compiler.)
2018-05-21 11:54:09 -04:00
Ryan C. Gordon
b7e88aaae0 audio: Added ARM NEON versions of audio converters.
These are _much_ faster than the scalar equivalents on the Raspberry Pi that
I tested on. Often 3x to 4x as fast!
2018-05-16 02:03:06 -04:00
Ryan C. Gordon
cb0e614fb1 audio: SSE2 float-to-int converters should clamp input.
The scalar versions already do this.
2018-05-15 02:29:35 -04:00
Ryan C. Gordon
a07e5815a5 audio: Fix range on float-to-int data clamping.
I can't tell if there was a good reason for this or it was just me getting
numbers wrong due to exhaustion.
2018-05-15 01:40:05 -04:00
Ryan C. Gordon
7832cb652e audio: float to int converters should clamp inclusively.
If we have to test if a sample is > 1.0f anyhow, we might as well use this
to avoid the unnecessary multiplication when it's == 1.0f, too. (etc).
2018-05-15 01:35:53 -04:00
Ryan C. Gordon
e2ec1eb12e audio: converting int32 to/from float shouldn't use doubles.
The concern is that a massive int sample, like 0x7FFFFFFF, won't fit in a
float32, which doesn't have enough bits to hold a whole number this large,
just to divide it to get a value between 0 and 1.
Previously we would convert to double, to get more bits, do the division, and
cast back to a float, but this is expensive.

Casting to double is more accurate, but it's 2x to 3x slower. Shifting out
the least significant byte of an int32, so it'll definitely fit in a float,
and dividing by 0x7FFFFF is still accurate to about 5 decimal places, and the
difference doesn't appear to be perceptable.
2018-05-15 01:04:11 -04:00
Ryan C. Gordon
4df859c586 cpuinfo: Added SDL_HasAVX512F().
This checks for the "foundation" AVX-512 instructions (that all AVX-512
compatible CPUs support).
2018-05-21 11:35:42 -04:00
Ryan C. Gordon
4718791f11 cpuinfo: Make CPU flags easier to read and add to. 2018-05-14 00:03:39 -04:00
Ryan C. Gordon
8543ad7df1 cpuinfo: Added some internal SIMD-aligned allocation functions.
Fixes Bugzilla #4150 (sort of).
2018-05-21 11:34:57 -04:00
Sam Lantinga
999af8099b Merged latest changes from Steam Link app 2018-05-18 13:09:30 -07:00
Ryan C. Gordon
e2619f1dcf dynapi: don't let system loader resolve the initializer to the wrong version.
Fixes problems launching Firewatch on Linux (which statically links SDL but
also dynamically loads a system-wide copy from a plugin shared library) with
a newer SDL build.
2018-05-17 12:50:46 -04:00
Ozkan Sezer
652d59fb3b make sure SDL_vsnprintf() nul terminates if it is using _vsnprintf
The change makes sure that SDL_vsnprintf() nul terminates if it is
using _vsnprintf() for the job.

I made this patch for Watcom, whose _vsnprintf() doesn't guarantee
nul termination.  The preprocessor check can be extended to windows
in general too, if required.

Closes bug #3769.
2018-05-10 09:02:39 +03:00
Ozkan Sezer
fe032ff4c9 do the direct3d tap dance for overscan hint only if SDL_VIDEO_RENDER_D3D == 1 2018-05-10 08:25:23 +03:00
Sam Lantinga
a4d0571e4a Reverted change for bug 4152 - restrict the win10 mouse bug workaround to win10 v1709 only
Daniel Gibson

Sorry, but it seems like Microsoft didn't fix the issue properly.

I just updated my Win10 machine, it now is Version 1803, Build 17134.1

I tested with SDL2 2.0.7 (my workaround was released with 2.0.8) and still got
lots of events that directly undid the prior "real" events - just like before.
(See simple testcase in attachement)
By default it sets SDL_HINT_MOUSE_RELATIVE_MODE_WARP - which triggered (and on my machine still triggers) the buggy behavior. You can start it with -raw, then it'll not set that hint and the events will be as expected.
The easiest way to see the difference is looking at the window title, which shows accumulated X and Y values: If you just move your mouse to the right, in -raw mode the number just increases. In non-raw mode (using mouse warping) it stays around 0.

I also had a WinAPI-only testcase: https://gist.github.com/DanielGibson/b5b033c67b9137f0280af9fc53352c68
It just calls SetCursorPos(320,240); on each WM_MOUSEMOVE event, and it also
logs all those events to a mouseevents.log textfile.
This log indeed looks a bit different since the latest Win10 update: It seems like all those events with x=320 y=240 do arrive - but only after I stopped moving the mouse - even though the cursor seems to be moved back every frame (or so).
So moving the mouse to the right gives X coordinates like
330, 325, 333, 340, 330, ...
and then when stopping movement I get lots of events with X coordinate 320
2018-05-07 20:10:12 -07:00
Sam Lantinga
eb14b635cd Fixed bug 4134 - Render targets lose scale quality after minimizing a fullscreen window
Olli-Samuli Lehmus

If one creates a window with the SDL_WINDOW_FULLSCREEN_DESKTOP flag, and creates a render target with SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear"), and afterwards sets SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"), after minimizing the window, the scale quality hint is lost on the render target. Textures however do keep their interpolation modes.
2018-05-07 19:52:25 -07:00
Sam Lantinga
606c5a585c Fixed bug 4152 - Windows 10 v1803 update seems to have fixed the jumping mouse bug (see bug #3931.) 2018-05-05 10:27:53 -07:00
Sam Lantinga
386790efbf Improved error messages when Vulkan isn't configured (thanks Daniel Gibson!) 2018-04-23 22:29:14 -07:00
Sam Lantinga
8f780e76e1 Fixed build 2018-04-23 22:17:56 -07:00
Sam Lantinga
f521b22eb5 Added SDL_THREAD_PRIORITY_TIME_CRITICAL 2018-04-23 22:07:56 -07:00
Sam Lantinga
a1b8fa6071 TryLockMutex: Fix error handling for TryLockMutex
Christian Herzig

pthread_mutex_trylock() and by the way, pthread_mutex_lock() do not set errno.
Pthread-methods directly return error code as int. See related man-pages for
details.
2018-04-23 21:50:03 -07:00
Sam Lantinga
a9ae1b508d Handle NULL return from SDL_DBus_GetContext() 2018-04-23 20:24:12 -07:00
Sam Lantinga
b5d231eede Handle NULL return from SDL_DBus_GetContext() 2018-04-23 19:20:12 -07:00
Sam Lantinga
432312561f Added SDL_LinuxSetThreadPriority() to directly set the priority of a Linux thread (tid)
This function tries using RealtimeKit connecting over DBUS as needed.
2018-04-23 19:18:52 -07:00
Sam Lantinga
816a6e68e5 Added support for adjusting thread priorities using Linux RealtimeKit
Michael Sartain

This is a quick pass at adding Linux RealtimeKit thread priority support to SDL.

It allows me to bump the thread priority to high without root privileges or setting any caps, etc.

rtkit readme here:
    http://git.0pointer.net/rtkit.git/tree/README
2018-04-23 17:10:36 -07:00
Ryan C. Gordon
dc8b55e50b coreaudio: Use the standard SDL audio thread instead of spinning a new one.
Fixes corner cases, like the audio callback not firing if the device is
disconnected, etc.
2018-04-16 02:11:09 -04:00
Ryan C. Gordon
2df59062dc wayland: zxdg_shell_v6 needs a configure event before using a surface at all.
Fixes Bugzilla #4109.
Fixes Bugzilla #4119.
2018-04-15 17:42:09 -04:00
Sam Lantinga
b7228bc51f Added support for the GameSir G3w 2018-04-11 18:28:03 -07:00
Sam Lantinga
6a0ef0cdbc SDL:
On Windows, have SDL_ShowWindow() not activate the window if the window has the WS_EX_NOACTIVATE window flag.
2018-04-09 10:37:31 -07:00
Sam Lantinga
4d78a99544 Fixed bug where an SDL window that was activated while hidden could never be shown.
Test code:
{
	SDL_Window *win = SDL_CreateWindow( "Dummy", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 128, 128, SDL_WINDOW_HIDDEN );
	SDL_SysWMinfo info;
	SDL_VERSION( &info.version );
	SDL_GetWindowWMInfo( win, &info );
	SetActiveWindow( info.info.win.window );
	{
		DWORD then = SDL_GetTicks();
		while ( ( SDL_GetTicks() - then ) < 3000 )
		{
			SDL_Event evt;
			SDL_PollEvent( &evt );
		}
		SDL_ShowWindow( win );

		then = SDL_GetTicks();
		while ( ( SDL_GetTicks() - then ) < 3000 )
		{
			SDL_Event evt;
			SDL_PollEvent( &evt );
		}
	}
	SDL_DestroyWindow( win );
}
2018-03-26 12:38:29 -07:00
Sam Lantinga
e14278ef6f Fixed bug 3804 - Message box on Windows truncates button ID
Simon Hug

I just wanted to fix a simple compiler warning in SDL_ShowMessageBox on Windows (which Sam fixed recently) and ended up finding some issues.

Attached patch fixes these issues:

- Because Windows only reports the lower 16 bits of the control identifier that was pushed, the button IDs used by SDL (C type int, most likely 32 bits) can get cut off.

- The documentation states (somewhat ambiguously) that the button ID will be -1 if the dialog was closed, but the current code sets 0. For SDL 2.1, I think this should be a return code of SDL_ShowMessageBox itself. That will free up the button ID and it seems a more appropriate place for signaling this event.

- Ampersands in controls will create mnemonics on Windows (underlined letters that, if combined with the Alt key, will push the button). I was thinking of adding a hint or flag to let the users enable it, but that might have unexpected results.

- When the size of the text gets calculated, it doesn't use the same parameters as the static control. This can cut off text or wrap it weirdly.

- On Windows, the Tab key is used to switch between control groups and sometimes between buttons in dialogs. This didn't seem to work correctly.

Attached patch also adds:

- Icons. Just the system ones that can be loaded with the ordinals IDI_ERROR, IDI_WARNING and IDI_INFORMATION.

- A button limit of 2^16 - 101.

- Some more specific error messages, but they never reach the user because how SDL_ShowMessageBox handles them if an implementation returns with an error.
2018-03-24 10:26:40 -07:00
Sam Lantinga
b41b9d34c7 Fixed return value 2018-03-19 14:52:53 -07:00
Sam Lantinga
8e062f6925 Generalized the handling of instantaneous guide button presses so there's a minimum of 100 ms between guide button press and release.
This happens with at least the following controllers: All Apple MFI controllers, ASUS Gamepad, XiaoMi Bluetooth Controller
2018-03-19 14:42:51 -07:00
Sam Lantinga
d529b001bc Added mapping for the ASUS Gamepad removing the guide button, which doesn't generate events even though it's reported in the Android APIs. 2018-03-19 13:16:11 -07:00
Sam Lantinga
f536fbea71 Reimplemented Android cursor API support using reflection so it builds with older SDKs 2018-03-16 11:08:53 -07:00
Sam Lantinga
e20d4173bf Added Android custom cursor implementation
This is commented out in SDLActivity.java, with the note #CURSORIMPLEENTATION because it requires API 24, which is higher than the minimum required SDK
2018-03-15 18:22:48 -07:00
Sam Lantinga
d401a77eff Fixed bug 4102 - define _WIN32_WINNT_WIN7 if not already defined
Ozkan Sezer

The following patch defines _WIN32_WINNT_WIN7 if it is not already
defined in core/windows/SDL_windows.c,  similar to what is already
there for _WIN32_WINNT_VISTA.
2018-03-10 21:22:42 -08:00
Sam Lantinga
cc7b2fc512 Temporary fix for bug 3432 - macOS 10.12: small scrolls (1 wheel notch) don't generate events
Eric Wasylishen

This bug was reintroduced by https://hg.libsdl.org/SDL/rev/fcf24b38a28a

The steps to reproduce are the same: run the "testrelative" SDL demo with "--info all",
connect a USB mouse with a scroll wheel, and roll the scroll wheel one "notch". You'll get log output like:

testdraw2[1644:67222] INFO: SDL EVENT: Mouse: wheel scrolled 0 in x and 0 in y (reversed: 1) in window 1

As far as I can tell macOS doesn't have an API for getting the number of "wheel notches"; I get a deltaY of 0.100006 for one "notch", and it's heavily accelerated (if you roll the wheel quickly you'll get large deltas). So NSEvent's deltaY is only meant to be used for scrolling a scroll view, with the given distance in points, not something like selecting an item in a game.

Here's a temporary patch that at restores the foor/ceil in Cocoa_HandleMouseWheel.
Not ideal, but at least it restores the ability to scroll one notch of a mousewheel.
2018-03-10 21:13:50 -08:00
Sam Lantinga
129431b4f4 Delay delivery of the pause button release on MFI controllers so it doesn't happen in the same frame as the button press 2018-03-08 16:32:22 -08:00
Sam Lantinga
92847022f5 Added a mapping for the latest firmware for the Xbox One S controller on Android 2018-03-07 18:10:01 -08:00